VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
roadMovementController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 
10 
11 #pragma once
12 
16 #include <matrix/vlVector.h>
17 #include <list>
18 #include "vrfutil/rwRailSegment.h"
22 #include "vrfmodel/roadSegment.h"
23 
24 class DtRailSegment;
33 class DtRoadConstants;
34 class DtRoadDrivingLogic;
35 class DtBoolSetting;
36 
37 
43 #define DT_RAIL_SEGMENT_MERGE_ERROR_BOUND 0.3
44 
66 {
67 public:
71  DtLocalObject* owner,
72  DtSimulationServices* simManager,
73  DtComponentDescriptor* desc = 0,
74  DtReaderWriterRegistry* parentRegistry = 0);
75 
77  virtual ~DtRoadMovementController() override;
78 
81 
84  virtual const char* type() const override;
85 
90  virtual bool init() override;
91 
94  virtual void preFirstTickInit() override;
95 
96  virtual bool beginProcessingTask(const DtTaskMessage& task, DtSimTaskStatePtr taskState) override;
97 
103  virtual void tick() override;
104 
105  virtual void clear();
106 
109  virtual bool tickWhileDestroyed() const override;
110 
112  virtual void registerTaskMsgCallbacks() override;
113 
117  static DtSimComponent * creator(const DtString& name,
118  DtLocalObject* owner,
119  DtSimulationServices* simManager,
120  DtComponentDescriptor* desc = 0,
121  DtReaderWriterRegistry* parentRegistry = 0);
122 
124 
127 
131  static void moveAlongCallback(DtSimMessage * msg, void * usr);
132 
133  static void setConvoyFollowCallback(DtSimMessage * msg, void * usrData);
134 
136  static void settingsObjectConsumerCallback(const DtSettingsObject* settingsObject, void* usr);
137 
139 
140  //-------------------------------------------------------------------
145 
146  virtual const DtRoadConstants* roadConstants(){ return myRoadConstants; }
147 
151  virtual void setRoadConstants(const DtRoadConstants* rc)
152  {
153  myRoadConstants = rc;
154  }
155 
156  virtual DtRoadPathFunctions* pathFunctions(){ return myRoadPathFunctions; }
158  {
159  myRoadPathFunctions = pf;
160  }
161 
162  virtual DtRoadDrivingLogic* drivingLogic(){ return myDrivingLogic; }
164  {
165  myDrivingLogic = dl;
166  }
167 
169  {
170  return myRoadObstructionFinder;
171  }
174  {
175  myRoadObstructionFinder = of;
176  }
177 
178  virtual DtRoadMovementUpdater* movementUpdater(){ return myRoadUpdater; }
179 
183  {
184  myRoadUpdater = u;
185  }
187  //------------------------------------------------------------------
188 
191 
193  { return myProcessState; }
195  { return myObjectParams; }
196  virtual const DtRoadMovementDescriptor* descriptor() const;
198 
201  virtual bool drivingOnLeftEnabled() const;
202 
203  virtual void setCurrentMovementState(DtRailMovementState state);
204  virtual DtRailMovementState currentMovementState() const;
205 
206  virtual DtRoadSegment* currentRoadSegment()const;
207  virtual void setCurrentRoadSegment(DtRoadSegment* seg);
208 
210  virtual double frontOffset() const;
211  virtual void setFrontOffset(const double o);
212 
216  virtual double rearAxleOffset() const;
217  virtual void setRearAxleOffset(const double o);
218 
220  virtual DtVector localRearAxleLocation() const;
221 
223  virtual DtRailSegmentList * pathList();
224  virtual const DtRailSegmentList * pathList() const;
225 
228  virtual DtRoadSegmentPart roadSegmentPart()const;
229  virtual void setRoadSegmentPart(const DtRoadSegmentPart s);
231 
234 
240  virtual void updateTaskVisualizations() override;
241 
244  virtual bool findPointOnTerrain(const DtVector& worldLocation, DtVector& worldLocationOnTerrain);
245 
247  virtual std::vector<DtVector>& debugPoints()
248  {
249  return myObstacleLocations;
250  }
253  virtual std::vector<std::vector<DtVector> >& debugBoxes()
254  {
255  return myObstacleBoxes;
256  }
258 
261  virtual const double followSpeedFactor() const;
262 
263  virtual double getDistanceBehindConvoyTarget(const DtSimObject* convoyTgt) const;
264 
265  virtual DtSimObjectReference getObjectFromObstruction(DtRailObstructionPtr &obs);
267 
269 
270  const DtRailSegmentList* path() const { return &myPath; };
271 
273 
274 protected:
275 
278 
281  const DtRoadMovementController& orig);
282 
285  const DtRoadMovementController& orig);
286 
291  virtual bool createPSR();
292 
294  virtual bool createUpdater();
295  virtual bool createPathFunctions();
296 
298  virtual bool createRoadObstructionFinder();
299 
300  virtual bool createDrivingLogic();
302 
305 
307  virtual void processSetting( const DtBoolSetting* setting);
308 
309  virtual void processSetConvoyFollowCallback(DtSimMessage * msg);
310 
313  virtual void processMoveAlongTask(DtSimMessage * msg);
315 
319  virtual bool initializeCurrentState(DtRailMoveAlongTask * task);
320 
322  virtual bool setUpRoute(const DtRwRailSegmentList& path);
323 
327  virtual int entryLanePosition(double heading,unsigned int numLanes);
328 
331  virtual void clearTask() override;
332 
334  virtual void clearPath();
335 
339  virtual void initiateLaneChange(const int newLaneNum);
340 
343  virtual void checkPathEnd();
344 
354  virtual void manageRoadSegmentElevationLookup();
355  virtual DtRoadSegment* lastSegmentWithElevation();
356  virtual void setLastSegmentWithElevation(DtRoadSegment* seg);
357 
358  static void scriptedSetCallback(DtSimMessage *msg, void * usrData);
359  virtual void processScriptedSet(DtSimMessage *msg);
360 
361 protected:
362 
367 
372 
377 
383 
386 
390 
397 
404 
410 
415 
420 
431 
435 
440  std::vector<DtVector> myTaskVisPath;
441 
445  std::vector<DtVector> myCurrentTaskVisPath;
446 
449  std::map<DtRoadSegment*, unsigned> myRoadSegmentTaskVisMap;
450 
453 
459 
462 
464  std::vector<DtVector> myOriginalPath;
465 
467 
472  std::vector<DtVector> myObstacleLocations;
473 
476 
480  std::vector<std::vector<DtVector> > myObstacleBoxes;
481 
485 
487 
489 };
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
DtRailMovementState
Used to keep the current state of an entity as it travels along a route using the rail system...
Definition: railMovementControllerPSR.h:33
bool myNotInitialized
Definition: roadMovementController.h:412
DtRoadSegmentList myRoadPath
This path is computed, and includes the lane connections and the geometry of the paths connecting the...
Definition: roadMovementController.h:402
virtual std::vector< std::vector< DtVector > > & debugBoxes()
Accessor for the array of 4-point arrays representing areas where the controller is looking for obsta...
Definition: roadMovementController.h:253
File: rwRailSegment.h.
std::vector< std::vector< DtVector > > myObstacleBoxes
A set of polygons representing bounding volumes of the lanes to search for obstacle vehicles...
Definition: roadMovementController.h:480
DtRoadDrivingLogic * myDrivingLogic
Class to hold functions defining the driving logic.
Definition: roadMovementController.h:385
Description: This repository holds all information that is common to all the forms of all objects wit...
Definition: vrfMovingObjectStateRepository.h:31
Definition: boolSetting.h:30
DtRoadObstructionFinder * myRoadObstructionFinder
Class to hold functions that find obstructions (vehicles) along the entity&#39;s current lane and adjacen...
Definition: roadMovementController.h:389
DtRoadMovementUpdater * myRoadUpdater
Class to hold functions that perform the kinematic update and compute the resulting position...
Definition: roadMovementController.h:395
std::list< DtRailSegment * > DtRailSegmentList
Definition: railSegment.h:194
virtual DtRailMovementControllerPSR * psr()
Definition: roadMovementController.h:192
virtual const char * type() const override=0
Returns a string identifies the class type of component. Type values are defined in compTypes...
DtRoadSegment * myCurrentRoadSegment
Definition: roadMovementController.h:403
double myRearAxleOffset
Offset in x from entity center to the center of the rear axle. When turning, the turn circle center i...
Definition: roadMovementController.h:430
virtual void setDrivingLogic(DtRoadDrivingLogic *dl)
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:163
DtRoadSegmentPart myRoadSegmentPart
Keeps track of what part of the road segment the vehicle currently occupies (entry curve...
Definition: roadMovementController.h:434
virtual void registerTaskMsgCallbacks()
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
DtRailSegment are segments entities can follow when using the rail movement system.
Definition: railSegment.h:20
Instances of DtRailMovementControllerPSR are used to hold the shared/checkpointable data for a rail m...
Definition: railMovementControllerPSR.h:48
This class provides a base class for all controllers that are capable of executing a DtSimTask...
Definition: singleTaskControllerComponent.h:22
virtual DtRoadMovementUpdater * movementUpdater()
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:178
virtual const DtRoadConstants * roadConstants()
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:146
int myLastNumObstaclePoints
The number of obstacles last tick.
Definition: roadMovementController.h:475
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
bool myRoadAltitudesSet
Definition: roadMovementController.h:414
A container for constants that define the path of a vehicle on the road in terms of design-vehicles a...
Definition: roadConstants.h:21
Definition: roadPathFunctions.h:19
Definition: readerWriterRegistry.h:39
const DtRoadConstants * myRoadConstants
The following members hold classes that define key functions of the driving controller. By setting them to derived classes, these functions can be modified.
Definition: roadMovementController.h:376
double myFrontOffset
Distance from entity center to front. This is computed as boundingVolume-&gt;halfLength + boundingVolume...
Definition: roadMovementController.h:419
std::shared_ptr< DtSimTaskState > DtSimTaskStatePtr
Definition: taskAndTaskStateDefines.h:18
DtRoadMovementController is a movement controller that models an entity&#39;s movement along a road path...
Definition: roadMovementController.h:65
virtual bool beginProcessingTask(const DtTaskMessage &task, DtSimTaskStatePtr taskState) override
Called by the task manager when this controller should start executing the specified task...
Definition: settingsObject.h:27
std::list< DtRoadSegment * > DtRoadSegmentList
Definition: roadSegment.h:389
virtual DtRoadPathFunctions * pathFunctions()
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:156
std::shared_ptr< DtRailObstruction > DtRailObstructionPtr
Definition: railObstructionInfo.h:78
const DtRoadMovementDescriptor * myRoadMoveDescriptor
Definition: roadMovementController.h:364
virtual const DtMovingObjectParameters * objectParameters()
Definition: roadMovementController.h:194
virtual void updateTaskVisualizations()
Called to update task visualizations after every tick. Implemented by subclasses. ...
Definition: simComponent.h:443
virtual bool init() override
Calls setRadio()
std::vector< DtVector > myObstacleLocations
These visualizations are updated every tick.Location of obstacle vehicles that constrain movement...
Definition: roadMovementController.h:472
DtRailSegmentList myPath
This is the input path to the controller.
Definition: roadMovementController.h:399
bool myHaveCreatedDebugVis
Several visualizations are created once and never updated. They are created only if the entity notify...
Definition: roadMovementController.h:461
virtual void setRoadConstants(const DtRoadConstants *rc)
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:151
DtPlatformLocalObjectFacade myPlatformLocalObjectFacade
Definition: roadMovementController.h:488
std::vector< DtVector > myTaskVisPath
For debug visualizationThe path of the road segments. Holds world (geoc) coordinates. Computed once.
Definition: roadMovementController.h:440
Models an entity moving along a generated road path. Provides a kinematics-based model of an entity m...
Definition: roadMovementUpdater.h:48
const DtMovingObjectParameters * myObjectParams
Definition: roadMovementController.h:366
File: simMsg.h.
Definition: simMessage.h:35
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
virtual std::vector< DtVector > & debugPoints()
Accessor for the individual points representing obstacle vehicles.
Definition: roadMovementController.h:247
virtual bool tickWhileDestroyed() const
If the component returns true here, it will be ticked regardless of the destroyed state of the host e...
The moving-object-param parameter type is used for objects that are capable of movement, such as individual entities and aggregates. DtMovingObjectParameters; holds all of the configurable parameters for the DtVrfMovingObjectStateRepository class. Parameters include support points, maximum speed, maximum reverse speed, turning radius, maximum slope, ordered speed, maximum acceleration, maximum deceleration, and fuel efficiency. Aggregates are moving objects and have this parameter type. All of the platform-specific parameter types derive from this one. .
Definition: movingObjectParameters.h:32
std::map< DtRoadSegment *, unsigned > myRoadSegmentTaskVisMap
Maps road segments to the index of the task vis path points that make up this segment.
Definition: roadMovementController.h:449
DtRoadPathFunctions * myRoadPathFunctions
Class to hold functions that process lists of road segments, i.e. a road path. These functions create...
Definition: roadMovementController.h:382
const DtRailSegmentList * path() const
Definition: roadMovementController.h:270
DtRailMovementControllerPSR * myProcessState
Definition: roadMovementController.h:363
DtRoadSegmentPart
This enumeration is a convenience for indicating what part of the lane geometry a point is on...
Definition: roadSegment.h:393
std::vector< DtVector > myOriginalPath
Holds the start (local) locations of the original rail path segments.
Definition: roadMovementController.h:464
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:89
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:80
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
DtRoadSegment * myLastSegmentWithElevation
The last road segment that the controller has successfully obtained terrain elevation for...
Definition: roadMovementController.h:407
virtual void clearTask() override
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false...
File: railMoveAlongTask.h.
Definition: railMoveAlongTask.h:34
bool myWarnedAboutMissingConvoyLeaderOnce
Definition: roadMovementController.h:413
std::vector< DtVector > myCurrentTaskVisPath
The currently displayed task vis path. Only a portion of myTaskVisPath is shown at any given time to ...
Definition: roadMovementController.h:445
DtVrfMovingObjectStateRepository * myMovingStateRep
Definition: roadMovementController.h:365
Description of one segment of a road.
Definition: roadSegment.h:406
bool myDrivingOnLeft
Definition: roadMovementController.h:411
An object containing functions to find obstructions in road segments in a road path; part of a DtRoad...
Definition: roadObstructionFinder.h:30
virtual void setPathFunctions(DtRoadPathFunctions *pf)
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:157
virtual void setObstructionFinder(DtRoadObstructionFinder *of)
After creating a new obstFinder, call init() on it.
Definition: roadMovementController.h:173
virtual DtRoadDrivingLogic * drivingLogic()
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:162
int myLastSegmentIndex
For debugging output.
Definition: roadMovementController.h:409
Definition: railSplineCalculator.h:25
virtual void setMovementUpdater(DtRoadMovementUpdater *u)
After creating a new updater, call init(), setEntityState(), and setPSR() on the new updater...
Definition: roadMovementController.h:182
Definition: roadDrivingLogic.h:18
unsigned myCurrentTaskVisPathPtIndex
The current starting point index of the displayed task vis path.
Definition: roadMovementController.h:452
virtual DtRoadObstructionFinder * obstructionFinder()
A new set of road constants can be set in a class derived from DtRoadConstansts; then set the pointer...
Definition: roadMovementController.h:168
A DtTaskMsg is a DtRadioMsg with a pointer to a task. The type of the taskMsg is just the type of the...
Definition: taskMessage.h:21
int myLastNumBoxes
The number of boxes last tick.
Definition: roadMovementController.h:483
A locally simulated VRF object.
Definition: localObject.h:98
A DtComponentDescriptor that has parameters that indicate how an entity should move along a rail segm...
Definition: roadMovementDescriptor.h:25

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)