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

Public Member Functions | |
| DtSurfaceEntityFollowEntityController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
| virtual | ~DtSurfaceEntityFollowEntityController () |
| Destructor. | |
| virtual DtString | type () const |
| Returns a string identifies the class type of component. | |
| virtual void | processFollowEntityTask (DtSimMessage *msg) |
| Retrives the entity to follow and offset from the task message. | |
| virtual const DtString & | entityToFollow () |
| Returns the name of the entity being followed. | |
| virtual void | setEntityToFollow (const DtString &entity) |
| Sets the name of the entity to follow in the process state repository. | |
| virtual void | registerTaskMsgCallbacks () |
| Registers interest in follow entity tasks by calling addTaskProcessorCallback with followEntityCallback as the function pointer, and the 'this' pointer as the user data. | |
| virtual bool | setupControlPoint () |
| Sets myControlPoint to the follow location. | |
| virtual void | tick () |
| The main processing method. | |
| virtual void | matchFollowedEntity () |
| Sets the throttle and rudder ports to attempts to match the heading & speed of the lead entity. | |
| virtual double | findDesiredSpeed () |
| Returns the desired speed based on the distance from the follower to the leader. | |
| virtual void | setupGoalVector (const DtVector &goalPosition) |
| Overridden to set the goal vector to face oppposite the heading of the followed entity. | |
| virtual bool | passedGoal () |
| virtual void | doMoving (double desiredSpeed) |
| Prevents the base class from attempting to stop too soon. | |
offset vector | |
The offset from the entity's position to follow at, in entity coordinates. This comes from the follow task message. | |
| virtual const DtVector & | offsetVector () const |
| virtual void | setOffsetVector (const DtVector &offsets) |
Static Public Member Functions | |
| static void | followEntityCallback (DtSimMessage *msg, void *usrData) |
| Called when a follow entity message is received. | |
| static DtSimComponent * | creator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
Protected Member Functions | |
| DtSurfaceEntityFollowEntityController () | |
| Default constructor; not implemented. | |
| DtSurfaceEntityFollowEntityController (const DtSurfaceEntityFollowEntityController &orig) | |
| copy constructor; not implemented | |
| const DtSurfaceEntityFollowEntityController & | operator= (const DtSurfaceEntityFollowEntityController &orig) |
| assignment operator; not implemented | |
Protected Attributes | |
| DtVrfObject * | myEntityPointer |
| Set fresh each frame by setupControlPoint. | |
DtSurfaceEntityFollowEntityController is a controller that models following behavior for surface entities.
End User Description:
DtSurfaceEntityFollowEntityController (surfEntFolwCtl.h) is derived from DtSurfaceEntityMoveToController. It changes the functionality of DtSurfaceEntityMoveToController from Move To Waypoint to Follow Entity by instructing it to move to a waypoint which is constantly updated with the current location of the goal entity being followed plus an offset.
Uses Descriptor Type: DtSurfaceEntityPilotControllerDescriptor
| DtSurfaceEntityFollowEntityController::DtSurfaceEntityFollowEntityController | ( | 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 DtSurfaceEntityFollowEntityController::~DtSurfaceEntityFollowEntityController | ( | ) | [virtual] |
Destructor.
Deletes myControlPoint
Default constructor; not implemented.
| DtSurfaceEntityFollowEntityController::DtSurfaceEntityFollowEntityController | ( | const DtSurfaceEntityFollowEntityController & | orig | ) | [protected] |
copy constructor; not implemented
| virtual DtString DtSurfaceEntityFollowEntityController::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.
Reimplemented from DtSurfaceEntityMoveToController.
| static void DtSurfaceEntityFollowEntityController::followEntityCallback | ( | DtSimMessage * | msg, |
| void * | usrData | ||
| ) | [static] |
Called when a follow entity message is received.
Instances of this component will register this callback in registerTaskMsgCallbacks (with their own 'this' pointer as user data) by calling addTaskProcessorCallback in order to request for notification of follow entity tasks. When this callback is activated, the user data pointer is cast to an instance of this class upon which processFollowEntityTask is called with the follow task message.
| virtual void DtSurfaceEntityFollowEntityController::processFollowEntityTask | ( | DtSimMessage * | msg | ) | [virtual] |
Retrives the entity to follow and offset from the task message.
Called by followEntityCallback to take the name of the entity to follow and the follow offset and store them in the process state repository. The name of the entity is also stored in the PSR as the control object name for debugging purposes.
| virtual const DtString& DtSurfaceEntityFollowEntityController::entityToFollow | ( | ) | [virtual] |
Returns the name of the entity being followed.
This accessor has the side effect of setting myProcessState->entityToFollow() to DtString::nullString(), if the entity is not tasked and myProcessState->entityToFollow() is not already equal to nullString.
| virtual void DtSurfaceEntityFollowEntityController::setEntityToFollow | ( | const DtString & | entity | ) | [virtual] |
Sets the name of the entity to follow in the process state repository.
| virtual const DtVector& DtSurfaceEntityFollowEntityController::offsetVector | ( | ) | const [virtual] |
| virtual void DtSurfaceEntityFollowEntityController::setOffsetVector | ( | const DtVector & | offsets | ) | [virtual] |
| virtual void DtSurfaceEntityFollowEntityController::registerTaskMsgCallbacks | ( | ) | [virtual] |
Registers interest in follow entity tasks by calling addTaskProcessorCallback with followEntityCallback as the function pointer, and the 'this' pointer as the user data.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual bool DtSurfaceEntityFollowEntityController::setupControlPoint | ( | ) | [virtual] |
Sets myControlPoint to the follow location.
Looks up the lead the entity in the object manager and stores a pointer to it in myEntityPointer. Allocates myControlPoint if necessary and sets its location to the location of the entity we're following plus the indicated offset.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual void DtSurfaceEntityFollowEntityController::tick | ( | ) | [virtual] |
The main processing method.
Calls down to the base class (DtSurfaceEntityPilotController::tick). Before running any processing three checks are made. First, tasked() is called and must return true. Next, dT() is called and must return a value greater than zero (which indicates that simulation time has passed since the last frame). Finally, attemptToActiveAllPorts() is called on mySurfaceControlPortGroup to insure that the connection to the actuator can be activated. If the checks all pass, setupControlPoint() is called. If the call fails, the port group is deactivated. The distance squared between the vessel and the control point is calculated and stored in myDistanceSquared. If passedGoal() returns true, emergencyStop() is called. Otherwise if atGoal() returns true, matchFollowedEntity is called. If neither of those conditions are true (which is the normal follow state), doMoving() is called with the value returned from findDesiredSpeed().
Reimplemented from DtSurfaceEntityMoveToController.
| virtual void DtSurfaceEntityFollowEntityController::matchFollowedEntity | ( | ) | [virtual] |
Sets the throttle and rudder ports to attempts to match the heading & speed of the lead entity.
The speed of the lead entity and the distance between the leader and the follower are passed into calculateControlForThrottle and the result is placed on myThrottlePort. The angle from the heading of the follower to the leader is passed into calculateControlForTurn and the result is placed on myRudderPort.
| virtual double DtSurfaceEntityFollowEntityController::findDesiredSpeed | ( | ) | [virtual] |
Returns the desired speed based on the distance from the follower to the leader.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual void DtSurfaceEntityFollowEntityController::setupGoalVector | ( | const DtVector & | goalPosition | ) | [virtual] |
Overridden to set the goal vector to face oppposite the heading of the followed entity.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual bool DtSurfaceEntityFollowEntityController::passedGoal | ( | ) | [virtual] |
Reimplemented from DtSurfaceEntityMoveToController.
| static DtSimComponent* DtSurfaceEntityFollowEntityController::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). |
Reimplemented from DtSurfaceEntityMoveToController.
| virtual void DtSurfaceEntityFollowEntityController::doMoving | ( | double | desiredSpeed | ) | [virtual] |
Prevents the base class from attempting to stop too soon.
Overridden to call DtSurfaceEntityPilotController::sailTo rather than driftTo when nearGoal() is false. This will allow the ship to follow the leader more closely, without cutting the throttle to avoid overshooting the target. Keep in mind that if the near-distance is too small, the ship may overshoot the target because it doesn't have any braking capacity.
Reimplemented from DtSurfaceEntityMoveToController.
| const DtSurfaceEntityFollowEntityController& DtSurfaceEntityFollowEntityController::operator= | ( | const DtSurfaceEntityFollowEntityController & | orig | ) | [protected] |
assignment operator; not implemented
Set fresh each frame by setupControlPoint.