VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DtRoadDrivingLogic Class Reference

Public Member Functions

 DtRoadDrivingLogic (DtRoadMovementController *parentController)
 
 ~DtRoadDrivingLogic ()
 
Driving Behavior Constants

These functions define constants that affect various driving decisions. Override to change driving behavior.

virtual double maxDesignDriverLateralAcceleration_G ()
 
virtual double desiredDecelerationFractionOfMax ()
 
virtual double desiredAccelerationFractionOfMax ()
 
virtual double desiredLateralAccelerationFractionOfMax ()
 
virtual double desiredFixedHeadway ()
 
virtual double minimumCurveSpeed ()
 
virtual double maximumLaneChangeTurnAngle ()
 
virtual double laneChangeFractionToClearLane ()
 
virtual double laneEndCheckLookaheadTime ()
 
virtual double laneSwitchDecisionAccelThreshold ()
 
virtual double maxForcedDecelForGapAcceptance ()
 
Driving Logic

These are the public entry points for determining the constrained acceleration for a vehicle give the traffic and road situation, and the lane the vehicle desires to be in.

virtual double combinedAcceleration (DtRoadSegment *currentRoadSegment, const double desiredDecelToUse, const double tickPeriod, const double currentSpeed, const double orderedSpeed, const int laneNumber, const double positionInLane, const double laneSpaceRequired, const double laneChangeWidth, const double maxAcceleration, const double maxLateralAccel, bool &laneContinues, bool &pathContinues, double &distanceToLaneEnd, double &freeFlowAccel, double &orderedSpeedAccel, bool debug=false)
 
virtual int selectedLane (DtRoadSegment *currentRoadSegment, const int roadLaneN, const bool currentLaneContinues, const double distanceToLaneEnd, const double positionInLane, const double currentSpeed, const double currentLaneAcceleration, const double freeFlowAcceleration, const double tickPeriod, const double desiredDecelToUse, const double maxLateralAccel, const DtSimObject *convoyTgt, int &desiredFutureLane, bool debug=false)
 
virtual double oldLaneObstacleConstraint (DtRoadSegment *currentSegment, const DtMovingObjectParameters *params, const double currentPosition, const double currentOffset, const DtRoadObstructionFinder *obstructionFinder, const double desiredDecelToUse, const double dt, const double accelForNoObstacle, const double currentSpeed, const int currentLaneN, std::vector< DtVector > &obstacleLocations, std::vector< std::vector< DtVector > > &debugBoxes, bool debug=false)
 
virtual double distanceNeededToChangeLanes (const double minTurnRadius, const double distanceBetweenLanes, const double speed, bool debug=false)
 

Protected Member Functions

virtual bool laneConstrainedBelowFreeFlow (const double currentLaneAcceleration, const double otherLaneAcceleration, const double tickPeriod, const double currentSpeed)
 
virtual bool mergeGapAvailableBehind (const DtRoadSegment *currentRoadSegment, const int roadLaneNum, const double positionInLane, const double nominalDecel, const double tickPeriod, const double ownSpeed, bool debug=false)
 
Component Constraint Functions

These functions compute individual constraints and are called by the public entry point functions.

double followConvoyAcceleration (const double currentSpeed, const double tickPeriod, const double deceleration, const double convoyGap, const DtSimObject *leadVehicle, bool debug=false)
 
virtual double orderedSpeedAcceleration (const double currentSpeed, const double orderedSpeed, const double dt, bool debug=false)
 
virtual double extraAccelConstraint (const double currentSpeed, const double dt, bool debug=false)
 
double downstreamTcdAccelConstraint (DtRoadSegment *startSegment, const double desiredDecelToUse, const double dt, const double currentSpeed, const int roadLaneN, const double positionAlongLane, const double maxAccel, const double maxLateralAccel, bool debug=false)
 
virtual double downstreamCurveAccelConstraint (DtRoadSegment *startSegment, const double desiredDecelToUse, const double dt, const double currentSpeed, const int roadLaneN, const double positionAlongLane, const double maxAccel, const double maxLateralAccel, bool debug=false)
 
