VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
groundMoveToObstacleAvoider.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2025 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
10 
11 #pragma once
12 
15 
19 
21 
24 
25 
27 {
28 public:
30  const DtLocalObject* hostEntity,
32 
35 
37 
41 
42 public:
44  {
45  avoiderNotActive = 0,
46  avoiderNoObstacles = 1,
47  avoiderAvoiding = 2,
48  avoiderStoppedForMovingObstacle = 3,
49  avoiderStoppedForStaticObstacle = 4,
50  };
51 
53  {
54  obstacleStatic = 0,
55  obstacleDynamic = 1
56  };
57 
59  {
60  enum AvoiderStatusTypeValue myStatusType;
61  enum ObstacleType myObstacleType;
64  };
65 
66  std::string avoiderStatusString(enum AvoiderStatusTypeValue);
67 
84  virtual void steeringAndSpeedThroughObstacles(
85  const DtVector& localGoalPosition,
86  const double desiredImmediateHeading,
87  const double desiredSpeed, const double desiredAccelLimit,
88  double& desiredHeadingOut, double& desiredSpeedOut,
89  AvoiderStatus& avoiderStatus,
90  const bool debug = false);
91 
93  virtual void searchAreaVisualization(std::vector<DtVector>& boundary);
94 
96  virtual void staticObstacleVisualization(std::vector<std::vector<DtVector>>& walls);
97 
98  virtual void dynamicObstacleVisualization(DtExtent& extent);
100 
102 
107 
108 protected:
109 
113  virtual double maxOffroadSpeed() const { return 20.0; }
114 
120  virtual double lookaheadTime() const { return 7.0; }
121 
123 
125 
128 
134  virtual bool shouldYieldToRight() { return true; }
135 
140  virtual bool shouldYieldToLeft() { return false; }
141 
143 
145 
148 
151 
154  {
157  EntityObstacleData(DtSimObjectReference obj, DtVector loc, DtVector vel,
158  double heading, double len, double width);
159 
161  DtVector bodyOffset;
162  DtVector bodyVelocity;
164  double bboxLength;
165  double bboxWidth;
166 
168  bool isStatic;
169  double maxX;
170  double minX;
171  };
172 
174  {
175  DtVector startLocation;
176  double heading;
179  FeatureObstacleEdge(const DtVector& loc);
180  };
181 
183  {
187 
193 
194  std::vector<FeatureObstacleEdge> edges;
195  };
197 
199 
200 
204 
205 protected:
206 
208  virtual void provideDynamicObstacles(std::list<struct EntityObstacleData>& vehicles);
209 
210  virtual void computeEntityObstacleData(const DtSimObjectReference& obj,
211  EntityObstacleData& entityObstacleData);
213  virtual void provideStaticObstacles(std::list<struct FeatureObstacleData>& walls);
214 
218  virtual void testAndSetClockwiseOrdering(FeatureObstacleData& obstacle);
219 
220 
221  virtual void setInitialObstacleEdgeHeadings(FeatureObstacleData& obstacle) const;
222  virtual void setIsFacingEntity(FeatureObstacleData& obstacle,
223  const DtVector& entityLocation);
224 
232  virtual DtExtent makeDynamicObstacleSearchArea(const DtVector& localGoal);
233 
241  virtual MAKVRinTerra::DtFeatureGeometry::Area makeStaticObstacleSearchArea(
242  const DtVector& localGoal);
243 
245 
247 
250 
251 protected:
252 
253  virtual bool isNotSelf(const DtSimObject* obj);
254  virtual bool isNotBehind(const DtSimObject* obj);
256  virtual bool isNotEmbarkedOnDifferentParent(const DtSimObject* obj);
257 
258  virtual bool doesNotOverlapInAltitude(const DtSimObject* obj);
259  static bool ignoreSelfFilterFcn(const DtSimObject* obj, void* usr);
260  static bool ignoreBehindFilterFcn(const DtSimObject* obj, void* usr);
261 
262  static bool ignoreEmbarkedOnDifferentParentFcn(const DtSimObject* obj, void* usr);
263 
264  static bool ignoreDifferentAltitudeFcn(const DtSimObject* obj, void* usr);
265 
266  virtual DtCompositePredicate dynamicObstaclePredicate();
267 
270  virtual void putFeatureInCache(const MAKVRinTerra::DtFeature& f);
271 
273 
275 
279 
280 public:
285  {
286  double lowSpeed;
287  double highSpeed;
288  SpeedInterval(const double a, const double b)
289  {
290  lowSpeed = a;
291  highSpeed = b;
292  }
293  };
294 
295  typedef std::list<SpeedInterval> IntervalList;
296 
297 protected:
298 
300  {
301  public:
302  SpeedConstraint();
303  SpeedConstraint(const SpeedConstraint& other);
304  ~SpeedConstraint();
305  SpeedConstraint& operator=(const SpeedConstraint& other);
306 
307  double myHeading;
313 
317 
321  bool myIsWall;
327 
332 
334  void setUnconstrained();
335 
337  void removeInterval(const double start, const double end);
338 
344  void merge(const SpeedConstraint& other);
345 
347  IntervalList intersectWithIntervalList(
348  const IntervalList& otherIntervals) const;
349 
351  double highestSpeedAllowed() const;
352  };
353 
355 
357 
362 
372  virtual void computeFinalAction(
373  const std::list<struct EntityObstacleData>& vehicles,
374  const std::list<struct FeatureObstacleData>& walls,
375  const double desiredHeading, const double desiredSpeed,
376  double& outHeading, double& outSpeed, AvoiderStatus& status);
377 
401  virtual double computeSpeedAndScoreForPathHeading(const double pathHeading,
402  double refHeading, SpeedConstraint& refConstraint, const bool maybeYieldRow,
403  const std::list<struct EntityObstacleData>& vehicles,
404  const std::list<struct FeatureObstacleData>& walls, const double desiredSpeed, const double desiredHeading,
405  double& outSpeed, SpeedConstraint& resultConstraint);
406 
416  virtual double computeSpeedAndScoreForStraightAhead(
417  const std::list<struct EntityObstacleData>& vehicles,
418  const std::list<struct FeatureObstacleData>& walls,
419  const double desiredSpeed,
420  const double desiredHeading,
421  SpeedConstraint& outConstraint,
422  double& outSpeed);
423 
450  virtual SpeedConstraint computeSpeedConstraintFromDynamicObstacle(
451  const double originOffset,
452  const double ownHalfWidth, const double ownHalfLength,
453  const EntityObstacleData& obstacle,
454  bool leftTurn, bool rightTurn, const double cornerBufferWidth);
455 
459  virtual SpeedConstraint computeSpeedConstraintFromStaticObstacle(
460  const double originOffset,
461  const double ownHalfWidth, const double ownHalfLength,
462  const FeatureObstacleData& obstacle,
463  bool leftTurn, bool rightTurn, const double cornerBufferWidth);
464 
466 
468 
469 
470  //-------------------------------
475 
477 
486  virtual double actionScore(const SpeedConstraint& constrainedAction,
487  const double desiredHeading, const double desiredSpeed,
488  double& speedForBestScore);
489 
500  virtual void updateBestScoreAndSpeed(double& bestScore, double& bestSpeed,
501  const double speed, const double heading,
502  const double desiredSpeed, const double desiredHeading,
503  const bool applyYield = false, const bool isStatic = false);
504 
509  virtual double combinedScore(const double speed, const double heading,
510  const double desiredSpeed, const double desiredHeading,
511  const bool yieldTo = false, const bool isStatic = false);
512 
515  virtual double speedGreaterThanDesiredScore(const double speed, const double heading,
516  const double desiredSpeed, const double desiredHeading);
517  virtual double speedLessThanDesiredScore(const double speed, const double heading,
518  const double desiredSpeed, const double desiredHeading);
519  virtual double speedInDesiredDirectionScore(const double speed, const double heading,
520  const double desiredSpeed, const double desiredHeading);
521  virtual double speedLessThanFeasibleScore(const double speed, const double heading,
522  const double desiredSpeed, const double desiredHeading);
523  virtual double speedGreaterThanFeasibleScore(const double speed, const double heading,
524  const double desiredSpeed, const double desiredHeading);
525  virtual double headingInDesiredDirectionScore(const double speed, const double heading,
526  const double desiredSpeed, const double desiredHeading);
527  virtual double yieldToScore(const double speed, const double heading,
528  const double desiredSpeed, const double desiredHeading);
529 
531 
533 
536 
539  virtual void computeBodyTransform();
540 
546  virtual void computeHorizontalRotation(const double angle,
547  DtDcm& rot);
548 
552  virtual void markVehiclesWithRightOfWay(const double desiredHeading,
553  const std::list<struct EntityObstacleData>& vehicles);
554 
562  virtual double maxSpeedForPassBehind(const double timeLimit,
563  const double distance);
564 
574  virtual double minSpeedForPassAhead(const double timeLimit,
575  const double distance);
576 
581  virtual double minTurnRadiusForCurrentSpeed() const;
582 
586  virtual double maxAccelerationForSpeed();
587 
591  virtual double maxTractionForConditions();
592 
601 
602  virtual double highestFeasibleSpeed() const;
603  virtual void setHighestFeasibleSpeed(const double s);
604 
605  virtual double lowestFeasibleSpeed() const;
606  virtual void setLowestFeasibleSpeed(const double s);
607 
609 
611 
612 
613 protected:
623 
624 
628 
631 
634 
637  double myBrakingLimit;
638 
642 
646 
649 
652 
654  double mySpeed;
655 
658  double myHeading;
659 
661 
666  std::set<DtSimObjectReference> myVehiclesToYieldTo;
667 
669  std::list<DtSimObjectReference> myCachedEntityObstacles;
671 
675 
678  std::shared_ptr<MAKVRinTerra::DtFeatureSet> myObstacleFeatureSet;
679 
685 
692 
699  std::list<FeatureObstacleData> myCachedFeatureObstacles;
700 
704  DtCoordTransform myLocalToHorizontalBody;
705 
707  bool myDebug;
711 
715 };
716 
Definition: groundMoveToObstacleAvoider.h:299
double bboxLength
Heading of obstacle relative to ownship heading.
Definition: groundMoveToObstacleAvoider.h:164
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
Contains the DtCompositePredicate class declaration.
Definition: compositePredicate.h:23
Description: This repository holds all information that is common to all the forms of local ground en...
Definition: groundVehicleStateRepository.h:30
std::vector< DtPoint > PointVector
Definition: featureGeometry.h:76
double highSpeed
Definition: groundMoveToObstacleAvoider.h:287
bool isStatic
Saved each tick to reuse.
Definition: groundMoveToObstacleAvoider.h:168
DtVector myLocalDestination
Definition: groundMoveToObstacleAvoider.h:620
double myHeading
Definition: groundMoveToObstacleAvoider.h:307
bool myHaveAskedForFeatureObstacles
Set true when a query has been made through the terrain interface for a feature set with obstacle fea...
Definition: groundMoveToObstacleAvoider.h:688
std::list< DtSimObjectReference > myCachedEntityObstacles
Lists of vehicle obstacles found last time we looked.
Definition: groundMoveToObstacleAvoider.h:669
double minX
Definition: groundMoveToObstacleAvoider.h:170
DtVector bodyOffset
In case there is other data needed?
Definition: groundMoveToObstacleAvoider.h:161
ObstacleType
Called each tick of the parent controller to provide steering and speed, given the goal and consideri...
Definition: groundMoveToObstacleAvoider.h:52
virtual double maxOffroadSpeed() const
The maximum assumed speed while driving off road. This affects the search distance for dynamic obstac...
Definition: groundMoveToObstacleAvoider.h:113
DtSimObjectReference object
Definition: groundMoveToObstacleAvoider.h:160
std::list< SpeedInterval > IntervalList
Definition: groundMoveToObstacleAvoider.h:295
const DtSimulationServices * mySimulationServices
Definition: groundMoveToObstacleAvoider.h:616
std::shared_ptr< MAKVRinTerra::DtFeatureSet > myObstacleFeatureSet
Used for feature set for last query. Held until it is loaded, and then not needed until the next quer...
Definition: groundMoveToObstacleAvoider.h:678
SpeedInterval(const double a, const double b)
Definition: groundMoveToObstacleAvoider.h:288
double myLateralAccelerationLimit
Limit from desired acceleration input and physical limits.
Definition: groundMoveToObstacleAvoider.h:630
MAKVRinTerra::DtFeatureGeometry::PointVector myStaticObstacleSearchArea
Definition: groundMoveToObstacleAvoider.h:714
std::vector< FeatureObstacleEdge > edges
The features here will all assume to be open; thus if it is a closed area, the first vertex will be r...
Definition: groundMoveToObstacleAvoider.h:194
bool myIsContactLeft
Definition: groundMoveToObstacleAvoider.h:326
Definition: featureGeometry.h:61
IntervalList myIntervals
A list of allowed time intervals. Non-overlapping, and in order.
Definition: groundMoveToObstacleAvoider.h:310
DtChord myWallChord
Definition: groundMoveToObstacleAvoider.h:322
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
double myLastEntityQueryTime
Definition: groundMoveToObstacleAvoider.h:670
DtVector bodyVelocity
2D offset from ownship in body coordinates
Definition: groundMoveToObstacleAvoider.h:162
const DtGroundMoveToDestinationControllerComponent * myParentController
Definition: groundMoveToObstacleAvoider.h:618
double mySpeed
Speed in direction of movement.
Definition: groundMoveToObstacleAvoider.h:654
bool myIsContactRight
Definition: groundMoveToObstacleAvoider.h:325
double myAccelerationLimit
Highest (forward) acceleration physically possible now.
Definition: groundMoveToObstacleAvoider.h:633
double myCurrentAltitude
Used in task visualizations.
Definition: groundMoveToObstacleAvoider.h:651
(NB– replace DtFeatureCollision and DtEntityCollision in the feature sensor and obstacle avoider comp...
Definition: groundMoveToObstacleAvoider.h:153
An range of speeds that is allowed in a SpeedConstraint. This is public so that private helper functi...
Definition: groundMoveToObstacleAvoider.h:284
bool myWasEmbarked
Remembers embarkation state last tick. When this changes, the list of vehicle obstacles is refreshed...
Definition: groundMoveToObstacleAvoider.h:674
bool myShouldYieldTo
If using yield preferences, this constraint is from an obstacle that is on the side of the line in th...
Definition: groundMoveToObstacleAvoider.h:331
double myLowestFeasibleSpeedNow
Lowest speed that can be achieved in 1 second given the limitations of myBrakingLimit.
Definition: groundMoveToObstacleAvoider.h:645
double myBrakingLimit
Highest braking acceleration, limited by desired acceleration and physical limits. Negative.
Definition: groundMoveToObstacleAvoider.h:637
DtGroundMoveToDestinationControllerComponent is a controller that provides a kinematics-based model o...
Definition: groundMoveToDestinationControllerComponent.h:40
bool isFacingEntity
Definition: groundMoveToObstacleAvoider.h:177
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
double myLastObstacleSearchHeading
Definition: groundMoveToObstacleAvoider.h:684
DT_DLL_vrfutil double angle(double vec1[3], double vec2[3])
std::set< DtSimObjectReference > myVehiclesToYieldTo
If right of way priorities are being used, this is a set of vehicle obstacles that have the right of ...
Definition: groundMoveToObstacleAvoider.h:666
double relativeHeading
Velocity in ownship body coordinates.
Definition: groundMoveToObstacleAvoider.h:163
double bboxWidth
Definition: groundMoveToObstacleAvoider.h:165
AvoiderStatusTypeValue
Called each tick of the parent controller to provide steering and speed, given the goal and consideri...
Definition: groundMoveToObstacleAvoider.h:43
Definition: groundMoveToObstacleAvoider.h:58
bool myIsGoingBackwards
Definition: groundMoveToObstacleAvoider.h:621
DtSimObjectReference myKeyVehicleObstacle
Definition: groundMoveToObstacleAvoider.h:708
double myHeading
Heading of movement. This is 180 degrees from heading if moving backwards.
Definition: groundMoveToObstacleAvoider.h:658
DtSimObjectReference myblockingVehicle
Definition: groundMoveToObstacleAvoider.h:323
std::list< FeatureObstacleData > myCachedFeatureObstacles
The features found the last time the terrain was queried. Vertices of lines, in local coordinates...
Definition: groundMoveToObstacleAvoider.h:699
double heading
Definition: groundMoveToObstacleAvoider.h:176
DtVector myLastObstacleSearchLocation
These record the state of the entity when it made the last feature query. A new query is made when th...
Definition: groundMoveToObstacleAvoider.h:683
DtChord myWallObstacle
Definition: groundMoveToObstacleAvoider.h:63
Definition: groundMoveToObstacleAvoider.h:173
virtual bool shouldYieldToRight()
Indicates if yield-to-right is in effect. Ownship should yield (within reason) to vehicle obstacles a...
Definition: groundMoveToObstacleAvoider.h:134
virtual bool shouldYieldToLeft()
Indicates if yield-to-left is in effect. Ownship should yield (within reason) to vehicle obstacles ap...
Definition: groundMoveToObstacleAvoider.h:140
DtVector startLocation
Definition: groundMoveToObstacleAvoider.h:175
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
const DtGroundVehicleStateRepository * myVehicleState
Definition: groundMoveToObstacleAvoider.h:619
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
double maxX
if velocity is 0
Definition: groundMoveToObstacleAvoider.h:169
bool myDebug
Set by calling controller.
Definition: groundMoveToObstacleAvoider.h:707
DtExtent myDynamicObstacleSearchArea
For task visualization. Make these available to the calling controller. TODO.
Definition: groundMoveToObstacleAvoider.h:713
DtSimObjectReference myVehicleObstacle
Definition: groundMoveToObstacleAvoider.h:62
DtCoordTransform myLocalToHorizontalBody
A coordinate transformation from local coordinates to a topo coordinate system that is rotated to the...
Definition: groundMoveToObstacleAvoider.h:704
Definition: groundMoveToObstacleAvoider.h:26
bool myIsObstacleWall
Definition: groundMoveToObstacleAvoider.h:709
bool myIsVehicleStopped
Definition: groundMoveToObstacleAvoider.h:324
double myInitialClearDistance
Distance of origin to closest edge of conflict area:
Definition: groundMoveToObstacleAvoider.h:312
double lowSpeed
Definition: groundMoveToObstacleAvoider.h:286
Represents a GIS feature. Features consist of a DtFeatureGeometry (2.5D geometric vector data) and a ...
Definition: feature.h:36
const DtLocalObject * myEntity
Definition: groundMoveToObstacleAvoider.h:617
bool myIsWall
Obstacle information:--—— Generally, the constraint is driven by a single obstacle. This usually limits the upper speed.
Definition: groundMoveToObstacleAvoider.h:321
bool myHaveLoadedFeatureObstacles
Set true when a feature set has been loaded and the obstacles put into myCachedFeatureObstacles.
Definition: groundMoveToObstacleAvoider.h:691
Definition: groundMoveToObstacleAvoider.h:182
Represents a feature geometry.
Definition: featureGeometry.h:40
double myMaxSpeedForMinTurnRadius
Fastest speed to use for tight turns.
Definition: groundMoveToObstacleAvoider.h:648
double myHighestFeasibleSpeedNow
Highest speed that can be achieved in 1 second given the desired acceleration and the physical limit ...
Definition: groundMoveToObstacleAvoider.h:641
DtChord myKeyWallObstacle
Definition: groundMoveToObstacleAvoider.h:710
A locally simulated VRF object.
Definition: localObject.h:98
virtual double lookaheadTime() const
The amount of time to lookahead. This affects the search distance for all obstacles. Note that the time required to slow to a stop is spd/accel; consider the max speed above and a gentle deceleration of 3-5mps. Default value: 10.0 s.
Definition: groundMoveToObstacleAvoider.h:120

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)