Boeing Simulation 3.1 API Specification

worldsimulator
Class SimulatorUAV

java.lang.Object
  |
  +--objects.WhatWhere
        |
        +--objects.MovableWhatWhere
              |
              +--worldsimulator.SimulatorUAV
All Implemented Interfaces:
Component, Extensible, Locatable, Movable, Runnable, Serializable, UAV

public class SimulatorUAV
extends MovableWhatWhere
implements UAV, Component, Runnable, Serializable

This class simulates a UAV based on the data pushed to it by the Simulator. It also has events that it fires so that registered listeners can know what it is doing.

Version:
$Revision: 1.31 $
Author:
Dave Jurgens
, Jim Adamich
See Also:
Serialized Form

Field Summary
private static boolean DEBUG
          Debug flag.
protected static double DISTANCE_PER_PERIOD
          The maximum percentage of the world that the UAV can move in one update cycle.
private  objects.Locatable goal
          The location where this UAV will attept to go towards.
private  Long id
          The unique ID used to distinguish this UAV from another UAV.
private  util.Queue imageQueue
          The queue that will hold the UAVImage objects that the ComponentizedSimulator will push to this class.
private  connect.ChannelBundle managerChannels
          The channels over which this UAV will communicate with the uav.UAVManager.
private  int num
           
private  connect.ChannelBundle objectLocater
          The channels over which this UAV will communicate with the ObjectLocater.
private static long serialVersionUID
           
private  connect.ChannelBundle simulatorChannels
          The channels over which this UAV will communicate with the ComponentizedSimulator.
private  util.ConsumerQueue simulatorQueue
          The multithreaded queue for reading in objects from the server.
private  boolean started
          Internal flag to make sure that a UAV is not started twice.
protected static long STEP_COST
          The time in milliseconds in which at step method can start and finish its execution.
protected static objects.Dimension UAV_DIM
          The default dimensions of the UAV
private static int uavNum
           
protected static long UPDATE_PERIOD
          The time in milliseconds at which this UCAV will update it's movement.
protected static double VIEWING_RADIUS
          The radius in which a UAV can see other objects.
 
Fields inherited from class objects.WhatWhere
dim, loc
 
Constructor Summary
SimulatorUAV(connect.CreatesConnection toUAVManager, connect.CreatesConnection toSimulator)
          Constructs this object with a random location.
SimulatorUAV(objects.Location loc, connect.CreatesConnection toUAVManager, connect.CreatesConnection toSimulator)
           
 
Method Summary
protected  boolean allowMethod(util.MethodRequest request)
          Returns true due to undefined behavior at this point.
 void connect(connect.CreatesConnection host)
          Connects to an ObjectLocater and then continuously writes out UAVImage objects from the imageQueue.
private  void debug(String msg)
           
 boolean equals(Object other)
          Returns true if the object is a SimulatorUAV and has the same ID value.
 connect.CreatesConnection getConnection()
          Returns null because no connection is allowed.
 objects.Locatable getGoal()
           
 long getID()
          Returns the unique ID for this UAV.
 worldsimulator.SimulatorUAV getUAV()
          Returns an instance of this.
 double getViewingRadius()
          Returns the distance on the unit square within which this UAV is able to see other objects.
 int hashCode()
          Returns the hash code based on its ID.
private  void receiveImage(uav.UAVImage image)
           
 void run()
          Calls the periodic step function.
 void setGoal(objects.Locatable loc)
          Sets the goal toward which this object will move.
 void startPeriodicMovements()
          Starts the Thread that will periodically move this UAV.
 void startProcessingThread()
          Processes MethodRequest objects that are sent to this object.
 void step()
          Contacts the simulator for information regard what the UAV can see.
 String toString()
           
 
Methods inherited from class objects.MovableWhatWhere
setLoc, setLoc
 
Methods inherited from class objects.WhatWhere
bound, getCenter, getDimensions, getDistance, getHeight, getLoc, getWidth, isEastOf, isNorthOf, isSouthOf, isWestOf, overlaps
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface objects.Movable
setLoc, setLoc
 
Methods inherited from interface objects.Locatable
getDistance, getLoc, isEastOf, isNorthOf, isSouthOf, isWestOf
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

imageQueue

private final transient util.Queue imageQueue
The queue that will hold the UAVImage objects that the ComponentizedSimulator will push to this class.


managerChannels

