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

DtSurfaceEntityMoveToController is a controller that models the movement of a surface entity to a specific waypoint. More...

Inheritance diagram for DtSurfaceEntityMoveToController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtSurfaceEntityMoveToController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtSurfaceEntityMoveToController ()
 destructor
virtual DtString type () const
 Returns a string identifies the class type of component.
virtual void tick ()
 Takes control of the surface entity output port group and determines the progress controls required to move the ship to the destination waypoint.
virtual void setupGoalVector (const DtVector &goalPosition)
 Updates myGoalVector.
virtual void doMoving (double desiredSpeed)
 Calls driftTo with the value returned by getLocalDestination() and the given desired speed.
virtual bool passedGoal ()
 Determines if the ship has sailed past myControlpoint.
virtual bool atGoal ()
 Determines if the entity is within the at-distance parameter to the waypoint.
virtual bool nearGoal ()
 Determines if the entity is within the near-distance parameter to the waypoint.
virtual double findDesiredSpeed ()
virtual void processMoveToTask (DtSimMessage *msg)
 Retrieves the name of the target waypoint from the task message.
virtual void registerTaskMsgCallbacks ()
 Registers interest in move to tasks by calling addTaskProcessorCallback with moveToCallback as the function pointer, and the 'this' pointer as the user data.

Static Public Member Functions

static void moveToCallback (DtSimMessage *msg, void *user)
 Called when a move to 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

virtual bool setupControlPoint ()
 Updates myControlPoint.
virtual double distanceSquaredToDestination2D (const DtVector &current) const
 Returns distance squared from destination point to current location.
virtual void getLocalDestination (DtVector &local) const

Protected Attributes

DtVrfObjectmyControlPoint
 Pointer to the target waypoint.
DtVector myControlPointLastLocation
 Stores last known location of the waypoint.
DtVector myGoalVector
 Maintained by setupGoalVector()
bool myAtGoal
bool myNearGoal
bool myPassedGoal

Private Member Functions

 DtSurfaceEntityMoveToController ()
 default constructor - not implemented
 DtSurfaceEntityMoveToController (const DtSurfaceEntityMoveToController &orig)
 copy constructor
const
DtSurfaceEntityMoveToController
operator= (const DtSurfaceEntityMoveToController &orig)
 assignment operator

Detailed Description

DtSurfaceEntityMoveToController is a controller that models the movement of a surface entity to a specific waypoint.

End User Description: DtSurfaceEntityMoveToController (surfEntMvToCtl.h) is derived from DtSurfaceEntityPilotController and implements the Move To Waypoint task for surface entities. It is the parent class of most of the movement controllers. It overrides DtTaskControllerComponent:: registerTaskMsgCallbacks() and registers the callback function moveToCallback() for DtMoveToType. When a move to message is received, the callback invokes processMoveToTask(), which looks up the waypoint in the object manager and stores a pointer to it in myControlPoint.

Uses Descriptor Type: DtSurfaceEntityPilotControllerDescriptor


Constructor & Destructor Documentation

