58#define DEFAULT_SC_GAIN -0.4
59#define DEFAULT_GCC_GAIN_SPEED 0.8
60#define DEFAULT_GCC_GAIN_SPACE 0.04
61#define DEFAULT_GC_GAIN_SPEED 0.07
62#define DEFAULT_GC_GAIN_SPACE 0.23
63#define DEFAULT_CA_GAIN_SPACE 0.8
64#define DEFAULT_CA_GAIN_SPEED 0.23
69#define GAP_THRESHOLD_SPEEDCTRL 120
70#define GAP_THRESHOLD_GAPCTRL 100
72#define DEFAULT_EMERGENCY_OVERRIDE_THRESHOLD 2.0
101 std::ostringstream internals;
112 const std::string cfmID = attrs.
get<std::string>(
SUMO_ATTR_ID,
nullptr, ok);
113 if (cfmID !=
"ACC") {
114 throw ProcessError(
TLF(
"incompatible carFollowModel '%' when loading state for ACC", cfmID));
117 bis >> ACC_ControlMode;
118 bis >> lastUpdateTime;
127 const double vACC =
_v(veh, gap2pred, speed, predSpeed, desSpeed,
true);
167 const int max_iter = 50;
169 const double tol = 0.1;
170 const double damping = 0.1;
173 while (n_iter < max_iter) {
176 res = res + damping * a;
205 double gclAccel = 0.0;
206 const double deltaVel = predSpeed - speed;
209 const double d0 =
MAX2(0.,
MIN2(75. / speed - 5., 2.));
211 const double spacingErr = gap2pred -
myHeadwayTime * speed - d0;
214 if (fabs(spacingErr) < 0.2 && fabs(vErr) < 0.1) {
219 std::cout <<
" applying gap control: spacingErr=" << spacingErr <<
" speedErr=" << vErr << std::endl;
222 }
else if (spacingErr < 0) {
227 std::cout <<
" applying collision avoidance: spacingErr=" << spacingErr <<
" speedErr=" << vErr << std::endl;
235 std::cout <<
" applying gap closing: spacingErr=" << spacingErr <<
" speedErr=" << vErr << std::endl;
245 const double predSpeed,
const double desSpeed,
const bool )
const {
253 std::cout <<
SIMTIME <<
" MSCFModel_ACC::_v() for veh '" << veh->
getID() <<
"'\n"
254 <<
" gap=" << gap2pred <<
" speed=" << speed <<
" predSpeed=" << predSpeed
255 <<
" desSpeed=" << desSpeed <<
" tau=" <<
myHeadwayTime << std::endl;
261 double vErr = speed - desSpeed;
262 int setControlMode = 0;
268 if (gap2pred > gapLimit_SC) {
272 std::cout <<
" applying speedControl" << std::endl;
278 if (setControlMode) {
281 }
else if (gap2pred < gapLimit_GC) {
285 if (setControlMode) {
295 std::cout <<
" applying speedControl" << std::endl;
309 std::cout <<
" result: accel=" << accelACC <<
" newSpeed=" << newSpeed << std::endl;
313 return MAX2(0., newSpeed);
#define DEFAULT_GC_GAIN_SPACE
#define DEFAULT_GCC_GAIN_SPEED
#define DEFAULT_GCC_GAIN_SPACE
#define DEFAULT_CA_GAIN_SPACE
#define DEFAULT_GC_GAIN_SPEED
#define DEFAULT_CA_GAIN_SPEED
#define GAP_THRESHOLD_SPEEDCTRL
#define DEFAULT_EMERGENCY_OVERRIDE_THRESHOLD
#define GAP_THRESHOLD_GAPCTRL
@ SUMO_ATTR_GCC_GAIN_SPEED
@ SUMO_ATTR_GC_GAIN_SPACE
@ SUMO_ATTR_CA_GAIN_SPACE
@ SUMO_ATTR_GCC_GAIN_SPACE
@ SUMO_ATTR_COLLISION_MINGAP_FACTOR
@ SUMO_ATTR_CA_GAIN_SPEED
@ SUMO_ATTR_APPLYDRIVERSTATE
@ SUMO_ATTR_GC_GAIN_SPEED
@ SUMO_ATTR_STATE
The state of a link.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the vehicle variables from the given description.
int ACC_ControlMode
The vehicle's ACC control mode. 0 for speed control and 1 for gap control.
void saveState(OutputDevice &out, const MSCFModel &cfm) const
Saves the vehicle variables.
The ACC car-following model.
double accelSpeedControl(double vErr) const
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)
double myCollisionAvoidanceGainSpeed
double myCollisionAvoidanceGainSpace
double myGapControlGainSpace
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
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 accelGapControl(const MSVehicle *const veh, const double gap2pred, const double speed, const double predSpeed, double vErr) const
double myGapClosingControlGainSpeed
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 myGapControlGainSpeed
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.
~MSCFModel_ACC()
Destructor.
MSCFModel_ACC(const MSVehicleType *vtype)
Constructor.
double myEmergencyThreshold
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
double myApplyDriverstate
double myGapClosingControlGainSpace
double mySpeedControlGain
The car-following model abstraction.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
void applyHeadwayPerceptionError(const MSVehicle *const veh, double speed, double &gap) const
Overwrites gap by the perceived value obtained from the vehicle's driver state.
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.
CalcReason
What the return value of stop/follow/free-Speed is used for.
@ FUTURE
the return value is used for calculating future speeds
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1, bool relaxEmergency=true) const
Returns the maximum next velocity for stopping within gap.
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Representation of a vehicle in the micro simulation.
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
const MSLane * getLane() const
Returns the lane the vehicle is on.
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
The car-following model and parameter.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
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.