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

DtPathMovementController is a controller that models movement along a generated path for an entity. More...

Inheritance diagram for DtPathMovementController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtPathMovementController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=NULL, DtReaderWriterRegistry *parentRegistry=NULL)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtPathMovementController ()
virtual bool init ()
 Initial setup of component after creation.
virtual bool createPSR ()
 Creates myProcessState data member, and adds it to our process state repository manager.
virtual DtString type () const
 Returns a string identifies the class type of component.
virtual void registerTaskMsgCallbacks ()
 Overridden to register interest in move to messages.
virtual void processPlannedMoveToTask (DtSimMessage *msg)
virtual void processTaskCompleteReport (DtSimMessage *msg)
virtual void processDestinationChanged ()
 Ensures that the destination stored in the ProcessStateRepository is consistent with the location of the destination control point.
virtual void processSetLocation (DtSimMessage *msg)
 Aborts any running path planning thread, or stops any move along subtask that has been started.
virtual void tick ()
 Main processing for component.

Static Public Member Functions

static void plannedMoveToCallback (DtSimMessage *msg, void *usr)
static void taskCompleteReportCallback (DtSimMessage *msg, void *usr)
static void destinationChangedCallback (DtVrfObject *obj, void *usrData)
static void setLocationCallback (DtSimMessage *msg, void *usr)
 Calls processSetLocation.
static DtSimComponentcreator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,

Protected Member Functions

virtual void startPlannedMoveTo (const DtString &objectName)
 Starts a planned move to task with the specified object as the target position.
virtual void startPlannedMoveTo (const DtVector &localDestination)
 Starts a planned move to task to the specified coordinates.
virtual void registerDestinationChangedCallback ()
 Registers a vertices changed callback with the destination object named in the PSR.
virtual void unregisterDestinationChangedCallback ()
 Unregisters a vertices changed callback from the destination object named in the PSR.
void abort ()
 Call this method from outside the spawned thread to tell the spawned process to abort the path planning process and exit.
virtual bool pathDone ()
 Call this from outside the spawned thread.
virtual DtVrfObjectpublishPath ()
 Creates a new VRF Object corresponding to the path generated by the path planner.
virtual void removePublishedPath ()
 Removes the VrfObject corresponding to the path that was published and whose name is stored in myPathName.
virtual bool makePath (const DtVector &start, const DtVector &end)
 uses the DtPathPlanner to calculate a path from start to end.
virtual void clearTask ()
 Overridden from DtTaskControllerComponent to clean up the path calculating thread, remove any generated path objects, and stop any subtasks if the current task is aborted.
virtual void threadMain ()
 Actual main method for the spawned thread.
virtual DtPathMetriccreatePathMetric ()
 Just for testing -- creates and returns our path metric.

Static Protected Member Functions

static void * staticThreadMain (void *data)
 Main function for the spawned thread.

Protected Attributes

DtPathPlannermyPathPlanner
DtPathMovementControllerPSRmyProcessState
 Container for state data associated with this component.
const
DtPathMovementControllerDescriptor
myPathDescriptor
bool myDestinationChangedCallbackRegistered
bool myDone
 Bookkeeping for callback registration.
volatile bool myProcessing
 Needs to be volatile since one thread checks this value while the other sets it.
pthread_t myThread
DtVector myStartPoint
DtVector myEndPoint
DtPathMetricmyPathMetric
double myLastMessageTime
 Message information members.
double myTotalElapsedTime

Private Member Functions

 DtPathMovementController ()
 Not Implemented.
 DtPathMovementController (const DtPathMovementController &orig)
 Not Implemented.
DtPathMovementControlleroperator= (const DtPathMovementController &orig)
 Not Implemented.
virtual void processObjectAboutToBeRemoved (DtVrfObject *obj)
 If the object being removed is the current destination, then the task is abandoned.
static void objectAboutToBeRemovedCallback (DtVrfObject *obj, void *usr)
 If the object being removed is the current destination, then the task is abandoned.

Detailed Description

DtPathMovementController is a controller that models movement along a generated path for an entity.

End User Description: This task controller component responds to path movement tasks by spawning a thread in which a DtPathPlanner calculates the best path from the current position to the destination. Once the path is calculated, it is published as a VRF control object and a move along route subtask is issued within the same entity to carry out the movement. Once the subtask completes, or if the task is aborted, the route object that was published will be removed. If a task was planned to a named object, and that object changes location during the run of this task, the original path will be removed, and a new path will be planned.

Note:
The entity will remain in place while it is planning a path. If the terrain is complex, the distance to the destination is large, or there is not much available processor this may be a lengthy process.
Because this controller spawns a separate thread, the use of this controller breaks repeatability. See the repeatability section of the manual for more information.

This component responds to DtPlanAndMoveToTask and DtPlanAndMoveToLocationTask task types.

