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

DtHumanFollowController is a controller that models following behavior for humans. More...

Inheritance diagram for DtHumanFollowController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtHumanFollowController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtHumanFollowController ()
 destructor
virtual DtString type () const
 Returns a string identifies the class type of component.
virtual bool init ()
 Init. Call immediately after construction.
virtual bool createPSR ()
 Creates myProcessState data member, and adds it to our process state repository manager.
virtual void tick ()
 Calculate new control values.
virtual void processFollowEntityTask (DtSimMessage *msg)
virtual const DtStringentityToFollow ()
 What entity are we following? This accessor has the side effect of setting myProcessState->myEntityToFollow to DtString::nullString(), if the entity is not tasked and myEntityToFollow is not already the null string.
virtual void setEntityToFollow (const DtString &entity)
virtual const DtVectoroffsetVector () const
 The offset from the entity's position to follow at, in entity coordinates.
virtual void setOffsetVector (const DtVector &offsets)
virtual void registerTaskMsgCallbacks ()
 Overrides this so it can register its interest in followEntity commands.
virtual bool setupDestination ()
 Sets the world destination in the process state repository to the location of the entity we're following plus the indicated offset and then calls down to the base class.
virtual bool passedDestination ()
 Overrides to force the entity to be near the destination as well as across the 'destination' line to be considered past the destination.
virtual double findDesiredSpeed ()
 Overrides so we can speed up when falling behind and slow down if we get past the position we're supposed to be in.
virtual double findDesiredHeading ()
 Overrides so the entity won't turn toward the destination point when it is close to or past the destination; rather, in these cases, it assumes the heading of the lead entity.
virtual void setupDestinationVector () const
 Determine the destination vector for the entity out of the heading of the entity being followed.
virtual void stop ()
 Overrides so we don't complete the task when we're at the right location with regard to the followed entity.
virtual void clearTask ()
 If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false, and calls clearCurrentTaskMesage() to clear out the current task message.

Static Public Member Functions

static void followEntityCallback (DtSimMessage *msg, void *usrData)
 Instances of this component will register this callback with their own 'this' pointer as user data with the msg executive requesting notification of move-to tasks.
static DtSimComponentcreator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,

Protected Member Functions

 DtHumanFollowController (const DtHumanFollowController &orig)
 copy constructor; shallow; does not copy the ports.
const DtHumanFollowControlleroperator= (const DtHumanFollowController &orig)
 assignment operator; see comments on copy constructor!
virtual void invalidateDestinationVector () const
 Tells the component that any cached destination vector should be recalculated.
virtual bool nearDestination ()
 Determines if the entity is close enough to the destination that it should start slowing down (see findDesiredSpeed()).
virtual bool getDestination (DtVector &destination)
 getDestination()
virtual const DtVectordestinationVector () const
 Returns the current destination vector for the entity.
virtual bool atDestination ()
 Are we within the at-distance parameter to the destination? If the myDistanceSquared member calculated in tick() is less than or equal to the square of the value provided in the at-distance parameter of the DtGroundMoveToDescriptor, atDestination() sets myAtDestination to true.
virtual void doMoving ()
 Calls determineGearSetting(), findDesiredSpeed() and findDesiredHeading() and then sets port values based on those results.
virtual bool destinationIsInsideObstruction (const DtVector &localDestination) const
 Returns whether or not current destination is inside an obstruction.
virtual bool createPortGroups ()
 Creates and initializes port groups.
virtual bool createPorts ()
 Creates myDestinationOutputPort.
virtual void moveToDestination ()
 Attempts to move to the destination location. Override to provide movement functionality.
virtual double distanceToDestination () const

Protected Attributes

DtVrfObjectmyEntityToFollow
 Set fresh each frame in setupDestination().
DtHumanStateRepositorymyHumanStateRepository
 Cache pointer to our specific type of state repository.
DtHumanFollowPSRmyProcessState
 Container for state data associated with this component.
DtVector myLocalDestination
DtVector myWorldDestination
DtVector myDestinationVector
bool myDestinationVectorIsValid
bool myNearDestination
bool myPassedDestination
bool myAtDestination
double myDistanceSquared
bool myDestinationIsInsideObstruction
double myCurrentSpeed
double myAtDistanceSquared
 Square of distance we're considered to be 'at' our destination (within 1/4 meter).
