| Package | org.MARS.robot |
| Class | public class Robot |
| Inheritance | Robot RigidBody SimpleParticle flash.events.EventDispatcher |
| Implements | IBody, IODE, ISimulatable |
| Property | Defined by | ||
|---|---|---|---|
| actuators : Array [read-only]
Robot's actuators
| Robot | ||
![]() | av : Number | RigidBody | |
![]() | collisionTypeID : String | RigidBody | |
| controller : IController
[read-only]
Robot's controller
| Robot | ||
![]() | elasticity : Number | SimpleParticle | |
![]() | force : Vector | SimpleParticle | |
![]() | friction : Number | SimpleParticle | |
![]() | I : Number | RigidBody | |
![]() | inverseI : Number | RigidBody | |
![]() | inverseMass : Number | SimpleParticle | |
| isAlive : Boolean [read-only]
| Robot | ||
| locomotion : ILocomotion
[read-only]
Robot's locomotion system
| Robot | ||
![]() | mass : Number | SimpleParticle | |
![]() | position : Vector | SimpleParticle | |
| previousPosition : Vector
[read-only]
| Robot | ||
![]() | q : Number | RigidBody | |
![]() | rotation : 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 | ||
![]() | shape : Shape | RigidBody | |
![]() | state : Array
Gets the state of the differential equation
Consider a particle with position x and velocity v. | SimpleParticle | |
![]() | torque : Number | RigidBody | |
![]() | velocity : Vector | SimpleParticle | |
![]() | vx : Number | SimpleParticle | |
![]() | vy : Number | SimpleParticle | |
![]() | x : Number
Note that these values that constitute this IODE's state use getters/setters
that access specific indices within _state.
| SimpleParticle | |
![]() | y : Number | SimpleParticle | |
| Method | Defined 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 | ||
![]() |
accumulateForces():void
Accumulates forces
| SimpleParticle | |
|
addActuator(actuator:IActuator):void
Add the provided actuator to the robot
| Robot | ||
![]() |
Adds a force to the particle
| SimpleParticle | |
![]() |
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 | |
![]() |
addForceGenerator(generator:IForceGenerator):void
Adds a force generator to influence this particle
| SimpleParticle | |
|
Add the provided sensor to the robot
| Robot | ||
|
addToEnvironment():void
Simple way to attach the robot to the Environment for simulation
| Robot | ||
![]() |
addTorque(torque:Number):void
Adds torque to the body
This is the rotational equivalent to adding a force | RigidBody | |
![]() |
clearForces():void
Clears all forces
| SimpleParticle | |
![]() |
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 | ||
![]() |
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 | ||
![]() |
removeForceGenerator(generator:IForceGenerator):void
Removes a force generator
| SimpleParticle | |
|
step():void
A function that is called on every step of the physics engine.
| Robot | ||
| actuators | property |
actuators:Array [read-only]Robot's actuators
Implementation public function get actuators():Array
| controller | property |
controller:IController [read-only]Robot's controller
Implementation public function get controller():IController
| isAlive | property |
isAlive:Boolean [read-only]Implementation
public function get isAlive():Boolean
| locomotion | property |
locomotion:ILocomotion [read-only]Robot's locomotion system
Implementation public function get locomotion():ILocomotion
| previousPosition | property |
| sensors | property |
sensors:Array [read-only]Robot's sensors
Implementation public function get sensors():Array
| 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
Parametersx: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)
|
| addActuator | () | method |
public function addActuator(actuator:IActuator):voidAdd the provided actuator to the robot
Parametersactuator:IActuator |
| addSensor | () | method |
public function addSensor(sensor:ISensor):voidAdd the provided sensor to the robot
Parameterssensor:ISensor |
| addToEnvironment | () | method |
public function addToEnvironment():voidSimple way to attach the robot to the Environment for simulation
| collide | () | method |
public function collide():voidPrint a message that the robot has collided with a wall or a heavy object
| fallOff | () | method |
public function fallOff():voidPrint a message that the robot has fallen off of the table
| getDerivative | () | method |
public override function getDerivative(state:Array, derivative:Array):voidGets the derivative of the body
Parametersstate:Array — body's state
|
|
derivative:Array — Array to populate with body's derivative
|
See also
| isOnTable | () | method |
public function isOnTable():BooleanCheck if the robot is on the table by checking if both of its wheels are on the table.
ReturnsBoolean — true if both wheels are on the table, false
if any of the wheels is off the table.
|
| step | () | method |
public function step():voidA 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.