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

DtRailMovementController is a controller that models movement of an entity along a provided path as if it were locked on rails along each segment. More...

Inheritance diagram for DtRailMovementController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtRailMovementController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtRailMovementController ()
 destructor
virtual DtString type () const
 Returns a string identifies the class type of component.
virtual bool init ()
 Create and initialize our movement driver and updater.
virtual void tick ()
 Determines how the entity moves along the given path.Checks if entity has completed it's task.
virtual void clear ()
virtual bool tickWhileDestroyed () const
 If the component returns true here, it will be ticked regardless of the destroyed state of the host entity.
virtual void processMoveAlongTask (DtSimMessage *msg)
 Handle messages to move along a generated path.
virtual void registerTaskMsgCallbacks ()
 Overrides this so it can register it's interest in RailMoveAlong commands.
virtual void setCurrentMovementState (DtRailMovementState state)
virtual DtRailMovementState currentMovementState () const
virtual DtRailSegmentnextSegment ()
 Returns nextSegment in list.
virtual bool drivingOnLeftEnabled () const
virtual const int turnDirection () const
 Returns the direction we're turning.
virtual void setTurnDirection (const int turn)
virtual bool turning () const
virtual void setTurning (bool turn)
virtual const int currentLane () const
 Set/get current lane position.
virtual void setCurrentLane (const int lane)
virtual const int passingLane () const
 Set/get passing lane, the lane an entity will move into when passing.
virtual void setPassingLane (const int lane)
virtual void setFollowThreshold (const double)
 The maximum follow threshold.
virtual const double followThreshold () const
virtual const double followSpeedFactor () const
 The factor by which we should multiple our speed if we are outside the follow threshold to catch up or slow down back into the threshold.
virtual DtRailSegmentListpathList ()
 Returns a pointer to our path list.
virtual const DtRailSegmentListpathList () const
virtual bool setUpDestination (DtRailSegment *seg, bool incrementSegmentIndex=true, bool useCurrentPos=false, DtVector pos=DtVector::zero())
 Sets myCurrentSeg to seg, this is the segment the entity is currently going to be moving along.
double getDistanceSqAlongSeg (const DtVector &destination)
 Finds the distance squared the destination is along our current segment.
double getDistanceBehindConvoyTarget (DtVrfObject *convoyTgt)
 Finds the distance along the rail between this entity and the entity it is following if it is following.
virtual double travelDistanceSq ()
 This is the minimum distance squared the enity will comfortably follow another entity in the same lane This is twice the bounding radius of the entity plus if using accleration includes the braking distance.
virtual bool ifDrawDebugRoutes () const
 Whether or not to publish debugging turn route composed of the 3 points used to generate the turn spline.
virtual void drawDebugSplineTurnRoute (const DtVector &ee, const DtVector &md, const DtVector &ex)
virtual DtVrfObjectgetObjectFromObstruction (DtRailObstructionPtr &obs)

Static Public Member Functions

static void settingConsumerCallback (const DtSettingsObject *settingsObject, void *usr)
 Callback for changing which side of the road entity is driving on. Calls processSetting.
static void moveAlongCallback (DtSimMessage *msg, void *usr)
 Instances of this component will register this callback with their own 'this' pointer as user data with the msg executive requesting notification of rail-move-along tasks.
static void setConvoyFollowCallback (DtSimMessage *msg, void *usrData)
static DtSimComponentcreator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,

Protected Member Functions

 DtRailMovementController ()
 default constructor - should not be called
 DtRailMovementController (const DtRailMovementController &orig)
 copy constructor
DtRailMovementControlleroperator= (const DtRailMovementController &orig)
 assignment operator
virtual bool createPSR ()
virtual void processSetting (const DtBoolSetting *setting)
 Sets myDrivingOnLeftEnabled with value in setting.
virtual void processSetConvoyFollowCallback (DtSimMessage *msg)
virtual bool initializeCurrentState (DtRailMoveAlongTask *task)
 When loading up from a scenario we need to find out where we were on the route and initialize from our process state repository.
virtual bool setUpRoute (const DtRwTemplatedListPtr< DtRwRailSegment > &path)
 Set up our path from the rail move along task's path.
virtual int entryLanePosition (double heading, unsigned int numLanes)
 Determines which lane we should be starting in.
virtual void checkMovementState (const int passingLane)
virtual void clearTask ()
 Override to clear route name and route state data stored in myProcessState.
virtual bool decideToGiveUpTask () const
 This function is used to determine if the controller should give up trying to execute the current task.
