org.lejon
Class DDModel

java.lang.Object
  extended byorg.lejon.DriveModel
      extended byorg.lejon.DDModel
All Implemented Interfaces:
SteeringEventListener

public class DDModel
extends DriveModel
implements SteeringEventListener

High-level implementation of a dual differential drive architecture for processing odometric navigation actions. The application submits MotionCommands defining actions, i.e. figures TRANSLATE, CURVE or ROTATE with its special parameters. The parameters are evaluated and the low-level layer is set up accordingly. If an action is executed the application can request MotionReports containing information about the state of the running action. Also, if an action is finished the application will be notified from a MotionEventListener if present.


Field Summary
 
Fields inherited from class org.lejon.DriveModel
IDLE, MOVING, PAUSE, SETUP
 
Method Summary
 void cancel()
          Changes to execution state IDLE.
 MotionReport getMotionReport()
          Returns the up-to-date motion report for the current action.
static DDModel instance(DriveParameters parameters)
          Returns the singleton instance of this class instantiated with the drive parameters.
 void move()
          Executes the latest action that has been set up.
 void pause()
          Pauses the running action.
 void resume()
          Restarts the action that is paused.
 void setMotionCommand(MotionCommand motionCommand)
          Sets up a new action.
 void steeringFinished()
          Is called from the Steerer thread when the requested action is completely finished.
 
Methods inherited from class org.lejon.DriveModel
addMotionEventListener, removeMotionEventListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static DDModel instance(DriveParameters parameters)
Returns the singleton instance of this class instantiated with the drive parameters.

Parameters:
parameters - the drive parameters
Returns:
the drive object

setMotionCommand

public void setMotionCommand(MotionCommand motionCommand)
Sets up a new action. This is only possible if the drive is in execution state IDLE. If the MotionCommand is not valid or the given parameters are not compatible it will return silently and the action will not be executed by calling move(). If the new action was set up successfully the drive will change in state SETUP.

Specified by:
setMotionCommand in class DriveModel
Parameters:
motionCommand - a motion command defining the new action.

getMotionReport

public MotionReport getMotionReport()
Returns the up-to-date motion report for the current action.

Specified by:
getMotionReport in class DriveModel
Returns:
the current motion report

move

public void move()
Executes the latest action that has been set up. This is only possible if the drive is in execution state SETUP. After starting successfully the drive changes to execution state MOVING. If the action is finished and a MotionEventListener has been set, the motionFinished() will be called.

Specified by:
move in class DriveModel

pause

public void pause()
Pauses the running action. This is only possible if the drive is in execution state MOVING. After pausing successfully the drive changes to execution state PAUSE.

Specified by:
pause in class DriveModel

resume

public void resume()
Restarts the action that is paused. This is only possible if the drive is in execution state PAUSE. After resuming successfully the drive changes to execution state MOVING.

Specified by:
resume in class DriveModel

cancel

public void cancel()
Changes to execution state IDLE. This method can be called in all execution states. If an action is currently running the drive will stop immediately. All status and position information will be kept until an new action is set up by sendMotionCommand().

Specified by:
cancel in class DriveModel

steeringFinished

public void steeringFinished()
Description copied from interface: SteeringEventListener
Is called from the Steerer thread when the requested action is completely finished.

Specified by:
steeringFinished in interface SteeringEventListener