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  getFloatParam(v, oc, "bluelight.reactiondist", oc.getFloat("device.bluelight.reactiondist")),
74  getFloatParam(v, oc, "bluelight.mingapfactor", oc.getFloat("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 < getFloatParam(myHolder, OptionsCont::getOptions(), "bluelight.near-dist", 12.5, false)
223  ? getFloatParam(myHolder, OptionsCont::getOptions(), "bluelight.reaction-prob-near", 0.577, false)
224  : getFloatParam(myHolder, OptionsCont::getOptions(), "bluelight.reaction-prob-far", 0.189, false));
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 SUMOVehicle* foe : blockingFoes) {
282  const double dist = ego.getPosition().distanceTo2D(foe->getPosition());
283  if (dist < myReactionDist) {
284  MSVehicle* microFoe = dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(foe));
285  if (microFoe->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
286  // emergency vehicles should not react
287  continue;
288  }
289  const double timeToBrake = foe->getSpeed() / 4.5;
290  if (timeToArrival < TIME2STEPS(timeToBrake + 1)) {
291  ;
292  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
293  speedTimeLine.push_back(std::make_pair(SIMSTEP, foe->getSpeed()));
294  speedTimeLine.push_back(std::make_pair(avi.arrivalTime, 0));
295  microFoe->getInfluencer().setSpeedTimeLine(speedTimeLine);
296  //std::cout << SIMTIME << " foe=" << foe->getID() << " dist=" << dist << " timeToBrake= " << timeToBrake << " ttA=" << STEPS2TIME(timeToArrival) << "\n";
297  }
298  }
299  }
300  }
301 
302  // ego is at the end of its current lane and cannot continue
303  const double distToEnd = ego.getLane()->getLength() - ego.getPositionOnLane();
304  //std::cout << SIMTIME << " " << getID() << " lane=" << ego.getLane()->getID() << " pos=" << ego.getPositionOnLane() << " distToEnd=" << distToEnd << " conts=" << toString(ego.getBestLanesContinuation()) << " furtherEdges=" << upcomingEdges.size() << "\n";
305  if (ego.getBestLanesContinuation().size() == 1 && distToEnd <= POSITION_EPS
306  // route continues
307  && upcomingEdges.size() > 1) {
308  const MSEdge* currentEdge = &ego.getLane()->getEdge();
309  // move onto the intersection as if there was a connection from the current lane
310  const MSEdge* next = currentEdge->getInternalFollowingEdge(upcomingEdges[1], ego.getVClass());
311  if (next == nullptr) {
312  next = upcomingEdges[1];
313  }
314  // pick the lane that causes the minimizes lateral jump
315  const std::vector<MSLane*>* allowed = next->allowedLanes(ego.getVClass());
316  MSLane* nextLane = next->getLanes().front();
317  double bestJump = std::numeric_limits<double>::max();
318  double newPosLat = 0;
319  if (allowed != nullptr) {
320  for (MSLane* nextCand : *allowed) {
321  for (auto ili : nextCand->getIncomingLanes()) {
322  if (&ili.lane->getEdge() == currentEdge) {
323  double jump = fabs(ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane());
324  if (jump < bestJump) {
325  //std::cout << SIMTIME << " nextCand=" << nextCand->getID() << " from=" << ili.lane->getID() << " jump=" << jump << "\n";
326  bestJump = jump;
327  nextLane = nextCand;
328  // stay within newLane
329  const double maxVehOffset = MAX2(0.0, nextLane->getWidth() - ego.getVehicleType().getWidth()) * 0.5;
330  newPosLat = ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane();
331  newPosLat = MAX2(-maxVehOffset, newPosLat);
332  newPosLat = MIN2(maxVehOffset, newPosLat);
333  }
334  }
335  }
336  }
337  }
338  ego.leaveLane(NOTIFICATION_JUNCTION, nextLane);
341  ego.setTentativeLaneAndPosition(nextLane, 0, newPosLat); // update position
342  ego.enterLaneAtMove(nextLane);
343  // sublane model must adapt state to the new lane
345  }
346  return true; // keep the device
347 }
348 
349 
350 void
351 MSDevice_Bluelight::resetVehicle(MSVehicle* veh2, const std::string& targetTypeID) {
352  MSVehicleType* targetType = MSNet::getInstance()->getVehicleControl().getVType(targetTypeID);
353  //targetType is nullptr if the vehicle type has already changed to its old vehicleType
354  if (targetType != nullptr) {
355 #ifdef DEBUG_BLUELIGHT_RESCUELANE
356  std::cout << SIMTIME << " device=" << getID() << " reset " << veh2->getID() << "\n";
357 #endif
358 
359  std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
360  auto it = std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID());
361  if (it != influencedBy.end()) {
362  influencedBy.erase(it);
363  const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
364  }
365  if (influencedBy.size() == 0) {
366  veh2->replaceVehicleType(targetType);
369  }
370  }
371 }
372 
373 
374 
375 bool
377  UNUSED_PARAMETER(veh);
378 #ifdef DEBUG_BLUELIGHT
379  std::cout << SIMTIME << " device '" << getID() << "' notifyEnter: reason=" << toString(reason) << " enteredLane=" << Named::getIDSecure(enteredLane) << "\n";
380 #else
381  UNUSED_PARAMETER(reason);
382  UNUSED_PARAMETER(enteredLane);
383 #endif
384  return true; // keep the device
385 }
386 
387 
388 bool
389 MSDevice_Bluelight::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* enteredLane) {
390  UNUSED_PARAMETER(veh);
391 #ifdef DEBUG_BLUELIGHT
392  std::cout << SIMTIME << " device '" << getID() << "' notifyLeave: reason=" << toString(reason) << " approachedLane=" << Named::getIDSecure(enteredLane) << "\n";
393 #else
394  UNUSED_PARAMETER(reason);
395  UNUSED_PARAMETER(enteredLane);
396 #endif
397  return true; // keep the device
398 }
399 
400 
401 void
403  if (tripinfoOut != nullptr) {
404  tripinfoOut->openTag("bluelight");
405  tripinfoOut->closeTag();
406  }
407 }
408 
409 std::string
410 MSDevice_Bluelight::getParameter(const std::string& key) const {
411  if (key == "reactiondist") {
412  return toString(myReactionDist);
413  }
414  throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
415 }
416 
417 
418 void
419 MSDevice_Bluelight::setParameter(const std::string& key, const std::string& value) {
420  double doubleValue;
421  try {
422  doubleValue = StringUtils::toDouble(value);
423  } catch (NumberFormatException&) {
424  throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
425  }
426  if (key == "reactiondist") {
427  myReactionDist = doubleValue;
428  } else {
429  throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
430  }
431 }
432 
433 
434 /****************************************************************************/
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 double getFloatParam(const SUMOVehicle &v, const OptionsCont &oc, const std::string &paramName, const double deflt, bool required=false)
Definition: MSDevice.cpp:206
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:203
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:474
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:836
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:752
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:182
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:378
Changes the wished vehicle speed / lanes.
Definition: MSVehicle.h:1349
void setLaneChangeMode(int value)
Sets lane changing behavior.
Definition: MSVehicle.cpp:790
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:779
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:398
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:6258
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:6613
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:5720
void enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Definition: MSVehicle.cpp:5360
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:1242
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:6230
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:5626
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
Definition: MSVehicle.cpp:4811
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:6708
Influencer & getInfluencer()
Definition: MSVehicle.cpp:7182
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:974
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.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
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:271
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:261
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.
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:60
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