Eclipse SUMO - Simulation of Urban MObility
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-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 /****************************************************************************/
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>
38 #include <microsim/MSVehicleType.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 // ---------------------------------------------------------------------------
53 void
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 
65 void
66 MSDevice_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 // ---------------------------------------------------------------------------
84 MSDevice_Bluelight::MSDevice_Bluelight(SUMOVehicle& holder, const std::string& id,
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 
96 }
97 
98 
99 bool
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)
116  try {
118  } catch (InvalidArgument&) {
119  // not supported by the current laneChangeModel
120  }
121  } else {
122  // restore defaults
127  try {
130  } catch (InvalidArgument&) {
131  // not supported by the current laneChangeModel
132  }
133  }
134  // build a rescue lane for all vehicles on the route of the emergency vehicle within the range of the siren
138  // use edges on the way of the emergency vehicle
139  std::vector<const MSEdge*> upcomingEdges;
140  std::set<MSVehicle*, ComparatorIdLess> upcomingVehicles;
141  std::set<std::string> lastStepInfluencedVehicles = myInfluencedVehicles;
142  std::vector<MSLink*> upcomingLinks;
143  double affectedJunctionDist = ego.getPositionOnLane() + myReactionDist;
144  for (const MSLane* const l : ego.getUpcomingLanesUntil(myReactionDist)) {
145  upcomingEdges.push_back(&l->getEdge());
146 
147  affectedJunctionDist -= l->getLength();
148  if (affectedJunctionDist > 0 && l->isInternal()) {
149  upcomingLinks.push_back(l->getIncomingLanes()[0].viaLink);
150  }
151  }
152 
153  for (const MSEdge* const e : upcomingEdges) {
154  //inform all vehicles on upcomingEdges
155  for (const SUMOVehicle* v : e->getVehicles()) {
156  upcomingVehicles.insert(dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(v)));
157  if (lastStepInfluencedVehicles.count(v->getID()) > 0) {
158  lastStepInfluencedVehicles.erase(v->getID());
159  }
160  }
161  }
162  // reset all vehicles that were in myInfluencedVehicles in the previous step but not in the current step todo refactor
163  for (std::string vehID : lastStepInfluencedVehicles) {
164  myInfluencedVehicles.erase(vehID);
165  Parameterised::Map::iterator it = myInfluencedTypes.find(vehID);
166  MSVehicle* veh2 = dynamic_cast<MSVehicle*>(vc.getVehicle(vehID));
167  if (veh2 != nullptr && it != myInfluencedTypes.end()) {
168  // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
169  resetVehicle(veh2, it->second);
170  }
171  }
172 
173  for (MSVehicle* veh2 : upcomingVehicles) {
174  assert(veh2 != nullptr);
175  if (veh2->getLane() == nullptr) {
176  continue;
177  }
178  if (std::find(upcomingEdges.begin(), upcomingEdges.end(), &veh2->getLane()->getEdge()) != upcomingEdges.end()) {
179  if (veh2->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
180  // emergency vehicles should not react
181  continue;
182  }
183  const int numLanes = (int)veh2->getLane()->getEdge().getNumLanes();
184  // make sure that vehicles are still building the rescue lane as they might have moved to a new edge or changed lanes
185  if (myInfluencedVehicles.count(veh2->getID()) > 0) {
186  // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
187  MSVehicleType& t = veh2->getSingularType();
188  // Setting the lateral alignment to build a rescue lane
190  if (veh2->getLane()->getIndex() == numLanes - 1) {
192  }
194 #ifdef DEBUG_BLUELIGHT_RESCUELANE
195  std::cout << "Refresh alignment for vehicle: " << veh2->getID()
196  << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
197  << " alignment=" << toString(align) << "\n";
198 #endif
199  }
200 
201  double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
202  //emergency vehicle has to slow down when entering the rescue lane
203  if (distanceDelta <= 10 && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) > 0 && veh2->getSpeed() < 1) {
204  // set ev speed to 20 km/h 0 5.56 m/s
205  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
206  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed()));
207  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(2), 5.56));
208  redLight.setSpeedTimeLine(speedTimeLine);
209  }
210 
211  // the perception of the sound of the siren should be around 25 meters
212  // todo only vehicles in front of the emergency vehicle should react
213  if (distanceDelta <= myReactionDist && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) == 0) {
214  // only a percentage of vehicles should react to the emergency vehicle to make the behaviour more realistic
215  double reaction = RandHelper::rand();
216  MSVehicle::Influencer& lanechange = veh2->getInfluencer();
217 
218  //other vehicle should not use the rescue lane so they should not make any lane changes
219  lanechange.setLaneChangeMode(1605);//todo change lane back
220  // the vehicles should react according to the distance to the emergency vehicle taken from real world data
221  double reactionProb = (
222  distanceDelta < myHolder.getFloatParam("device.bluelight.near-dist", false, 12.5)
223  ? myHolder.getFloatParam("device.bluelight.reaction-prob-near", false, 0.577)
224  : myHolder.getFloatParam("device.bluelight.reaction-prob-far", false, 0.189));
225  // todo works only for one second steps
226  //std::cout << SIMTIME << " veh2=" << veh2->getID() << " distanceDelta=" << distanceDelta << " reaction=" << reaction << " reactionProb=" << reactionProb << "\n";
227  if (veh2->isActionStep(SIMSTEP) && reaction < reactionProb * veh2->getActionStepLengthSecs()) {
228  myInfluencedVehicles.insert(veh2->getID());
229  myInfluencedTypes.insert(std::make_pair(veh2->getID(), veh2->getVehicleType().getID()));
230  if (myMinGapFactor != 1.) {
231  // TODO this is a permanent change to the vtype!
233  }
234 
235  // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
236  MSVehicleType& t = veh2->getSingularType();
237  // Setting the lateral alignment to build a rescue lane
239  if (veh2->getLane()->getIndex() == numLanes - 1) {
241  }
245  // disable strategic lane-changing
246 #ifdef DEBUG_BLUELIGHT_RESCUELANE
247  std::cout << SIMTIME << " device=" << getID() << " formingRescueLane=" << veh2->getID()
248  << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
249  << " alignment=" << toString(align) << "\n";
250 #endif
251  std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
252  if (std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID()) == influencedBy.end()) {
253  influencedBy.push_back(myHolder.getID());
254  const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
255  }
256  veh2->getLaneChangeModel().setParameter(toString(SUMO_ATTR_LCA_STRATEGIC_PARAM), "-1");
257  }
258  }
259 
260  } else { //if vehicle is passed all vehicles which had to react should get their state back after they leave the communication range
261  if (myInfluencedVehicles.count(veh2->getID()) > 0) {
262  double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
263  if (distanceDelta > myReactionDist && veh.getID() != veh2->getID()) {
264  myInfluencedVehicles.erase(veh2->getID());
265  Parameterised::Map::iterator it = myInfluencedTypes.find(veh2->getID());
266  if (it != myInfluencedTypes.end()) {
267  // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
268  resetVehicle(veh2, it->second);
269  }
270  }
271  }
272  }
273  }
274  // make upcoming junction foes slow down
275  for (MSLink* link : upcomingLinks) {
276  auto avi = link->getApproaching(&ego);
277  MSLink::BlockingFoes blockingFoes;
278  link->opened(avi.arrivalTime, avi.arrivalSpeed, avi.arrivalSpeed, ego.getLength(),
279  0, ego.getCarFollowModel().getMaxDecel(), ego.getWaitingTime(), ego.getLateralPositionOnLane(), &blockingFoes, true, &ego);
280  const SUMOTime timeToArrival = avi.arrivalTime - SIMSTEP;
281  for (const SUMOTrafficObject* foe : blockingFoes) {
282  if (!foe->isVehicle()) {
283  continue;
284  }
285  const double dist = ego.getPosition().distanceTo2D(foe->getPosition());
286  if (dist < myReactionDist) {
287  MSVehicle* microFoe = dynamic_cast<MSVehicle*>(const_cast<SUMOTrafficObject*>(foe));
288  if (microFoe->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
289  // emergency vehicles should not react
290  continue;
291  }
292  const double timeToBrake = foe->getSpeed() / 4.5;
293  if (timeToArrival < TIME2STEPS(timeToBrake + 1)) {
294  ;
295  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
296  speedTimeLine.push_back(std::make_pair(SIMSTEP, foe->getSpeed()));
297  speedTimeLine.push_back(std::make_pair(avi.arrivalTime, 0));
298  microFoe->getInfluencer().setSpeedTimeLine(speedTimeLine);
299  //std::cout << SIMTIME << " foe=" << foe->getID() << " dist=" << dist << " timeToBrake= " << timeToBrake << " ttA=" << STEPS2TIME(timeToArrival) << "\n";
300  }
301  }
302  }
303  }
304 
305  // ego is at the end of its current lane and cannot continue
306  const double distToEnd = ego.getLane()->getLength() - ego.getPositionOnLane();
307  //std::cout << SIMTIME << " " << getID() << " lane=" << ego.getLane()->getID() << " pos=" << ego.getPositionOnLane() << " distToEnd=" << distToEnd << " conts=" << toString(ego.getBestLanesContinuation()) << " furtherEdges=" << upcomingEdges.size() << "\n";
308  if (ego.getBestLanesContinuation().size() == 1 && distToEnd <= POSITION_EPS
309  // route continues
310  && upcomingEdges.size() > 1) {
311  const MSEdge* currentEdge = &ego.getLane()->getEdge();
312  // move onto the intersection as if there was a connection from the current lane
313  const MSEdge* next = currentEdge->getInternalFollowingEdge(upcomingEdges[1], ego.getVClass());
314  if (next == nullptr) {
315  next = upcomingEdges[1];
316  }
317  // pick the lane that causes the minimizes lateral jump
318  const std::vector<MSLane*>* allowed = next->allowedLanes(ego.getVClass());
319  MSLane* nextLane = next->getLanes().front();
320  double bestJump = std::numeric_limits<double>::max();
321  double newPosLat = 0;
322  if (allowed != nullptr) {
323  for (MSLane* nextCand : *allowed) {
324  for (auto ili : nextCand->getIncomingLanes()) {
325  if (&ili.lane->getEdge() == currentEdge) {
326  double jump = fabs(ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane());
327  if (jump < bestJump) {
328  //std::cout << SIMTIME << " nextCand=" << nextCand->getID() << " from=" << ili.lane->getID() << " jump=" << jump << "\n";
329  bestJump = jump;
330  nextLane = nextCand;
331  // stay within newLane
332  const double maxVehOffset = MAX2(0.0, nextLane->getWidth() - ego.getVehicleType().getWidth()) * 0.5;
333  newPosLat = ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane();
334  newPosLat = MAX2(-maxVehOffset, newPosLat);
335  newPosLat = MIN2(maxVehOffset, newPosLat);
336  }
337  }
338  }
339  }
340  }
341  ego.leaveLane(NOTIFICATION_JUNCTION, nextLane);
344  ego.setTentativeLaneAndPosition(nextLane, 0, newPosLat); // update position
345  ego.enterLaneAtMove(nextLane);
346  // sublane model must adapt state to the new lane
348  }
349  return true; // keep the device
350 }
351 
352 
353 void
354 MSDevice_Bluelight::resetVehicle(MSVehicle* veh2, const std::string& targetTypeID) {
355  MSVehicleType* targetType = MSNet::getInstance()->getVehicleControl().getVType(targetTypeID);
356  //targetType is nullptr if the vehicle type has already changed to its old vehicleType
357  if (targetType != nullptr) {
358 #ifdef DEBUG_BLUELIGHT_RESCUELANE
359  std::cout << SIMTIME << " device=" << getID() << " reset " << veh2->getID() << "\n";
360 #endif
361 
362  std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
363  auto it = std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID());
364  if (it != influencedBy.end()) {
365  influencedBy.erase(it);
366  const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
367  }
368  if (influencedBy.size() == 0) {
369  veh2->replaceVehicleType(targetType);
372  }
373  }
374 }
375 
376 
377 
378 bool
380  UNUSED_PARAMETER(veh);
381 #ifdef DEBUG_BLUELIGHT
382  std::cout << SIMTIME << " device '" << getID() << "' notifyEnter: reason=" << toString(reason) << " enteredLane=" << Named::getIDSecure(enteredLane) << "\n";
383 #else
384  UNUSED_PARAMETER(reason);
385  UNUSED_PARAMETER(enteredLane);
386 #endif
387  return true; // keep the device
388 }
389 
390 
391 bool
392 MSDevice_Bluelight::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* enteredLane) {
393  UNUSED_PARAMETER(veh);
394 #ifdef DEBUG_BLUELIGHT
395  std::cout << SIMTIME << " device '" << getID() << "' notifyLeave: reason=" << toString(reason) << " approachedLane=" << Named::getIDSecure(enteredLane) << "\n";
396 #else
397  UNUSED_PARAMETER(reason);
398  UNUSED_PARAMETER(enteredLane);
399 #endif
400  return true; // keep the device
401 }
402 
403 
404 void
406  if (tripinfoOut != nullptr) {
407  tripinfoOut->openTag("bluelight");
408  tripinfoOut->closeTag();
409  }
410 }
411 
412 std::string
413 MSDevice_Bluelight::getParameter(const std::string& key) const {
414  if (key == "reactiondist") {
415  return toString(myReactionDist);
416  }
417  throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
418 }
419 
420 
421 void
422 MSDevice_Bluelight::setParameter(const std::string& key, const std::string& value) {
423  double doubleValue;
424  try {
425  doubleValue = StringUtils::toDouble(value);
426  } catch (NumberFormatException&) {
427  throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
428  }
429  if (key == "reactiondist") {
430  myReactionDist = doubleValue;
431  } else {
432  throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
433  }
434 }
435 
436 
437 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define INFLUENCED_BY
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define TL(string)
Definition: MsgHandler.h:315
#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_MINGAP_LAT
@ SUMO_ATTR_LCA_STRATEGIC_PARAM
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
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.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
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:559
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:264
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 * > * 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 std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
Definition: MSEdge.cpp:848
static bool gUseMesoSim
Definition: MSGlobals.h:103
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:566
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:756
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:627
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:184
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:378
Changes the wished vehicle speed / lanes.
Definition: MSVehicle.h:1356
void setLaneChangeMode(int value)
Sets lane changing behavior.
Definition: MSVehicle.cpp:791
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:780
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:399
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...
Definition: MSVehicle.cpp:6318
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...
Definition: MSVehicle.cpp:6673
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:673
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5774
void enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Definition: MSVehicle.cpp:5414
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:1244
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:6290
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.
Definition: MSVehicle.cpp:5680
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
Definition: MSVehicle.cpp:4865
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
Definition: MSVehicle.cpp:6768
Influencer & getInfluencer()
Definition: MSVehicle.cpp:7251
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:416
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:493
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:377
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:584
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:977
The car-following model and parameter.
Definition: MSVehicleType.h:63
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.
double getMinGap() const
Get the free space in front of vehicles of this class.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:91
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
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.
Definition: OptionsCont.cpp:76
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
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.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:276
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition: Position.h:266
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.cpp:94
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
double getFloatParam(const std::string &paramName, const bool required=false, const double deflt=INVALID_DOUBLE) const
Retrieve a floating point parameter for the traffic object.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
Structure representing possible vehicle parameter.
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