edu.cmu.emulator.world
Class MovableObject

java.lang.Object
  extended by edu.cmu.emulator.world.MovableObject
Direct Known Subclasses:
Antenna, EmuNode

public class MovableObject
extends Object

Represents the general MovableObject. It tracks the object's position, velocity, etc in the emulated world.

Position and navigation attributes should not be set directly. Instead, navigation methods should be invoked to set these attributes. This allows for proper handling of listener code and termination of ongoing navigation.

EmuNode and Antenna extend this class.

See the world documentation for more information.


Field Summary
protected  RelVector accelerationMPS2
           
protected  HashMap attributeMap
           
protected  ArrayList children
           
private static boolean debugListeners
           
private static boolean debugSegment
           
protected  DirRelOrientationMatrix dirOrientation
          relative orientation computed from the velocityMPS
protected  GroupWorker groupWorker
           
static int ID_ACCELERATION_MPS2
           
static int ID_ORIENTATION
           
static int ID_POSITION
           
static int ID_ROTATION
           
static int ID_VELOCITY_MPS
           
protected  String name
           
protected  Navigator navigator
           
static int OM_PARENT
           
static int OM_VELOCITY
           
protected  RelOrientationMatrix orientation
          relative orientation in parent's reference frame
protected  int orientationMode
          The value is OM_PARENT or OM_VELOCITY.
protected  MovableObject parent
           
protected  RelPositionVector position
          relative position in parent's reference frame
protected  RelVector rotation
           
protected  long segmentEndMillis
           
protected  double[] segmentEndPos
           
protected  ListenerManager segmentListenerManager
           
protected  long segmentStartMillis
           
protected  double[] segmentStartPos
           
protected  String uName
           
protected  RelVector velocityMPS
           
 
Constructor Summary
MovableObject()
          Construct a MovableObject with the world as parent
MovableObject(MovableObject parent)
          Construct a MovableObject with the given parent
 
Method Summary
 void addChild(MovableObject child)
           
 void addSegmentListener(SegmentListener listener, int threadMode)
           
 void addWaypointListener(WaypointListener wpl)
           
 void addWaypointListener(WaypointListener wpl, int threadMode)
           
(package private)  void endSegment()
          Called by system code
 void fixOrientation(double[][] newOrientation)
          Set to a fixed orientation.
 double[] getAbsAcceleration()
           
 void getAbsAcceleration(double[] accel)
           
 double[][] getAbsOrientation()
          Get the absolute orientation .
 void getAbsOrientation(double[][] oMatrix)
           
 double[] getAbsPosition()
           
 void getAbsPosition(double[] pos)
           
 double[] getAbsRotation()
           
 void getAbsRotation(double[] vel)
           
 double[] getAbsVelocity()
           
 void getAbsVelocity(double[] vel)
           
 RelVector getAcceleration()
           
 Object getAttribute(String name)
           
 MovableObject getChild(int index)
           
 double getDistance(MovableObject other)
          Calculates the distance between this object and another MovableObject.
 String getName()
           
 int getNumChildren()
           
 RelOrientationMatrix getOrientation()
           
 void getOrientation(double[][] oMatrix)
           
 int getOrientationMode()
          Get the orientation mode
 MovableObject getParent()
           
 RelPositionVector getPosition()
           
 RelVector getRotation()
           
 String getUName()
           
 RelVector getVelocity()
           
 boolean isMoving()
          Checks if the node is in motion in the world..
 void moveToOverTime(double[] rPos, double timeSecs)
          Move to a given position over a given time interval.
 void moveToOverTime(double[] rPos, double timeSecs, long startTimeSecs)
          Move to a given position over a given time interval starting at the specified time.
 void moveToOverTime(double[] rPos, long timeMillis)
          Move to a given position over a given time interval.
 void moveToOverTime(double[] rPos, long timeMillis, long startTimeMillis)
          Move to a given position over a given time interval starting at the specified time.
 void moveToWithSpeed(double[] rPos, double speedMPS)
          Move to a given position at a given speed.
 void moveToWithSpeed(double[] rPos, double speedMPS, double startTimeSecs)
          Move to a given position at a given speed at a given start time.
 void moveToWithSpeed(double[] rPos, double speedMPS, long startTimeMillis)
          Move to a given position at a given speed at a given start time.
