![]() |
VR-Forces 4.10 Class Documentation
|
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 () |
| Typical value (see AASHTO Green Book), civilian driver comfort level. More... | |
| virtual double | desiredDecelerationFractionOfMax () |
| This could be overridden to use an entity-specific "aggressiveness" parameter. More... | |
| virtual double | desiredAccelerationFractionOfMax () |
| This could be overridden to use an entity-specific "aggressiveness" parameter. More... | |
| virtual double | desiredLateralAccelerationFractionOfMax () |
| This could be overridden to use an entity-specific "aggressiveness" parameter. More... | |
| virtual double | desiredFixedHeadway () |
| The desired fixed gap between cars when one is following the other (very slowly, or stopped). More... | |
| virtual double | minimumCurveSpeed () |
| A minimum speed to go around curves, especially artificially sharp curves generated by awkwardly formed paths. More... | |
| virtual double | maximumLaneChangeTurnAngle () |
| The maximum angle a vehicle makes with the lane direction when it is changing lanes (slowly). More... | |
| virtual double | laneChangeFractionToClearLane () |
| The fraction of a lane change maneuver that a vehicle has to complete before it can ignore obstacles in its old lane. More... | |
| virtual double | laneEndCheckLookaheadTime () |
| 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. More... | |
| virtual double | laneSwitchDecisionAccelThreshold () |
| The difference in acceleration between an adjacent lane and the current lane that will trigger a lane change. More... | |
| virtual double | maxForcedDecelForGapAcceptance () |
| 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. More... | |
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) |
| Computes the acceleration allowed in the given lane. More... | |
| 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 DtVrfObject *convoyTgt, int &desiredFutureLane, bool debug=false) |
| Analyzes the acceleration in the current lane and the situation in adjacent lanes to select a lane to be in. More... | |
| 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) |
| 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. More... | |
| virtual double | distanceNeededToChangeLanes (const double minTurnRadius, const double distanceBetweenLanes, const double speed, bool debug=false) |
| The distance along a lane it takes to change lanes using an S- turn composed of two circular arcs. More... | |
Protected Member Functions | |
| virtual bool | laneConstrainedBelowFreeFlow (const double currentLaneAcceleration, const double otherLaneAcceleration, const double tickPeriod, const double currentSpeed) |
| Determines whether the difference in conditions between two lanes warrants a lane change. More... | |
| virtual bool | mergeGapAvailableBehind (const DtRoadSegment *currentRoadSegment, const int roadLaneNum, const double positionInLane, const double nominalDecel, const double tickPeriod, const double ownSpeed, bool debug=false) |
| Determines if there is an acceptable merge gap available in the given lane. More... | |
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 DtVrfObject *leadVehicle, bool debug=false) |
| virtual double | orderedSpeedAcceleration (const double currentSpeed, const double orderedSpeed, const double dt, bool debug=false) |
| This function computes the acceleration to get to the ordered speed in time dt. More... | |
| virtual double | extraAccelConstraint (const double currentSpeed, const double dt, bool debug=false) |
| A placeholder for user extension. More... | |
| 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) |
| Not currently used– future work. More... | |
| 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) |
| 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. More... | |
| virtual double | downstreamSpeedLimitAccelConstraint (DtRoadSegment *currentSegment, const double desiredDecelToUse, const double dt, const double currentSpeed, bool debug=false) |
| 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. More... | |
| 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) |
| 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. More... | |
| 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) |
| Determines acceleration required to stop for an obstacle, or more more typically, "car-following" acceleration. More... | |
| 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) |
| Computes the acceleration allowed based on how much space is remaining to complete the current lane change maneuver. More... | |
Protected Attributes | |
| DtRoadMovementController * | myParentController |
| DtRoadDrivingLogic::DtRoadDrivingLogic | ( | DtRoadMovementController * | parentController | ) |
| DtRoadDrivingLogic::~DtRoadDrivingLogic | ( | ) |
|
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.
|
inlinevirtual |
This could be overridden to use an entity-specific "aggressiveness" parameter.
Default value 0.3
|
inlinevirtual |
This could be overridden to use an entity-specific "aggressiveness" parameter.
Default value 0.5
|
inlinevirtual |
This could be overridden to use an entity-specific "aggressiveness" parameter.
Default value 0.4
|
inlinevirtual |
The desired fixed gap between cars when one is following the other (very slowly, or stopped).
In meters.
Default value 1.0
|
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
|
inlinevirtual |
The maximum angle a vehicle makes with the lane direction when it is changing lanes (slowly).
In radians.
Default value 0.8
|
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
|
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
|
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
|
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 |
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.
| laneNumber | is 0-based (0 is the right lane). |
| positionInLane | is 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. |
| laneSpaceRequired | is 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 |
Analyzes the acceleration in the current lane and the situation in adjacent lanes to select a lane to be in.
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 |
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 |
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.
|
protected |
|
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.
|
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;
|
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.
|
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.
| desiredDecelToUse | The rate at which the vehicle desires to decelerate to the target curve speed limit. |
| dt | The length of the tick, i.e. the time that the vehicle would use the acceleration value that is returned. |
| currentSpeed | The current speed of the vehicle. |
| roadLaneN | The lane the vehicle is in. 0-based. |
| positionAlongLane | is the position of the turn center along the lane (not the entity origin) |
| maxAccel | The maximum acceleration the vehicle is capable of. Used to provide an upper bound for the return value. |
| maxLateralAccel | Is the max lateral acceleration the driver will use; this determines the speed limit on the curves. |
|
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.
| desiredDecelToUse | The rate at which the vehicle will decelerate to the target curve speed limit. |
| dt | The length of the tick, i.e. the time that the vehicle would use the acceleration value that is returned. |
| currentSpeed | The current speed of the vehicle. |
|
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.
| desiredDecelToUse | The rate at which the vehicle desires to decelerate to the target curve speed limit. |
| dt | The length of the tick, i.e. the time that the vehicle would use the acceleration value that is returned. |
| currentSpeed | The current speed of the vehicle. |
| roadLaneN | The lane the vehicle is in. 0-based. |
| positionAlongLane | is 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. |
| extraSpaceRequired | is 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. |
| distanceBetweenLanes | is 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. |
| maxAccel | The maximum acceleration the vehicle is capable of. Used to provide an upper bound for the return value. |
| laneContinues | is 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. |
| distanceToLaneEnd | is the distance to the lane end, if it ends. |
| pathContinues | is 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.) |
|
protectedvirtual |
Determines acceleration required to stop for an obstacle, or more more typically, "car-following" acceleration.
| currentSegment | is the road segment |
| roadLaneN | is the lane, 0-based, in which to look ahead for cars. |
| positionAlongLane | is 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. |
| desiredDecelToUse | is the nominal deceleration rate to assume for both own vehicle and the obstacle vehicle ahead. A NEGATIVE value. |
| spaceNeeded | is the space needed behind the obstacle–e.g., space needed to start a lane change. |
| obstacleDistanceAhead | returns the distance from the front bumper to the obstacle ahead, if one is found. Otherwise, it returns -1. |
| obstacleSpeed | is the downstream speed of the obstacle, if there is one. Otherwise, returns DBL_MAX. |
|
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.
| currentOffset | is 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. |
| desiredDecelToUse | is the nominal deceleration rate to assume for the vehicle. A NEGATIVE value. |
| accelForNoObstacle | is the value returned if there is no constraint, e.g. if currentOffset = 0. |
| completionFraction | is 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. |
| completionDistance | is the distance within which completionFraction of the lane change maneuver must be completed. |
|
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.
|
protectedvirtual |
Determines if there is an acceptable merge gap available in the given lane.
| currentSegment | is the road segment |
| roadLaneN | is the lane, 0-based, in which to look ahead for cars. |
| positionAlongLane | is the distance from the beginning of the road segment, i.e. the beginning of the entry curve. |
| desiredDecelToUse | is the nominal deceleration rate to assume for both own vehicle and the obstacle vehicle ahead. A NEGATIVE value. |
|
protected |