46 #define DEBUG_COND (veh->isSelected()) 52 #define DEFAULT_SC_GAIN_CACC -0.4 53 #define DEFAULT_GCC_GAIN_GAP_CACC 0.005 54 #define DEFAULT_GCC_GAIN_GAP_DOT_CACC 0.05 55 #define DEFAULT_GC_GAIN_GAP_CACC 0.45 56 #define DEFAULT_GC_GAIN_GAP_DOT_CACC 0.0125 57 #define DEFAULT_CA_GAIN_GAP_CACC 0.45 58 #define DEFAULT_CA_GAIN_GAP_DOT_CACC 0.05 61 #define DEFAULT_EMERGENCY_OVERRIDE_THRESHOLD 2.0 86 const double vCACC =
_v(veh, gap2pred, speed, predSpeed, desSpeed,
true);
92 std::cout <<
"Apply Safe speed"<<
"\n";
93 std::cout <<
SIMTIME <<
" veh=" << veh->
getID() <<
" v=" << speed <<
" vL=" << predSpeed <<
" gap=" << gap2pred <<
" vCACC=" << vCACC <<
" vSafe=" << vSafe <<
" cm=" << vars->
CACC_ControlMode <<
"\n";
125 const double speed,
const double predSpeed,
const double desSpeed,
double vErr)
const {
127 double newSpeed = 0.0;
129 std::pair<const MSVehicle* const, double> leaderInfo = veh->
getLeader(100);
130 if (leaderInfo.first ) {
131 if (leaderInfo.first->getCarFollowModel().getModelID() !=
SUMO_TAG_CF_CACC) {
133 newSpeed =
acc_CFM.
_v(veh, gap2pred, speed, predSpeed, desSpeed,
true);
139 double spacingErr = gap - desSpacing;
141 double spacingErr1 = predSpeed - speed +
myHeadwayTime * accel;
143 if ((spacingErr > 0 && spacingErr < 0.2) && (vErr < 0.1)) {
148 std::cout <<
" applying gap control" << std::endl;
152 }
else if (spacingErr < 0) {
157 std::cout <<
" applying collision avoidance" << std::endl;
165 std::cout <<
" applying gap closing" << std::endl;
182 const double predSpeed,
const double desSpeed,
const bool )
const {
184 double newSpeed = 0.0;
188 std::cout <<
SIMTIME <<
" MSCFModel_CACC::_v() for veh '" << veh->
getID() <<
"'\n" 189 <<
" gap=" << gap2pred <<
" speed=" << speed <<
" predSpeed=" << predSpeed
190 <<
" desSpeed=" << desSpeed << std::endl;
195 double vErr = speed - desSpeed;
196 int setControlMode = 0;
203 double time_gap = gap2pred / speed;
207 std::cout <<
" applying speedControl" << std::endl;
213 if (setControlMode) {
216 }
else if (time_gap < 1.5 ){
218 newSpeed =
speedGapControl(veh, gap2pred, speed, predSpeed, desSpeed, vErr);
220 if (setControlMode) {
230 std::cout <<
" applying speedControl" << std::endl;
235 newSpeed =
speedGapControl(veh, gap2pred, speed, predSpeed, desSpeed, vErr);
241 std::cout <<
" result: accel=" <<
SPEED2ACCEL(newSpeed-speed) <<
" newSpeed=" << newSpeed << std::endl;
245 return MAX2(0., newSpeed);
#define DEFAULT_EMERGENCY_OVERRIDE_THRESHOLD
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
Representation of a vehicle in the micro simulation.
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
MSLane * getLane() const
Returns the lane the vehicle is on.
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
The car-following model abstraction.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
int CACC_ControlMode
The vehicle's CACC precious time step gap error.
#define DEFAULT_GC_GAIN_GAP_CACC
The car-following model and parameter.
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double myCollisionAvoidanceGainGapDot
double getMaxSpeed() const
Returns the maximum speed.
double myGapClosingControlGainGapDot
double speedSpeedContol(const double speed, double vErr) const
#define DEFAULT_GCC_GAIN_GAP_CACC
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points...
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
The ACC car-following model.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
#define DEFAULT_SC_GAIN_CACC
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
double myCollisionAvoidanceGainGap
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)
double getMinGap() const
Get the free space in front of vehicles of this class.
MSCFModel_CACC(const MSVehicleType *vtype)
Constructor.
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
const SUMOVTypeParameter & getParameter() const
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.
#define DEFAULT_GC_GAIN_GAP_DOT_CACC
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
~MSCFModel_CACC()
Destructor.
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
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_CA_GAIN_GAP_DOT_CACC
double myGapControlGainGap
#define DEFAULT_CA_GAIN_GAP_CACC
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
double _v(const MSVehicle *const veh, const double gap2pred, const double mySpeed, const double predSpeed, const double desSpeed, const bool respectMinGap=true) const
double myGapClosingControlGainGap
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
double speedGapControl(const MSVehicle *const veh, const double gap2pred, const double speed, const double predSpeed, const double desSpeed, double vErr) const
double mySpeedControlGain
const std::string & getID() const
Returns the name of the vehicle.
double myGapControlGainGapDot
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) ...
#define DEFAULT_GCC_GAIN_GAP_DOT_CACC