lejos.robotics.navigation
Class Move

java.lang.Object
  extended by lejos.robotics.navigation.Move
All Implemented Interfaces:
Transmittable

public class Move
extends Object
implements Transmittable

Models a movement performed by a pilot

Author:
Lawrie Griffiths

Nested Class Summary
static class Move.MoveType
          The type of movement made in sufficient detail to allow errors in the movement to be modeled.
 
Constructor Summary
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
static float convertAngleToDistance(float angle, float turnRadius)
          Static utility method for converting angle (given turn radius) into distance.
static float convertDistanceToAngle(float distance, float turnRadius)
          Static utility method for converting distance (given turn radius) into angle.
 void dumpObject(DataOutputStream dos)
           
 float getAngleTurned()
          Get the angle turned by a rotate or an arc operation.
 float getArcRadius()
          Get the radius of the arc
 float getDistanceTraveled()
          Get the distance traveled.
 Move.MoveType getMoveType()
          Get the type of the movement performed
 float getRotateSpeed()
          Get the rotate speed
 long getTimeStamp()
          The time stamp is the system clock at the time the Move object is created.
 float getTravelSpeed()
          Get the travel speed
 boolean isMoving()
          Test if move was in progress
 void loadObject(DataInputStream dis)
           
 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
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 units
    angle - the angle turned in degrees
    isMoving - 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 type
    distance - the distance traveled in pilot units
    angle - the angle turned in degrees
    travelSpeed - the travel speed
    rotateSpeed - the rotate speed
    isMoving - 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 type
    distance - the distance traveled in pilot units
    angle - the angle turned in degrees
    isMoving - 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 -

    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 using System.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(DataOutputStream dos)
                    throws IOException
    Specified by:
    dumpObject in interface Transmittable
    Throws:
    IOException

    loadObject

    public void loadObject(DataInputStream dis)
                    throws IOException
    Specified by:
    loadObject in interface Transmittable
    Throws:
    IOException

    toString

    public String toString()
    Overrides:
    toString in class Object