virtual double downstreamSpeedLimitAccelConstraint (DtRoadSegment *currentSegment, const double desiredDecelToUse, const double dt, const double currentSpeed, bool debug=false)
 
virtual double laneEndAccelConstraint (DtRoadSegment *currentSegment, const double orderedSpeed, const double desiredDecelToUse, const double dt, const double currentSpeed, const int roadLaneN, const double positionAlongLane, const double extraSpaceRequired, const double maxAccel, bool &laneContinues, double &distanceToLaneEnd, bool &pathContinues, bool debug=false)
 
virtual double obstacleAccelConstraint (DtRoadSegment *currentSegment, const DtRoadObstructionFinder *obstructionFinder, const double maxAcceleration, const double desiredDecelToUse, const double dt, const double currentSpeed, const int roadLaneN, const double positionAlongLane, const double spaceNeeded, double &obstacleDistanceAhead, double &obstacleSpeed, std::vector< std::vector< DtVector > > &debugBoxes, std::vector< DtVector > &obstacleLocations, bool debug=false)
 
virtual double completeLaneChangeMnvrAccelConstraint (DtRoadSegment *currentSegment, const double currentOffset, const double desiredDecelToUse, const DtMovingObjectParameters *params, const double dt, const double accelForNoObstacle, const double currentSpeed, const double completionFraction, const double completionDistance, bool debug=false)
 

Protected Attributes

DtRoadMovementControllermyParentController
 

Constructor & Destructor Documentation

DtRoadDrivingLogic::DtRoadDrivingLogic ( DtRoadMovementController parentController)
DtRoadDrivingLogic::~DtRoadDrivingLogic ( )

Member Function Documentation

virtual double DtRoadDrivingLogic::maxDesignDriverLateralAcceleration_G ( )
inlinevirtual

Typical value (see AASHTO Green Book), civilian driver comfort level. In Gs. This is used as an assumption about other drivers when making driving decisions.

virtual double DtRoadDrivingLogic::desiredDecelerationFractionOfMax ( )
inlinevirtual

This could be overridden to use an entity-specific "aggressiveness" parameter.

Default value 0.3

virtual double DtRoadDrivingLogic::desiredAccelerationFractionOfMax ( )
inlinevirtual

This could be overridden to use an entity-specific "aggressiveness" parameter.

Default value 0.5

virtual double DtRoadDrivingLogic::desiredLateralAccelerationFractionOfMax ( )
inlinevirtual

This could be overridden to use an entity-specific "aggressiveness" parameter.

Default value 0.4

virtual double DtRoadDrivingLogic::desiredFixedHeadway ( )
inlinevirtual

The desired fixed gap between cars when one is following the other (very slowly, or stopped). In meters.

Default value 1.0

virtual double DtRoadDrivingLogic::minimumCurveSpeed ( )
inlinevirtual

A minimum speed to go around curves, especially artificially sharp curves generated by awkwardly formed paths. This overrides the speed that would be computed from max lateral acceleration limits. In meters/sec.

Default value 1.0

virtual double DtRoadDrivingLogic::maximumLaneChangeTurnAngle ( )
inlinevirtual

The maximum angle a vehicle makes with the lane direction when it is changing lanes (slowly). In radians.

Default value 0.8

virtual double DtRoadDrivingLogic::laneChangeFractionToClearLane ( )
inlinevirtual

The fraction of a lane change maneuver that a vehicle has to complete before it can ignore obstacles in its old lane.

Default value 0.4

virtual double DtRoadDrivingLogic::laneEndCheckLookaheadTime ( )
inlinevirtual

The time before reaching the end of a lane that the entity starts to prefer to be in a lane that continues to the next segment of the path. In seconds.

Default value 15.0

virtual double DtRoadDrivingLogic::laneSwitchDecisionAccelThreshold ( )
inlinevirtual

The difference in acceleration between an adjacent lane and the current lane that will trigger a lane change. In mps^2. Note 1mph/s = 0.45 mps^2.

