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

DtSurfaceEntityFollowEntityController is a controller that models following behavior for surface entities. More...

Inheritance diagram for DtSurfaceEntityFollowEntityController:
Inheritance graph
[legend]

List of all members.

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 DtStringentityToFollow ()
 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 DtVectoroffsetVector () 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 DtSimComponentcreator (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

DtVrfObjectmyEntityPointer
 Set fresh each frame by setupControlPoint.

Detailed Description

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


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.

Deletes myControlPoint

Default constructor; not implemented.

copy constructor; not implemented


Member Function Documentation

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

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.

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.

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 void DtSurfaceEntityFollowEntityController::setOffsetVector ( const DtVector offsets) [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.

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.

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.

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.

Returns:
false if nearGoal(), otherwise returns DtSurfaceEntityMoveToController::passedGoal

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*,

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.

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


Member Data Documentation

Set fresh each frame by setupControlPoint.


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)