This component can be configured though its descriptor, the DtPathMovementControllerDescriptor. See this class for information on altering the path planning parameters in the OPE file.

This component maintains its internal state in a DtPathMovementControllerPSR.

The path planning that is done by this component is done using the DtPathPlanner class. Check this class for information on customizing the path planning algorithm.

Uses Descriptor Type: DtPathMovementControllerDescriptor


Constructor & Destructor Documentation

Not Implemented.

Not Implemented.

DtPathMovementController::DtPathMovementController ( const DtString name,
DtVrfObject owner,
DtSimManager simManager,
DtComponentDescriptor desc = NULL,
DtReaderWriterRegistry parentRegistry = NULL 
)

(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)


Member Function Documentation

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

Not Implemented.

virtual bool DtPathMovementController::init ( ) [virtual]

Initial setup of component after creation.

Reimplemented from DtControllerComponent.

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 DtString DtPathMovementController::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:
DtPathMovementType

Implements DtTaskControllerComponent.

Overridden to register interest in move to messages.

Reimplemented from DtTaskControllerComponent.

static void DtPathMovementController::plannedMoveToCallback ( DtSimMessage msg,
void *  usr 
) [static]
static void DtPathMovementController::taskCompleteReportCallback ( DtSimMessage msg,
void *  usr 
) [static]
static void DtPathMovementController::destinationChangedCallback ( DtVrfObject obj,
void *  usrData 
) [static]

Ensures that the destination stored in the ProcessStateRepository is consistent with the location of the destination control point.

Intended to be called only when the position of the control point has changed.

Note:
Also invalidates the destination vector as the world position has changed.
static void DtPathMovementController::objectAboutToBeRemovedCallback ( DtVrfObject obj,
void *  usr 
) [static]

If the object being removed is the current destination, then the task is abandoned.

If the object being removed is the current destination, then the task is abandoned.

static void DtPathMovementController::setLocationCallback ( DtSimMessage msg,
void *  usr 
) [static]

Calls processSetLocation.

Aborts any running path planning thread, or stops any move along subtask that has been started.

Next call to tick() will start a new path planning thread from the entities new position.

virtual void DtPathMovementController::tick ( ) [virtual]

Main processing for component.

Reimplemented from DtSimComponent.

virtual void DtPathMovementController::startPlannedMoveTo ( const DtString objectName) [protected, virtual]

Starts a planned move to task with the specified object as the target position.

virtual void DtPathMovementController::startPlannedMoveTo ( const DtVector localDestination) [protected, virtual]

Starts a planned move to task to the specified coordinates.

Calls to makePath() to kick off the path planning thread.

virtual void DtPathMovementController::registerDestinationChangedCallback ( ) [protected, virtual]

Registers a vertices changed callback with the destination object named in the PSR.

Registers for a setLocation message.

Unregisters a vertices changed callback from the destination object named in the PSR.

void DtPathMovementController::abort ( ) [protected]

Call this method from outside the spawned thread to tell the spawned process to abort the path planning process and exit.

virtual bool DtPathMovementController::pathDone ( ) [protected, virtual]

Call this from outside the spawned thread.

Returns true if the path planning thread has completed and exited.

virtual DtVrfObject* DtPathMovementController::publishPath ( ) [protected, virtual]

Creates a new VRF Object corresponding to the path generated by the path planner.

Returns the VrfObject pointer to the new route object.

virtual void DtPathMovementController::removePublishedPath ( ) [protected, virtual]

Removes the VrfObject corresponding to the path that was published and whose name is stored in myPathName.

virtual bool DtPathMovementController::makePath ( const DtVector start,
const DtVector end 
) [protected, virtual]

uses the DtPathPlanner to calculate a path from start to end.

virtual void DtPathMovementController::clearTask ( ) [protected, virtual]

Overridden from DtTaskControllerComponent to clean up the path calculating thread, remove any generated path objects, and stop any subtasks if the current task is aborted.

Reimplemented from DtSingleTaskControllerComponent.

static void* DtPathMovementController::staticThreadMain ( void *  data) [static, protected]

Main function for the spawned thread.

Simply casts data to a DtGroupPathMovementController and calls threadMain().

virtual void DtPathMovementController::threadMain ( ) [protected, virtual]

Actual main method for the spawned thread.

virtual DtPathMetric* DtPathMovementController::createPathMetric ( ) [protected, virtual]

Just for testing -- creates and returns our path metric.

static DtSimComponent* DtPathMovementController::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.

Member Data Documentation

Container for state data associated with this component.

This state is saved and restored as part of a scenario (or checkpoint).

Bookkeeping for callback registration.

Needs to be volatile since one thread checks this value while the other sets it.

pthread_t DtPathMovementController::myThread [protected]

Message information members.


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)