34#define INTERACTION_GAP 150
39#define DEBUG_FOLLOW_SPEED
41#define DEBUG_COND (veh->isSelected())
75 double& sdxc,
double& sdxo,
double& sdxv)
const {
77 const double dv = predSpeed - speed;
80 const double v_slower = (dv >= 0 || leaderAccel < 1) ? speed : predSpeed + dv * rndVal;
91 const double dv = predSpeed - speed;
95 const double leaderAccel = pred !=
nullptr ? pred->
getAcceleration() : 0;
99 double sdxc, sdxo, sdxv;
102 const double sdv =
myCC6 * dx * dx / 10000;
103 const double sdvc = speed > 0 ?
myCC4 - sdv : 0;
104 const double sdvo = predSpeed >
myCC5 ? sdv +
myCC5 : sdv;
109 if (dv < sdvo && dx <= sdxc) {
121 accel =
MIN2(leaderAccel + dv * dv / (cc0 - dx), 0.0);
124 accel =
MIN2(leaderAccel + 0.5 * (dv - sdvo), 0.0);
128 if (accel > -
myCC7) {
132 accel =
MAX2(accel, -10 + 0.5 * sqrt(speed));
137 }
else if (dv < sdvc && dx < sdxv) {
139 accel = 0.5 * dv * dv / (sdxc - dx - 0.1);
142 }
else if (dv < sdvo && dx < sdxo) {
161 accel =
MIN2(dv * dv / (sdxo - dx), accelMax);
172#ifdef DEBUG_FOLLOW_SPEED
175 <<
" v=" << speed <<
" pV=" << predSpeed <<
" g=" << gap2pred
176 <<
" dv=" << dv <<
" dx=" << dx
177 <<
" sdxc=" << sdxc <<
" sdxo=" << sdxo <<
" sdxv=" << sdxv <<
" sdv=" << sdv <<
" sdvo=" << sdvo <<
" sdvc=" << sdvc
179 <<
" a=" << accel <<
" V=" << vNew <<
"\n";
185 vNew =
MAX2(0.0, vNew);
@ SUMO_ATTR_COLLISION_MINGAP_FACTOR
#define UNUSED_PARAMETER(x)
The W99 Model car-following model.
MSCFModel_W99(const MSVehicleType *vtype)
Constructor.
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
void computeThresholds(double speed, double predSpeed, double leaderAccel, double rndVal, double &sdxc, double &sdxo, double &sdxv) const
~MSCFModel_W99()
Destructor.
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed (no dawdling)
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
The car-following model abstraction.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
CalcReason
What the return value of stop/follow/free-Speed is used for.
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1, bool relaxEmergency=true) const
Returns the maximum next velocity for stopping within gap.
double myAccel
The vehicle's maximum acceleration [m/s^2].
const MSVehicleType * myType
The type to which this model definition belongs to.
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
static bool gSemiImplicitEulerUpdate
Representation of a vehicle in the micro simulation.
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
The car-following model and parameter.
double getMinGap() const
Get the free space in front of vehicles of this class.
const SUMOVTypeParameter & getParameter() const
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.