double myNearDistanceSquared
 Square of distance we're considered to be 'near' our destination (within 3 meters).
double myApproachSpeed
 Maximum speed to use when we are considered to be 'near' our destination.
double myPassedSlowDownFactor
 Multiplicative factor used to compute the appropriate speed when we need to slow down relative to the entity we're following (because we've passed the point we need to be).
double myFarCatchUpFactor
 Multiplicative factor used to compute the appropriate speed when we need to catch up to the entity we're following and we're far from where we need to be.
double myNearCatchUpFactor
 Multiplicative factor used to compute the appropriate speed when we need to catch up to the entity we're following (because we're far from where we need to be).
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:
DtHumanMovementControlOutputPortGroupmyHumanMovementControlOutputPortGroup
 Output Group Name: movement-control
.
DtVectorOutputPortmyDestinationOutputPort
 Output Port Name: destination
Output Port Description: Specifies the current destination of the entity in geocentric coordiantes.

Detailed Description

DtHumanFollowController is a controller that models following behavior for humans.

Developer Description: Each simulation frame the destination to which the entity moves is recalculated to be in the right place with respect to the followed entity.

Uses Descriptor Type: DtGroundMoveToDescriptor


Constructor & Destructor Documentation

DtHumanFollowController::DtHumanFollowController ( const DtString name,
DtVrfObject owner,
DtSimManager simManager,
DtComponentDescriptor desc = 0,
DtReaderWriterRegistry parentRegistry = 0 
)

