VR-Forces 4.0.4 Class Documentation
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
DtHumanCollisionAvoidanceController Class Reference

DtHumanCollisionAvoidanceController is a controller that helps entities to avoid running into other entities and/or feature obstructions. More...

Inheritance diagram for DtHumanCollisionAvoidanceController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtHumanCollisionAvoidanceController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtHumanCollisionAvoidanceController ()
 Destructor.
virtual bool init ()
 Initializes the follow controller name, the object ID, and the collisionBV (bounding volume)
virtual void tick ()
 Calculate new control values based on potential collisions.
virtual double distanceSquaredToDestination (DtVector offsetVector)
 Calculates the distance squared from the current location (in local coords) to the destination, minus the specified offset vector.
virtual bool isInsideObstruction (const DtCollision *potentialCollision, double &clearingDistance)
 Determine if the entity is inside the potential obstruction.
virtual void avoidCollision (const DtCollision &potentialCollision)
 Activates all control ports/groups and provides the necessary speed, direction, and heading values.
virtual void clearCollision ()
 This just cleans up some state variables when it's determined that an entity is no longer potentially colliding.
virtual void clearingCollision ()
 Moves the vehicle in a straight line for the defined clearingDistance after it is no longer at risk of colliding with the obstruction.
virtual DtString type () const
 Returns a string identifies the class type of component.

Static Public Member Functions

static DtSimComponentcreator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,

Protected Member Functions

 DtHumanCollisionAvoidanceController ()
 Default constructor; should not be called.
 DtHumanCollisionAvoidanceController (const DtHumanCollisionAvoidanceController &orig)
 copy constructor
const
DtHumanCollisionAvoidanceController
operator= (const DtHumanCollisionAvoidanceController &orig)
 assignment operator
virtual void registerTaskMsgCallbacks ()
 Override for interest in task complete messages, we care about stopMoving tasks.
virtual void processTaskComplete (DtSimMessage *msg)
bool isAppreciablyMoving (DtVector velocity, double velocityTolerance) const
 If the magnitude of any component of the velocity is greater than the velocity tolerance, then the entity is considered appreciably moving.
bool setDefaultPortValuesForAvoidance ()
 Sets the ports to appropriate default values.
bool determineObstructionMovementDirection (DtDcm obstructionLocalOrientationMatrix, const DtVector &obstructionVelocity, int &obstructionDirectionSign) const
 Determines if the obstruction is moving forward or in reverse.
void avoidMovingObstruction (const DtCollision &potentialCollision)
 Calculates and sets control values for avoiding a moving obstruction based on obstruction's relative movement (head-on, in front of, etc.) If the obstruction is moving in roughly the same direction, and the entity is in front, it does nothing.
void avoidNonMovingObstruction (const DtCollision &potentialCollision)
 Calculates control values for avoiding a non-moving obstruction.
virtual void calculateAvoidanceByVertices (const DtVector &vertex1, const DtVector &vertex2, double entityBoundingVolumeRadius, DtVector &localVectorToDestination, DtVector &localVectorToObstruciton)
 Calculates control values for avoiding using the vertices that define the obstruction.
virtual void calculateAvoidanceUsingExtent (DtExtent &extent, double entityBoundingVolumeRadius, DtVector &localVectorToDestination, DtVector &localVectorToObstruciton)
 Calculates control values for avoiding using the extent of the obstruction-- Useful for point vector features.
virtual void calculateAvoidanceUsingBoundingVolume (const DtCollision &potentialCollision, double entityBoundingVolumeRadius, DtVector &localVectorToDestination, DtVector &localVectorToObstruciton)
 Calculates very rough control values for avoiding using the bounding volume.
void startClearingCollision (double clearingDistance)
 Sets state as appropriate for clearing a collision and then starts clearing the collision.
bool calculateCollisionBV ()
 Calculates a bounding volume representing the potential collision volume occupied by the entity.
bool createPortGroups ()
 Called by init.
bool createPorts ()
 Called by init.
virtual bool createPSR ()
 Creates myProcessState data member, and adds it to our process state repository manager.
virtual void computeClearingHeading (const DtVector &localVertex1, const DtVector &localVertex2, const DtVector &localObstaclePos, double &clearingHeading) const
virtual void getObstructionFootprint (const DtCollision &collision, DtLocalVertexList &localObstructionFootprint) const