protected  void notifySegmentListeners(long timeMillis, boolean atStart)
           
 void removeSegmentListener(SegmentListener listener)
           
 void removeWaypointListener(WaypointListener wpl)
           
 void setAttribute(String name, Object value)
           
 void setName(String name)
           
 void setOrientationMode(int orientationMode)
          Set the orientation mode.
 void setStationaryAtPos(double[] rPos)
          Set the node to a specific position, and make it stationary.
 void setUName(String name)
           
 void startRoute(Route newRoute)
          Start navigation of a route.
(package private)  void startSegment(long startTimeMillis, long navTimeMillis, double[] segmentStartPos, double[] segmentEndPos)
          Called by system code
(package private)  void stopInPlace(long timeMillis)
          Called by system code
 void update(long timeMillis)
          Called by system code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name

uName

protected String uName

position

protected RelPositionVector position
relative position in parent's reference frame


velocityMPS

protected RelVector velocityMPS

accelerationMPS2

protected RelVector accelerationMPS2

orientation

protected RelOrientationMatrix orientation
relative orientation in parent's reference frame


dirOrientation

protected DirRelOrientationMatrix dirOrientation
relative orientation computed from the velocityMPS


orientationMode

protected int orientationMode
The value is OM_PARENT or OM_VELOCITY.
OM_VELOCITY: the parent of orientation is dirOrientation
OM_PARENT : the parent of orientation is MovableObject.parent.orientation
default value is OM_VELOCITY


rotation

protected RelVector rotation

ID_POSITION

public static final int ID_POSITION
See Also:
Constant Field Values

ID_VELOCITY_MPS

public static final int ID_VELOCITY_MPS
See Also:
Constant Field Values

ID_ACCELERATION_MPS2

public static final int ID_ACCELERATION_MPS2
See Also:
Constant Field Values

ID_ORIENTATION

public static final int ID_ORIENTATION
See Also:
Constant Field Values

ID_ROTATION

public static final int ID_ROTATION
See Also:
Constant Field Values

OM_PARENT

public static final int OM_PARENT
See Also:
Constant Field Values

OM_VELOCITY

public static final int OM_VELOCITY
See Also:
Constant Field Values

parent

protected MovableObject parent

children

protected ArrayList children

segmentListenerManager

protected ListenerManager segmentListenerManager

groupWorker

protected GroupWorker groupWorker

attributeMap

protected HashMap attributeMap

segmentStartMillis

protected long segmentStartMillis

segmentEndMillis

protected long segmentEndMillis

segmentStartPos

protected double[] segmentStartPos

segmentEndPos

protected double[] segmentEndPos

navigator

protected Navigator navigator

debugListeners

private static final boolean debugListeners
See Also:
Constant Field Values

debugSegment

private static final boolean debugSegment
See Also:
Constant Field Values
Constructor Detail

MovableObject

public MovableObject(MovableObject parent)
Construct a MovableObject with the given parent


MovableObject

public MovableObject()
Construct a MovableObject with the world as parent

Method Detail

setOrientationMode

public void setOrientationMode(int orientationMode)
Set the orientation mode.
OM_PARENT - relative to parent's reference frame.
OM_VELOCITY - relative to this objects velocity within its parent's reference frame.

See Also:
orientationMode

getOrientationMode

public int getOrientationMode()
Get the orientation mode


getParent

public MovableObject getParent()

setName

public void setName(String name)

getName

public String getName()

setUName

public void setUName(String name)

getUName

public String getUName()

getNumChildren

public int getNumChildren()

getChild

public MovableObject getChild(int index)

addChild

public void addChild(MovableObject child)

getPosition

public RelPositionVector getPosition()

getAbsPosition

public double[] getAbsPosition()

getAbsPosition

