1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file MSCFModel.h 11 /// @author Tobias Mayer 12 /// @author Daniel Krajzewicz 13 /// @author Jakob Erdmann 14 /// @author Michael Behrisch 15 /// @date Mon, 27 Jul 2009 16 /// @version $Id$ 17 /// 18 // The car-following model abstraction 19 /****************************************************************************/ 20 #ifndef MSCFModel_h 21 #define MSCFModel_h 22 23 // =========================================================================== 24 // included modules 25 // =========================================================================== 26 #include <config.h> 27 28 #include <cmath> 29 #include <string> 30 #include <utils/common/StdDefs.h> 31 #include <utils/common/FileHelpers.h> 32 33 #define INVALID_SPEED 299792458 + 1 // nothing can go faster than the speed of light! 34 // Factor that the minimum emergency decel is increased by in corresponding situations 35 #define EMERGENCY_DECEL_AMPLIFIER 1.2 36 37 // =========================================================================== 38 // class declarations 39 // =========================================================================== 40 class MSVehicleType; 41 class MSVehicle; 42 class MSLane; 43 class MSPerson; 44 class MSLink; 45 46 47 // =========================================================================== 48 // class definitions 49 // =========================================================================== 50 /** 51 * @class MSCFModel 52 * @brief The car-following model abstraction 53 * 54 * MSCFModel is an interface for different car following Models to implement. 55 * It provides methods to compute a vehicles velocity for a simulation step. 56 */ 57 class MSCFModel { 58 59 public: 60 61 class VehicleVariables { 62 public: 63 virtual ~VehicleVariables(); 64 }; 65 66 /** @brief Constructor 67 * @param[in] vtype the type for which this model is built and also the parameter object to configure this model 68 */ 69 MSCFModel(const MSVehicleType* vtype); 70 71 72 /// @brief Destructor 73 virtual ~MSCFModel(); 74 75 76 /// @name Methods to override by model implementation 77 /// @{ 78 79 /** @brief Applies interaction with stops and lane changing model 80 * influences. Called at most once per simulation step (exactcly once per action step) 81 * @param[in] veh The ego vehicle 82 * @param[in] vPos The possible velocity 83 * @return The velocity after applying interactions with stops and lane change model influences 84 */ 85 virtual double finalizeSpeed(MSVehicle* const veh, double vPos) const; 86 87 88 /// @brief apply custom speed adaptations within the given speed bounds patchSpeedBeforeLC(const MSVehicle * veh,double vMin,double vMax)89 virtual double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const { 90 UNUSED_PARAMETER(veh); 91 UNUSED_PARAMETER(vMin); 92 return vMax; 93 } 94 95 96 /** @brief Computes the vehicle's safe speed without a leader 97 * 98 * Returns the velocity of the vehicle in dependence to the length of the free street and the target 99 * velocity at the end of the free range. If onInsertion is true, the vehicle may still brake 100 * before the next movement. 101 * @param[in] veh The vehicle (EGO) 102 * @param[in] speed The vehicle's speed 103 * @param[in] seen The look ahead distance 104 * @param[in] maxSpeed The maximum allowed speed 105 * @param[in] onInsertion whether speed at insertion is asked for 106 * @return EGO's safe speed 107 */ 108 virtual double freeSpeed(const MSVehicle* const veh, double speed, double seen, 109 double maxSpeed, const bool onInsertion = false) const; 110 111 112 /** @brief Computes the vehicle's follow speed (no dawdling) 113 * 114 * Returns the velocity of the vehicle in dependence to the vehicle's and its leader's values and the distance between them. 115 * @param[in] veh The vehicle (EGO) 116 * @param[in] speed The vehicle's speed 117 * @param[in] gap2pred The (netto) distance to the LEADER 118 * @param[in] predSpeed The speed of LEADER 119 * @return EGO's safe speed 120 */ 121 virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const = 0; 122 123 124 /** @brief Computes the vehicle's safe speed (no dawdling) 125 * This method is used during the insertion stage. Whereas the method 126 * followSpeed returns the desired speed which may be lower than the safe 127 * speed, this method only considers safety constraints 128 * 129 * Returns the velocity of the vehicle in dependence to the vehicle's and its leader's values and the distance between them. 130 * @param[in] veh The vehicle (EGO) 131 * @param[in] speed The vehicle's speed 132 * @param[in] gap2pred The (netto) distance to the LEADER 133 * @param[in] predSpeed The speed of LEADER 134 * @return EGO's safe speed 135 */ 136 virtual double insertionFollowSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const; 137 138 139 /** @brief Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) 140 * 141 * Returns the velocity of the vehicle when approaching a static object (such as the end of a lane) assuming no reaction time is needed. 142 * @param[in] veh The vehicle (EGO) 143 * @param[in] speed The vehicle's speed 144 * @param[in] gap The (netto) distance to the the obstacle 145 * @return EGO's safe speed for approaching a non-moving obstacle 146 * @todo generic Interface, models can call for the values they need 147 */ 148 virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap) const = 0; 149 150 151 /** @brief Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints 152 * due to acceleration capabilities and previous speeds. 153 * @param[in] veh The vehicle (EGO) 154 * @param[in] speed The vehicle's speed 155 * @param[in] gap The (netto) distance to the the obstacle 156 * @return EGO's safe speed for approaching a non-moving obstacle at insertion 157 * @see stopSpeed() and insertionFollowSpeed() 158 * 159 */ 160 virtual double insertionStopSpeed(const MSVehicle* const veh, double speed, double gap) const; 161 162 /** @brief Computes the vehicle's follow speed that avoids a collision for the given amount of time 163 * 164 * Returns the velocity of the vehicle in dependence to the vehicle's and its leader's values and the distance between them. 165 * @param[in] veh The vehicle (EGO) 166 * @param[in] speed The vehicle's speed 167 * @param[in] gap2pred The (netto) distance to the LEADER 168 * @param[in] predSpeed The speed of LEADER 169 * @param[in] predMaxDecel The maximum leader decelration 170 * @return EGO's safe speed 171 */ 172 virtual double followSpeedTransient(double duration, const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const; 173 174 /** @brief Returns the maximum gap at which an interaction between both vehicles occurs 175 * 176 * "interaction" means that the LEADER influences EGO's speed. 177 * @param[in] veh The EGO vehicle 178 * @param[in] vL LEADER's speed 179 * @return The interaction gap 180 * @todo evaluate signature 181 */ 182 virtual double interactionGap(const MSVehicle* const veh, double vL) const; 183 184 185 /** @brief Returns the model's ID; the XML-Tag number is used 186 * @return The model's ID 187 */ 188 virtual int getModelID() const = 0; 189 190 191 /** @brief Duplicates the car-following model 192 * @param[in] vtype The vehicle type this model belongs to (1:1) 193 * @return A duplicate of this car-following model 194 */ 195 virtual MSCFModel* duplicate(const MSVehicleType* vtype) const = 0; 196 197 198 /** @brief Returns model specific values which are stored inside a vehicle 199 * and must be used with casting 200 */ createVehicleVariables()201 virtual VehicleVariables* createVehicleVariables() const { 202 return 0; 203 } 204 /// @} 205 206 207 /** @brief Get the vehicle type's maximum acceleration [m/s^2] 208 * @return The maximum acceleration (in m/s^2) of vehicles of this class 209 */ getMaxAccel()210 inline double getMaxAccel() const { 211 return myAccel; 212 } 213 214 215 /** @brief Get the vehicle type's maximal comfortable deceleration [m/s^2] 216 * @return The maximal comfortable deceleration (in m/s^2) of vehicles of this class 217 */ getMaxDecel()218 inline double getMaxDecel() const { 219 return myDecel; 220 } 221 222 223 /** @brief Get the vehicle type's maximal phisically possible deceleration [m/s^2] 224 * @return The maximal physically possible deceleration (in m/s^2) of vehicles of this class 225 */ getEmergencyDecel()226 inline double getEmergencyDecel() const { 227 return myEmergencyDecel; 228 } 229 230 231 /** @brief Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers 232 * @return The apparent deceleration (in m/s^2) of vehicles of this class 233 */ getApparentDecel()234 inline double getApparentDecel() const { 235 return myApparentDecel; 236 } 237 238 /** @brief Get the factor of minGap that must be maintained to avoid a collision event 239 */ getCollisionMinGapFactor()240 inline double getCollisionMinGapFactor() const { 241 return myCollisionMinGapFactor; 242 } 243 244 245 /// @name Virtual methods with default implementation 246 /// @{ 247 248 /** @brief Get the driver's imperfection 249 * @return The imperfection of drivers of this class 250 */ getImperfection()251 virtual double getImperfection() const { 252 return -1; 253 } 254 255 256 /** @brief Get the driver's desired headway [s] 257 * @return The desired headway of this class' drivers in s 258 */ getHeadwayTime()259 virtual double getHeadwayTime() const { 260 return myHeadwayTime; 261 } 262 /// @} 263 264 265 266 267 /// @name Currently fixed methods 268 /// @{ 269 270 /** @brief Returns the maximum speed given the current speed 271 * 272 * The implementation of this method must take into account the time step 273 * duration. 274 * 275 * Justification: Due to air brake or other influences, the vehicle's next maximum 276 * speed may depend on the vehicle's current speed (given). 277 * 278 * @param[in] speed The vehicle's current speed 279 * @param[in] speed The vehicle itself, for obtaining other values 280 * @return The maximum possible speed for the next step 281 */ 282 virtual double maxNextSpeed(double speed, const MSVehicle* const veh) const; 283 284 285 /** @brief Returns the minimum speed given the current speed 286 * (depends on the numerical update scheme and its step width) 287 * Note that it wouldn't have to depend on the numerical update 288 * scheme if the semantics would rely on acceleration instead of velocity. 289 * 290 * @param[in] speed The vehicle's current speed 291 * @param[in] speed The vehicle itself, for obtaining other values, if needed as e.g. road conditions. 292 * @return The minimum possible speed for the next step 293 */ 294 virtual double minNextSpeed(double speed, const MSVehicle* const veh = 0) const; 295 296 /** @brief Returns the minimum speed after emergency braking, given the current speed 297 * (depends on the numerical update scheme and its step width) 298 * Note that it wouldn't have to depend on the numerical update 299 * scheme if the semantics would rely on acceleration instead of velocity. 300 * 301 * @param[in] speed The vehicle's current speed 302 * @param[in] speed The vehicle itself, for obtaining other values, if needed as e.g. road conditions. 303 * @return The minimum possible speed for the next step 304 */ 305 virtual double minNextSpeedEmergency(double speed, const MSVehicle* const veh = 0) const; 306 307 308 /** @brief Returns the distance the vehicle needs to halt including driver's reaction time tau (i.e. desired headway), 309 * assuming that during the reaction time, the speed remains constant 310 * @param[in] speed The vehicle's current speed 311 * @return The distance needed to halt 312 */ brakeGap(const double speed)313 inline double brakeGap(const double speed) const { 314 return brakeGap(speed, myDecel, myHeadwayTime); 315 } 316 317 static double brakeGap(const double speed, const double decel, const double headwayTime); 318 319 static double brakeGapEuler(const double speed, const double decel, const double headwayTime); 320 321 static double freeSpeed(const double currentSpeed, const double decel, const double dist, const double maxSpeed, const bool onInsertion, const double actionStepLength); 322 323 /** @brief Returns the minimum gap to reserve if the leader is braking at maximum (>=0) 324 * @param[in] speed EGO's speed 325 * @param[in] leaderSpeed LEADER's speed 326 * @param[in] leaderMaxDecel LEADER's max. deceleration rate 327 */ getSecureGap(const double speed,const double leaderSpeed,const double leaderMaxDecel)328 inline virtual double getSecureGap(const double speed, const double leaderSpeed, const double leaderMaxDecel) const { 329 // The solution approach leaderBrakeGap >= followerBrakeGap is not 330 // secure when the follower can brake harder than the leader because the paths may still cross. 331 // As a workaround we use a value of leaderDecel which errs on the side of caution 332 const double maxDecel = MAX2(myDecel, leaderMaxDecel); 333 double secureGap = MAX2((double) 0, brakeGap(speed, myDecel, myHeadwayTime) - brakeGap(leaderSpeed, maxDecel, 0)); 334 return secureGap; 335 } 336 337 virtual /** @brief Returns the velocity after maximum deceleration 338 * @param[in] v The velocity 339 * @return The velocity after maximum deceleration 340 */ getSpeedAfterMaxDecel(double v)341 inline double getSpeedAfterMaxDecel(double v) const { 342 return MAX2((double) 0, v - (double) ACCEL2SPEED(myDecel)); 343 } 344 /// @} 345 346 /** @brief Computes the minimal time needed to cover a distance given the desired speed at arrival. 347 * @param[in] dist Distance to be covered 348 * @param[in] currentSpeed Actual speed of vehicle 349 * @param[in] arrivalSpeed Desired speed at arrival 350 */ 351 SUMOTime getMinimalArrivalTime(double dist, double currentSpeed, double arrivalSpeed) const; 352 353 354 /** @brief Computes the time needed to travel a distance dist given an initial speed 355 * and constant acceleration. The speed during traveling is assumed not to exceed the max speed. 356 * @param[in] dist Distance to be covered (assumed >= 0.) 357 * @param[in] speed Initial speed of vehicle 358 * @param[in] accel Assumed acceleration until reaching maxspeed or speed=0. 359 * @return Returns the estimated time needed to cover the given distance 360 * If distance will never be covered with the given parameters INVALID_DOUBLE (from MSLink.h) is returned. 361 */ 362 static double estimateArrivalTime(double dist, double speed, double maxSpeed, double accel); 363 364 /** @brief Computes the time needed to travel a distance dist given an initial speed, arrival speed, 365 * constant acceleration and deceleration. The speed during traveling is assumed not to exceed the max speed. 366 * @param[in] dist Distance to be covered (assumed >= 0.) 367 * @param[in] initialSpeed Initial speed of vehicle 368 * @param[in] arrivalSpeed desired arrival speed of vehicle 369 * @param[in] accel Assumed acceleration until reaching maxspeed. 370 * @param[in] accel Assumed deceleration until reaching targetspeed. 371 * @return Returns the estimated time needed to cover the given distance 372 * If distance will never be covered with the given parameters INVALID_DOUBLE (from MSLink.h) is returned. 373 * @note Currently, this is still a stub for actually very special situations in LC context: 374 * It is assumed that 0==initialSpeed==arrivalSpeed<=maxspeed, accel==decel>0 (because currently 375 * this is only used for lane change purposes, where lateral accel == lateral decel) 376 */ 377 static double estimateArrivalTime(double dist, double initialSpeed, double arrivalSpeed, double maxSpeed, double accel, double decel); 378 379 /** @brief Computes the acceleration needed to arrive not before the given time 380 * @param[in] dist - the distance of the critical point 381 * @param[in] time - the time after which an arrival at dist is allowed 382 * @param[in] speed - the current speed 383 * @return Returns the acceleration which would ensure an arrival at distance dist earliest for the given time 384 */ 385 static double avoidArrivalAccel(double dist, double time, double speed, double maxDecel); 386 387 388 /** @brief Computes the minimal possible arrival speed after covering a given distance 389 * @param[in] dist Distance to be covered 390 * @param[in] currentSpeed Actual speed of vehicle 391 */ 392 double getMinimalArrivalSpeed(double dist, double currentSpeed) const; 393 394 /** @brief Computes the minimal possible arrival speed after covering a given distance for Euler update 395 * @param[in] dist Distance to be covered 396 * @param[in] currentSpeed Actual speed of vehicle 397 */ 398 double getMinimalArrivalSpeedEuler(double dist, double currentSpeed) const; 399 400 401 /** @brief return the resulting gap if, starting with gap currentGap, two vehicles 402 * continue with constant accelerations (velocities bounded by 0 and maxSpeed) for 403 * a given timespan of length 'duration'. 404 * @param[in] currentGap (pos(veh1) - pos(veh2) at start) 405 * @param[in] v1 initial speed of vehicle 1 406 * @param[in] v2 initial speed of vehicle 2 407 * @param[in] a1 acceleration of vehicle 1 408 * @param[in] a2 acceleration of vehicle 2 409 * @param[in] maxV1 maximal speed of vehicle 1 410 * @param[in] maxV2 maximal speed of vehicle 2 411 * @param[in] duration time span for the process 412 * @return estimated gap after 'duration' seconds 413 */ 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()); 415 416 /** 417 * @brief Calculates the time at which the position passedPosition has been passed 418 * In case of a ballistic update, the possibility of a stop within a time step 419 * requires more information about the last time-step than in case of the euler update 420 * to determine the last position if the currentSpeed is zero. 421 * @param[in] lastPos the position at time t=0 (must be < currentPos) 422 * @param[in] passedPos the position for which the passing time is to be determined (has to lie within [lastPos, currentPos]!) 423 * @param[in] currentPos the position at time t=TS (one time-step after lastPos) (must be > lastPos) 424 * @param[in] lastSpeed the speed at moment t=0 425 * @param[in] currentSpeed the speed at moment t=TS 426 * @return time t in [0,TS] at which passedPos in [lastPos, currentPos] was passed. 427 */ 428 static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed); 429 430 431 432 /** 433 * @brief Calculates the speed after a time t \in [0,TS] 434 * given the initial speed and the distance traveled in an interval of step length TS. 435 * @note If the acceleration were known, this would be much nicer, but in this way 436 * we need to reconstruct it (for the ballistic update at least, where we assume that 437 * a stop may occur within the interval) 438 * @param[in] t time in [0,TS] for which the speed shall be determined 439 * @param[in] oldSpeed speed before the last time step (referred to as t == 0) 440 * @param[in] distance covered 441 * @return speed at time t 442 */ 443 static double speedAfterTime(const double t, const double oldSpeed, const double dist); 444 445 446 /// @brief calculates the distance travelled after accelerating for time t 447 static double distAfterTime(double t, double speed, double accel); 448 449 450 451 /* @brief estimate speed while accelerating for the given distance 452 * @param[in] dist The distance during which accelerating takes place 453 * @param[in] v The initial speed 454 * @param[in] accel The acceleration 455 * XXX affected by ticket #860 (the formula is invalid for the Euler position update rule) 456 * XXX (Leo) Migrated estimateSpeedAfterDistance() to MSCFModel from MSVehicle as Jakob suggested (removed inline property, because myType is fw-declared) 457 */ 458 double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const; 459 460 /// @name Setter methods 461 /// @{ 462 463 /** @brief Sets a new value for maximum acceleration [m/s^2] 464 * @param[in] accel The new acceleration in m/s^2 465 */ setMaxAccel(double accel)466 virtual void setMaxAccel(double accel) { 467 myAccel = accel; 468 } 469 470 471 /** @brief Sets a new value for maximal comfortable deceleration [m/s^2] 472 * @param[in] decel The new deceleration in m/s^2 473 */ setMaxDecel(double decel)474 virtual void setMaxDecel(double decel) { 475 myDecel = decel; 476 } 477 478 479 /** @brief Sets a new value for maximal physically possible deceleration [m/s^2] 480 * @param[in] decel The new deceleration in m/s^2 481 */ setEmergencyDecel(double decel)482 virtual void setEmergencyDecel(double decel) { 483 myEmergencyDecel = decel; 484 } 485 486 487 /** @brief Sets a new value for the apparent deceleration [m/s^2] 488 * @param[in] decel The new deceleration in m/s^2 489 */ setApparentDecel(double decel)490 virtual void setApparentDecel(double decel) { 491 myApparentDecel = decel; 492 } 493 494 495 /** @brief Sets a new value for driver imperfection 496 * @param[in] accel The new driver imperfection 497 */ setImperfection(double imperfection)498 virtual void setImperfection(double imperfection) { 499 UNUSED_PARAMETER(imperfection); 500 } 501 502 503 /** @brief Sets a new value for desired headway [s] 504 * @param[in] headwayTime The new desired headway (in s) 505 */ setHeadwayTime(double headwayTime)506 virtual void setHeadwayTime(double headwayTime) { 507 myHeadwayTime = headwayTime; 508 } 509 /// @} 510 511 /** @brief Returns the maximum safe velocity for following the given leader 512 * @param[in] gap2pred The (netto) distance to the LEADER 513 * @param[in] egoSpeed The FOLLOWERS's speed 514 * @param[in] predSpeed The LEADER's speed 515 * @param[in] predMaxDecel The LEADER's maximum deceleration 516 * @param[in] onInsertion Indicator whether the call is triggered during vehicle insertion 517 * @return the safe velocity 518 */ 519 double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion = false) const; 520 521 522 /** @brief Returns the minimal deceleration for following the given leader safely 523 * @param[in] gap The (netto) distance to the LEADER 524 * @param[in] egoSpeed The FOLLOWERS's speed 525 * @param[in] predSpeed The LEADER's speed 526 * @param[in] predMaxDecel The LEADER's maximum deceleration 527 * @return The minimal deceleration b>0 that, if applied constantly until a full stop, 528 * asserts that the vehicle does not crash into the leader. 529 * @note If b > predMaxDecel, this function actually does not calculate the tangency for the trajectories, i.e. a double root for the gap, 530 * but applies a simpler approach following the spirit of maximumSafeFollowSpeed, where the 531 * leader's decel is assumed as maximum of its actual value and the followers decel. 532 */ 533 double calculateEmergencyDeceleration(double gap, double egoSpeed, double predSpeed, double predMaxDecel) const; 534 535 536 /** @brief Returns the maximum next velocity for stopping within gap 537 * @param[in] gap The (netto) distance to the desired stopping point 538 * @param[in] currentSpeed The current speed of the ego vehicle 539 * @param[in] onInsertion Indicator whether the call is triggered during vehicle insertion 540 * @param[in] headway The desired time headway to be included in the calculations (default argument -1 induces the use of myHeadway) 541 */ 542 double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion = false, double headway = -1) const; 543 544 545 /** @brief Returns the maximum next velocity for stopping within gap 546 * when using the semi-implicit Euler update 547 * @param[in] gap The (netto) distance to the LEADER 548 */ 549 double maximumSafeStopSpeedEuler(double gap, double headway = -1) const; 550 551 552 /** @brief Returns the maximum next velocity for stopping within gap 553 * when using the ballistic positional update. 554 * @note This takes into account the driver's reaction time tau (i.e. the desired headway) and the car's current speed. 555 * (The latter is required to calculate the distance covered in the following timestep.) 556 * @param[in] gap The (netto) distance to the desired stopping point 557 * @param[in] currentSpeed The current speed of the ego vehicle 558 * @param[in] onInsertion Indicator whether the call is triggered during vehicle insertion 559 * @param[in] headway The desired time headway to be included in the calculations (default argument -1 induces the use of myHeadway) 560 * @return the safe velocity (to be attained at the end of the following time step) that assures the possibility of stopping within gap. 561 * If a negative value is returned, the required stop has to take place before the end of the time step. 562 */ 563 double maximumSafeStopSpeedBallistic(double gap, double currentSpeed, bool onInsertion = false, double headway = -1) const; 564 565 /** 566 * @brief try to get the given parameter for this carFollowingModel 567 * 568 * @param[in] veh the vehicle from which the parameter must be retrieved 569 * @param[in] key the key of the parameter 570 * @return the value of the requested parameter 571 */ getParameter(const MSVehicle * veh,const std::string & key)572 virtual std::string getParameter(const MSVehicle* veh, const std::string& key) const { 573 UNUSED_PARAMETER(veh); 574 UNUSED_PARAMETER(key); 575 return ""; 576 } 577 578 /** 579 * @brief try to set the given parameter for this carFollowingModel 580 * 581 * @param[in] veh the vehicle for which the parameter must be set 582 * @param[in] key the key of the parameter 583 * @param[in] value the value to be set for the given parameter 584 */ setParameter(MSVehicle * veh,const std::string & key,const std::string & value)585 virtual void setParameter(MSVehicle* veh, const std::string& key, const std::string& value) const { 586 UNUSED_PARAMETER(veh); 587 UNUSED_PARAMETER(key); 588 UNUSED_PARAMETER(value); 589 } 590 591 protected: 592 593 /** @brief Overwrites gap2pred and predSpeed by the perceived values obtained from the vehicle's driver state, 594 * @see MSCFModel_Krauss::stopSpeed() and MSCFModel_Krauss::followSpeed() for integration into a CF model 595 * @param[in] veh The vehicle (EGO) 596 * @param[in] speed The vehicle's speed 597 * @param[in, out] gap2pred The (netto) distance to the LEADER 598 * @param[in, out] predSpeed The speed of LEADER 599 * @param[in] pred The leading vehicle (LEADER) 600 */ 601 void applyHeadwayAndSpeedDifferencePerceptionErrors(const MSVehicle* const veh, double speed, double& gap, double& predSpeed, double predMaxDecel, const MSVehicle* const pred) const; 602 603 /** @brief Overwrites gap by the perceived value obtained from the vehicle's driver state 604 * @param[in] veh The vehicle (EGO) 605 * @param[in] speed The vehicle's speed 606 * @param[in, out] gap The (netto) distance to the the obstacle 607 */ 608 void applyHeadwayPerceptionError(const MSVehicle* const veh, double speed, double& gap) const; 609 610 611 protected: 612 /// @brief The type to which this model definition belongs to 613 const MSVehicleType* myType; 614 615 /// @brief The vehicle's maximum acceleration [m/s^2] 616 double myAccel; 617 618 /// @brief The vehicle's maximum deceleration [m/s^2] 619 double myDecel; 620 /// @brief The vehicle's maximum emergency deceleration [m/s^2] 621 double myEmergencyDecel; 622 /// @brief The vehicle's deceleration as expected by surrounding traffic [m/s^2] 623 double myApparentDecel; 624 /// @brief The factor of minGap that must be maintained to avoid a collision event 625 double myCollisionMinGapFactor; 626 627 /// @brief The driver's desired time headway (aka reaction time tau) [s] 628 double myHeadwayTime; 629 630 631 632 }; 633 634 635 #endif /* MSCFModel_h */ 636 637