Packageorg.MARS.robot
Classpublic class Robot
InheritanceRobot Inheritance RigidBody Inheritance SimpleParticle Inheritance flash.events.EventDispatcher
ImplementsIBody, IODE, ISimulatable

Simulates a mobile autonomous robot



Public Properties
 PropertyDefined by
  actuators : Array
[read-only] Robot's actuators
Robot
 Inheritedav : Number
RigidBody
 InheritedcollisionTypeID : String
RigidBody
  controller : IController
[read-only] Robot's controller
Robot
 Inheritedelasticity : Number
SimpleParticle
 Inheritedforce : Vector
SimpleParticle
 Inheritedfriction : Number
SimpleParticle
 InheritedI : Number
RigidBody
 InheritedinverseI : Number
RigidBody
 InheritedinverseMass : Number
SimpleParticle
  isAlive : Boolean
[read-only]
Robot
  locomotion : ILocomotion
[read-only] Robot's locomotion system
Robot
 Inheritedmass : Number
SimpleParticle
 Inheritedposition : Vector
SimpleParticle
  previousPosition : Vector
[read-only]
Robot
 Inheritedq : Number
RigidBody
 Inheritedrotation : RotationMatrix
Gets the rotation matrix of the body

Because the creation of a rotation matrix involves 2 trigonometric function calls, it's worthwhile to do a check to see if we need to create a new rotation matrix.

RigidBody
  sensors : Array
[read-only] Robot's sensors
Robot
 Inheritedshape : Shape
RigidBody
 Inheritedstate : Array
Gets the state of the differential equation

Consider a particle with position x and velocity v.

SimpleParticle
 Inheritedtorque : Number
RigidBody
 Inheritedvelocity : Vector
SimpleParticle
 Inheritedvx : Number
SimpleParticle
 Inheritedvy : Number
SimpleParticle
 Inheritedx : Number
Note that these values that constitute this IODE's state use getters/setters that access specific indices within _state.
SimpleParticle
 Inheritedy : Number
SimpleParticle
Protected Properties
 PropertyDefined by
 Inherited_elasticity : Number
elastic coefficient of particle (used in collision response)
SimpleParticle
 Inherited_force : Vector
holds all accummulate forces
SimpleParticle
 Inherited_friction : Number
frictional coefficient (used in collision response)
SimpleParticle
 Inherited_generators : Array
holds all IForceGenerators affecting this particle
SimpleParticle
 Inherited_I : Number
inertia tensor
RigidBody
 Inherited_inverseI : Number
inverse inertia tensor
RigidBody
 Inherited_inverseMass : Number
holds the inverse mass- this is an optimization as multiplication is faster than division and we can calculate this offline
SimpleParticle
 Inherited_mass : Number
holds the mass of the particle
SimpleParticle
 Inherited_rotation : RotationMatrix
rotation matrix of body
RigidBody
 Inherited_shape : Shape
body shape
RigidBody
 Inherited_state : Array
holds the state of the system
SimpleParticle
 Inherited_torque : Number
torque accumulator
RigidBody
Public Methods
 MethodDefined by
  
Robot(x:Number, y:Number, rotation:Number, shape:Shape, controller:IController, locomotion:ILocomotion, mass:Number = 100, solver:IODESolver = null, friction:Number = 0.2, elasticity:Number = 0.15)
Create a robot using the given parameters
Robot
 Inherited
Accumulates forces
SimpleParticle
  
addActuator(actuator:IActuator):void
Add the provided actuator to the robot
Robot
 Inherited
addForce(force:Vector):void
Adds a force to the particle
SimpleParticle
 Inherited
addForceAtPoint(point:Vector, force:Vector):void
Adds a force at a specific point on the body

IF the point specified is not the center of mass (0,0), the force will induce a change in angular velocity as well as linear.

RigidBody
 Inherited
Adds a force generator to influence this particle
SimpleParticle
  
addSensor(sensor:ISensor):void
Add the provided sensor to the robot
Robot
  