DtSurfaceEntityMoveToController::DtSurfaceEntityMoveToController ( 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

default constructor - not implemented

copy constructor


Member Function Documentation

virtual DtString DtSurfaceEntityMoveToController::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:
DtSurfaceEntityMoveToType

Reimplemented from DtSurfaceEntityPilotController.

Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityPatrolRouteController, DtSurfaceEntityPatrolBetweenController, DtSurfaceEntityMoveToLocationController, and DtSurfaceEntityFollowEntityController.

virtual void DtSurfaceEntityMoveToController::tick ( ) [virtual]

Takes control of the surface entity output port group and determines the progress controls required to move the ship to the destination waypoint.

The steps are:

  1. The tick() function calls first calls down the base class (DtSurfaceEntityPilotController::tick).
  2. Before any real processing takes place, tick() checks to see if the controller is tasked (tasked() returns true), and if dT (the amount of simulated time since the controller was last ticked) is non-zero. If these checks pass, it attempts to activate the surface-control output port group. If it is not tasked, dT is 0, or the port group cannot be activated, tick() returns.
  3. If tick() does not return, it calls setupControlPoint() to look the up the waypoint in the object manager.
  4. If setupControlPoint() returns false, then tick() deactivates the port group and returns. Otherwise, tick() calculates the distance squared from the entity to the waypoint and sets the member variable myDistanceSquared to that value.
  5. If passedGoal() returns true, DtSurfaceEntityPilotController::emergencyStop() is called. Otherwise, if atGoal() returns false doMoving() is called using the speed returned by findDesiredSpeed() to continue to provide inputs which guide the ship to the goal. If atGoal() is true and the ship has drifted to a complete stop, taskComplete() is called to signal that the move to task has been completed.

Reimplemented from DtSurfaceEntityPilotController.

Reimplemented in DtSurfaceEntityFollowEntityController.

virtual void DtSurfaceEntityMoveToController::setupGoalVector ( const DtVector goalPosition) [virtual]

Updates myGoalVector.

When the move to task arrives (or when the waypoint we're following moves), set up a vector from the waypoint to the entity to use in determining when/if we pass the waypoint. This is done by subtracting the DtVector representing the control point's position from the one representing the entity's position. This vector is used by passedGoal() to determine when (or if) the entity goes to far, and should stop. The result is stored in myGoalVector.

Reimplemented in DtSurfaceEntityFollowEntityController.

virtual void DtSurfaceEntityMoveToController::doMoving ( double  desiredSpeed) [virtual]

Determines if the ship has sailed past myControlpoint.

The determination is done based on an imaginary line drawn through the goal vector, perpendicular to the entity's heading. If the entity has passed that line, or will pass it during this simulation frame based on the current speed (computed last frame) passedGoal returns true.

Reimplemented in DtSurfaceEntityFollowEntityController, DtSurfaceEntityPatrolBetweenController, and DtSurfaceEntityMoveAlongController.

Determines if the entity is within the at-distance parameter to the waypoint.

Returns:
true if the entity is within the at-distance parameter to the waypoint.

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, atGoal() returns true. The result is stored in myAtGoal.

Reimplemented in DtSurfaceEntityMoveAlongController, and DtSurfaceEntityPatrolBetweenController.

Determines if the entity is within the near-distance parameter to the waypoint.

Returns:
true if the entity is within the at-distance parameter to the waypoint.

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, nearGoal() returns true. This is not currently used for moving to a point, only for entity following. The result is stored in myNearGoal.

Returns:
The ordered speed from the entity's state repository

Reimplemented in DtSurfaceEntityFollowEntityController.

static void DtSurfaceEntityMoveToController::moveToCallback ( DtSimMessage msg,
void *  user 
) [static]

Called when a move to 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 move-to tasks. When this callback is activated, the user data pointer is cast to an instance of this class upon which processMoveToTask is called with the move to task message.

Retrieves the name of the target waypoint from the task message.

Called by moveToCallback to lookup the control point stored in the move to message and store a pointer to it in myControlPoint. If the lookup is successful, setupGoalVector() is called. The name of the waypoint is saved as the control object name in the process state repository.

Registers interest in move to tasks by calling addTaskProcessorCallback with moveToCallback as the function pointer, and the 'this' pointer as the user data.

Reimplemented from DtTaskControllerComponent.

Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityPatrolBetweenController, DtSurfaceEntityPatrolRouteController, DtSurfaceEntityFollowEntityController, and DtSurfaceEntityMoveToLocationController.

static DtSimComponent* DtSurfaceEntityMoveToController::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:
A new instance of this class.

Reimplemented from DtSurfaceEntityPilotController.

Reimplemented in DtSurfaceEntityFollowEntityController, DtSurfaceEntityMoveAlongController, DtSurfaceEntityMoveToLocationController, DtSurfaceEntityPatrolBetweenController, and DtSurfaceEntityPatrolRouteController.

const DtSurfaceEntityMoveToController& DtSurfaceEntityMoveToController::operator= ( const DtSurfaceEntityMoveToController orig) [private]

assignment operator

virtual bool DtSurfaceEntityMoveToController::setupControlPoint ( ) [protected, virtual]

Updates myControlPoint.

Looks up the control point based on the control object name stored in the process state repository. If necessary the myControlPoint pointer is updated. If the control point has changed, setupGoalVector is called to reset myGoalVector.

Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityFollowEntityController, and DtSurfaceEntityMoveToLocationController.

virtual double DtSurfaceEntityMoveToController::distanceSquaredToDestination2D ( const DtVector current) const [protected, virtual]

Returns distance squared from destination point to current location.

Positions are all in local coordinates.

Reimplemented in DtSurfaceEntityMoveToLocationController.

virtual void DtSurfaceEntityMoveToController::getLocalDestination ( DtVector local) const [protected, virtual]
Returns:
The position of myControlPoint in local coordinates

Reimplemented in DtSurfaceEntityMoveToLocationController.


Member Data Documentation

Pointer to the target waypoint.

Stores last known location of the waypoint.

Maintained by setupGoalVector()


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)