![]() |
VR-Forces 4.0.4 Class Documentation
|
DtSurfaceEntityMoveAlongController is a controller that models movement of a ship along a route. More...

Public Member Functions | |
| DtSurfaceEntityMoveAlongController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
| virtual | ~DtSurfaceEntityMoveAlongController () |
| Destructor. | |
| virtual bool | init () |
| Creates myControlPoint. | |
| virtual DtString | type () const |
| Returns a string identifies the class type of component. | |
| virtual void | processMoveAlongTask (DtSimMessage *msg) |
| Retrives the route name from the task message. | |
| virtual void | processRouteChanged (DtVrfObject *obj) |
| Handles changes to the verticies in the route. | |
| virtual bool | atGoal () |
| Overridden to head to the next vertex in the route every time a vertex is reached until the end of the route is reached. | |
| virtual bool | passedGoal () |
| Overridden to head to the next vertex in the route every time a vertex is reached until the end of the route is reached. | |
| virtual void | doMoving (double desiredSpeed) |
| Overriden to call sailTo during route traversal until moving towards the the final point in the route at which time driftTo is called instead so the vessel will drift to a stop at the final vertex. | |
| virtual bool | targetNextVertex () |
| Advance to the next vertex in the route state. | |
Static Public Member Functions | |
| static void | moveAlongCallback (DtSimMessage *msg, void *usr) |
| Called when a move along message is received. | |
| static void | routeChangedCallback (DtVrfObject *obj, void *user) |
| Calls processRouteChanged(). | |
| static DtSimComponent * | creator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
Protected Member Functions | |
| DtSurfaceEntityMoveAlongController () | |
| default constructor; not implemented | |
| DtSurfaceEntityMoveAlongController (const DtSurfaceEntityMoveAlongController &orig) | |
| copy constructor; not implemented | |
| const DtSurfaceEntityMoveAlongController & | operator= (const DtSurfaceEntityMoveAlongController &orig) |
| assignment operator; not implemented | |
| virtual bool | setupRoute () |
| Updates the route state in the process state repository. | |
| virtual bool | setupControlPoint () |
| Overridden to synchronize myControlPoint with the current vertex in the route. | |
| virtual void | registerTaskMsgCallbacks () |
| Registers interest in move along tasks by calling addTaskProcessorCallback with moveAlongCallback as the function pointer and the 'this' pointer as the user data. | |
| virtual void | emptyVertexList () |
| Removes and deletes vertices from the vertex list in process state repository (calls process state repository's emptyRouteVertices()). | |
Protected Attributes | |
| DtVrfObject * | myRoute |
| This is looked up once per tick - assumed unchanging while we have control. | |
| bool | myRouteHasChanged |
| This gets set to true when a modifyRoute message for the route we're following is received. | |
DtSurfaceEntityMoveAlongController is a controller that models movement of a ship along a route.
End User Description: DtSurfaceEntityMoveAlongController (surfEntMvAlgCtl.h) is derived from DtSurfaceEntityMoveToController and implements the Move Along route task for surface entities. It works by creating a temporary waypoint which the base class is targeting, and moving that waypoing to each successive point in the route. By overriding DtSurfaceEntityMoveToController::doMoving, the move along controller is able to call sailTo() instead of driftTo() for all the target vertices along the route except for the final vertex where it will attempt to drift to a stop. Both atGoal() and passedGoal() are overridden to call down to the base class, and then call targetNextVertex() to advance myRouteState to the next vertex.
It overrides DtTaskControllerComponent::registerTaskMsgCallbacks() and registers the callback function moveAlongCallback() for DtMoveAlongType. When a message is received, the callback invokes processMoveAlongTask(), which looks up the route in the object manager and stores a pointer to it in myRoute.
Uses Descriptor Type: DtSurfaceEntityPilotControllerDescriptor
| DtSurfaceEntityMoveAlongController::DtSurfaceEntityMoveAlongController | ( | 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 DtSurfaceEntityMoveAlongController::~DtSurfaceEntityMoveAlongController | ( | ) | [virtual] |
Destructor.
Removes any remaining vertices changed callback added by processMoveAlongTask. Deletes myControlPoint. Calls emptyVertexList().
default constructor; not implemented
| DtSurfaceEntityMoveAlongController::DtSurfaceEntityMoveAlongController | ( | const DtSurfaceEntityMoveAlongController & | orig | ) | [protected] |
copy constructor; not implemented
| virtual bool DtSurfaceEntityMoveAlongController::init | ( | ) | [virtual] |
Creates myControlPoint.
Reimplemented from DtSurfaceEntityPilotController.
| virtual DtString DtSurfaceEntityMoveAlongController::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.
Reimplemented in DtSurfaceEntityPatrolRouteController.
| static void DtSurfaceEntityMoveAlongController::moveAlongCallback | ( | DtSimMessage * | msg, |
| void * | usr | ||
| ) | [static] |
Called when a move along message is received.
Instances of this component will register this callback (with their own 'this' pointer as user data) by calling addTaskProcessorCallback in order to request for notification of move-along tasks. When this callback is activated, the user data pointer is cast to an instance of this class upon which processMoveAlongTask is called with the move along message.
| virtual void DtSurfaceEntityMoveAlongController::processMoveAlongTask | ( | DtSimMessage * | msg | ) | [virtual] |
Retrives the route name from the task message.
Called by moveAlongCallback to lookup the route stored in the move to message and store a pointer to it in myRoute. The name of the route and the reverse flag are saved in the process state repository. A verticies changed callback is registered on the route with routeChangedCallback as the function pointer. The myRouteHasChanged flag is then set to false. Finally, setupControlPoint() is called.
| static void DtSurfaceEntityMoveAlongController::routeChangedCallback | ( | DtVrfObject * | obj, |
| void * | user | ||
| ) | [static] |
Calls processRouteChanged().
Casts the user data pointer to an instance of this class upon which it calls processRouteChanged() with the object pointer.
| virtual void DtSurfaceEntityMoveAlongController::processRouteChanged | ( | DtVrfObject * | obj | ) | [virtual] |
Handles changes to the verticies in the route.
Checks to make sure that the route is not null, that it's name matches the name stored in the process state repository, and that the controller is tasked. Iterates over the vertices in the route and compares them to the route vertices stored in the process state repository. If one of the verticies differs, myRouteHasChanged is set to true.
| virtual bool DtSurfaceEntityMoveAlongController::atGoal | ( | ) | [virtual] |
Overridden to head to the next vertex in the route every time a vertex is reached until the end of the route is reached.
Calls down to DtSurfaceEntityMoveToController::atGoal() to determine if the current vertex has been reached. If not, false is returned. If the base class returns true, targetNextVertex is called to advance the target waypoint. If this call returns false, it indicates that the last vertex in the route has been reached and atGoal will return true.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual bool DtSurfaceEntityMoveAlongController::passedGoal | ( | ) | [virtual] |
Overridden to head to the next vertex in the route every time a vertex is reached until the end of the route is reached.
Calls down to DtSurfaceEntityMoveToController::passedGoal() to determine if the current vertex has been passed. If not, false is returned. If the base class returns true, targetNextVertex is called to advance the target waypoint. If this call returns false, it indicates that the last vertex in the route has been passed and passedGoal will return true.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual void DtSurfaceEntityMoveAlongController::doMoving | ( | double | desiredSpeed | ) | [virtual] |
Overriden to call sailTo during route traversal until moving towards the the final point in the route at which time driftTo is called instead so the vessel will drift to a stop at the final vertex.
Reimplemented from DtSurfaceEntityMoveToController.
Reimplemented in DtSurfaceEntityPatrolRouteController.
| virtual bool DtSurfaceEntityMoveAlongController::targetNextVertex | ( | ) | [virtual] |
Advance to the next vertex in the route state.
Checks to see if the current vertex stored in the route state of the process state repository is the last vertex in the route. If so, false is returned. If not, the route state is advanced and setupControlPoint() is called. If sucessful, doMoving is called with findDesiredSpeed. If not, false is returned.
Reimplemented in DtSurfaceEntityPatrolRouteController.
| static DtSimComponent* DtSurfaceEntityMoveAlongController::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.
Reimplemented in DtSurfaceEntityPatrolRouteController.
| const DtSurfaceEntityMoveAlongController& DtSurfaceEntityMoveAlongController::operator= | ( | const DtSurfaceEntityMoveAlongController & | orig | ) | [protected] |
assignment operator; not implemented
| virtual bool DtSurfaceEntityMoveAlongController::setupRoute | ( | ) | [protected, virtual] |
Updates the route state in the process state repository.
Looks up the route in the object manager using the name stored in the process state repository and stores the pointer to it in myRoute. If the lookup fails, setupRoute returns false. Otherwise, if the PSR does not have a valid route state pointer, or if myRouteHasChanged, the PSR's route verticies are updated based on the vertices in myRoute. Additionally, if myRouteHasChanged setToClosest is called on the PSR's route state and myRouteHasChanged is reset to false.
| virtual bool DtSurfaceEntityMoveAlongController::setupControlPoint | ( | ) | [protected, virtual] |
Overridden to synchronize myControlPoint with the current vertex in the route.
Calls setupRoute and returns false if it fails. Updates the local position of myControlPoint with the location of the current vertex of the route state from the process state repository. If myRouteHasChanged, setupGoalVector() is called with the location of myControlPoint.
Reimplemented from DtSurfaceEntityMoveToController.
| virtual void DtSurfaceEntityMoveAlongController::registerTaskMsgCallbacks | ( | ) | [protected, virtual] |
Registers interest in move along tasks by calling addTaskProcessorCallback with moveAlongCallback as the function pointer and the 'this' pointer as the user data.
Reimplemented from DtSurfaceEntityMoveToController.
Reimplemented in DtSurfaceEntityPatrolRouteController.
| virtual void DtSurfaceEntityMoveAlongController::emptyVertexList | ( | ) | [protected, virtual] |
Removes and deletes vertices from the vertex list in process state repository (calls process state repository's emptyRouteVertices()).
DtVrfObject* DtSurfaceEntityMoveAlongController::myRoute [protected] |
This is looked up once per tick - assumed unchanging while we have control.
This gets set to true when a modifyRoute message for the route we're following is received.