Simple way to attach the robot to the Environment for simulation
Robot
 Inherited
addTorque(torque:Number):void
Adds torque to the body

This is the rotational equivalent to adding a force

RigidBody
 Inherited
clearForces():void
Clears all forces
SimpleParticle
 Inherited
clearTorque():void
Clears any accumulated torque
RigidBody
  
collide():void
Print a message that the robot has collided with a wall or a heavy object
Robot
  
fallOff():void
Print a message that the robot has fallen off of the table
Robot
  
getDerivative(state:Array, derivative:Array):void
Gets the derivative of the body
Robot
 Inherited
Gets the velocity of the body at a specified point

Note that this point is given in world-coordinates.

RigidBody
  
isOnTable():Boolean
Check if the robot is on the table by checking if both of its wheels are on the table.
Robot
 Inherited
Removes a force generator
SimpleParticle
  
step():void
A function that is called on every step of the physics engine.
Robot
Protected Methods
 MethodDefined by
 Inherited
Calculates the body's inertia tensor

The inertia tensor is the rotational equivalent to mass- it is also linked to mass.

RigidBody
Property detail
actuatorsproperty
actuators:Array  [read-only]

Robot's actuators

Implementation
    public function get actuators():Array
controllerproperty 
controller:IController  [read-only]

Robot's controller

Implementation
    public function get controller():IController
isAliveproperty 
isAlive:Boolean  [read-only]Implementation
    public function get isAlive():Boolean
locomotionproperty 
locomotion:ILocomotion  [read-only]

Robot's locomotion system

Implementation
    public function get locomotion():ILocomotion
previousPositionproperty 
previousPosition:Vector  [read-only]Implementation
    public function get previousPosition():Vector
sensorsproperty 
sensors:Array  [read-only]

Robot's sensors

Implementation
    public function get sensors():Array
Constructor detail
Robot()constructor
public function Robot(x:Number, y:Number, rotation:Number, shape:Shape, controller:IController, locomotion:ILocomotion, mass:Number = 100, solver:IODESolver = null, friction:Number = 0.2, elasticity:Number = 0.15)

Create a robot using the given parameters

Parameters
x:Number — - starting x position of the robot
 
y:Number — - starting y position of the robot
 
rotation:Number — - starting rotation of the robot (in radians)
 
shape:Shape — - shape of the robot
 
controller:IController — - robot's controller
 
locomotion:ILocomotion — - robot's locomotion system
 
mass:Number (default = 100) — - mass of the robot (100 by default)
 
solver:IODESolver (default = null) — - ODE solver to override the default provided by the physics engine (null by defaul)
 
friction:Number (default = 0.2) — - friction of the robot's edge used in calculation of the collision resolution (0.2 by default)
 
elasticity:Number (default = 0.15) — - elasticity of the robot's body used in calculation of the collision resolution (0.15 by default)
Method detail
addActuator()method
public function addActuator(actuator:IActuator):void

Add the provided actuator to the robot

Parameters
actuator:IActuator
addSensor()method 
public function addSensor(sensor:ISensor):void

Add the provided sensor to the robot

Parameters
sensor:ISensor
addToEnvironment()method 
public function addToEnvironment():void

Simple way to attach the robot to the Environment for simulation

collide()method 
public function collide():void

Print a message that the robot has collided with a wall or a heavy object

fallOff()method 
public function fallOff():void

Print a message that the robot has fallen off of the table

getDerivative()method 
public override function getDerivative(state:Array, derivative:Array):void

Gets the derivative of the body

Parameters
state:Array — body's state
 
derivative:Array — Array to populate with body's derivative

See also

IODE.getDerivative
RigidBody
isOnTable()method 
public function isOnTable():Boolean

Check if the robot is on the table by checking if both of its wheels are on the table.

Returns
Boolean — true if both wheels are on the table, false if any of the wheels is off the table.
step()method 
public function step():void

A function that is called on every step of the physics engine. Updates the reading on each sensor and advances the robot's conroller one step as well.