![]() |
VR-Forces 4.0.4 Class Documentation
|
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...

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 DtRailSegment * | nextSegment () |
| 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 DtRailSegmentList * | pathList () |
| Returns a pointer to our path list. | |
| virtual const DtRailSegmentList * | pathList () 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 DtVrfObject * | getObjectFromObstruction (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 DtSimComponent * | creator (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 | |
| DtRailMovementController & | operator= (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 |
| DtRailMovementControllerPSR * | myProcessState |
| bool | myFirstTick |
| double | myTurnDistanceSq |
| int | myTurnDirection |
| bool | myDrivingOnLeft |
| Left is -1, right is 1 and 0 is straight. | |
| DtVrfMovingObjectStateRepository * | myMovingStateRep |
| DtRailSegment * | myCurrentSegment |
| DtRailSegment * | myNextSegment |
| DtRailMovementDriver * | myRailDriver |
| Determines how the entity should move along the given rail path. | |
| DtRailMovementUpdater * | myRailUpdater |
| Takes speed and lane input from the driver and updates the entity's position and orietation along the rail. | |
| DtVector | myPassingPoint |
| bool | myNotInitialized |
| const DtRailMovementDescriptor * | myRailMoveDescriptor |
| DtRailObstructionFinder * | myObstructionFinder |
| std::list< DtString > | myTurnBugNameList |
| List if debug "turn bug" object names created. | |
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
| DtRailMovementController::DtRailMovementController | ( | 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 DtRailMovementController::~DtRailMovementController | ( | ) | [virtual] |
destructor
| DtRailMovementController::DtRailMovementController | ( | ) | [protected] |
default constructor - should not be called
| DtRailMovementController::DtRailMovementController | ( | const DtRailMovementController & | orig | ) | [protected] |
copy constructor
| 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.
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] |
| virtual bool DtRailMovementController::tickWhileDestroyed | ( | ) | const [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.
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.
| virtual void DtRailMovementController::processMoveAlongTask | ( | DtSimMessage * | msg | ) | [virtual] |
Handle messages to move along a generated path.
These paths are generated by the DtRailPathPlanner in the DtMovementSelectorController.
| virtual void DtRailMovementController::registerTaskMsgCallbacks | ( | ) | [virtual] |
Overrides this so it can register it's interest in RailMoveAlong commands.
Reimplemented from DtTaskControllerComponent.
| static void DtRailMovementController::setConvoyFollowCallback | ( | DtSimMessage * | msg, |
| void * | usrData | ||
| ) | [static] |
| virtual void DtRailMovementController::setCurrentMovementState | ( | DtRailMovementState | state | ) | [virtual] |
| virtual DtRailMovementState DtRailMovementController::currentMovementState | ( | ) | const [virtual] |
| virtual DtRailSegment* DtRailMovementController::nextSegment | ( | ) | [virtual] |
Returns nextSegment in list.
| virtual bool DtRailMovementController::drivingOnLeftEnabled | ( | ) | const [virtual] |
| 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.
| virtual DtRailSegmentList* DtRailMovementController::pathList | ( | ) | [virtual] |
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.
| double DtRailMovementController::getDistanceSqAlongSeg | ( | const DtVector & | destination | ) |
Finds the distance squared the destination is along our current segment.
| double DtRailMovementController::getDistanceBehindConvoyTarget | ( | DtVrfObject * | convoyTgt | ) |
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.
| virtual bool DtRailMovementController::ifDrawDebugRoutes | ( | ) | const [virtual] |
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] |
| virtual DtVrfObject* DtRailMovementController::getObjectFromObstruction | ( | DtRailObstructionPtr & | obs | ) | [virtual] |
| static DtSimComponent* DtRailMovementController::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). |
| 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] |
| virtual bool DtRailMovementController::initializeCurrentState | ( | DtRailMoveAlongTask * | task | ) | [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.
DtVector DtRailMovementController::myLocalDestination [protected] |
DtRailSegmentList DtRailMovementController::myPath [protected] |
bool DtRailMovementController::myFirstTick [protected] |
double DtRailMovementController::myTurnDistanceSq [protected] |
int DtRailMovementController::myTurnDirection [protected] |
bool DtRailMovementController::myDrivingOnLeft [protected] |
Left is -1, right is 1 and 0 is straight.
DtRailSegment* DtRailMovementController::myCurrentSegment [protected] |
DtRailSegment* DtRailMovementController::myNextSegment [protected] |
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.
DtVector DtRailMovementController::myPassingPoint [protected] |
bool DtRailMovementController::myNotInitialized [protected] |
const DtRailMovementDescriptor* DtRailMovementController::myRailMoveDescriptor [protected] |
std::list<DtString> DtRailMovementController::myTurnBugNameList [protected] |
List if debug "turn bug" object names created.
These are deleted when the task is complete.