Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSCFModel_CC.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// A series of automatic Cruise Controllers (CC, ACC, CACC)
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include "CC_Const.h"
25#include <microsim/MSLane.h>
26#include <microsim/MSVehicle.h>
30#include <string.h>
31
35
36#include "CC_VehicleVariables.h"
37#include <libsumo/Helper.h>
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
57class MSCFModel_CC : public MSCFModel {
58public:
59
75 MSCFModel_CC(const MSVehicleType* vtype);
76
79
80 virtual double getSecureGap(const MSVehicle* const veh, const MSVehicle* const /*pred*/, const double speed, const double leaderSpeed, const double leaderMaxDecel) const;
81
84
90 virtual double finalizeSpeed(MSVehicle* const veh, double vPos) const;
91
92
101 double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed,
102 double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
103
109 virtual double insertionFollowSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
110
111
119 double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
120
133 virtual double freeSpeed(const MSVehicle* const veh, double speed, double seen,
134 double maxSpeed, const bool onInsertion = false, const CalcReason usage = CalcReason::CURRENT) const;
135
136 virtual double maxNextSpeed(double speed, const MSVehicle* const veh) const;
137
138 virtual double minNextSpeed(double speed, const MSVehicle* const veh = 0) const;
139
140
150 double interactionGap(const MSVehicle* const, double vL) const;
151
152
157 int getModelID() const {
158 return SUMO_TAG_CF_CC;
159 }
161
162
163
168 MSCFModel* duplicate(const MSVehicleType* vtype) const;
169
170 VehicleVariables* createVehicleVariables() const;
171
178 double getCACCConstantSpacing(const MSVehicle* veh) const;
179
191// void setVehicleInformation(const MSVehicle* veh, double speed, double acceleration, Position position, double time) const;
192
200 virtual std::string getParameter(const MSVehicle* veh, const std::string& key) const;
201
209 virtual void setParameter(MSVehicle* veh, const std::string& key, const std::string& value) const;
210
223 void getVehicleInformation(const MSVehicle* veh, double& speed, double& acceleration, double& controllerAcceleration, Position& position, double& time) const;
224
231 void switchOnACC(const MSVehicle* veh, double ccDesiredSpeed) const;
232
240
244 void getRadarMeasurements(const MSVehicle* veh, double& distance, double& relativeSpeed) const;
245
251 double getACCAcceleration(const MSVehicle* veh) const;
252
263 int isPlatoonLaneChangeSafe(const MSVehicle* veh, bool left) const;
264
271 void setLeader(MSVehicle* veh, MSVehicle* const leader, std::string leaderId) const;
272
279 bool isLeader(const MSVehicle* veh) const;
280
294 int commitToLaneChange(const MSVehicle* veh, bool left) const;
295
302 MSVehicle* findVehicle(std::string id) const;
303
307 int getMyLanesCount() const;
308
309private:
310
314 void recomputeParameters(const MSVehicle* veh) const;
315
321 void resetConsensus(const MSVehicle* veh) const;
322
323private:
329 void changeWholePlatoonLane(MSVehicle* const veh, int direction) const;
330
337 void performAutoLaneChange(MSVehicle* const veh) const;
338
345 void performPlatoonLaneChange(MSVehicle* const veh) const;
346
347 double _v(const MSVehicle* const veh, double gap2pred, double egoSpeed, double predSpeed) const;
348
355 double _cc(const MSVehicle* veh, double egoSpeed, double desSpeed) const;
356
365 double _acc(const MSVehicle* veh, double egoSpeed, double predSpeed, double gap2pred, double headwayTime) const;
366
378 double _cacc(const MSVehicle* veh, double egoSpeed, double predSpeed, double predAcceleration, double gap2pred, double leaderSpeed, double leaderAcceleration, double spacing) const;
379
390 double _ploeg(const MSVehicle* veh, double egoSpeed, double predSpeed, double predAcceleration, double gap2pred) const;
391
399 double _consensus(const MSVehicle* veh, double egoSpeed, Position egoPosition, double time) const;
400
410 double d_i_j(const struct Plexe::VEHICLE_DATA* vehicles, const double h[MAX_N_CARS], int i, int j) const;
411
420 double _flatbed(const MSVehicle* veh, double egoAcceleration, double egoSpeed, double predSpeed,
421 double gap2pred, double leaderSpeed) const;
422
423
424private:
425
428
430 const double myCcDecel;
431
433 const double myCcAccel;
434
436 const double myConstantSpacing;
437
439 const double myKp;
440
442 const double myLambda;
443
445 const double myC1;
446
448 const double myXi;
449
451 const double myOmegaN;
452
454 const double myTau;
455
458 const int myLanesCount;
459
461 const double myPloegH;
462 const double myPloegKp;
463 const double myPloegKd;
464
466 const double myFlatbedKa;
467 const double myFlatbedKv;
468 const double myFlatbedKp;
469 const double myFlatbedH;
470 const double myFlatbedD;
471
472private:
475};
#define MAX_N_CARS
Definition CC_Const.h:77
@ SUMO_TAG_CF_CC
A set of automatic Cruise Controllers, including classic Cruise Control (CC), Adaptive Cruise Control...
double _v(const MSVehicle *const veh, double gap2pred, double egoSpeed, double predSpeed) const
virtual std::string getParameter(const MSVehicle *veh, const std::string &key) const
set the information about a generic car. This method should be invoked by TraCI when a wireless messa...
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Overload base MSCFModel::insertionFollowSpeed method to inject automated vehicles as soon as they are...
const double myPloegKd
const double myFlatbedH
const double myFlatbedKp
const double myPloegH
Ploeg's CACC parameters.
double getACCAcceleration(const MSVehicle *veh) const
returns the ACC computed acceleration when the faked CACC is controlling the car. This can be used to...
int getModelID() const
Returns the model's name.
bool isLeader(const MSVehicle *veh) const
Returns whether a vehicle is a leader of a platoon or not. By default, a vehicle on its own using an ...
int getMyLanesCount() const
returns the number of lanes set in the configuration file
double _flatbed(const MSVehicle *veh, double egoAcceleration, double egoSpeed, double predSpeed, double gap2pred, double leaderSpeed) const
flatbed platoon towing model
void getVehicleInformation(const MSVehicle *veh, double &speed, double &acceleration, double &controllerAcceleration, Position &position, double &time) const
get the information about a vehicle. This can be used by TraCI in order to get speed and acceleration...
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
virtual double getSecureGap(const MSVehicle *const veh, 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)
VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
MSVehicle * findVehicle(std::string id) const
void getRadarMeasurements(const MSVehicle *veh, double &distance, double &relativeSpeed) const
return the data that is currently being measured by the radar
double _consensus(const MSVehicle *veh, double egoSpeed, Position egoPosition, double time) const
controller based on consensus strategy
const double myPloegKp
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 _ploeg(const MSVehicle *veh, double egoSpeed, double predSpeed, double predAcceleration, double gap2pred) const
controller for the Ploeg's CACC which computes the control input variation. Opposed to other controll...
void performPlatoonLaneChange(MSVehicle *const veh) const
If safe to do so, moves a platoon to a user-desired lane. If not safe, this method continues to try a...
void changeWholePlatoonLane(MSVehicle *const veh, int direction) const
Moves an entire platoon on an adjacent lane, calling changeLane() on all members.
const double myTau
engine time constant used for actuation lag
double d_i_j(const struct Plexe::VEHICLE_DATA *vehicles, const double h[MAX_N_CARS], int i, int j) const
computes the desired distance between vehicle i and vehicle j
const double myOmegaN
design constant for CACC
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)
const double myC1
design constant for CACC
const int myLanesCount
number of lanes in the highway, in the absence of on-/off-ramps. This is used to move to the correct ...
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
double _cacc(const MSVehicle *veh, double egoSpeed, double predSpeed, double predAcceleration, double gap2pred, double leaderSpeed, double leaderAcceleration, double spacing) const
controller for the CACC which computes the acceleration to be applied. the value needs to be passed t...
virtual void setParameter(MSVehicle *veh, const std::string &key, const std::string &value) const
try to set the given parameter for this carFollowingModel
const double myConstantSpacing
the constant gap for CACC
double getCACCConstantSpacing(const MSVehicle *veh) const
returns CACC desired constant spacing
~MSCFModel_CC()
Destructor.
const double myFlatbedKv
void recomputeParameters(const MSVehicle *veh) const
Recomputes controller related parameters after setting them.
const double myXi
design constant for CACC
const double myFlatbedKa
flatbed CACC parameters
void switchOnACC(const MSVehicle *veh, double ccDesiredSpeed) const
switch on the ACC, so disabling the human driver car control
int commitToLaneChange(const MSVehicle *veh, bool left) const
MSCFModel * myHumanDriver
the car following model which drives the car when automated cruising is disabled, i....
const double myLambda
design constant for ACC
void performAutoLaneChange(MSVehicle *const veh) const
Check whether a platoon would gain speed by moving to the left or whether it should move to the right...
void setLeader(MSVehicle *veh, MSVehicle *const leader, std::string leaderId) const
Sets the leader for a member of the platoon.
const double myKp
design constant for CC
virtual double minNextSpeed(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
MSCFModel_CC & operator=(const MSCFModel_CC &)=delete
Invalidated assignment operator.
const double myCcAccel
The maximum acceleration that the CC can output.
int isPlatoonLaneChangeSafe(const MSVehicle *veh, bool left) const
computes whether a lane change for a whole platoon is safe or not. This is done by checking the lane ...
virtual 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.
const double myCcDecel
The maximum deceleration that the CC can output.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
const double myFlatbedD
void resetConsensus(const MSVehicle *veh) const
Resets the consensus controller. In particular, sets the "initialized" vector all to false....
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
enum Plexe::ACTIVE_CONTROLLER getActiveController(const MSVehicle *veh) const
return the currently active controller
double _cc(const MSVehicle *veh, double egoSpeed, double desSpeed) const
controller for the CC which computes the acceleration to be applied. the value needs to be passed to ...
double _acc(const MSVehicle *veh, double egoSpeed, double predSpeed, double gap2pred, double headwayTime) const
controller for the ACC which computes the acceleration to be applied. the value needs to be passed to...
The car-following model abstraction.
Definition MSCFModel.h:55
CalcReason
What the return value of stop/follow/free-Speed is used for.
Definition MSCFModel.h:77
@ CURRENT
the return value is used for calculating the next speed
Definition MSCFModel.h:79
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
The car-following model and parameter.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
ACTIVE_CONTROLLER
Determines the currently active controller, i.e., ACC, CACC, or the driver. In future we might need t...
Definition CC_Const.h:49