virtual int findObstructionsAndAdjust (DtRailObstructionFinder *obsFinder, const DtRailMovementDriver *railDriver, const DtVrfObject *entity, const DtVrfObject *convoyTgt, const int drivingLane, const int passingLane, double &drivingSpeed)
 Will always return a non-zero value for the lane to switch into.
virtual void testObstructionFinder (const int drivingLane, const double drivingSpeed)
 For debugging purposes.

Protected Attributes

DtVector myLocalDestination
DtRailSegmentList myPath
DtRailSegmentListIterator myPathIterator
DtRailMovementControllerPSRmyProcessState
bool myFirstTick
double myTurnDistanceSq
int myTurnDirection
bool myDrivingOnLeft
 Left is -1, right is 1 and 0 is straight.
DtVrfMovingObjectStateRepositorymyMovingStateRep
DtRailSegmentmyCurrentSegment
DtRailSegmentmyNextSegment
DtRailMovementDrivermyRailDriver
 Determines how the entity should move along the given rail path.
DtRailMovementUpdatermyRailUpdater
 Takes speed and lane input from the driver and updates the entity's position and orietation along the rail.
DtVector myPassingPoint
bool myNotInitialized
const DtRailMovementDescriptormyRailMoveDescriptor
DtRailObstructionFindermyObstructionFinder
std::list< DtStringmyTurnBugNameList
 List if debug "turn bug" object names created.

Detailed Description

DtRailMovementController is a controller that models movement of an entity along a provided path as if it were locked on rails along each segment.

The path consists of a list of DtRailSegments. Each segment provides the heading along which the entity should be oriented and the speed which it should travel along the segment. Other attributes can be associated with the rail segment. Registers for interest in DtRailMoveAlongTasks.

Uses Descriptor Type: DtRailMovementDescriptor


Constructor & Destructor Documentation