Default value 4.0

virtual double DtRoadDrivingLogic::maxForcedDecelForGapAcceptance ( )
inlinevirtual

When the vehicle is considering merging into an adjacent lane, the deceleration required of a vehicle in that lane must be smaller than this before the vehicle will accept the gap. This is a negative quantity.

Default value -4.0

virtual double DtRoadDrivingLogic::combinedAcceleration ( DtRoadSegment currentRoadSegment,
const double  desiredDecelToUse,
const double  tickPeriod,
const double  currentSpeed,
const double  orderedSpeed,
const int  laneNumber,
const double  positionInLane,
const double  laneSpaceRequired,
const double  laneChangeWidth,
const double  maxAcceleration,
const double  maxLateralAccel,
bool laneContinues,
bool pathContinues,
double distanceToLaneEnd,
double freeFlowAccel,
double orderedSpeedAccel,
bool  debug = false 
)
virtual

Computes the acceleration allowed in the given lane. Calls: orderedSpeedAcceleration downstreamSpeedLimitAcceleration downstreamCurveAccelConstraint laneEndAccelConstraint and takes the minimum of the results to compute freeFlowAccel. Then calls obstacleAccelConstraint and takes the minimum of that and freeFlowAccel to produce the return value. Returns lane-end information in laneContinues and distanceToLaneEnd.

Parameters
laneNumberis 0-based (0 is the right lane).
positionInLaneis the position of the point on the vehicle used to determine what segment the entity is on, i.e. the center of the rear axle.
laneSpaceRequiredis the amount of space in front of this position that the entity should leave in front of it if it comes to a stop; normally this is the room needed to change lanes + the distance from the rear axle to the front bumper.
virtual int DtRoadDrivingLogic::selectedLane ( DtRoadSegment currentRoadSegment,
const int  roadLaneN,
const bool  currentLaneContinues,
const double  distanceToLaneEnd,
const double  positionInLane,
const double  currentSpeed,
const double  currentLaneAcceleration,
const double  freeFlowAcceleration,
const double  tickPeriod,
const double  desiredDecelToUse,
const double  maxLateralAccel,
const DtSimObject convoyTgt,
int desiredFutureLane,
bool  debug = false 
)
virtual

Analyzes the acceleration in the current lane and the situation in adjacent lanes to select a lane to be in.

Returns
Lane number (0-based) of desired lane. Also, if traffic is preventing a lane change, desiredLane will return the number of the lane the vehicle would like to change to. This is used to keep the vehicle back from an obstacle enough to change lanes around it, and in the future could be used to turn on a turn indicator light.

Priorities for lanes ("left" and "right" referenced to driving on the right side of the road):

1) if d <= D(pass-stopped), where d is the distance to the end of the current lane, i.e. the current lane doesn't continue past d, change to a lane that does continue; D(pass-stopped) is the distance required to pass a stopped design vehicle (i.e, a lane change at speed plus design vehicle length plus own length).

2) If L - C > T1, move left (within lanes moving the same direction). where L is the allowed acceleration in the lane to the left, C is the acceleration allowed in the current lane, and T1 is a threshold.

3) If R - C > T1, move right.

4) if d < Dfar, i.e. the current lane ends in d, change to a lane that does continue; Dfar is a look-ahead distance.

4b) If an adjacent lane ends and d < Dfar for that lane, then don't change to that lane.

5) If overtaking is allowed, entity is in left lane, the current lane does not end before Dfar, lane lines permit overtaking, and L - C > T2, overtake (left). (Future work.)

6) If in the left lane, and R >= C, move right.

Constraints:

A) If there is no lane to the right or left, do not change lanes in that direction (duh)

B) If an adjacent lane ends ahead, and d < D(pass) for that lane or on exit curve, do not change into that lane.

C) If there is not an acceptable gap in traffic in an adjacent lane, do not change to that lane. If this constraint comes into effect for a priority lane change per above, do not consider any further lower-priority lane selections.

