mil.navy.nps.dis
Class CollisionPdu

java.lang.Object
  extended bymil.navy.nps.dis.PduElement
      extended bymil.navy.nps.dis.ProtocolDataUnit
          extended bymil.navy.nps.dis.CollisionPdu
All Implemented Interfaces:
java.lang.Cloneable, SerializationInterface

public class CollisionPdu
extends ProtocolDataUnit

Report collision between entities.

Version:
1.0
Author:
Don McGregor (http://www.npsnet.org/~mcgredo)
Location:
Web: http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/CollisionPdu.java
or locally: ~/mil/navy/nps/dis/CollisionPdu.java
Hierarchy Diagram:
Summary:
Collisions between entities shall be communicated by issuing a Collision PDU.
Explanation:
The collision pdu denotes the collision between two entities. It inherits the header information from ProtocolDataUnit, an abstract class that contains assorted protocol information. It implements the IDs of the issuing entity, the colliding entity, the event, and where the impact occurred with respect to the issuing entity.

As with other PDUs, it knows how to serialize and deserialize itself from the wire. It also knows how to clone itself, and knows how to calculate its size when sent to the wire.

Note:
Here we don't have any padding field, because it isn't used in DIS. However, it is serialized and deSerialized when written to the wire. Also note that we have not created accessor methods for the nested fields.
History:
10Sep97 /JPL /New
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation
11Dec97 /Ronan Fauglas /changed access methods: thisVariable() --> getThisVariable()
15Nov99 /Christian Taranti /Revised and added commends. Javadoc compliant.
References:
DIS-Java-VRML Working Group: http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/
DIS Data Dictionary:Collision PDU
DIS specification: IEEE 1278.1, Section 4.4.2.2, 5.4.3.2
See Also:
EntityStatePdu, PduElement, ProtocolDataUnit, SerializationInterface, CollisionTypeField

Field Summary
protected  EntityID collidingEntityID
          Colliding Entity ID - This field shall identify the entity that has collided with the issuing entity.
protected  UnsignedByte collisionType
          Collision Type - This field shall identify the type of collision.
protected  EventID eventID
          Event ID - this field shall contain an identification generated by the issuing simulation application to associate related collision events.
protected  EntityID issuingEntityID
          Issuing Entity ID - This field shall identify the entity that is issueing the Pdu
protected  EntityCoordinate location
          Location - [m,m,m] This field shall specify the location of the collision with respect to the entity with which the issuing entity collided.
protected  float mass
          Mass - [kg] this field shall contain the mass of the issuing entity.
static int sizeOf
          Constant value- [bytes] size of an collision PDU without headder.
protected  LinearVelocity velocity
          Velocity - [m/s] This field shall contain the velocity of the issuing entity (at the time the collision is detected).
 
Fields inherited from class mil.navy.nps.dis.ProtocolDataUnit
DEBUG, exerciseID, pduType, protocolFamily, protocolVersion, timeReceived, timestamp
 
Constructor Summary
CollisionPdu()
          Default constructor--fills with zeros for all values.
 
Method Summary
 java.lang.Object clone()
          Makes deep copies of all the instance variables, so we don't have two objects pointing to the same data.
 void deSerialize(java.io.DataInputStream inputStream)
          Deserialize our data from the input stream.
 EntityID getCollidingEntityID()
          Returns the ID of the colliding entity.
 UnsignedByte getCollisionType()
          Returns the type of the collision.
 EventID getEventID()
          Returns the ID of the event.
 EntityID getIssuingEntityID()
          Returns the ID of the issuing entity.
 LinearVelocity getLinearVelocity()
          Returns the linear velocity (safe deep copy).
 EntityCoordinate getLocation()
          Returns location of the colliding entity (safe deep copy).
 float getMass()
          Returns the mass of the colliding entity
 int length()
          returns the size of the class (return sizeOf)
 java.lang.String pduName()
          returns new String("Collision PDU").
 void printValues(int indentLevel, java.io.PrintStream printStream)
          Prints the valules of the PDU fields.
 void serialize(java.io.DataOutputStream outputStream)
          Serialize our data out to the stream.
 void setCollidingEntityID(EntityID pCollidingEntityID)
          Sets the ID of the colliding entity.
 void setCollisionType(UnsignedByte pCollisionType)
          Sets the type of the collision.
 void setEventID(EventID pEventID)
          Sets the ID of the event.
 void setIssuingEntityID(EntityID pIssuingEntityID)
          Sets the ID of the issuing entity.
 void setLinearVelocity(float x, float y, float z)
          Sets the linear velocity given each of the xyz velocities
 void setLinearVelocity(LinearVelocity pLinearVelocity)
          Sets the linear velocity given a lienar velocity
 void setLocation(EntityCoordinate pLocation)
          Sets location of the colliding entity.
 void setLocation(float x, float y, float z)
          Sets location of the colliding entity given (x,y,z).
 void setMass(float pMass)
          Sets the mass of the colliding entity
 
Methods inherited from class mil.navy.nps.dis.ProtocolDataUnit
byteArrayToPdu, datagramToPdu, debug, getExerciseID, getPaddingOfLength, getPduType, getProtocolFamily, getProtocolVersion, getRtpHeaderEnabled, getTimeReceived, getTimestamp, getVRMLTimestamp, makeTimestampCurrent, setExerciseID, setExerciseID, setPduType, setPduType, setProtocolFamily, setProtocolFamily, setProtocolVersion, setProtocolVersion, setRtpHeaderEnabled, setSimulationStartTime, setTimeReceived, setTimestamp, setTimestamp, stampTimeReceived, toString, trace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

issuingEntityID

protected EntityID issuingEntityID
Issuing Entity ID - This field shall identify the entity that is issueing the Pdu


collidingEntityID

protected EntityID collidingEntityID
Colliding Entity ID - This field shall identify the entity that has collided with the issuing entity.
Value:
If the entity ID is unknown or the collision is with a terrain object, this field shall contain ENTITY_ID_UNKNOWN.


eventID

protected EventID eventID
Event ID - this field shall contain an identification generated by the issuing simulation application to associate related collision events.


collisionType

protected UnsignedByte collisionType
Collision Type - This field shall identify the type of collision.
Value:
Enumeration, see references below for semantics.
References:
see Section 10 in the EBV-doc


velocity

protected LinearVelocity velocity
Velocity - [m/s] This field shall contain the velocity of the issuing entity (at the time the collision is detected).
Value:
The velocity shall be represented in world Coordinates.


mass

protected float mass
Mass - [kg] this field shall contain the mass of the issuing entity.
Value:
In kilograms.


location

protected EntityCoordinate location
Location - [m,m,m] This field shall specify the location of the collision with respect to the entity with which the issuing entity collided.


sizeOf

public static final int sizeOf
Constant value- [bytes] size of an collision PDU without headder. sizeOf = 60 bytes

See Also:
Constant Field Values
Constructor Detail

CollisionPdu

public CollisionPdu()
Default constructor--fills with zeros for all values.

Method Detail

clone

public java.lang.Object clone()
Description copied from class: PduElement
Makes deep copies of all the instance variables, so we don't have two objects pointing to the same data. The accessor methods make copies of the objects, rather than returning the objects themselves. The runtime provides the right object type with the call to super.clone(), and we cast it to our type. Subclasses should do the same thing, and all these ivars will be taken care of automatically.

Overrides:
clone in class ProtocolDataUnit

serialize

public void serialize(java.io.DataOutputStream outputStream)
Description copied from class: PduElement
Serialize our data out to the stream. Subclasses of us should call super.Serialize() to make sure the superclasse's data is serialized out. The order in which instance variables are serialized is significant. They must be serialized in the same order they appear in the DIS spec. Prints out some information during execution if debugging flag is set.

Specified by:
serialize in interface SerializationInterface
Overrides:
serialize in class ProtocolDataUnit
Throws:
java.lang.RuntimeException - when IO error occurs.

deSerialize

public void deSerialize(java.io.DataInputStream inputStream)
Description copied from class: PduElement
Deserialize our data from the input stream. Subclasses of us should call super.deSerialize to make sure the superclass's data are properly affected. The order in which instance variables are serialized is significant. They must be deSerialized in the same order as they have been serialized as specified by the DIS spec.

Specified by:
deSerialize in interface SerializationInterface
Overrides:
deSerialize in class ProtocolDataUnit
Throws:
java.lang.RuntimeException - when IO error occurs.

length

public int length()
returns the size of the class (return sizeOf)

Overrides:
length in class ProtocolDataUnit
Returns:
the length of the PDU header (currently 12 bytes). Note that this should NOT include the length of the RTP header.

pduName

public java.lang.String pduName()
returns new String("Collision PDU"). The string is allocated dynamically.

Specified by:
pduName in class ProtocolDataUnit
Returns:
the name of the PDU as a String

printValues

public void printValues(int indentLevel,
                        java.io.PrintStream printStream)
Prints the valules of the PDU fields. this is important for debugging.

Overrides:
printValues in class ProtocolDataUnit

getIssuingEntityID

public EntityID getIssuingEntityID()
Returns the ID of the issuing entity.


setIssuingEntityID

public void setIssuingEntityID(EntityID pIssuingEntityID)
Sets the ID of the issuing entity.


getCollidingEntityID

public EntityID getCollidingEntityID()
Returns the ID of the colliding entity.


setCollidingEntityID

public void setCollidingEntityID(EntityID pCollidingEntityID)
Sets the ID of the colliding entity.


getEventID

public EventID getEventID()
Returns the ID of the event.


setEventID

public void setEventID(EventID pEventID)
Sets the ID of the event.


getCollisionType

public UnsignedByte getCollisionType()
Returns the type of the collision.


setCollisionType

public void setCollisionType(UnsignedByte pCollisionType)
Sets the type of the collision.


getLinearVelocity

public LinearVelocity getLinearVelocity()
Returns the linear velocity (safe deep copy).


setLinearVelocity

public void setLinearVelocity(LinearVelocity pLinearVelocity)
Sets the linear velocity given a lienar velocity


setLinearVelocity

public void setLinearVelocity(float x,
                              float y,
                              float z)
Sets the linear velocity given each of the xyz velocities


getMass

public float getMass()
Returns the mass of the colliding entity


setMass

public void setMass(float pMass)
Sets the mass of the colliding entity


getLocation

public EntityCoordinate getLocation()
Returns location of the colliding entity (safe deep copy).


setLocation

public void setLocation(EntityCoordinate pLocation)
Sets location of the colliding entity.


setLocation

public void setLocation(float x,
                        float y,
                        float z)
Sets location of the colliding entity given (x,y,z).