DtRailMovementController::DtRailMovementController ( 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 - should not be called

copy constructor


Member Function Documentation

virtual DtString DtRailMovementController::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:
DtRailMovementType

Implements DtTaskControllerComponent.

virtual bool DtRailMovementController::init ( ) [virtual]

Create and initialize our movement driver and updater.

Reimplemented from DtControllerComponent.

virtual void DtRailMovementController::tick ( ) [virtual]

Determines how the entity moves along the given path.Checks if entity has completed it's task.

The DtRailMovementDriver checks for upcoming intersections and determines appropriate behaviour. Checks for entities in the way of the path and determines if possible to pass them. Determines the speed and lane position the entity needs and passes this to the DtRailMovementUpdater.Checks if entity has completed it's task.

Reimplemented from DtSimComponent.

virtual void DtRailMovementController::clear ( ) [virtual]

If the component returns true here, it will be ticked regardless of the destroyed state of the host entity.

Otherwise, tick will only be called when the entity is alive.

Returns:
false.

Reimplemented from DtSimComponent.

static void DtRailMovementController::settingConsumerCallback ( const DtSettingsObject settingsObject,
void *  usr 
) [static]

Callback for changing which side of the road entity is driving on. Calls processSetting.

static void DtRailMovementController::moveAlongCallback ( DtSimMessage msg,
void *  usr 
) [static]

Instances of this component will register this callback with their own 'this' pointer as user data with the msg executive requesting notification of rail-move-along tasks.

Handle messages to move along a generated path.

These paths are generated by the DtRailPathPlanner in the DtMovementSelectorController.

Overrides this so it can register it's interest in RailMoveAlong commands.

Reimplemented from DtTaskControllerComponent.

static void DtRailMovementController::setConvoyFollowCallback ( DtSimMessage msg,
void *  usrData 
) [static]

Returns nextSegment in list.

virtual const int DtRailMovementController::turnDirection ( ) const [virtual]

Returns the direction we're turning.

virtual void DtRailMovementController::setTurnDirection ( const int  turn) [virtual]
virtual bool DtRailMovementController::turning ( ) const [virtual]
virtual void DtRailMovementController::setTurning ( bool  turn) [virtual]
virtual const int DtRailMovementController::currentLane ( ) const [virtual]

Set/get current lane position.

virtual void DtRailMovementController::setCurrentLane ( const int  lane) [virtual]
virtual const int DtRailMovementController::passingLane ( ) const [virtual]

Set/get passing lane, the lane an entity will move into when passing.

virtual void DtRailMovementController::setPassingLane ( const int  lane) [virtual]
virtual void DtRailMovementController::setFollowThreshold ( const double  ) [virtual]

The maximum follow threshold.

Initialized by the descriptor. Maximum delta off of the follow distance tolerated.

virtual const double DtRailMovementController::followThreshold ( ) const [virtual]
virtual const double DtRailMovementController::followSpeedFactor ( ) const [virtual]

The factor by which we should multiple our speed if we are outside the follow threshold to catch up or slow down back into the threshold.

Returns a pointer to our path list.

virtual const DtRailSegmentList* DtRailMovementController::pathList ( ) const [virtual]
virtual bool DtRailMovementController::setUpDestination ( DtRailSegment seg,
bool  incrementSegmentIndex = true,
bool  useCurrentPos = false,
DtVector  pos = DtVector::zero() 
) [virtual]

Sets myCurrentSeg to seg, this is the segment the entity is currently going to be moving along.

Uses this and the next segment to calculate the turn path if using turn smoothing. If the next segment is 0 we are on the last segment so there won't be any turning. incrementSegmentIndex indicates whether we are in fact setting up on a new segment and therefore should let the process state know we have moved to the next segment. This is the default, however if you are on the last segment or are loading up from a scenario this is not the case so pass false in.

Finds the distance squared the destination is along our current segment.

Finds the distance along the rail between this entity and the entity it is following if it is following.

virtual double DtRailMovementController::travelDistanceSq ( ) [virtual]

This is the minimum distance squared the enity will comfortably follow another entity in the same lane This is twice the bounding radius of the entity plus if using accleration includes the braking distance.

Whether or not to publish debugging turn route composed of the 3 points used to generate the turn spline.

virtual void DtRailMovementController::drawDebugSplineTurnRoute ( const DtVector ee,
const DtVector md,
const DtVector ex 
) [virtual]
static DtSimComponent* DtRailMovementController::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.
DtRailMovementController& DtRailMovementController::operator= ( const DtRailMovementController orig) [protected]

assignment operator

virtual bool DtRailMovementController::createPSR ( ) [protected, virtual]
virtual void DtRailMovementController::processSetting ( const DtBoolSetting setting) [protected, virtual]

Sets myDrivingOnLeftEnabled with value in setting.

virtual void DtRailMovementController::processSetConvoyFollowCallback ( DtSimMessage msg) [protected, virtual]

When loading up from a scenario we need to find out where we were on the route and initialize from our process state repository.

virtual bool DtRailMovementController::setUpRoute ( const DtRwTemplatedListPtr< DtRwRailSegment > &  path) [protected, virtual]

Set up our path from the rail move along task's path.

virtual int DtRailMovementController::entryLanePosition ( double  heading,
unsigned int  numLanes 
) [protected, virtual]

Determines which lane we should be starting in.

Currently just checks if we're driving on the left( british style) or the right side of the road and puts us in the far lane, the non-passing lanes.

virtual void DtRailMovementController::checkMovementState ( const int  passingLane) [protected, virtual]
virtual void DtRailMovementController::clearTask ( ) [protected, virtual]

Override to clear route name and route state data stored in myProcessState.

Reimplemented from DtSingleTaskControllerComponent.

virtual bool DtRailMovementController::decideToGiveUpTask ( ) const [protected, virtual]

This function is used to determine if the controller should give up trying to execute the current task.

Override this function to provide the test for determining if the task controller should give up. For example, a derived move-to-waypoint controller tasked to reach an unreachable waypoint might decide to give up after a certain amount of time, or after circling the point and failing to reach it. This function is called from within tick. If the controller is tasked and this function returns true, it calls giveUp(). The implementation in this class always returns false.

Reimplemented from DtSingleTaskControllerComponent.

virtual int DtRailMovementController::findObstructionsAndAdjust ( DtRailObstructionFinder obsFinder,
const DtRailMovementDriver railDriver,
const DtVrfObject entity,
const DtVrfObject convoyTgt,
const int  drivingLane,
const int  passingLane,
double &  drivingSpeed 
) [protected, virtual]

Will always return a non-zero value for the lane to switch into.

If it's the same lane as the current lane, it does return the current lane.

virtual void DtRailMovementController::testObstructionFinder ( const int  drivingLane,
const double  drivingSpeed 
) [protected, virtual]

For debugging purposes.


Member Data Documentation

Left is -1, right is 1 and 0 is straight.

Determines how the entity should move along the given rail path.

Calculates the desired speed and lane position

Takes speed and lane input from the driver and updates the entity's position and orietation along the rail.

List if debug "turn bug" object names created.

These are deleted when the task is complete.


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)