Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_Bluelight.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2025 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/****************************************************************************/
21// A device for emergency vehicle. The behaviour of other traffic participants will be triggered with this device.
22// For example building a rescue lane.
23/****************************************************************************/
24#include <config.h>
25
31#include <microsim/MSNet.h>
32#include <microsim/MSLane.h>
33#include <microsim/MSEdge.h>
34#include <microsim/MSLink.h>
35#include <microsim/MSVehicle.h>
39#include "MSDevice_Tripinfo.h"
40#include "MSDevice_Bluelight.h"
41
42//#define DEBUG_BLUELIGHT
43//#define DEBUG_BLUELIGHT_RESCUELANE
44
45#define INFLUENCED_BY "rescueLane"
46
47// ===========================================================================
48// method definitions
49// ===========================================================================
50// ---------------------------------------------------------------------------
51// static initialisation methods
52// ---------------------------------------------------------------------------
53void
55 oc.addOptionSubTopic("Bluelight Device");
56 insertDefaultAssignmentOptions("bluelight", "Bluelight Device", oc);
57
58 oc.doRegister("device.bluelight.reactiondist", new Option_Float(25.0));
59 oc.addDescription("device.bluelight.reactiondist", "Bluelight Device", TL("Set the distance at which other drivers react to the blue light and siren sound"));
60 oc.doRegister("device.bluelight.mingapfactor", new Option_Float(1.));
61 oc.addDescription("device.bluelight.mingapfactor", "Bluelight Device", TL("Reduce the minGap for reacting vehicles by the given factor"));
62}
63
64
65void
66MSDevice_Bluelight::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
68 if (equippedByDefaultAssignmentOptions(oc, "bluelight", v, false)) {
70 WRITE_WARNINGF(TL("bluelight device is not compatible with mesosim (ignored for vehicle '%')"), v.getID());
71 } else {
72 MSDevice_Bluelight* device = new MSDevice_Bluelight(v, "bluelight_" + v.getID(),
73 v.getFloatParam("device.bluelight.reactiondist"),
74 v.getFloatParam("device.bluelight.mingapfactor"));
75 into.push_back(device);
76 }
77 }
78}
79
80
81// ---------------------------------------------------------------------------
82// MSDevice_Bluelight-methods
83// ---------------------------------------------------------------------------
85 const double reactionDist, const double minGapFactor) :
86 MSVehicleDevice(holder, id),
87 myReactionDist(reactionDist),
88 myMinGapFactor(minGapFactor) {
89#ifdef DEBUG_BLUELIGHT
90 std::cout << SIMTIME << " initialized device '" << id << "' with myReactionDist=" << myReactionDist << "\n";
91#endif
92 // set only once to permit TraCI override
93 MSVehicle& veh = dynamic_cast<MSVehicle&>(holder);
95}
96
97
100
101
102bool
104 double /* newPos */, double newSpeed) {
105#ifdef DEBUG_BLUELIGHT
106 std::cout << SIMTIME << " device '" << getID() << "' notifyMove: newSpeed=" << newSpeed << "\n";
107#else
108 UNUSED_PARAMETER(newSpeed);
109#endif
110 //violate red lights this only need to be done once so shift it todo
111 MSVehicle& ego = dynamic_cast<MSVehicle&>(veh);
112 MSVehicle::Influencer& redLight = ego.getInfluencer();
113 const double vMax = ego.getLane()->getVehicleMaxSpeed(&ego);
114 if (ego.getSpeed() < 0.5 * vMax) {
115 // advance as far as possible (assume vehicles will keep moving out of the way)
119 try {
121 } catch (InvalidArgument&) {
122 // not supported by the current laneChangeModel
123 }
124 } else {
125 // restore defaults
132 try {
135 } catch (InvalidArgument&) {
136 // not supported by the current laneChangeModel
137 }
138 }
139 // build a rescue lane for all vehicles on the route of the emergency vehicle within the range of the siren
141 // use edges on the way of the emergency vehicle
142 std::vector<const MSEdge*> upcomingEdges;
143 std::set<MSVehicle*, ComparatorIdLess> upcomingVehicles;
144 std::set<std::string> lastStepInfluencedVehicles = myInfluencedVehicles;
145 std::vector<MSLink*> upcomingLinks;
146 double affectedJunctionDist = ego.getPositionOnLane() + myReactionDist;
147 for (const MSLane* const l : ego.getUpcomingLanesUntil(myReactionDist)) {
148 upcomingEdges.push_back(&l->getEdge());
149
150 affectedJunctionDist -= l->getLength();
151 if (affectedJunctionDist > 0 && l->isInternal()) {
152 upcomingLinks.push_back(l->getIncomingLanes()[0].viaLink);
153 }
154 }
155
156 for (const MSEdge* const e : upcomingEdges) {
157 //inform all vehicles on upcomingEdges
158 for (const SUMOVehicle* v : e->getVehicles()) {
159 upcomingVehicles.insert(dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(v)));
160 if (lastStepInfluencedVehicles.count(v->getID()) > 0) {
161 lastStepInfluencedVehicles.erase(v->getID());
162 }
163 }
164 }
165 // reset all vehicles that were in myInfluencedVehicles in the previous step but not in the current step todo refactor
166 for (std::string vehID : lastStepInfluencedVehicles) {
167 myInfluencedVehicles.erase(vehID);
168 Parameterised::Map::iterator it = myInfluencedTypes.find(vehID);
169 MSVehicle* veh2 = dynamic_cast<MSVehicle*>(vc.getVehicle(vehID));
170 if (veh2 != nullptr && it != myInfluencedTypes.end()) {
171 // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
172 resetVehicle(veh2, it->second);
173 }
174 }
175
176 for (MSVehicle* veh2 : upcomingVehicles) {
177 assert(veh2 != nullptr);
178 if (veh2->getLane() == nullptr) {
179 continue;
180 }
181 if (std::find(upcomingEdges.begin(), upcomingEdges.end(), &veh2->getLane()->getEdge()) != upcomingEdges.end()) {
182 if (veh2->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
183 // emergency vehicles should not react
184 continue;
185 }
186 const int numLanes = (int)veh2->getLane()->getEdge().getNumLanes();
187 // make sure that vehicles are still building the rescue lane as they might have moved to a new edge or changed lanes
188 if (myInfluencedVehicles.count(veh2->getID()) > 0) {
189 // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
190 MSVehicleType& t = veh2->getSingularType();
191 // Setting the lateral alignment to build a rescue lane
193 if (veh2->getLane()->getIndex() == numLanes - 1) {
195 }
197#ifdef DEBUG_BLUELIGHT_RESCUELANE
198 std::cout << "Refresh alignment for vehicle: " << veh2->getID()
199 << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
200 << " alignment=" << toString(align) << "\n";
201#endif
202 }
203
204 double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
205 //emergency vehicle has to slow down when entering the rescue lane
206 if (distanceDelta <= 10 && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) > 0 && veh2->getSpeed() < 1) {
207 // set ev speed to 20 km/h 0 5.56 m/s
208 const double redSpeed = ego.getVehicleType().getParameter().getJMParam(SUMO_ATTR_JM_DRIVE_RED_SPEED, 5.56);
209 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
210 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed()));
211 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(2), redSpeed));
212 redLight.setSpeedTimeLine(speedTimeLine);
213 }
214
215 // the perception of the sound of the siren should be around 25 meters
216 // todo only vehicles in front of the emergency vehicle should react
217 if (distanceDelta <= myReactionDist && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) == 0) {
218 // only a percentage of vehicles should react to the emergency vehicle to make the behaviour more realistic
219 double reaction = RandHelper::rand();
220 MSVehicle::Influencer& lanechange = veh2->getInfluencer();
221
222 //other vehicle should not use the rescue lane so they should not make any lane changes
223 lanechange.setLaneChangeMode(1605);//todo change lane back
224 // the vehicles should react according to the distance to the emergency vehicle taken from real world data
225 double reactionProb = (
226 distanceDelta < myHolder.getFloatParam("device.bluelight.near-dist", false, 12.5)
227 ? myHolder.getFloatParam("device.bluelight.reaction-prob-near", false, 0.577)
228 : myHolder.getFloatParam("device.bluelight.reaction-prob-far", false, 0.189));
229 // todo works only for one second steps
230 //std::cout << SIMTIME << " veh2=" << veh2->getID() << " distanceDelta=" << distanceDelta << " reaction=" << reaction << " reactionProb=" << reactionProb << "\n";
231 if (veh2->isActionStep(SIMSTEP) && reaction < reactionProb * veh2->getActionStepLengthSecs()) {
232 myInfluencedVehicles.insert(veh2->getID());
233 myInfluencedTypes.insert(std::make_pair(veh2->getID(), veh2->getVehicleType().getID()));
234 if (myMinGapFactor != 1.) {
235 // TODO this is a permanent change to the vtype!
237 }
238
239 // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
240 MSVehicleType& t = veh2->getSingularType();
241 // Setting the lateral alignment to build a rescue lane
243 if (veh2->getLane()->getIndex() == numLanes - 1) {
245 }
249 // disable strategic lane-changing
250#ifdef DEBUG_BLUELIGHT_RESCUELANE
251 std::cout << SIMTIME << " device=" << getID() << " formingRescueLane=" << veh2->getID()
252 << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
253 << " alignment=" << toString(align) << "\n";
254#endif
255 std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
256 if (std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID()) == influencedBy.end()) {
257 influencedBy.push_back(myHolder.getID());
258 const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
259 }
260 veh2->getLaneChangeModel().setParameter(toString(SUMO_ATTR_LCA_STRATEGIC_PARAM), "-1");
261 }
262 }
263
264 } else { //if vehicle is passed all vehicles which had to react should get their state back after they leave the communication range
265 if (myInfluencedVehicles.count(veh2->getID()) > 0) {
266 double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
267 if (distanceDelta > myReactionDist && veh.getID() != veh2->getID()) {
268 myInfluencedVehicles.erase(veh2->getID());
269 Parameterised::Map::iterator it = myInfluencedTypes.find(veh2->getID());
270 if (it != myInfluencedTypes.end()) {
271 // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
272 resetVehicle(veh2, it->second);
273 }
274 }
275 }
276 }
277 }
278 // make upcoming junction foes slow down
279 for (MSLink* link : upcomingLinks) {
280 auto avi = link->getApproaching(&ego);
281 MSLink::BlockingFoes blockingFoes;
282 link->opened(avi.arrivalTime, avi.arrivalSpeed, avi.arrivalSpeed, ego.getLength(),
283 0, ego.getCarFollowModel().getMaxDecel(), ego.getWaitingTime(), ego.getLateralPositionOnLane(), &blockingFoes, true, &ego);
284 const SUMOTime timeToArrival = avi.arrivalTime - SIMSTEP;
285 for (const SUMOTrafficObject* foe : blockingFoes) {
286 if (!foe->isVehicle()) {
287 continue;
288 }
289 const double dist = ego.getPosition().distanceTo2D(foe->getPosition());
290 if (dist < myReactionDist) {
291 MSVehicle* microFoe = dynamic_cast<MSVehicle*>(const_cast<SUMOTrafficObject*>(foe));
292 if (microFoe->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
293 // emergency vehicles should not react
294 continue;
295 }
296 const double timeToBrake = foe->getSpeed() / SUMOVTypeParameter::getDefaultDecel();
297 if (timeToArrival < TIME2STEPS(timeToBrake + 1)) {
298 // trigger emergency braking
299 const double decel = 0.5 * foe->getSpeed() * foe->getSpeed() / avi.dist;
300 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
301 speedTimeLine.push_back(std::make_pair(SIMSTEP, foe->getSpeed()));
302 speedTimeLine.push_back(std::make_pair(SIMSTEP + TIME2STEPS(foe->getSpeed() / decel), 0));
303 microFoe->getInfluencer().setSpeedTimeLine(speedTimeLine);
304 //std::cout << SIMTIME << " foe=" << foe->getID() << " timeToBrake=" << timeToBrake << " timeToArrival=" << STEPS2TIME(timeToArrival) << " decel=" << decel << "\n";
305 }
306 }
307 }
308 }
309 return true; // keep the device
310}
311
312
313void
314MSDevice_Bluelight::resetVehicle(MSVehicle* veh2, const std::string& targetTypeID) {
315 MSVehicleType* targetType = MSNet::getInstance()->getVehicleControl().getVType(targetTypeID);
316 //targetType is nullptr if the vehicle type has already changed to its old vehicleType
317 if (targetType != nullptr) {
318#ifdef DEBUG_BLUELIGHT_RESCUELANE
319 std::cout << SIMTIME << " device=" << getID() << " reset " << veh2->getID() << "\n";
320#endif
321
322 std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
323 auto it = std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID());
324 if (it != influencedBy.end()) {
325 influencedBy.erase(it);
326 const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
327 }
328 if (influencedBy.size() == 0) {
329 veh2->replaceVehicleType(targetType);
332 }
333 }
334}
335
336
337
338bool
340 UNUSED_PARAMETER(veh);
341#ifdef DEBUG_BLUELIGHT
342 std::cout << SIMTIME << " device '" << getID() << "' notifyEnter: reason=" << toString(reason) << " enteredLane=" << Named::getIDSecure(enteredLane) << "\n";
343#else
344 UNUSED_PARAMETER(reason);
345 UNUSED_PARAMETER(enteredLane);
346#endif
347 return true; // keep the device
348}
349
350
351bool
352MSDevice_Bluelight::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* enteredLane) {
353 UNUSED_PARAMETER(veh);
354#ifdef DEBUG_BLUELIGHT
355 std::cout << SIMTIME << " device '" << getID() << "' notifyLeave: reason=" << toString(reason) << " approachedLane=" << Named::getIDSecure(enteredLane) << "\n";
356#else
357 UNUSED_PARAMETER(reason);
358 UNUSED_PARAMETER(enteredLane);
359#endif
360 return true; // keep the device
361}
362
363
364void
366 if (tripinfoOut != nullptr) {
367 tripinfoOut->openTag("bluelight");
368 tripinfoOut->closeTag();
369 }
370}
371
372std::string
373MSDevice_Bluelight::getParameter(const std::string& key) const {
374 if (key == "reactiondist") {
375 return toString(myReactionDist);
376 }
377 throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
378}
379
380
381void
382MSDevice_Bluelight::setParameter(const std::string& key, const std::string& value) {
383 double doubleValue;
384 try {
385 doubleValue = StringUtils::toDouble(value);
386 } catch (NumberFormatException&) {
387 throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
388 }
389 if (key == "reactiondist") {
390 myReactionDist = doubleValue;
391 } else {
392 throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
393 }
394}
395
396
397/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define INFLUENCED_BY
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:304
#define SIMSTEP
Definition SUMOTime.h:61
#define SIMTIME
Definition SUMOTime.h:62
#define TIME2STEPS(x)
Definition SUMOTime.h:57
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
@ RIGHT
drive on the right side
@ LEFT
drive on the left side
@ SUMO_ATTR_JM_STOPLINE_GAP
@ SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD
@ SUMO_ATTR_LCA_SPEEDGAIN_REMAIN_TIME
@ SUMO_ATTR_MINGAP_LAT
@ SUMO_ATTR_LCA_STRATEGIC_PARAM
@ SUMO_ATTR_JM_DRIVE_RED_SPEED
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getLength() const
Returns the vehicle's length.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
void setCollisionMinGapFactor(const double factor)
Sets a new value for the factor of minGap that must be maintained to avoid a collision event.
Definition MSCFModel.h:588
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition MSCFModel.h:269
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
std::set< std::string > myInfluencedVehicles
MSDevice_Bluelight(SUMOVehicle &holder, const std::string &id, const double reactionDist, const double minGapFactor)
Constructor.
double myMinGapFactor
min gap reduction of other vehicles
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Bluelight-options.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
void resetVehicle(MSVehicle *veh2, const std::string &targetTypeID)
restore type of influenced vehicle
double myReactionDist
reaction distance of other vehicle (i.e. due to different noise levels of the siren)
Parameterised::Map myInfluencedTypes
~MSDevice_Bluelight()
Destructor.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
const std::string deviceName() const
return the name for this type of device
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition MSDevice.cpp:157
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition MSDevice.h:200
A road/street connecting two junctions.
Definition MSEdge.h:77
static bool gUseMesoSim
Definition MSGlobals.h:106
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:574
Notification
Definition of a vehicle state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:392
Changes the wished vehicle speed / lanes.
Definition MSVehicle.h:1349
void setLaneChangeMode(int value)
Sets lane changing behavior.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition MSVehicle.h:670
MSAbstractLaneChangeModel & getLaneChangeModel()
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
void replaceVehicleType(const MSVehicleType *type)
Replaces the current vehicle type by the one given.
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MSVehicle.h:581
Influencer & getInfluencer()
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition MSVehicle.h:413
double getSpeed() const
Returns the vehicle's current speed.
Definition MSVehicle.h:490
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition MSVehicle.h:969
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MSVehicle.h:374
The car-following model and parameter.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getMinGap() const
Get the free space in front of vehicles of this class.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
const SUMOVTypeParameter & getParameter() const
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition Named.h:67
const std::string & getID() const
Returns the id.
Definition Named.h:74
A storage for options typed value containers)
Definition OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:263
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
double getFloatParam(const std::string &paramName, const bool required=false, const double deflt=INVALID_DOUBLE, bool checkDist=true) const
Retrieve a floating point parameter for the traffic object.
Structure representing possible vehicle parameter.
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
std::string getLCParamString(const SumoXMLAttr attr, const std::string &defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
Representation of a vehicle.
Definition SUMOVehicle.h:62
Structure representing possible vehicle parameter.
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
#define UNUSED_PARAMETER(x)