31 #define INVALID_SPEED 299792458 + 1
33 #define EMERGENCY_DECEL_AMPLIFIER 1.2
107 double maxSpeed,
const bool onInsertion =
false)
const;
119 virtual double followSpeed(
const MSVehicle*
const veh,
double speed,
double gap2pred,
double predSpeed,
double predMaxDecel,
const MSVehicle*
const pred = 0)
const = 0;
170 virtual double followSpeedTransient(
double duration,
const MSVehicle*
const veh,
double speed,
double gap2pred,
double predSpeed,
double predMaxDecel)
const;
315 static double brakeGap(
const double speed,
const double decel,
const double headwayTime);
317 static double brakeGapEuler(
const double speed,
const double decel,
const double headwayTime);
319 static double freeSpeed(
const double currentSpeed,
const double decel,
const double dist,
const double maxSpeed,
const bool onInsertion,
const double actionStepLength);
328 inline virtual double getSecureGap(
const MSVehicle*
const ,
const MSVehicle*
const ,
const double speed,
const double leaderSpeed,
const double leaderMaxDecel)
const {
332 const double maxDecel =
MAX2(
myDecel, leaderMaxDecel);
362 static double estimateArrivalTime(
double dist,
double speed,
double maxSpeed,
double accel);
377 static double estimateArrivalTime(
double dist,
double initialSpeed,
double arrivalSpeed,
double maxSpeed,
double accel,
double decel);
385 static double avoidArrivalAccel(
double dist,
double time,
double speed,
double maxDecel);
414 static double gapExtrapolation(
const double duration,
const double currentGap,
double v1,
double v2,
double a1 = 0,
double a2 = 0,
const double maxV1 = std::numeric_limits<double>::max(),
const double maxV2 = std::numeric_limits<double>::max());
428 static double passingTime(
const double lastPos,
const double passedPos,
const double currentPos,
const double lastSpeed,
const double currentSpeed);
443 static double speedAfterTime(
const double t,
const double oldSpeed,
const double dist);
447 static double distAfterTime(
double t,
double speed,
double accel);
519 double maximumSafeFollowSpeed(
double gap,
double egoSpeed,
double predSpeed,
double predMaxDecel,
bool onInsertion =
false)
const;
542 double maximumSafeStopSpeed(
double gap,
double currentSpeed,
bool onInsertion =
false,
double headway = -1)
const;
#define UNUSED_PARAMETER(x)
virtual ~VehicleVariables()
The car-following model abstraction.
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
virtual double getSecureGap(const MSVehicle *const, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
static double gapExtrapolation(const double duration, const double currentGap, double v1, double v2, double a1=0, double a2=0, const double maxV1=std::numeric_limits< double >::max(), const double maxV2=std::numeric_limits< double >::max())
return the resulting gap if, starting with gap currentGap, two vehicles continue with constant accele...
virtual double minNextSpeedEmergency(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed after emergency braking, given the current speed (depends on the numerical ...
virtual std::string getParameter(const MSVehicle *veh, const std::string &key) const
try to get the given parameter for this carFollowingModel
virtual double followSpeedTransient(double duration, const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle's follow speed that avoids a collision for the given amount of time.
virtual void setImperfection(double imperfection)
Sets a new value for driver imperfection.
double maximumSafeStopSpeedBallistic(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap when using the ballistic positional update.
double getCollisionMinGapFactor() const
Get the factor of minGap that must be maintained to avoid a collision event.
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
static double brakeGapEuler(const double speed, const double decel, const double headwayTime)
virtual double interactionGap(const MSVehicle *const veh, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
static double avoidArrivalAccel(double dist, double time, double speed, double maxDecel)
Computes the acceleration needed to arrive not before the given time.
double getMinimalArrivalSpeed(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance.
virtual void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
virtual double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
apply custom speed adaptations within the given speed bounds
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const =0
Duplicates the car-following model.
virtual double minNextSpeed(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
virtual void setEmergencyDecel(double decel)
Sets a new value for maximal physically possible deceleration [m/s^2].
SUMOTime getMinimalArrivalTime(double dist, double currentSpeed, double arrivalSpeed) const
Computes the minimal time needed to cover a distance given the desired speed at arrival.
void applyHeadwayPerceptionError(const MSVehicle *const veh, double speed, double &gap) const
Overwrites gap by the perceived value obtained from the vehicle's driver state.
virtual void setMaxAccel(double accel)
Sets a new value for maximum acceleration [m/s^2].
static double speedAfterTime(const double t, const double oldSpeed, const double dist)
Calculates the speed after a time t \in [0,TS] given the initial speed and the distance traveled in a...
static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
virtual ~MSCFModel()
Destructor.
virtual void setMaxDecel(double decel)
Sets a new value for maximal comfortable deceleration [m/s^2].
double myEmergencyDecel
The vehicle's maximum emergency deceleration [m/s^2].
virtual VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
double maximumSafeStopSpeedEuler(double gap, double headway=-1) const
Returns the maximum next velocity for stopping within gap when using the semi-implicit Euler update.
void applyHeadwayAndSpeedDifferencePerceptionErrors(const MSVehicle *const veh, double speed, double &gap, double &predSpeed, double predMaxDecel, const MSVehicle *const pred) const
Overwrites gap2pred and predSpeed by the perceived values obtained from the vehicle's driver state,...
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const =0
Computes the vehicle's follow speed (no dawdling)
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
double calculateEmergencyDeceleration(double gap, double egoSpeed, double predSpeed, double predMaxDecel) const
Returns the minimal deceleration for following the given leader safely.
static double distAfterTime(double t, double speed, double accel)
calculates the distance travelled after accelerating for time t
MSCFModel(const MSVehicleType *vtype)
Constructor.
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
double myDecel
The vehicle's maximum deceleration [m/s^2].
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
virtual int getModelID() const =0
Returns the model's ID; the XML-Tag number is used.
virtual double getImperfection() const
Get the driver's imperfection.
double myAccel
The vehicle's maximum acceleration [m/s^2].
const MSVehicleType * myType
The type to which this model definition belongs to.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
virtual double getSpeedAfterMaxDecel(double v) const
Returns the velocity after maximum deceleration.
virtual void setApparentDecel(double decel)
Sets a new value for the apparent deceleration [m/s^2].
virtual void setParameter(MSVehicle *veh, const std::string &key, const std::string &value) const
try to set the given parameter for this carFollowingModel
double getMinimalArrivalSpeedEuler(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance for Euler update.
static double estimateArrivalTime(double dist, double speed, double maxSpeed, double accel)
Computes the time needed to travel a distance dist given an initial speed and constant acceleration....
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
double myApparentDecel
The vehicle's deceleration as expected by surrounding traffic [m/s^2].
virtual double insertionStopSpeed(const MSVehicle *const veh, double speed, double gap) const
Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints due to...
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
Representation of a lane in the micro simulation.
Representation of a vehicle in the micro simulation.
The car-following model and parameter.