private transient connect.ChannelBundle managerChannels
The channels over which this UAV will communicate with the uav.UAVManager.


simulatorChannels

private transient connect.ChannelBundle simulatorChannels
The channels over which this UAV will communicate with the ComponentizedSimulator.


objectLocater

private transient connect.ChannelBundle objectLocater
The channels over which this UAV will communicate with the ObjectLocater.


goal

private objects.Locatable goal
The location where this UAV will attept to go towards.


UAV_DIM

protected static final objects.Dimension UAV_DIM
The default dimensions of the UAV


VIEWING_RADIUS

protected static final double VIEWING_RADIUS
The radius in which a UAV can see other objects. These UAVs need an idea of what they can see. So the Simulator needs to look at where they are and then fill in what they're seeing based on what is within the VIEWING_RADIUS.

See Also:
Constant Field Values

DISTANCE_PER_PERIOD

protected static final double DISTANCE_PER_PERIOD
The maximum percentage of the world that the UAV can move in one update cycle.

See Also:
Constant Field Values

UPDATE_PERIOD

protected static final long UPDATE_PERIOD
The time in milliseconds at which this UCAV will update it's movement.

See Also:
Constant Field Values

STEP_COST

protected static final long STEP_COST
The time in milliseconds in which at step method can start and finish its execution.

See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
Debug flag.

See Also:
Constant Field Values

id

private final Long id
The unique ID used to distinguish this UAV from another UAV.


started

private boolean started
Internal flag to make sure that a UAV is not started twice.


simulatorQueue

private transient util.ConsumerQueue simulatorQueue
The multithreaded queue for reading in objects from the server.


uavNum

private static int uavNum

num

private final int num
Constructor Detail

SimulatorUAV

public SimulatorUAV(connect.CreatesConnection toUAVManager,
                    connect.CreatesConnection toSimulator)
Constructs this object with a random location.


SimulatorUAV

public SimulatorUAV(objects.Location loc,
                    connect.CreatesConnection toUAVManager,
                    connect.CreatesConnection toSimulator)
Method Detail

receiveImage

private void receiveImage(uav.UAVImage image)

startProcessingThread

public void startProcessingThread()
Processes MethodRequest objects that are sent to this object.


connect

public void connect(connect.CreatesConnection host)
Connects to an ObjectLocater and then continuously writes out UAVImage objects from the imageQueue.

Specified by:
connect in interface Component

getGoal

public objects.Locatable getGoal()

run

public final void run()
Calls the periodic step function.

Specified by:
run in interface Runnable
See Also:
step()

setGoal

public void setGoal(objects.Locatable loc)
Sets the goal toward which this object will move.


step

public void step()
Contacts the simulator for information regard what the UAV can see. This information is then transformed into a UAVImage and enqueued. The processing threads dequeue this information and write it to the ObjectLocater.


startPeriodicMovements

public void startPeriodicMovements()
Starts the Thread that will periodically move this UAV. If in a realtime system, it is not feasible for this object to periodically update its movements, then all connections will be closed.

See Also:
ThreadFactory, WorkerThread, RTWorkerThread, Ceaseable

allowMethod

protected boolean allowMethod(util.MethodRequest request)
Returns true due to undefined behavior at this point.


getConnection

public connect.CreatesConnection getConnection()
Returns null because no connection is allowed.

Specified by:
getConnection in interface Component

getViewingRadius

public double getViewingRadius()
Description copied from interface: UAV
Returns the distance on the unit square within which this UAV is able to see other objects.

Specified by:
getViewingRadius in interface UAV

getID

public long getID()
Description copied from interface: UAV
Returns the unique ID for this UAV.

Specified by:
getID in interface UAV

equals

public boolean equals(Object other)
Returns true if the object is a SimulatorUAV and has the same ID value. Note that this is not completely safe among distrubed systems since two SimulatorUAVs may get the same ID. However the chance of that happening is n * (1 / (263 -1)), where n is the total number of SimulatorUAVs.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code based on its ID.

Overrides:
hashCode in class Object

getUAV

public worldsimulator.SimulatorUAV getUAV()
Returns an instance of this. This method is used by remote compentents such as the ComponentizedSimulator.


toString

public String toString()
Overrides:
toString in class Object

debug

private void debug(String msg)

Boeing Simulation 3.1 API Specification

To submit a bug or feature email the author of that class. Funding for this research was provided by Boeing and DARPA.