Eclipse SUMO - Simulation of Urban MObility
MSCFModel_CACC.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // CACC car-following model based on [1], [2].
19 // [1] Milanes, V., and S. E. Shladover. Handling Cut-In Vehicles in Strings
20 // of Cooperative Adaptive Cruise Control Vehicles. Journal of Intelligent
21 // Transportation Systems, Vol. 20, No. 2, 2015, pp. 178-191.
22 // [2] Xiao, L., M. Wang and B. van Arem. Realistic Car-Following Models for
23 // Microscopic Simulation of Adaptive and Cooperative Adaptive Cruise
24 // Control Vehicles. Transportation Research Record: Journal of the
25 // Transportation Research Board, No. 2623, 2017. (DOI: 10.3141/2623-01).
26 /****************************************************************************/
27 #pragma once
28 #include <config.h>
29 
30 #include "MSCFModel.h"
31 #include "MSCFModel_ACC.h"
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MSVehicle;
38 class MSVehicleType;
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
47 class MSCFModel_CACC : public MSCFModel {
48 public:
53  MSCFModel_CACC(const MSVehicleType* vtype);
54 
57 
58 
61 
76  double freeSpeed(const MSVehicle* const veh, double speed, double seen,
77  double maxSpeed, const bool onInsertion = false, const CalcReason usage = CalcReason::CURRENT) const;
78 
87  double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed,
88  double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
89 
90 
98  double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
99 
100 
108  double getSecureGap(const MSVehicle* const veh, const MSVehicle* const pred, const double speed, const double leaderSpeed, const double leaderMaxDecel) const;
109 
117  double insertionFollowSpeed(const MSVehicle* const v, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
118 
119 
129  double interactionGap(const MSVehicle* const, double vL) const;
130 
134  void setHeadwayTime(double headwayTime) {
135  myHeadwayTime = headwayTime;
136  myHeadwayTimeACC = headwayTime;
137  acc_CFM.setHeadwayTime(headwayTime);
138  }
139 
147  virtual std::string getParameter(const MSVehicle* veh, const std::string& key) const;
148 
149 
157  virtual void setParameter(MSVehicle* veh, const std::string& key, const std::string& value) const;
158 
159 
164  int getModelID() const {
165  return SUMO_TAG_CF_CACC;
166  }
167 
172  double maximumLaneSpeedCF(const MSVehicle* const veh, double maxSpeed, double maxSpeedLane) const {
173  double result = MIN2(maxSpeed, maxSpeedLane);
174  if (myApplyDriverstate) {
175  applyOwnSpeedPerceptionError(veh, result);
176  }
177  return result;
178  }
180 
181 
182 
187  MSCFModel* duplicate(const MSVehicleType* vtype) const;
188 
191  ret->ACC_ControlMode = 0;
192  ret->CACC_ControlMode = 0;
194  ret->lastUpdateTime = 0;
195  return ret;
196  }
197 
198 
199 private:
205  };
206 
207  static std::map<std::string, CommunicationsOverrideMode> CommunicationsOverrideModeMap;
208 
211  enum VehicleMode {
212  CC_MODE = 0,
217  };
218 
220  static std::map<VehicleMode, std::string> VehicleModeNames;
221 
223  public:
228  };
229 
230 private:
231  double _v(const MSVehicle* const veh, const MSVehicle* const pred, const double gap2pred, const double mySpeed,
232  const double predSpeed, const double desSpeed, const bool respectMinGap, const CalcReason usage = CalcReason::CURRENT) const;
233 
234  double speedSpeedControl(const double speed, double vErr, VehicleMode& vehMode) const;
235  double speedGapControl(const MSVehicle* const veh, const double gap2pred,
236  const double speed, const double predSpeed, const double desSpeed, double vErr,
237  const MSVehicle* const pred, VehicleMode& vehMode) const;
238 
239 private:
252 
253 private:
256 };
@ SUMO_TAG_CF_CACC
T MIN2(T a, T b)
Definition: StdDefs.h:76
int ACC_ControlMode
The vehicle's ACC control mode. 0 for speed control and 1 for gap control.
The ACC car-following model.
Definition: MSCFModel_ACC.h:47
CommunicationsOverrideMode CACC_CommunicationsOverrideMode
int CACC_ControlMode
The vehicle's CACC precious time step gap error.
The CACC car-following model.
MSCFModel_CACC & operator=(const MSCFModel_CACC &s)
Invalidated assignment operator.
virtual std::string getParameter(const MSVehicle *veh, const std::string &key) const
try to get the given parameter for this carFollowingModel
MSCFModel_ACC acc_CFM
double getSecureGap(const MSVehicle *const veh, const MSVehicle *const pred, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the a gap such that the gap mode acceleration of the follower is zero.
double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
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_CACC(const MSVehicleType *vtype)
Constructor.
double myGapControlGainGap
double stopSpeed(const MSVehicle *const veh, const double speed, double gap2pred, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
double myApplyDriverstate
virtual void setParameter(MSVehicle *veh, const std::string &key, const std::string &value) const
try to set the given parameter for this carFollowingModel
double myGapClosingControlGainGap
double _v(const MSVehicle *const veh, const MSVehicle *const pred, const double gap2pred, const double mySpeed, const double predSpeed, const double desSpeed, const bool respectMinGap, const CalcReason usage=CalcReason::CURRENT) const
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double speedSpeedControl(const double speed, double vErr, VehicleMode &vehMode) const
double myEmergencyThreshold
double insertionFollowSpeed(const MSVehicle *const v, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's acceptable speed at insertion.
double myGapClosingControlGainGapDot
static std::map< std::string, CommunicationsOverrideMode > CommunicationsOverrideModeMap
double maximumLaneSpeedCF(const MSVehicle *const veh, double maxSpeed, double maxSpeedLane) const
Returns the maximum velocity the CF-model wants to achieve in the next step.
double mySpeedControlGain
double myCollisionAvoidanceGainGapDot
double speedGapControl(const MSVehicle *const veh, const double gap2pred, const double speed, const double predSpeed, const double desSpeed, double vErr, const MSVehicle *const pred, VehicleMode &vehMode) const
double myHeadwayTimeACC
double myGapControlGainGapDot
int getModelID() const
Returns the model's name.
~MSCFModel_CACC()
Destructor.
VehicleMode
Vehicle mode (default is CACC) Switch to ACC mode if CACC_ControlMode = 1 (gap control mode) and lead...
double mySpeedControlMinGap
void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
virtual MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
static std::map< VehicleMode, std::string > VehicleModeNames
Vehicle mode name map.
double myCollisionAvoidanceGainGap
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
The car-following model abstraction.
Definition: MSCFModel.h:55
virtual void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
Definition: MSCFModel.h:574
CalcReason
What the return value of stop/follow/free-Speed is used for.
Definition: MSCFModel.h:77
void applyOwnSpeedPerceptionError(const MSVehicle *const veh, double &speed) const
Overwrites sped by the perceived values obtained from the vehicle's driver state,.
Definition: MSCFModel.cpp:1054
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:710
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
The car-following model and parameter.
Definition: MSVehicleType.h:63