public void getAbsPosition(double[] pos)

getVelocity

public RelVector getVelocity()

getAbsVelocity

public double[] getAbsVelocity()

getAbsVelocity

public void getAbsVelocity(double[] vel)

getAcceleration

public RelVector getAcceleration()

getAbsAcceleration

public double[] getAbsAcceleration()

getAbsAcceleration

public void getAbsAcceleration(double[] accel)

getOrientation

public RelOrientationMatrix getOrientation()

getAbsOrientation

public double[][] getAbsOrientation()
Get the absolute orientation .

Returns:
double[][]

getAbsOrientation

public void getAbsOrientation(double[][] oMatrix)

getOrientation

public void getOrientation(double[][] oMatrix)

getRotation

public RelVector getRotation()

getAbsRotation

public double[] getAbsRotation()

getAbsRotation

public void getAbsRotation(double[] vel)

startRoute

public void startRoute(Route newRoute)
Start navigation of a route. Terminates any previous ongoing navigation.


isMoving

public boolean isMoving()
Checks if the node is in motion in the world..

Returns:
true of the node is moving towards its destination, false otherwise.

getDistance

public double getDistance(MovableObject other)
Calculates the distance between this object and another MovableObject. Abs consistency is loose.

Parameters:
other - distance of object to measure to
Returns:
the distance between the objects.

addSegmentListener

public void addSegmentListener(SegmentListener listener,
                               int threadMode)

removeSegmentListener

public void removeSegmentListener(SegmentListener listener)

notifySegmentListeners

protected void notifySegmentListeners(long timeMillis,
                                      boolean atStart)

addWaypointListener

public void addWaypointListener(WaypointListener wpl,
                                int threadMode)

addWaypointListener

public void addWaypointListener(WaypointListener wpl)

removeWaypointListener

public void removeWaypointListener(WaypointListener wpl)

getAttribute

public Object getAttribute(String name)

setAttribute

public void setAttribute(String name,
                         Object value)

setStationaryAtPos

public void setStationaryAtPos(double[] rPos)
Set the node to a specific position, and make it stationary. Terminates any previous ongoing navigation.


moveToWithSpeed

public void moveToWithSpeed(double[] rPos,
                            double speedMPS)
Move to a given position at a given speed. Terminates any previous ongoing navigation.


moveToWithSpeed

public void moveToWithSpeed(double[] rPos,
                            double speedMPS,
                            double startTimeSecs)
Move to a given position at a given speed at a given start time. Terminates any previous ongoing navigation.


moveToWithSpeed

public void moveToWithSpeed(double[] rPos,
                            double speedMPS,
                            long startTimeMillis)
Move to a given position at a given speed at a given start time. Terminates any previous ongoing navigation.


moveToOverTime

public void moveToOverTime(double[] rPos,
                           double timeSecs)
Move to a given position over a given time interval. Terminates any previous ongoing navigation.


moveToOverTime

public void moveToOverTime(double[] rPos,
                           double timeSecs,
                           long startTimeSecs)
Move to a given position over a given time interval starting at the specified time. Terminates any previous ongoing navigation.


moveToOverTime

public void moveToOverTime(double[] rPos,
                           long timeMillis)
Move to a given position over a given time interval. Terminates any previous ongoing navigation.


moveToOverTime

public void moveToOverTime(double[] rPos,
                           long timeMillis,
                           long startTimeMillis)
Move to a given position over a given time interval starting at the specified time. Terminates any previous ongoing navigation.


fixOrientation

public void fixOrientation(double[][] newOrientation)
Set to a fixed orientation. Terminates any previous ongoing navigation.

Parameters:
newOrientation - double[][]

startSegment

void startSegment(long startTimeMillis,
                  long navTimeMillis,
                  double[] segmentStartPos,
                  double[] segmentEndPos)
Called by system code


endSegment

void endSegment()
Called by system code


stopInPlace

void stopInPlace(long timeMillis)
Called by system code


update

public void update(long timeMillis)
Called by system code



Copyright © 2013. All Rights Reserved.