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();
78 
81 
84  virtual const char* type() const;
85 
90  virtual bool init();
91 
94  virtual void preFirstTickInit();
95 
101  virtual void tick();
102 
103  virtual void clear();
104 
107  virtual bool tickWhileDestroyed() const;
108 
110  virtual void registerTaskMsgCallbacks();
112 
116  static DtSimComponent * creator(const DtString& name,
117  DtLocalObject* owner,
118  DtSimulationServices* simManager,
119  DtComponentDescriptor* desc = 0,
120  DtReaderWriterRegistry* parentRegistry = 0);
121 
124 
128  static void moveAlongCallback(DtSimMessage * msg, void * usr);
129 
130  static void setConvoyFollowCallback(DtSimMessage * msg, void * usrData);
131 
133  static void settingsObjectConsumerCallback(const DtSettingsObject* settingsObject, void* usr);
134 
136 
137  //-------------------------------------------------------------------
142 
143  virtual const DtRoadConstants* roadConstants(){ return myRoadConstants; }
144 
148  virtual void setRoadConstants(const DtRoadConstants* rc)
149  {
150  myRoadConstants = rc;
151  }
152 
153  virtual DtRoadPathFunctions* pathFunctions(){ return myRoadPathFunctions; }
155  {
156  myRoadPathFunctions = pf;
157  }
158 
159  virtual DtRoadDrivingLogic* drivingLogic(){ return myDrivingLogic; }
161  {
162  myDrivingLogic = dl;
163  }
164 
166  {
167  return myRoadObstructionFinder;
168  }
171  {
172  myRoadObstructionFinder = of;
173  }
174 
175  virtual DtRoadMovementUpdater* movementUpdater(){ return myRoadUpdater; }
176 
180  {
181  myRoadUpdater = u;
182  }
184  //------------------------------------------------------------------
185 
188 
190  { return myProcessState; }
192  { return myObjectParams; }
193  virtual const DtRoadMovementDescriptor* descriptor() const;
195 
198  virtual bool drivingOnLeftEnabled() const;
199 
200  virtual void setCurrentMovementState(DtRailMovementState state);
201  virtual DtRailMovementState currentMovementState() const;
202 
203  virtual DtRoadSegment* currentRoadSegment()const;
204  virtual void setCurrentRoadSegment(DtRoadSegment* seg);
205 
207  virtual double frontOffset() const;
208  virtual void setFrontOffset(const double o);
209 
213  virtual double rearAxleOffset() const;
214  virtual void setRearAxleOffset(const double o);
215 
217  virtual DtRailSegmentList * pathList();
218  virtual const DtRailSegmentList * pathList() const;
219 
222  virtual DtRoadSegmentPart roadSegmentPart()const;
223  virtual void setRoadSegmentPart(const DtRoadSegmentPart s);
225 
228 
234  virtual void updateTaskVisualizations();
235 
238  virtual bool findPointOnTerrain(const DtVector& worldLocation, DtVector& worldLocationOnTerrain);
239 
241  virtual std::vector<DtVector>& debugPoints()
242  {
243  return myObstacleLocations;
244  }
247  virtual std::vector<std::vector<DtVector> >& debugBoxes()
248  {
249  return myObstacleBoxes;
250  }
252 
255  virtual const double followSpeedFactor() const;
256 
257  virtual double getDistanceBehindConvoyTarget(const DtSimObject* convoyTgt) const;
258 
259  virtual DtSimObjectReference getObjectFromObstruction(DtRailObstructionPtr &obs);
261 
263 
264  const DtRailSegmentList* path() const { return &myPath; };
265 
266 protected:
267 
270 
273  const DtRoadMovementController& orig);
274 
277  const DtRoadMovementController& orig);
278 
283  virtual bool createPSR();
284 
286  virtual bool createUpdater();
287  virtual bool createPathFunctions();
288 
290  virtual bool createRoadObstructionFinder();
291 
292  virtual bool createDrivingLogic();
294 
297 
299  virtual void processSetting( const DtBoolSetting* setting);
300 
301  virtual void processSetConvoyFollowCallback(DtSimMessage * msg);
302 
305  virtual void processMoveAlongTask(DtSimMessage * msg);
307 
311  virtual bool initializeCurrentState(DtRailMoveAlongTask * task);
312 
314  virtual bool setUpRoute(const DtRwRailSegmentList& path);
315 
319  virtual int entryLanePosition(double heading,unsigned int numLanes);
320 
323  virtual void clearTask();
324 
326  virtual void clearPath();
327 
331  virtual void initiateLaneChange(const int newLaneNum);
332 
335  virtual void checkPathEnd();
336 
346  virtual void manageRoadSegmentElevationLookup();
347  virtual DtRoadSegment* lastSegmentWithElevation();
348  virtual void setLastSegmentWithElevation(DtRoadSegment* seg);
349 
350  static void scriptedSetCallback(DtSimMessage *msg, void * usrData);
351  virtual void processScriptedSet(DtSimMessage *msg);
352 
353 protected:
354 
359 
364 
369 
375 
378 
382 
389 
396 
402 
407 
412 
423 
427 
432  std::vector<DtVector> myTaskVisPath;
433 
437  std::vector<DtVector> myCurrentTaskVisPath;
438 
441  std::map<DtRoadSegment*, unsigned> myRoadSegmentTaskVisMap;
442 
445 
451 
454 
456  std::vector<DtVector> myOriginalPath;
457 
459 
464  std::vector<DtVector> myObstacleLocations;
465 
468 
472  std::vector<std::vector<DtVector> > myObstacleBoxes;
473 
477 
479 
481 };
#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:404
DtRoadSegmentList myRoadPath
This path is computed, and includes the lane connections and the geometry of the paths connecting the...
Definition: roadMovementController.h:394
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:247
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:472
DtRoadDrivingLogic * myDrivingLogic
Class to hold functions defining the driving logic.
Definition: roadMovementController.h:377
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:381
DtRoadMovementUpdater * myRoadUpdater
Class to hold functions that perform the kinematic update and compute the resulting position...
Definition: roadMovementController.h:387
std::list< DtRailSegment * > DtRailSegmentList
Definition: railSegment.h:197
virtual DtRailMovementControllerPSR * psr()
Definition: roadMovementController.h:189
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:395
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:422
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:160
DtRoadSegmentPart myRoadSegmentPart
Keeps track of what part of the road segment the vehicle currently occupies (entry curve...
Definition: roadMovementController.h:426
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:23
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:175
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
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:143
int myLastNumObstaclePoints
The number of obstacles last tick.
Definition: roadMovementController.h:467
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:406
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:368
double myFrontOffset
Distance from entity center to front. This is computed as boundingVolume-&gt;halfLength + boundingVolume...
Definition: roadMovementController.h:411
DtRoadMovementController is a movement controller that models an entity&#39;s movement along a road path...
Definition: roadMovementController.h:65
Definition: settingsObject.h:27
std::list< DtRoadSegment * > DtRoadSegmentList
Definition: roadSegment.h:377
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:153
const DtRoadMovementDescriptor * myRoadMoveDescriptor
Definition: roadMovementController.h:356
virtual const DtMovingObjectParameters * objectParameters()
Definition: roadMovementController.h:191
virtual void updateTaskVisualizations()
Called to update task visualizations after every tick. Implemented by subclasses. ...
Definition: simComponent.h:437
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:464
DtRailSegmentList myPath
This is the input path to the controller.
Definition: roadMovementController.h:391
bool myHaveCreatedDebugVis
Several visualizations are created once and never updated. They are created only if the entity notify...
Definition: roadMovementController.h:453
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:148
DtPlatformLocalObjectFacade myPlatformLocalObjectFacade
Definition: roadMovementController.h:480
std::vector< DtVector > myTaskVisPath
For debug visualizationThe path of the road segments. Holds world (geoc) coordinates. Computed once.
Definition: roadMovementController.h:432
Models an entity moving along a generated road path. Provides a kinematics-based model of an entity m...
Definition: roadMovementUpdater.h:42
const DtMovingObjectParameters * myObjectParams
Definition: roadMovementController.h:358
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:241
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:441
DtRoadPathFunctions * myRoadPathFunctions
Class to hold functions that process lists of road segments, i.e. a road path. These functions create...
Definition: roadMovementController.h:374
const DtRailSegmentList * path() const
Definition: roadMovementController.h:264
DtRailMovementControllerPSR * myProcessState
Definition: roadMovementController.h:355
DtRoadSegmentPart
This enumeration is a convenience for indicating what part of the lane geometry a point is on...
Definition: roadSegment.h:381
std::vector< DtVector > myOriginalPath
Holds the start (local) locations of the original rail path segments.
Definition: roadMovementController.h:456
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:94
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:91
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:88
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:399
virtual void clearTask() override
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false...
File: railMoveAlongTask.h.
Definition: railMoveAlongTask.h:50
bool myWarnedAboutMissingConvoyLeaderOnce
Definition: roadMovementController.h:405
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:437
DtVrfMovingObjectStateRepository * myMovingStateRep
Definition: roadMovementController.h:357
Description of one segment of a road.
Definition: roadSegment.h:394
bool myDrivingOnLeft
Definition: roadMovementController.h:403
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:154
virtual void setObstructionFinder(DtRoadObstructionFinder *of)
After creating a new obstFinder, call init() on it.
Definition: roadMovementController.h:170
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:159
int myLastSegmentIndex
For debugging output.
Definition: roadMovementController.h:401
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:179
Definition: roadDrivingLogic.h:18
unsigned myCurrentTaskVisPathPtIndex
The current starting point index of the displayed task vis path.
Definition: roadMovementController.h:444
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:165
DtBoost::shared_ptr< DtRailObstruction > DtRailObstructionPtr
Definition: railObstructionInfo.h:78
int myLastNumBoxes
The number of boxes last tick.
Definition: roadMovementController.h:475
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86
A DtComponentDescriptor that has parameters that indicate how an entity should move along a rail segm...
Definition: roadMovementDescriptor.h:24

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)