org.lejon.events
Class MotionCommand

java.lang.Object
  extended byorg.lejon.events.MotionCommand

public class MotionCommand
extends java.lang.Object

Wrapper class for defining actions that can be executed by the drive object. Possible actions are TRANSLATE, ROTATE in place and driving CURVEs (segments of circles with constant radius).

Possible actions to be executed by a drive. The relevant parameters for a a specific action is shown in the following table.
figureparameters
TRANSLATEdistance [cm]
ROTATEangle [deg]
CURVEradius [cm], angle [deg]


Field Summary
static int CURVE
          Constant for action CURVE
static int NO_ACTION
          Constant for no action
static int ROTATE
          Constant for action ROTATE
static int TRANSLATE
          Constant for action TRANSLATE
 
Constructor Summary
MotionCommand()
          Creates a new empty instance.
MotionCommand(int action, int maxpower, int distance, int angle, int radius)
          Creates and initializes a new instance.
 
Method Summary
 int getAction()
          Returns the type of the action.
 int getAngle()
          Returns the relative direction angle to rotate to.
 int getDistance()
          Returns the distance to travel ahead.
 int getMaxPower()
          Returns the maximum motor power to use.
 int getRadius()
          Returns the curve radius.
 void setAction(int action)
          Sets the action type.
 void setAngle(int angle)
          Sets the relative direction angle to rotate to; for CURVE and ROATATE
 void setDistance(int distance)
          Sets the distance to travel ahead.
 void setMaxPower(int maxpower)
          Sets the maximum motor power to use.
 void setRadius(int radius)
          Sets the curve radius.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ACTION

public static final int NO_ACTION
Constant for no action

See Also:
Constant Field Values

TRANSLATE

public static final int TRANSLATE
Constant for action TRANSLATE

See Also:
Constant Field Values

ROTATE

public static final int ROTATE
Constant for action ROTATE

See Also:
Constant Field Values

CURVE

public static final int CURVE
Constant for action CURVE

See Also:
Constant Field Values
Constructor Detail

MotionCommand

public MotionCommand()
Creates a new empty instance.


MotionCommand

public MotionCommand(int action,
                     int maxpower,
                     int distance,
                     int angle,
                     int radius)
Creates and initializes a new instance.

Parameters:
action - type of action, one of {TRANSLATE, ROTATE, CURVE}
maxpower - max motor power to use, one of {0,1,...,7}
distance - distance [cm] to travel ahead; only for TRANSLATE
angle - relative direction angle [deg] to rotate to; for ROTATE and CURVE; angle < 0 means clockwise rotation
radius - curve radius [cm]; only for CURVE; must be greater than or equal to the axle length of the drive
Method Detail

getAction

public int getAction()
Returns the type of the action.

Returns:
the action code

getMaxPower

public int getMaxPower()
Returns the maximum motor power to use.

Returns:
the maximum motor power

getDistance

public int getDistance()
Returns the distance to travel ahead.

Returns:
the distance [cm]

getAngle

public int getAngle()
Returns the relative direction angle to rotate to.

Returns:
the angle [deg]

getRadius

public int getRadius()
Returns the curve radius.

Returns:
the radius [cm]

setAction

public void setAction(int action)
Sets the action type.

Parameters:
action - the action code

setMaxPower

public void setMaxPower(int maxpower)
Sets the maximum motor power to use.

Parameters:
maxpower - the max power level of the motors, one of {0,1,...7}

setDistance

public void setDistance(int distance)
Sets the distance to travel ahead.

Parameters:
distance - the distance [cm]

setAngle

public void setAngle(int angle)
Sets the relative direction angle to rotate to; for CURVE and ROATATE

Parameters:
angle - the angle [deg]

setRadius

public void setRadius(int radius)
Sets the curve radius.

Parameters:
radius - the radius [cm]