Static Protected Member Functions

static void taskCompleteReportCallback (DtSimMessage *msg, void *usr)
 Monitor taskReportComplete callback to see when entity stops moving during an embarkation task so we can stop collision avoiding.

Protected Attributes

double myClearingDistance
 This is only used when clearing.
bool myAvoidingCollision
Dt3dBoundingVolume * myCollisionBV
DtEntityIdentifier myObjectId
bool myHavePortGroup
DtHumanStateRepositorymyLifeformState
DtHumanCollisionAvoidancePSRmyProcessState
 Container for state data associated with this component.
double myTimeToCollide
 The minimum time before a collision (in seconds) which the collision avoidance controller compares to its own estimate of the time before a rear end collision to determine when to apply the brakes.
double myLateralClearance
 The width (in meters) added to the length of the bounding volume which is checked for potential collisions.
double myStoppingDistanceFactor
 The factor by which the collision avoidance controller multiplies the current stopping distance to determine the length of the bounding volume which is checked for potential collisions.
DtVector myNonMvObstructionLocation
Ports and Port Groups
DtCollisionInputPortmyCollisionAvoidancePort
 Input Port Name: potential-collision-info
Input Port Description:
Input Port Range:
Input Port Default Value:
Input Group Parent: collision-avoidance-control.
DtVectorInputPortmyDestinationInputPort
 Output Port Name: destination
Output Port Description: Specifies the current destination of the entity in geocentric coordiantes.
DtInputPortGroupmyCollisionAvoidancePortGroup
 Input Port Group Name: collision-avoidance-control
Input Port Group Description:
DtHumanMovementControlOutputPortGroupmyHumanMovementControlOutputPortGroup
 Output Group Name: movement-control
.
DtBooleanOutputPortmyCollisionPort
 Output Port Name: collision
Output Port Description: Specifies if there's a collision occuring Output Port Range:
Output Group Parent:
.

Detailed Description

DtHumanCollisionAvoidanceController is a controller that helps entities to avoid running into other entities and/or feature obstructions.

Uses Descriptor Type: DtComponentDescriptor


Constructor & Destructor Documentation