virtual double DtRoadDrivingLogic::oldLaneObstacleConstraint ( DtRoadSegment currentSegment,
const DtMovingObjectParameters params,
const double  currentPosition,
const double  currentOffset,
const DtRoadObstructionFinder obstructionFinder,
const double  desiredDecelToUse,
const double  dt,
const double  accelForNoObstacle,
const double  currentSpeed,
const int  currentLaneN,
std::vector< DtVector > &  obstacleLocations,
std::vector< std::vector< DtVector > > &  debugBoxes,
bool  debug = false 
)
virtual

Creates an acceleration constraint for an obstacle ahead in the lane, but assumes that the entity is in the process of changing lanes to a different lane. Thus allows movement up to the obstacle with no buffer space, and keeps speed low enough to complete the lane change maneuver before the obstacle.

virtual double DtRoadDrivingLogic::distanceNeededToChangeLanes ( const double  minTurnRadius,
const double  distanceBetweenLanes,
const double  speed,
bool  debug = false 
)
virtual

The distance along a lane it takes to change lanes using an S- turn composed of two circular arcs. Computes arc radius from speed, maxDesignDriverLateralAcceleration_G, and vehicle minimum turning radius.

double DtRoadDrivingLogic::followConvoyAcceleration ( const double  currentSpeed,
const double  tickPeriod,
const double  deceleration,
const double  convoyGap,
const DtSimObject leadVehicle,
bool  debug = false 
)
protected

This function computes the acceleration to get to the ordered speed in time dt. Note that it is ignored if the entity is following a convoy vehicle.

virtual double DtRoadDrivingLogic::orderedSpeedAcceleration ( const double  currentSpeed,
const double  orderedSpeed,
const double  dt,
bool  debug = false 
)
protectedvirtual

This function computes the acceleration to get to the ordered speed in time dt. Note that it is ignored if the entity is following a convoy vehicle.

virtual double DtRoadDrivingLogic::extraAccelConstraint ( const double  currentSpeed,
const double  dt,
bool  debug = false 
)
inlineprotectedvirtual

A placeholder for user extension. This function is called whether the entity is following a convoy vehicle or not. To add a speed constraint, this function could be overridden as:

double userSpeedLimit = <some function="" that="" provides="" a="" new="" speed="" limit>="">; double userAccelLimit = 1e8; if (dt > 0.0) { userAccelLimit = (userSpeedLimit - currentSpeed)/dt; } return userAccelLimit;

double DtRoadDrivingLogic::downstreamTcdAccelConstraint ( DtRoadSegment startSegment,
const double  desiredDecelToUse,
const double  dt,
const double  currentSpeed,
const int  roadLaneN,
const double  positionAlongLane,
const double  maxAccel,
const double  maxLateralAccel,
bool  debug = false 
)
protected

Not currently used– future work. Looks downstream for traffic control devices and generates an acceleration constraint base on them. For each TCD in the look distance, it determines what the constraint is for that TCD. To do this it must determine whether a stop is required. For lights, this means checking the current signal indication. For yellow indications, and yield and stop signs, the function must look for traffic to determine if the intersection can be entered.

virtual double DtRoadDrivingLogic::downstreamCurveAccelConstraint ( DtRoadSegment startSegment,
const double  desiredDecelToUse,
const double  dt,
const double  currentSpeed,
const int  roadLaneN,
const double  positionAlongLane,
const double  maxAccel,
const double  maxLateralAccel,
bool  debug = false 
)
protectedvirtual

Looks downstream in the path at the curves that connect road segments, computes a speed limit for each one that it encounters and then computes the resulting acceleration constraint given the current vehicle parameters. Cuts off search downstream when limited by an upstream constraint. If the path ends or the lane does not continue, no constraint is generated at that point. The curve speed limit is based on the lateral acceleration limit for the vehicle and the driver.