(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

copy constructor; shallow; does not copy the ports.


Member Function Documentation

virtual DtString DtHumanFollowController::type ( ) const [virtual]

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:
DtHumanFollowControllerType

Implements DtTaskControllerComponent.

virtual bool DtHumanFollowController::init ( ) [virtual]

Init. Call immediately after construction.

Reimplemented from DtControllerComponent.

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 DtHumanFollowController::tick ( ) [virtual]

Calculate new control values.

Reimplemented from DtSimComponent.

static void DtHumanFollowController::followEntityCallback ( DtSimMessage msg,
void *  usrData 
) [static]

Instances of this component will register this callback with their own 'this' pointer as user data with the msg executive requesting notification of move-to tasks.

virtual const DtString& DtHumanFollowController::entityToFollow ( ) [virtual]

What entity are we following? This accessor has the side effect of setting myProcessState->myEntityToFollow to DtString::nullString(), if the entity is not tasked and myEntityToFollow is not already the null string.

virtual void DtHumanFollowController::setEntityToFollow ( const DtString entity) [virtual]
virtual const DtVector& DtHumanFollowController::offsetVector ( ) const [virtual]

The offset from the entity's position to follow at, in entity coordinates.

This comes from the follow task message.

virtual void DtHumanFollowController::setOffsetVector ( const DtVector offsets) [virtual]
static DtSimComponent* DtHumanFollowController::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.

Overrides this so it can register its interest in followEntity commands.

Reimplemented from DtTaskControllerComponent.

Sets the world destination in the process state repository to the location of the entity we're following plus the indicated offset and then calls down to the base class.

Overrides to force the entity to be near the destination as well as across the 'destination' line to be considered past the destination.

virtual double DtHumanFollowController::findDesiredSpeed ( ) [virtual]

Overrides so we can speed up when falling behind and slow down if we get past the position we're supposed to be in.

virtual double DtHumanFollowController::findDesiredHeading ( ) [virtual]

Overrides so the entity won't turn toward the destination point when it is close to or past the destination; rather, in these cases, it assumes the heading of the lead entity.

virtual void DtHumanFollowController::setupDestinationVector ( ) const [virtual]

Determine the destination vector for the entity out of the heading of the entity being followed.

Converts the heading into topo coordinates, creates a topo destination vector, and then converts that to the entity's local coordinate system. This is used by the entity to determine if it has passed it's destination which is the entity being followed, including the specified offset.

Note:
this function is not currently used.
Assumes that the entity pointer member, the sim manager, the terrain database in the sim manager, and the coordinate system object in the terrain database are all non-NULL.
virtual void DtHumanFollowController::stop ( ) [virtual]

Overrides so we don't complete the task when we're at the right location with regard to the followed entity.

Simply calls DtGroundMoveToControllerComponent::doMoving().

virtual void DtHumanFollowController::clearTask ( ) [virtual]

If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false, and calls clearCurrentTaskMesage() to clear out the current task message.

Reimplemented from DtSingleTaskControllerComponent.

const DtHumanFollowController& DtHumanFollowController::operator= ( const DtHumanFollowController orig) [protected]

assignment operator; see comments on copy constructor!

virtual void DtHumanFollowController::invalidateDestinationVector ( ) const [protected, virtual]

Tells the component that any cached destination vector should be recalculated.

virtual bool DtHumanFollowController::nearDestination ( ) [protected, virtual]

Determines if the entity is close enough to the destination that it should start slowing down (see findDesiredSpeed()).

nearDestination() calls calculateCurrentBrakingDistance(). If the myDistanceSquared member calculated in tick() is less than or equal to the square of the value provided in the near-distance parameter of the DtGroundMoveToDescriptor, or if it is less than the square of the current braking distance, nearDestination() sets myNearDestination to true. If the above is not true, nearDestination() sets myNearDestination to false. myNearDestination is returned to the calling function.

virtual bool DtHumanFollowController::getDestination ( DtVector destination) [protected, virtual]

getDestination()

Parameters:
destinationthe position this object is trying to drive to in local coordinates.
Returns:
true if it has a valid destination () or false if it is unable to determine it's destination.
Note:
Used by other areas of the simulation to determine where this object is going. (Information)
virtual const DtVector& DtHumanFollowController::destinationVector ( ) const [protected, virtual]

Returns the current destination vector for the entity.

Note:
if the destination vector is currently invalidated, it recalculates it and sets it to valid.
See also:
setupDestinationVector
virtual bool DtHumanFollowController::atDestination ( ) [protected, virtual]

Are we within the at-distance parameter to the destination? If the myDistanceSquared member calculated in tick() is less than or equal to the square of the value provided in the at-distance parameter of the DtGroundMoveToDescriptor, atDestination() sets myAtDestination to true.

If the myDistanceSquared !<= at-distance, atDestination() sets myAtDestination to false. myAtDestination is returned to the calling function.

virtual void DtHumanFollowController::doMoving ( ) [protected, virtual]

Calls determineGearSetting(), findDesiredSpeed() and findDesiredHeading() and then sets port values based on those results.

virtual bool DtHumanFollowController::destinationIsInsideObstruction ( const DtVector localDestination) const [protected, virtual]

Returns whether or not current destination is inside an obstruction.

virtual bool DtHumanFollowController::createPortGroups ( ) [protected, virtual]

Creates and initializes port groups.

Reimplemented from DtSimComponent.

virtual bool DtHumanFollowController::createPorts ( ) [protected, virtual]

Creates myDestinationOutputPort.

Reimplemented from DtSimComponent.

virtual void DtHumanFollowController::moveToDestination ( ) [protected, virtual]

Attempts to move to the destination location. Override to provide movement functionality.

virtual double DtHumanFollowController::distanceToDestination ( ) const [protected, virtual]

Member Data Documentation

Set fresh each frame in setupDestination().

Cache pointer to our specific type of state repository.

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.

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

Output Group Name: movement-control
.

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

Output Port Range:
Output Group Parent:

Square of distance we're considered to be 'at' our destination (within 1/4 meter).

In meters^2. Default value: 1.0

Square of distance we're considered to be 'near' our destination (within 3 meters).

In meters^2. Default value: 9.0

Maximum speed to use when we are considered to be 'near' our destination.

In meters/second. Default value: 2.0

Multiplicative factor used to compute the appropriate speed when we need to slow down relative to the entity we're following (because we've passed the point we need to be).

Other entity's speed is multiplied by this factor to produce our desired speed in this case. Default value: 0.9

Multiplicative factor used to compute the appropriate speed when we need to catch up to the entity we're following and we're far from where we need to be.

'Far' means we're outside of the near distance from our follow position. Our entity's ordered speed is multiplied by this factor to produce our desired speed in this case. Default value: 1.25

Multiplicative factor used to compute the appropriate speed when we need to catch up to the entity we're following (because we're far from where we need to be).

'Near' means we're within of the near distance of our follow position. Other entity's speed is multiplied by this factor to produce our desired speed in this case. Default value: 1.1


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)