Skip to content

Commit

Permalink
fix #14621
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 28, 2024
1 parent f92eb46 commit 7dc5866
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/microsim/cfmodels/MSCFModel_IDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,27 @@ MSCFModel_IDM::insertionFollowSpeed(const MSVehicle* const v, double speed, doub
}


double
MSCFModel_IDM::insertionStopSpeed(const MSVehicle* const veh, double speed, double gap) const {
// we want to insert the vehicle in an equilibrium state
double result = MSCFModel::insertionStopSpeed(veh, speed, gap);
int i = 0;
while (result - speed < -ACCEL2SPEED(myDecel) && ++i < 10) {
speed = result;
result = MSCFModel::insertionStopSpeed(veh, speed, gap);
}
return result;
}


double
MSCFModel_IDM::stopSpeed(const MSVehicle* const veh, const double speed, double gap, double decel, const CalcReason /*usage*/) const {
applyHeadwayPerceptionError(veh, speed, gap);
if (gap < 0.01) {
return 0;
}
double result = _v(veh, gap, speed, 0, veh->getLane()->getVehicleMaxSpeed(veh), false);
//std::cout << SIMTIME << " stopSpeed speed=" << speed << " gap=" << gap << " decel=" << decel << " result=" << result << "\n";
if (gap > 0 && speed < NUMERICAL_EPS && result < NUMERICAL_EPS) {
// ensure that stops can be reached:
//std::cout << " switching to krauss: " << veh->getID() << " gap=" << gap << " speed=" << speed << " res1=" << result << " res2=" << maximumSafeStopSpeed(gap, speed, false, veh->getActionStepLengthSecs())<< "\n";
Expand Down
10 changes: 10 additions & 0 deletions src/microsim/cfmodels/MSCFModel_IDM.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ class MSCFModel_IDM : public MSCFModel {
*/
double insertionFollowSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;

/** @brief Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints
* due to acceleration capabilities and previous speeds.
* @param[in] veh The vehicle (EGO)
* @param[in] speed The vehicle's speed
* @param[in] gap The (netto) distance to the the obstacle
* @return EGO's safe speed for approaching a non-moving obstacle at insertion
* @see stopSpeed() and insertionFollowSpeed()
*
*/
double insertionStopSpeed(const MSVehicle* const veh, double speed, double gap) const;

/** @brief Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
* @param[in] veh The vehicle itself, for obtaining other values
Expand Down

0 comments on commit 7dc5866

Please sign in to comment.