 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
45 #define DEBUG_CACC_INSERTION_FOLLOW_SPEED 0
46 #define DEBUG_CACC_SECURE_GAP 0
47 #define DEBUG_COND (veh->isSelected())
55 #define DEFAULT_SC_GAIN_CACC -0.4
56 #define DEFAULT_GCC_GAIN_GAP_CACC 0.005
57 #define DEFAULT_GCC_GAIN_GAP_DOT_CACC 0.05
58 #define DEFAULT_GC_GAIN_GAP_CACC 0.45
59 #define DEFAULT_GC_GAIN_GAP_DOT_CACC 0.0125
60 #define DEFAULT_CA_GAIN_GAP_CACC 0.45
61 #define DEFAULT_CA_GAIN_GAP_DOT_CACC 0.05
62 #define DEFAULT_HEADWAYTIME_ACC 1.0
65 #define DEFAULT_EMERGENCY_OVERRIDE_THRESHOLD 2.0
92 const double vCACC =
_v(veh, pred, gap2pred, speed, predSpeed, desSpeed,
true);
99 <<
" v=" << speed <<
" vL=" << predSpeed <<
" gap=" << gap2pred
100 <<
" predDecel=" << predMaxDecel <<
" vCACC=" << vCACC <<
" vSafe=" << vSafe <<
"\n";
106 if (vSafe + speedOverride < vCACC) {
109 std::cout <<
"Apply Safe speed, override=" << speedOverride <<
"\n";
112 return vSafe + speedOverride;
139 #if DEBUG_CACC_SECURE_GAP == 1
140 std::cout <<
SIMTIME <<
"MSCFModel_ACC::getSecureGap speed=" << speed <<
" leaderSpeed=" << leaderSpeed
141 <<
" desSpacing=" << desSpacing <<
" desSpacingDefault=" << desSpacingDefault <<
"\n";
143 return MAX2(desSpacing, desSpacingDefault);
149 #if DEBUG_CACC_INSERTION_FOLLOW_SPEED == 1
151 std::cout <<
"MSCFModel_ACC::insertionFollowSpeed(), speed=" << speed <<
" gap2pred=" << gap2pred <<
" predSpeed=" << predSpeed <<
"\n";
156 const int max_iter = 50;
158 const double tol = 0.1;
159 double damping = 0.8;
162 while (n_iter < max_iter) {
164 const double vCACC =
_v(veh, pred, gap2pred, res, predSpeed, speed,
true);
166 const double a =
MIN2(vCACC, vSafe) - res;
167 res = res + damping * a;
168 #if DEBUG_CACC_INSERTION_FOLLOW_SPEED == 1
170 std::cout <<
" n_iter=" << n_iter <<
" vSafe=" << vSafe <<
" vCACC=" << vCACC <<
" a=" << a <<
" damping=" << damping <<
" res=" << res << std::endl;
201 const double speed,
const double predSpeed,
const double desSpeed,
double vErr,
204 double newSpeed = 0.0;
206 if (pred !=
nullptr) {
209 newSpeed =
acc_CFM.
_v(veh, gap2pred, speed, predSpeed, desSpeed,
true);
212 std::cout <<
" acc control mode" << std::endl;
220 std::cout <<
" CACC control mode" << std::endl;
225 double spacingErr = gap - desSpacing;
227 double spacingErr1 = predSpeed - speed +
myHeadwayTime * accel;
229 if ((spacingErr > 0 && spacingErr < 0.2) && (vErr < 0.1)) {
234 std::cout <<
" applying gap control" << std::endl;
238 }
else if (spacingErr < 0) {
243 std::cout <<
" applying collision avoidance err=" << spacingErr <<
" err1=" << spacingErr1 <<
"\n";
251 std::cout <<
" applying gap closing" << std::endl;
261 std::cout <<
" no leader" << std::endl;
273 const double predSpeed,
const double desSpeed,
const bool )
const {
274 double newSpeed = 0.0;
278 std::cout <<
SIMTIME <<
" MSCFModel_CACC::_v() for veh '" << veh->
getID()
279 <<
" gap=" << gap2pred <<
" speed=" << speed <<
" predSpeed=" << predSpeed
280 <<
" desSpeed=" << desSpeed << std::endl;
285 double vErr = speed - desSpeed;
286 int setControlMode = 0;
293 double time_gap = gap2pred / speed;
297 std::cout <<
" applying speedControl" << std::endl;
303 if (setControlMode) {
306 }
else if (time_gap < 1.5) {
310 std::cout <<
" speedGapControl" << std::endl;
313 newSpeed =
speedGapControl(veh, gap2pred, speed, predSpeed, desSpeed, vErr, pred);
315 if (setControlMode) {
325 std::cout <<
" applying speedControl (previous)" << std::endl;
332 std::cout <<
" previous speedGapControl (previous)" << std::endl;
335 newSpeed =
speedGapControl(veh, gap2pred, speed, predSpeed, desSpeed, vErr, pred);
341 <<
" newSpeed=" << newSpeed << std::endl;
345 return MAX2(0., newSpeed);
The car-following model and parameter.
#define UNUSED_PARAMETER(x)
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 myGapControlGainGap
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
#define DEFAULT_GC_GAIN_GAP_CACC
#define DEFAULT_EMERGENCY_OVERRIDE_THRESHOLD
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 stopSpeed(const MSVehicle *const veh, const double speed, double gap2pred) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double _v(const MSVehicle *const veh, const double gap2pred, const double mySpeed, const double predSpeed, const double desSpeed, const bool respectMinGap=true) const
#define DEFAULT_GCC_GAIN_GAP_DOT_CACC
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)
#define DEFAULT_CA_GAIN_GAP_DOT_CACC
double myGapClosingControlGainGapDot
double followSpeed(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)
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
double myGapControlGainGapDot
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
virtual void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
double myGapControlGainSpace
double mySpeedControlGain
double myCollisionAvoidanceGainGapDot
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
#define DEFAULT_CA_GAIN_GAP_CACC
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
int CACC_ControlMode
The vehicle's CACC precious time step gap error.
double myCollisionAvoidanceGainGap
The ACC car-following model.
double getMinGap() const
Get the free space in front of vehicles of this class.
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.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
double speedSpeedContol(const double speed, double vErr) const
#define DEFAULT_SC_GAIN_CACC
MSLane * getLane() const
Returns the lane the vehicle is on.
double myGapControlGainSpeed
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=true) const
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
#define DEFAULT_HEADWAYTIME_ACC
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the name of the vehicle.
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 abstraction.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
MSCFModel_CACC(const MSVehicleType *vtype)
Constructor.
#define DEFAULT_GCC_GAIN_GAP_CACC
virtual int getModelID() const =0
Returns the model's ID; the XML-Tag number is used.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
double myGapClosingControlGainGap
~MSCFModel_CACC()
Destructor.
#define DEFAULT_GC_GAIN_GAP_DOT_CACC
double speedGapControl(const MSVehicle *const veh, const double gap2pred, const double speed, const double predSpeed, const double desSpeed, double vErr, const MSVehicle *const pred) const
Representation of a vehicle in the micro simulation.