Parameters
desiredDecelToUseThe rate at which the vehicle desires to decelerate to the target curve speed limit.
dtThe length of the tick, i.e. the time that the vehicle would use the acceleration value that is returned.
currentSpeedThe current speed of the vehicle.
roadLaneNThe lane the vehicle is in. 0-based.
positionAlongLaneis the position of the turn center along the lane (not the entity origin)
maxAccelThe maximum acceleration the vehicle is capable of. Used to provide an upper bound for the return value.
maxLateralAccelIs the max lateral acceleration the driver will use; this determines the speed limit on the curves.
virtual double DtRoadDrivingLogic::downstreamSpeedLimitAccelConstraint ( DtRoadSegment currentSegment,
const double  desiredDecelToUse,
const double  dt,
const double  currentSpeed,
bool  debug = false 
)
protectedvirtual

Looks downstream in the path at the speed limits in the road segments, computes a speed limit for each one that it encounters and then computes the resulting acceleration constraint given the current vehicle parameters. Cuts off search downstream when limited by an upstream constraint.

Parameters
desiredDecelToUseThe rate at which the vehicle will decelerate to the target curve speed limit.
dtThe length of the tick, i.e. the time that the vehicle would use the acceleration value that is returned.
currentSpeedThe current speed of the vehicle.
virtual double DtRoadDrivingLogic::laneEndAccelConstraint ( DtRoadSegment currentSegment,
const double  orderedSpeed,
const double  desiredDecelToUse,
const double  dt,
const double  currentSpeed,
const int  roadLaneN,
const double  positionAlongLane,
const double  extraSpaceRequired,
const double  maxAccel,
bool laneContinues,
double distanceToLaneEnd,
bool pathContinues,
bool  debug = false 
)
protectedvirtual

Looks downstream in the path to determine if the current lane ends (i.e., does not continue to the next segment) at some point, and if so generates an acceleration constraint that will bring speed to zero at a distance far enough from the end to permit a lane change maneuver. Looks downstream for distance = speedLimit * DT_ROAD_MOVE_CONTROL_INTERX_LOOKAHEAD_TIME + extraSpaceRequired.

Parameters
desiredDecelToUseThe rate at which the vehicle desires to decelerate to the target curve speed limit.
dtThe length of the tick, i.e. the time that the vehicle would use the acceleration value that is returned.
currentSpeedThe current speed of the vehicle.
roadLaneNThe lane the vehicle is in. 0-based.
positionAlongLaneis the position along the lane. Since the resulting constraint should keep the front of the entity on the road, this should be the position of the front bumper.
extraSpaceRequiredis the distance before the end of the lane that should be used for the acceleration constraint. In most cases this is the distance required to change lanes, i.e. get out of the lane.
distanceBetweenLanesis the distance between the centerline of this lane and the centerline of an adjacent lane; determines how much forward space is required to change lanes.
maxAccelThe maximum acceleration the vehicle is capable of. Used to provide an upper bound for the return value.
laneContinuesis a return boolean flag that indicates whether the lane continues downstream to the horizon considered. If false, then the lane does not connect to a segment on the path somewhere ahead.
distanceToLaneEndis the distance to the lane end, if it ends.
pathContinuesis a boolean that indicates if the path continues, even when the lane does not. (If the path ends as well as the lane, then it is not important to change lanes because the lane is ending.)
virtual double DtRoadDrivingLogic::obstacleAccelConstraint ( DtRoadSegment currentSegment,
const DtRoadObstructionFinder obstructionFinder,
const double  maxAcceleration,
const double  desiredDecelToUse,
const double  dt,
const double  currentSpeed,
const int  roadLaneN,
const double  positionAlongLane,
const double  spaceNeeded,
double obstacleDistanceAhead,
double obstacleSpeed,
std::vector< std::vector< DtVector > > &  debugBoxes,
std::vector< DtVector > &  obstacleLocations,
bool  debug = false 
)
protectedvirtual

Determines acceleration required to stop for an obstacle, or more more typically, "car-following" acceleration.

