Class 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 class  Move.MoveType
      The 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 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​(java.io.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​(java.io.DataInputStream dis)  
      void setDynamics​(float travelSpeed, float rotateSpeed)
      use this method to recycle an existing Move instead of creating a new one
      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
      java.lang.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
Parameters:
isMoving -
angle -
turnRadius -