![]() |
VR-Forces 4.0.4 Class Documentation
|
DtHumanFollowController is a controller that models following behavior for humans. More...

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 DtString & | entityToFollow () |
| 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 DtVector & | offsetVector () 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 DtSimComponent * | creator (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 DtHumanFollowController & | operator= (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 DtVector & | destinationVector () 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 | |
| DtVrfObject * | myEntityToFollow |
| Set fresh each frame in setupDestination(). | |
| DtHumanStateRepository * | myHumanStateRepository |
| Cache pointer to our specific type of state repository. | |
| DtHumanFollowPSR * | myProcessState |
| 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 | |
| DtCollisionInputPort * | myCollisionAvoidancePort |
| Input Port Name: potential-collision-info Input Port Description: Input Port Range: Input Port Default Value: Input Group Parent: collision-avoidance-control. | |
| DtInputPortGroup * | myCollisionAvoidancePortGroup |
| Input Port Group Name: collision-avoidance-control Input Port Group Description: | |
| DtHumanMovementControlOutputPortGroup * | myHumanMovementControlOutputPortGroup |
| Output Group Name: movement-control . | |
| DtVectorOutputPort * | myDestinationOutputPort |
| Output Port Name: destination Output Port Description: Specifies the current destination of the entity in geocentric coordiantes. | |
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
| DtHumanFollowController::DtHumanFollowController | ( | const DtString & | name, |
| DtVrfObject * | owner, | ||
| DtSimManager * | simManager, | ||
| DtComponentDescriptor * | desc = 0, |
||
| DtReaderWriterRegistry * | parentRegistry = 0 |
||
| ) |
(const DtString&,DtVrfObject*,DtSimManager*,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
| virtual DtHumanFollowController::~DtHumanFollowController | ( | ) | [virtual] |
destructor
| DtHumanFollowController::DtHumanFollowController | ( | const DtHumanFollowController & | orig | ) | [protected] |
copy constructor; shallow; does not copy the ports.
| 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.
Implements DtTaskControllerComponent.
| virtual bool DtHumanFollowController::init | ( | ) | [virtual] |
Init. Call immediately after construction.
Reimplemented from DtControllerComponent.
| virtual bool DtHumanFollowController::createPSR | ( | ) | [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 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 void DtHumanFollowController::processFollowEntityTask | ( | DtSimMessage * | msg | ) | [virtual] |
| 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*,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
| virtual void DtHumanFollowController::registerTaskMsgCallbacks | ( | ) | [virtual] |
Overrides this so it can register its interest in followEntity commands.
Reimplemented from DtTaskControllerComponent.
| virtual bool DtHumanFollowController::setupDestination | ( | ) | [virtual] |
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 DtHumanFollowController::passedDestination | ( | ) | [virtual] |
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.
| 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] |
| destination | the position this object is trying to drive to in local coordinates. |
| virtual const DtVector& DtHumanFollowController::destinationVector | ( | ) | const [protected, virtual] |
Returns the current destination vector for the entity.
| 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] |
DtVrfObject* DtHumanFollowController::myEntityToFollow [protected] |
Set fresh each frame in setupDestination().
Cache pointer to our specific type of state repository.
DtHumanFollowPSR* DtHumanFollowController::myProcessState [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.
Input Port Group Name: collision-avoidance-control
Input Port Group Description:
DtHumanMovementControlOutputPortGroup* DtHumanFollowController::myHumanMovementControlOutputPortGroup [protected] |
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:
DtVector DtHumanFollowController::myLocalDestination [protected] |
DtVector DtHumanFollowController::myWorldDestination [protected] |
DtVector DtHumanFollowController::myDestinationVector [mutable, protected] |
bool DtHumanFollowController::myDestinationVectorIsValid [mutable, protected] |
bool DtHumanFollowController::myNearDestination [protected] |
bool DtHumanFollowController::myPassedDestination [protected] |
bool DtHumanFollowController::myAtDestination [protected] |
double DtHumanFollowController::myDistanceSquared [protected] |
double DtHumanFollowController::myCurrentSpeed [protected] |
double DtHumanFollowController::myAtDistanceSquared [protected] |
Square of distance we're considered to be 'at' our destination (within 1/4 meter).
In meters^2. Default value: 1.0
double DtHumanFollowController::myNearDistanceSquared [protected] |
Square of distance we're considered to be 'near' our destination (within 3 meters).
In meters^2. Default value: 9.0
double DtHumanFollowController::myApproachSpeed [protected] |
Maximum speed to use when we are considered to be 'near' our destination.
In meters/second. Default value: 2.0
double DtHumanFollowController::myPassedSlowDownFactor [protected] |
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
double DtHumanFollowController::myFarCatchUpFactor [protected] |
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
double DtHumanFollowController::myNearCatchUpFactor [protected] |
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