Parameters
currentSegmentis the road segment
roadLaneNis the lane, 0-based, in which to look ahead for cars.
positionAlongLaneis the distance from the beginning of the road segment, i.e. the beginning of the entry curve, to the rear axle. The function will add the distance to the front bumper to get the position from which to search for obstacles.
desiredDecelToUseis the nominal deceleration rate to assume for both own vehicle and the obstacle vehicle ahead. A NEGATIVE value.
spaceNeededis the space needed behind the obstacle–e.g., space needed to start a lane change.
obstacleDistanceAheadreturns the distance from the front bumper to the obstacle ahead, if one is found. Otherwise, it returns -1.
obstacleSpeedis the downstream speed of the obstacle, if there is one. Otherwise, returns DBL_MAX.
Returns
The acceleration constraint value. Also, this function sets the myObstacleDistanceInLane member variable, either to "infinity" if no obstacle is found, or to the distance to the obstacle if one is found. This is only done if roadLaneN is the same as the vehicle's current lane.
virtual double DtRoadDrivingLogic::completeLaneChangeMnvrAccelConstraint ( DtRoadSegment currentSegment,
const double  currentOffset,
const double  desiredDecelToUse,
const DtMovingObjectParameters params,
const double  dt,
const double  accelForNoObstacle,
const double  currentSpeed,
const double  completionFraction,
const double  completionDistance,
bool  debug = false 
)
protectedvirtual

Computes the acceleration allowed based on how much space is remaining to complete the current lane change maneuver. Since the curve radius used in the lane change maneuver gets larger with increased speed, if there is a limited space available (e.g. before an obstacle in the lane, or before the end-of-lane stopping point) then speed must be limited to prevent the curve radius (and thus the maneuver length) from getting too big. Using this function is a workaround for lack of true fine motion planning around obstacles; it should only be used when the obstacle is moving slowly.

Parameters
currentOffsetis the current offset from the centerline, where positive is to the right. I.e. when this value = the lane width, the vehicle has just started a lane change from the lane to the right. If the value = 0, then the maneuver is complete.
desiredDecelToUseis the nominal deceleration rate to assume for the vehicle. A NEGATIVE value.
accelForNoObstacleis the value returned if there is no constraint, e.g. if currentOffset = 0.
completionFractionis the fraction of the lane change maneuver that must be complete before the vehicle is clear of the obstacle ahead (i.e. in the old lane). This fraction must be completed in the completionDistance. In some cases, e.g. when this constraint is used to clear the old lane to avoid an obstacle, the fraction may be < 1.0. If the entire maneuver must be completed before completionDistance, then the fraction will be 1.0.
completionDistanceis the distance within which completionFraction of the lane change maneuver must be completed.
Returns
The maximum acceleration allowed this tick.
virtual bool DtRoadDrivingLogic::laneConstrainedBelowFreeFlow ( const double  currentLaneAcceleration,
const double  otherLaneAcceleration,
const double  tickPeriod,
const double  currentSpeed 
)
protectedvirtual

Determines whether the difference in conditions between two lanes warrants a lane change. In this base version of the function, the difference in accelerations is compared to DT_ROAD_MOVE_CONTROL_LANE_SWITCH_THRESHOLD; tickPeriod and currentSpeed are ignored.

virtual bool DtRoadDrivingLogic::mergeGapAvailableBehind ( const DtRoadSegment currentRoadSegment,
const int  roadLaneNum,
const double  positionInLane,
const double  nominalDecel,
const double  tickPeriod,
const double  ownSpeed,
bool  debug = false 
)
protectedvirtual

Determines if there is an acceptable merge gap available in the given lane.

Parameters
currentSegmentis the road segment
roadLaneNis the lane, 0-based, in which to look ahead for cars.
positionAlongLaneis the distance from the beginning of the road segment, i.e. the beginning of the entry curve.
desiredDecelToUseis the nominal deceleration rate to assume for both own vehicle and the obstacle vehicle ahead. A NEGATIVE value.

Member Data Documentation

DtRoadMovementController* DtRoadDrivingLogic::myParentController
protected

The documentation for this class was generated from the following file:

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)