Packageorg.MARS.robot.control
Classpublic class BrainOne
InheritanceBrainOne Inheritance AbstractElectronicDevice
ImplementsIController
SubclassesBrainTwo

The Brain One is a basic analogue controller device. It has an electrical circuit which reverses the directions of the connected motors for a small period of time whenever one of the sensors connected to the motor is triggered.

IO Port configuration:
0 and 1 - inputs from sensors (0 - left, 1 - right)
2 through 5 - outputs (must be connected directly to the locomotion)

See also

IOPort
Robot
ILocomotion


Public Properties
 PropertyDefined by
 InheritednumberOfPorts : Number
Get the number of IO ports in the device.
AbstractElectronicDevice
Protected Properties
 PropertyDefined by
  leftDelay : Number
BrainOne
  leftPort : IOPort
BrainOne
  leftTimer : Number = 0
BrainOne
 Inherited_ports : Array
AbstractElectronicDevice
  rightDelay : Number
BrainOne
  rightPort : IOPort
BrainOne
  rightTimer : Number = 0
BrainOne
Public Methods
 MethodDefined by
  
BrainOne(ld:Number, rd:Number)
Creates a Brain One with the timers connected to the left and right motors set to the number of seconds provided.
BrainOne
 Inherited
getPort(portNumber:Number):IOPort
Get a certain IO port by its number
AbstractElectronicDevice
  
setTimers(ld:Number, rd:Number):void
Set the values of the Brain's timers to the provided ones
BrainOne
  
step():void
A function that is called on every step of the physics engine.
BrainOne
Protected Methods
 MethodDefined by
  
BrainOne
  
BrainOne
  
BrainOne
  
BrainOne
Public Constants
 ConstantDefined by
  LEFT_SENSOR_PORT : Number = 0
[static]
BrainOne
  RIGHT_SENSOR_PORT : Number = 1
[static]
BrainOne
Property detail
leftDelayproperty
protected var leftDelay:Number
leftPortproperty 
protected var leftPort:IOPort
leftTimerproperty 
protected var leftTimer:Number = 0
rightDelayproperty 
protected var rightDelay:Number
rightPortproperty 
protected var rightPort:IOPort
rightTimerproperty 
protected var rightTimer:Number = 0
Constructor detail
BrainOne()constructor
public function BrainOne(ld:Number, rd:Number)

Creates a Brain One with the timers connected to the left and right motors set to the number of seconds provided.

NOTE: using timers of slightly different values will help the robot to avoid getting stuck in on place whenever it's movement is perpendicular to the edge of the surface.

Parameters
ld:Number — - left timer (in seconds)
 
rd:Number — - right timer (in seconds)
Method detail
leftWheelForward()method
protected function leftWheelForward():void
leftWheelReverse()method 
protected function leftWheelReverse():void
rightWheelForward()method 
protected function rightWheelForward():void
rightWheelReverse()method 
protected function rightWheelReverse():void
setTimers()method 
public function setTimers(ld:Number, rd:Number):void

Set the values of the Brain's timers to the provided ones

Parameters
ld:Number — - left timer (in seconds)
 
rd:Number — - right timer (in seconds)
step()method 
public function step():void

A function that is called on every step of the physics engine. It advances the timers and reverses the motors whenever needed.

Constant detail
LEFT_SENSOR_PORTconstant
public static const LEFT_SENSOR_PORT:Number = 0
RIGHT_SENSOR_PORTconstant 
public static const RIGHT_SENSOR_PORT:Number = 1