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

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

Inheritance diagram for DtGroundCollisionAvoidanceController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtGroundCollisionAvoidanceController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtGroundCollisionAvoidanceController ()
 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 void avoidCollision (const DtCollision &potentialCollision)
 Activates all automotive ports/groups and provides the necessary steering, brake, and throttle 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

 DtGroundCollisionAvoidanceController ()
 Default constructor; should not be called.
 DtGroundCollisionAvoidanceController (const DtGroundCollisionAvoidanceController &orig)
 copy constructor
const
DtGroundCollisionAvoidanceController
operator= (const DtGroundCollisionAvoidanceController &orig)
 assignment operator
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 (DtAutoTransmissionGear currentGear)
 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.
bool followingObstruction (const DtEntityIdentifier &entityID) const
 Checks to see if the entity is currently tasked to follow the specified entity.
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.
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 ()
 Overridden to create myAutomotiveControlPortGroup.
bool createPorts ()
 Overridden to create the automotive ports.

Protected Attributes

double myClearingDistance
 This is only used when clearing.
bool myAvoidingCollision
Dt3dBoundingVolume * myCollisionBV
DtEntityIdentifier myObjectId
bool myHavePortGroup
DtString myFollowEntityName
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.
DtInputPortGroupmyCollisionAvoidancePortGroup
 Input Port Group Name: collision-avoidance-control
Input Port Group Description:
DtStringInputPortmyFollowEntityInputPort
 Input Port Name: follow-entity-name
Input Port Description: Check this port to see if any possible collision is with the entity we're suppose to follow
Input Port Range:
Input Port Default Value:
.
DtBooleanOutputPortmyCollisionPort
 Output Port Name: collision
Output Port Description: Specifies if there's a collision occuring Output Port Range:
Output Group Parent:
.

Detailed Description

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

Uses Descriptor Type: DtGroundCollisionAvoidanceDescriptor


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 DtGroundAutoControllerComponent.

virtual void DtGroundCollisionAvoidanceController::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 void DtGroundCollisionAvoidanceController::avoidCollision ( const DtCollision potentialCollision) [virtual]

Activates all automotive ports/groups and provides the necessary steering, brake, and throttle 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:
DtGroundAutoCollisionAvoidanceType

Reimplemented from DtGroundAutoControllerComponent.

static DtSimComponent* DtGroundCollisionAvoidanceController::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 DtGroundCollisionAvoidanceController& DtGroundCollisionAvoidanceController::operator= ( const DtGroundCollisionAvoidanceController orig) [protected]

assignment operator

bool DtGroundCollisionAvoidanceController::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
  • Gear is set to the specified currentGear
  • Steering is set to 0.
  • ParkingBrake is set to false
    Parameters:
    currentGearThe current gear of the entity.
    Returns:
    A boolean signifying sucess or failure.
bool DtGroundCollisionAvoidanceController::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.
bool DtGroundCollisionAvoidanceController::followingObstruction ( const DtEntityIdentifier &  entityID) const [protected]

Checks to see if the entity is currently tasked to follow the specified entity.

Returns:
A boolean signifying success or failure.
void DtGroundCollisionAvoidanceController::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 updated.
void DtGroundCollisionAvoidanceController::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).
void DtGroundCollisionAvoidanceController::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.

Overridden to create myAutomotiveControlPortGroup.

Reimplemented from DtGroundAutoControllerComponent.

Overridden to create the automotive ports.

Reimplemented from DtGroundAutoControllerComponent.


Member Data Documentation

This is only used when clearing.

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

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

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

Input Port Name: follow-entity-name
Input Port Description: Check this port to see if any possible collision is with the entity we're suppose to follow
Input Port Range:
Input Port Default Value:
.

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


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)