org.lejon
Class Steerer

java.lang.Object
  extended byorg.lejon.Steerer
All Implemented Interfaces:
josx.util.TimerListener

public final class Steerer
extends java.lang.Object
implements josx.util.TimerListener

Low-level driver class for controlling the drive hardware. We use a ms-timer to create a timebase for periodic control and position update. The timeout is handled concurrently. The motion is controlled by a PID controller compensating the rotation differential of the wheels against a given setpoint.


Field Summary
static josx.platform.rcx.Motor MotorLeft
           
static int MotorModeL
           
static int MotorModeR
           
static int MotorPowerL
           
static int MotorPowerR
           
static josx.platform.rcx.Motor MotorRight
           
static josx.platform.rcx.Sensor SensorLeft
           
static josx.platform.rcx.Sensor SensorRight
           
 
Constructor Summary
Steerer()
          Creates an new instance with its own timer and PID controller
 
Method Summary
 void cancel()
          Cancels the running action.
 MotionReport getReport(MotionReport report)
          Returns the local pose of the drive and the distance travelled along the path.
 void init(DriveParameters driveParams, SteeringEventListener sel)
          Initializes the newly created instance against the given drive constants and sets up the callback mechanism.
 void move()
          (Re)start the action that was set up or paused previously.
 void pause()
          Pauses the running action.
 void setup(float setpointPID, int motorPowerL, int motorPowerR, int motorModeL, int motorModeR, int aimedTicksLeft, int aimedTicksRight)
          Setup a new action.
 void timedOut()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MotorLeft

public static josx.platform.rcx.Motor MotorLeft

MotorRight

public static josx.platform.rcx.Motor MotorRight

SensorLeft

public static josx.platform.rcx.Sensor SensorLeft

SensorRight

public static josx.platform.rcx.Sensor SensorRight

MotorModeL

public static int MotorModeL

MotorModeR

public static int MotorModeR

MotorPowerL

public static int MotorPowerL

MotorPowerR

public static int MotorPowerR
Constructor Detail

Steerer

public Steerer()
Creates an new instance with its own timer and PID controller

Method Detail

init

public void init(DriveParameters driveParams,
                 SteeringEventListener sel)
Initializes the newly created instance against the given drive constants and sets up the callback mechanism.

Parameters:
driveParams - the drive parameters
sel - the handler for steering events

setup

public void setup(float setpointPID,
                  int motorPowerL,
                  int motorPowerR,
                  int motorModeL,
                  int motorModeR,
                  int aimedTicksLeft,
                  int aimedTicksRight)
Setup a new action.

Parameters:
setpointPID - constant TICKS differential per period to control. This is the velocity diffential of left and right wheel. The setpoint is defined here as vl - vr.
motorPowerL - initial power level of left motor, one of {0,1,...,7}
motorPowerR - initial power level of right motor, one of {0,1,...,7}
motorModeL - the mode for left motor, 1 = FORWARD, 2 = BACKWARD
motorModeR - the mode for right motor, 1 = FORWARD, 2 = BACKWARD
aimedTicksLeft - the amount of TICKS of left wheel after action is finished. This defines the distance in TICKS the left wheel has to travel. The value must always be positive.
aimedTicksRight - the amount of TICKS of right wheel after action is finished. This defines the distance in TICKS the right wheel has to travel. The value must always be positive.

move

public void move()
(Re)start the action that was set up or paused previously.


pause

public void pause()
Pauses the running action.


cancel

public void cancel()
Cancels the running action.


getReport

public MotionReport getReport(MotionReport report)
Returns the local pose of the drive and the distance travelled along the path. The report is local to the current action.

Parameters:
report - the report object to fill
Returns:
the motion report

timedOut

public void timedOut()
Specified by:
timedOut in interface josx.util.TimerListener