Package lejos.robotics.navigation
Class Move
- java.lang.Object
-
- lejos.robotics.navigation.Move
-
- All Implemented Interfaces:
Transmittable
public class Move extends java.lang.Object implements Transmittable
Models a movement performed by a pilot- Author:
- Lawrie Griffiths
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMove.MoveTypeThe type of movement made in sufficient detail to allow errors in the movement to be modeled.
-
Constructor Summary
Constructors Constructor Description Move(boolean isMoving, float angle, float turnRadius)Alternate constructor that uses angle and turn radius instead.Move(float distance, float angle, boolean isMoving)Create a movement object to record a movement made by a pilot.Move(Move.MoveType type, float distance, float angle, boolean isMoving)Create a movement object to record a movement made by a pilot.Move(Move.MoveType type, float distance, float angle, float travelSpeed, float rotateSpeed, boolean isMoving)Create a movement object to record a movement made by a pilot.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static floatconvertAngleToDistance(float angle, float turnRadius)Static utility method for converting angle (given turn radius) into distance.static floatconvertDistanceToAngle(float distance, float turnRadius)Static utility method for converting distance (given turn radius) into angle.voiddumpObject(java.io.DataOutputStream dos)floatgetAngleTurned()Get the angle turned by a rotate or an arc operation.floatgetArcRadius()Get the radius of the arcfloatgetDistanceTraveled()Get the distance traveled.Move.MoveTypegetMoveType()Get the type of the movement performedfloatgetRotateSpeed()Get the rotate speedlonggetTimeStamp()The time stamp is the system clock at the time the Move object is created.floatgetTravelSpeed()Get the travel speedbooleanisMoving()Test if move was in progressvoidloadObject(java.io.DataInputStream dis)voidsetDynamics(float travelSpeed, float rotateSpeed)use this method to recycle an existing Move instead of creating a new onevoidsetValues(Move.MoveType type, float distance, float angle, boolean isMoving)use this method to recycle an existing Move instead of creating a new onejava.lang.StringtoString()
-
-
-
Constructor Detail
-
Move
public Move(float distance, float angle, boolean isMoving)Create a movement object to record a movement made by a pilot. This method automatically calculates the MoveType based on the data as follows:
- (distance NOT 0) AND (angle NOT 0) --> ARC
- (distance = 0) AND (angle NOT 0) --> ROTATE
- (distance NOT 0) AND (angle = 0) --> TRAVEL
- (distance = 0) AND (angle = 0) --> STOP
- Parameters:
distance- the distance traveled in pilot unitsangle- the angle turned in degreesisMoving- true iff the movement was created while the robot was moving
-
Move
public Move(Move.MoveType type, float distance, float angle, float travelSpeed, float rotateSpeed, boolean isMoving)
Create a movement object to record a movement made by a pilot.- Parameters:
type- the movement typedistance- the distance traveled in pilot unitsangle- the angle turned in degreestravelSpeed- the travel speedrotateSpeed- the rotate speedisMoving- true iff the movement was created while the robot was moving
-
Move
public Move(Move.MoveType type, float distance, float angle, boolean isMoving)
Create a movement object to record a movement made by a pilot.- Parameters:
type- the movement typedistance- the distance traveled in pilot unitsangle- the angle turned in degreesisMoving- true iff the movement was created while the robot was moving
-
Move
public Move(boolean isMoving, float angle, float turnRadius)Alternate constructor that uses angle and turn radius instead. Useful for constructing arcs, but it can't represent a straight line of travel with a set distance (use the other constructor to specify distance). This method automatically calculates the MoveType based on the data as follows:
- (radius NOT 0) AND (angle NOT 0) --> ARC
- (radius = 0) AND (angle NOT 0) --> ROTATE
- (radius = 0) AND (angle = 0) --> STOP
- (radius = +infinity) AND (angle = 0) --> TRAVEL
- NOTE: can't calculate distance based only on angle and radius, therefore distance can't be calculated and will equal NaN)
- Parameters:
isMoving-angle-turnRadius-
-
-
Method Detail
-
setValues
public void setValues(Move.MoveType type, float distance, float angle, boolean isMoving)
use this method to recycle an existing Move instead of creating a new one- Parameters:
distance-angle-isMoving-
-
setDynamics
public void setDynamics(float travelSpeed, float rotateSpeed)use this method to recycle an existing Move instead of creating a new one- Parameters:
travelSpeed- the new travelspeedrotateSpeed- the new rotate speed
-
getDistanceTraveled
public float getDistanceTraveled()
Get the distance traveled. This can be in a straight line or an arc path.- Returns:
- the distance traveled
-
getTimeStamp
public long getTimeStamp()
The time stamp is the system clock at the time the Move object is created. It is set automatically in the Move constructor usingSystem.currentTimeMillis()- Returns:
- Time stamp in milliseconds.
-
getAngleTurned
public float getAngleTurned()
Get the angle turned by a rotate or an arc operation.- Returns:
- the angle turned
-
getMoveType
public Move.MoveType getMoveType()
Get the type of the movement performed- Returns:
- the movement type
-
getArcRadius
public float getArcRadius()
Get the radius of the arc- Returns:
- the radius of the arc
-
getTravelSpeed
public float getTravelSpeed()
Get the travel speed- Returns:
- the travel speed
-
getRotateSpeed
public float getRotateSpeed()
Get the rotate speed- Returns:
- the rotate speed
-
isMoving
public boolean isMoving()
Test if move was in progress- Returns:
- true iff the robot was moving when this Move object was created
-
convertDistanceToAngle
public static float convertDistanceToAngle(float distance, float turnRadius)Static utility method for converting distance (given turn radius) into angle.- Parameters:
distance-turnRadius-- Returns:
- angle
-
convertAngleToDistance
public static float convertAngleToDistance(float angle, float turnRadius)Static utility method for converting angle (given turn radius) into distance.- Parameters:
angle-turnRadius-- Returns:
- distance
-
dumpObject
public void dumpObject(java.io.DataOutputStream dos) throws java.io.IOException- Specified by:
dumpObjectin interfaceTransmittable- Throws:
java.io.IOException
-
loadObject
public void loadObject(java.io.DataInputStream dis) throws java.io.IOException- Specified by:
loadObjectin interfaceTransmittable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-