(const DtString&,DtVrfObject*,DtSimManager*,

Parameters:
nameReader writer name of this component.
ownerThe DtVrfObject that owns this component
simManagerThe simulation manager (provides access to terrain, message interface, simulation clock).
descThe component descriptor used to initialize this component.
parentRegistryPointer to the parent reader writer registry (the containing object that reads/writes this object).
(const DtString&,DtVrfObject*,DtSimManager*, DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)

Destructor.

Cleans up any allocated ports/port groups, and bounding volumes.

Default constructor; should not be called.

Here because the compiler will generate an unprotected one otherwise.

copy constructor


Member Function Documentation

Initializes the follow controller name, the object ID, and the collisionBV (bounding volume)

Returns:
A boolean indicating success or failure.

Reimplemented from DtControllerComponent.

virtual void DtHumanCollisionAvoidanceController::tick ( ) [virtual]

Calculate new control values based on potential collisions.

If the controller has received potential collision data, then it acts to avoid a collision. If it does not receive collision data, but has on the previous tick, then the controller starts clearing the collision.

See also:
avoidCollision()
clearingCollision()

Reimplemented from DtSimComponent.

Calculates the distance squared from the current location (in local coords) to the destination, minus the specified offset vector.

Returns:
a double set to the distance squared.
virtual bool DtHumanCollisionAvoidanceController::isInsideObstruction ( const DtCollision potentialCollision,
double &  clearingDistance 
) [virtual]

Determine if the entity is inside the potential obstruction.

Returns the necessary clearing distance if we are inside the obstruction.

virtual void DtHumanCollisionAvoidanceController::avoidCollision ( const DtCollision potentialCollision) [virtual]

Activates all control ports/groups and provides the necessary speed, direction, and heading values.

Parameters:
obstructionA pointer to a DtVrfObject to avoid. Assumed to be non-NULL.
See also:
avoidMovingObstruction()
avoidNonMovingObstruction()

This just cleans up some state variables when it's determined that an entity is no longer potentially colliding.

Moves the vehicle in a straight line for the defined clearingDistance after it is no longer at risk of colliding with the obstruction.

This is done to keep the vehicle from turning back to the goal too soon, which would cause a jitter as the vehicle went in and out of the collision state.

Returns a string identifies the class type of component.

Type values are defined in compTypes.h. DtSimComponent creation functions are registered with the DtSimComponentFactory using the type values as the key.

Returns:
DtHumanCollisionAvoidanceControllerType

Implements DtTaskControllerComponent.

static DtSimComponent* DtHumanCollisionAvoidanceController::creator ( const DtString name,
DtVrfObject owner,
DtSimManager simManager,
DtComponentDescriptor desc = 0,
DtReaderWriterRegistry parentRegistry = 0 
) [static]

(const DtString&,DtVrfObject*,DtSimManager*,

Parameters:
nameReader writer name of this component.
ownerThe DtVrfObject that owns this component
simManagerThe simulation manager (provides access to terrain, message interface, simulation clock).
descThe component descriptor used to initialize this component.
parentRegistryPointer to the parent reader writer registry (the containing object that reads/writes this object).
(const DtString&,DtVrfObject*,DtSimManager*, DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)

Returns:
New instance of this class.
const DtHumanCollisionAvoidanceController& DtHumanCollisionAvoidanceController::operator= ( const DtHumanCollisionAvoidanceController orig) [protected]

assignment operator

Override for interest in task complete messages, we care about stopMoving tasks.

Reimplemented from DtTaskControllerComponent.

static void DtHumanCollisionAvoidanceController::taskCompleteReportCallback ( DtSimMessage msg,
void *  usr 
) [static, protected]

Monitor taskReportComplete callback to see when entity stops moving during an embarkation task so we can stop collision avoiding.

virtual void DtHumanCollisionAvoidanceController::processTaskComplete ( DtSimMessage msg) [protected, virtual]
bool DtHumanCollisionAvoidanceController::isAppreciablyMoving ( DtVector  velocity,
double  velocityTolerance 
) const [protected]

If the magnitude of any component of the velocity is greater than the velocity tolerance, then the entity is considered appreciably moving.

Returns:
A boolean signifying whether or not the entity is appreciably moving.

Sets the ports to appropriate default values.

  • Throttle is set to the approximate throttle for the ordered speed.
  • Break is set to either 0 or .5 depending on dif. between current and ordered speed
  • Steering is set to 0.
  • ParkingBrake is set to false
    Returns:
    A boolean signifying sucess or failure.
bool DtHumanCollisionAvoidanceController::determineObstructionMovementDirection ( DtDcm  obstructionLocalOrientationMatrix,
const DtVector obstructionVelocity,
int &  obstructionDirectionSign 
) const [protected]

Determines if the obstruction is moving forward or in reverse.

Parameters:
obstructionDirectionSignA reference to an integer representing the direction of movement: 1 for forward, -1 for reverse.
Returns:
a boolean signifying success or failure in the calculation.
void DtHumanCollisionAvoidanceController::avoidMovingObstruction ( const DtCollision potentialCollision) [protected]

Calculates and sets control values for avoiding a moving obstruction based on obstruction's relative movement (head-on, in front of, etc.) If the obstruction is moving in roughly the same direction, and the entity is in front, it does nothing.

If it is behind, and following the entity, then it lets the follow entity controller take over. If not following the entity, then it slows down to avoid a collision.

If the obstruction is coming head on, then the entity attempts to turn out of the way as if the obstruction was a non-moving entity.

Note:
Assumes that the obstruction is an entity, since it is moving. If the potential collision is not an entity, this function will have to be
void DtHumanCollisionAvoidanceController::avoidNonMovingObstruction ( const DtCollision potentialCollision) [protected]

Calculates control values for avoiding a non-moving obstruction.

If the entity is not following the obstruction, and the entity can turn, it turns to the opposite direction of the obstruction's location to the entity. (i.e. if the obstruction is on the right, the entity turns to the left.) Otherwise, the entity stops, since either the leader has stopped or it is unable to turn.

Note:
Does not assume that the obstruction is an entity, since it is not moving. Uses only the data contained in the collision object, and does not look up any other data (such as a vrfObject).
virtual void DtHumanCollisionAvoidanceController::calculateAvoidanceByVertices ( const DtVector vertex1,
const DtVector vertex2,
double  entityBoundingVolumeRadius,
DtVector localVectorToDestination,
DtVector localVectorToObstruciton 
) [protected, virtual]

Calculates control values for avoiding using the vertices that define the obstruction.

This is used with objects that have at least 2 vertices

virtual void DtHumanCollisionAvoidanceController::calculateAvoidanceUsingExtent ( DtExtent extent,
double  entityBoundingVolumeRadius,
DtVector localVectorToDestination,
DtVector localVectorToObstruciton 
) [protected, virtual]

Calculates control values for avoiding using the extent of the obstruction-- Useful for point vector features.

virtual void DtHumanCollisionAvoidanceController::calculateAvoidanceUsingBoundingVolume ( const DtCollision potentialCollision,
double  entityBoundingVolumeRadius,
DtVector localVectorToDestination,
DtVector localVectorToObstruciton 
) [protected, virtual]

Calculates very rough control values for avoiding using the bounding volume.

void DtHumanCollisionAvoidanceController::startClearingCollision ( double  clearingDistance) [protected]

Sets state as appropriate for clearing a collision and then starts clearing the collision.

Parameters:
clearingDistanceThe distance the entity will move before it considers itself of having fully avoided the collision. This is to prevent entities from immediately turning back into the path of the potential collision once initially avoided it.
See also:
clearingCollision()

Calculates a bounding volume representing the potential collision volume occupied by the entity.

The entities oriented bounding volume is extended in the direction of travel. It represents a prediction of the entity's future movement for some period of time.

Returns:
A boolean signifying success or failure. If the function fails, the bounding volume is not defined to be valid.
Note:
Almost exact same function as in the DtObstructionSensor class.
This function assumes simplified movement, and only works for movement "forward/backward" in body coordinates (x direction). For more complicated collision bounding volumes, this function must be overridden.

Called by init.

Derived classes should override this method to create all their input/output port groups.

Reimplemented from DtSimComponent.

Called by init.

Derived classes should override this method to create all their input/output ports and port groups.

Reimplemented from DtSimComponent.

virtual bool DtHumanCollisionAvoidanceController::createPSR ( ) [protected, virtual]

Creates myProcessState data member, and adds it to our process state repository manager.

Passes in the name and type specified in the component descriptor (if they exist) to the DtVrfProcessStateRepository::createRepository factory method. If name and/or type is not specified, uses the appropriate default strings defined in procSRTypes.h.

virtual void DtHumanCollisionAvoidanceController::computeClearingHeading ( const DtVector localVertex1,
const DtVector localVertex2,
const DtVector localObstaclePos,
double &  clearingHeading 
) const [protected, virtual]
virtual void DtHumanCollisionAvoidanceController::getObstructionFootprint ( const DtCollision collision,
DtLocalVertexList localObstructionFootprint 
) const [protected, virtual]

Member Data Documentation

This is only used when clearing.

Dt3dBoundingVolume* DtHumanCollisionAvoidanceController::myCollisionBV [protected]
DtEntityIdentifier DtHumanCollisionAvoidanceController::myObjectId [protected]

Container for state data associated with this component.

This state is saved and restored as part of a scenario (or checkpoint).

Input Port Name: potential-collision-info
Input Port Description:
Input Port Range:
Input Port Default Value:
Input Group Parent: collision-avoidance-control.

Output Port Name: destination
Output Port Description: Specifies the current destination of the entity in geocentric coordiantes.

Output Port Range:
Output Group Parent:

Input Port Group Name: collision-avoidance-control
Input Port Group Description:

Output Group Name: movement-control
.

Output Port Name: collision
Output Port Description: Specifies if there's a collision occuring Output Port Range:
Output Group Parent:
.

The minimum time before a collision (in seconds) which the collision avoidance controller compares to its own estimate of the time before a rear end collision to determine when to apply the brakes.


Parameter Default Value: 0.0
Parameter Units: seconds

The width (in meters) added to the length of the bounding volume which is checked for potential collisions.


Parameter Default Value: 0.25
Parameter Units: meters

The factor by which the collision avoidance controller multiplies the current stopping distance to determine the length of the bounding volume which is checked for potential collisions.


Parameter Default Value: 1.0


The documentation for this class was generated from the following file:

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)