Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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}
93
94
97
98
99bool
101 double /* newPos */, double newSpeed) {
102#ifdef DEBUG_BLUELIGHT
103 std::cout << SIMTIME << " device '" << getID() << "' notifyMove: newSpeed=" << newSpeed << "\n";
104#else
105 UNUSED_PARAMETER(newSpeed);
106#endif
107 //violate red lights this only need to be done once so shift it todo
108 MSVehicle& ego = dynamic_cast<MSVehicle&>(veh);
109 MSVehicle::Influencer& redLight = ego.getInfluencer();
110 const double vMax = ego.getLane()->getVehicleMaxSpeed(&ego);
111 redLight.setSpeedMode(7);
112 if (ego.getSpeed() < 0.5 * vMax) {
113 // advance as far as possible (assume vehicles will keep moving out of the way)
117 try {
119 } catch (InvalidArgument&) {
120 // not supported by the current laneChangeModel
121 }
122 } else {
123 // restore defaults
130 try {
133 } catch (InvalidArgument&) {
134 // not supported by the current laneChangeModel
135 }
136 }
137 // 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 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
209 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed()));
210 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(2), 5.56));
211 redLight.setSpeedTimeLine(speedTimeLine);
212 }
213
214 // the perception of the sound of the siren should be around 25 meters
215 // todo only vehicles in front of the emergency vehicle should react
216 if (distanceDelta <= myReactionDist && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) == 0) {
217 // only a percentage of vehicles should react to the emergency vehicle to make the behaviour more realistic
218 double reaction = RandHelper::rand();
219 MSVehicle::Influencer& lanechange = veh2->getInfluencer();
220
221 //other vehicle should not use the rescue lane so they should not make any lane changes
222 lanechange.setLaneChangeMode(1605);//todo change lane back
223 // the vehicles should react according to the distance to the emergency vehicle taken from real world data
224 double reactionProb = (
225 distanceDelta < myHolder.getFloatParam("device.bluelight.near-dist", false, 12.5)
226 ? myHolder.getFloatParam("device.bluelight.reaction-prob-near", false, 0.577)
227 : myHolder.getFloatParam("device.bluelight.reaction-prob-far", false, 0.189));
228 // todo works only for one second steps
229 //std::cout << SIMTIME << " veh2=" << veh2->getID() << " distanceDelta=" << distanceDelta << " reaction=" << reaction << " reactionProb=" << reactionProb << "\n";
230 if (veh2->isActionStep(SIMSTEP) && reaction < reactionProb * veh2->getActionStepLengthSecs()) {
231 myInfluencedVehicles.insert(veh2->getID());
232 myInfluencedTypes.insert(std::make_pair(veh2->getID(), veh2->getVehicleType().getID()));
233 if (myMinGapFactor != 1.) {
234 // TODO this is a permanent change to the vtype!
236 }
237
238 // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
239 MSVehicleType& t = veh2->getSingularType();
240 // Setting the lateral alignment to build a rescue lane
242 if (veh2->getLane()->getIndex() == numLanes - 1) {
244 }
248 // disable strategic lane-changing
249#ifdef DEBUG_BLUELIGHT_RESCUELANE
250 std::cout << SIMTIME << " device=" << getID() << " formingRescueLane=" << veh2->getID()
251 << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
252 << " alignment=" << toString(align) << "\n";
253#endif
254 std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
255 if (std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID()) == influencedBy.end()) {
256 influencedBy.push_back(myHolder.getID());
257 const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
258 }
259 veh2->getLaneChangeModel().setParameter(toString(SUMO_ATTR_LCA_STRATEGIC_PARAM), "-1");
260 }
261 }
262
263 } else { //if vehicle is passed all vehicles which had to react should get their state back after they leave the communication range
264 if (myInfluencedVehicles.count(veh2->getID()) > 0) {
265 double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
266 if (distanceDelta > myReactionDist && veh.getID() != veh2->getID()) {
267 myInfluencedVehicles.erase(veh2->getID());
268 Parameterised::Map::iterator it = myInfluencedTypes.find(veh2->getID());
269 if (it != myInfluencedTypes.end()) {
270 // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
271 resetVehicle(veh2, it->second);
272 }
273 }
274 }
275 }
276 }
277 // make upcoming junction foes slow down
278 for (MSLink* link : upcomingLinks) {
279 auto avi = link->getApproaching(&ego);
280 MSLink::BlockingFoes blockingFoes;
281 link->opened(avi.arrivalTime, avi.arrivalSpeed, avi.arrivalSpeed, ego.getLength(),
282 0, ego.getCarFollowModel().getMaxDecel(), ego.getWaitingTime(), ego.getLateralPositionOnLane(), &blockingFoes, true, &ego);
283 const SUMOTime timeToArrival = avi.arrivalTime - SIMSTEP;
284 for (const SUMOTrafficObject* foe : blockingFoes) {
285 if (!foe->isVehicle()) {
286 continue;
287 }
288 const double dist = ego.getPosition().distanceTo2D(foe->getPosition());
289 if (dist < myReactionDist) {
290 MSVehicle* microFoe = dynamic_cast<MSVehicle*>(const_cast<SUMOTrafficObject*>(foe));
291 if (microFoe->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
292 // emergency vehicles should not react
293 continue;
294 }
295 const double timeToBrake = foe->getSpeed() / SUMOVTypeParameter::getDefaultDecel();
296 if (timeToArrival < TIME2STEPS(timeToBrake + 1)) {
297 // trigger emergency braking
298 const double decel = 0.5 * foe->getSpeed() * foe->getSpeed() / avi.dist;
299 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
300 speedTimeLine.push_back(std::make_pair(SIMSTEP, foe->getSpeed()));
301 speedTimeLine.push_back(std::make_pair(SIMSTEP + TIME2STEPS(foe->getSpeed() / decel), 0));
302 microFoe->getInfluencer().setSpeedTimeLine(speedTimeLine);
303 //std::cout << SIMTIME << " foe=" << foe->getID() << " timeToBrake=" << timeToBrake << " timeToArrival=" << STEPS2TIME(timeToArrival) << " decel=" << decel << "\n";
304 }
305 }
306 }
307 }
308
309 // ego is at the end of its current lane and cannot continue
310 const double distToEnd = ego.getLane()->getLength() - ego.getPositionOnLane();
311 //std::cout << SIMTIME << " " << getID() << " lane=" << ego.getLane()->getID() << " pos=" << ego.getPositionOnLane() << " distToEnd=" << distToEnd << " conts=" << toString(ego.getBestLanesContinuation()) << " furtherEdges=" << upcomingEdges.size() << "\n";
312 if (ego.getBestLanesContinuation().size() == 1 && distToEnd <= POSITION_EPS
313 // route continues
314 && upcomingEdges.size() > 1) {
315 const MSEdge* currentEdge = &ego.getLane()->getEdge();
316 // move onto the intersection as if there was a connection from the current lane
317 const MSEdge* next = currentEdge->getInternalFollowingEdge(upcomingEdges[1], ego.getVClass());
318 if (next == nullptr) {
319 next = upcomingEdges[1];
320 }
321 // pick the lane that causes the minimizes lateral jump
322 const std::vector<MSLane*>* allowed = next->allowedLanes(ego.getVClass());
323 MSLane* nextLane = next->getLanes().front();
324 double bestJump = std::numeric_limits<double>::max();
325 double newPosLat = 0;
326 if (allowed != nullptr) {
327 for (MSLane* nextCand : *allowed) {
328 for (auto ili : nextCand->getIncomingLanes()) {
329 if (&ili.lane->getEdge() == currentEdge) {
330 double jump = fabs(ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane());
331 if (jump < bestJump) {
332 //std::cout << SIMTIME << " nextCand=" << nextCand->getID() << " from=" << ili.lane->getID() << " jump=" << jump << "\n";
333 bestJump = jump;
334 nextLane = nextCand;
335 // stay within newLane
336 const double maxVehOffset = MAX2(0.0, nextLane->getWidth() - ego.getVehicleType().getWidth()) * 0.5;
337 newPosLat = ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane();
338 newPosLat = MAX2(-maxVehOffset, newPosLat);
339 newPosLat = MIN2(maxVehOffset, newPosLat);
340 }
341 }
342 }
343 }
344 }
345 ego.leaveLane(NOTIFICATION_JUNCTION, nextLane);
348 ego.setTentativeLaneAndPosition(nextLane, 0, newPosLat); // update position
349 ego.enterLaneAtMove(nextLane);
350 // sublane model must adapt state to the new lane
352 }
353 return true; // keep the device
354}
355
356
357void
358MSDevice_Bluelight::resetVehicle(MSVehicle* veh2, const std::string& targetTypeID) {
359 MSVehicleType* targetType = MSNet::getInstance()->getVehicleControl().getVType(targetTypeID);
360 //targetType is nullptr if the vehicle type has already changed to its old vehicleType
361 if (targetType != nullptr) {
362#ifdef DEBUG_BLUELIGHT_RESCUELANE
363 std::cout << SIMTIME << " device=" << getID() << " reset " << veh2->getID() << "\n";
364#endif
365
366 std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
367 auto it = std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID());
368 if (it != influencedBy.end()) {
369 influencedBy.erase(it);
370 const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
371 }
372 if (influencedBy.size() == 0) {
373 veh2->replaceVehicleType(targetType);
376 }
377 }
378}
379
380
381
382bool
384 UNUSED_PARAMETER(veh);
385#ifdef DEBUG_BLUELIGHT
386 std::cout << SIMTIME << " device '" << getID() << "' notifyEnter: reason=" << toString(reason) << " enteredLane=" << Named::getIDSecure(enteredLane) << "\n";
387#else
388 UNUSED_PARAMETER(reason);
389 UNUSED_PARAMETER(enteredLane);
390#endif
391 return true; // keep the device
392}
393
394
395bool
396MSDevice_Bluelight::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* enteredLane) {
397 UNUSED_PARAMETER(veh);
398#ifdef DEBUG_BLUELIGHT
399 std::cout << SIMTIME << " device '" << getID() << "' notifyLeave: reason=" << toString(reason) << " approachedLane=" << Named::getIDSecure(enteredLane) << "\n";
400#else
401 UNUSED_PARAMETER(reason);
402 UNUSED_PARAMETER(enteredLane);
403#endif
404 return true; // keep the device
405}
406
407
408void
410 if (tripinfoOut != nullptr) {
411 tripinfoOut->openTag("bluelight");
412 tripinfoOut->closeTag();
413 }
414}
415
416std::string
417MSDevice_Bluelight::getParameter(const std::string& key) const {
418 if (key == "reactiondist") {
419 return toString(myReactionDist);
420 }
421 throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
422}
423
424
425void
426MSDevice_Bluelight::setParameter(const std::string& key, const std::string& value) {
427 double doubleValue;
428 try {
429 doubleValue = StringUtils::toDouble(value);
430 } catch (NumberFormatException&) {
431 throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
432 }
433 if (key == "reactiondist") {
434 myReactionDist = doubleValue;
435 } else {
436 throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
437 }
438}
439
440
441/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define INFLUENCED_BY
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define TL(string)
Definition MsgHandler.h:305
#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
@ ARBITRARY
maintain the current alignment
@ 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
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
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.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
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:155
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:195
A road/street connecting two junctions.
Definition MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
Definition MSEdge.cpp:479
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
Definition MSEdge.cpp:900
static bool gUseMesoSim
Definition MSGlobals.h:106
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double getLength() const
Returns the lane's length.
Definition MSLane.h:606
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:574
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:764
double getWidth() const
Returns the lane's width.
Definition MSLane.h:635
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
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:383
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...
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition MSVehicle.h:670
MSAbstractLaneChangeModel & getLaneChangeModel()
void enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
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 getWidth() const
Get the width which vehicles of this class shall have when being drawn.
const std::string & getID() const
Returns the name of the vehicle type.
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 const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
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 ...
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)