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.org/sumo
3 // Copyright (C) 2013-2022 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", "Set the distance at which other drivers react to the blue light and siren sound");
60 }
61 
62 
63 void
64 MSDevice_Bluelight::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
66  if (equippedByDefaultAssignmentOptions(oc, "bluelight", v, false)) {
68  WRITE_WARNINGF("bluelight device is not compatible with mesosim (ignored for vehicle '%')", v.getID());
69  } else {
70  MSDevice_Bluelight* device = new MSDevice_Bluelight(v, "bluelight_" + v.getID(),
71  getFloatParam(v, oc, "bluelight.reactiondist", oc.getFloat("device.bluelight.reactiondist"), false));
72  into.push_back(device);
73  }
74  }
75 }
76 
77 
78 // ---------------------------------------------------------------------------
79 // MSDevice_Bluelight-methods
80 // ---------------------------------------------------------------------------
81 MSDevice_Bluelight::MSDevice_Bluelight(SUMOVehicle& holder, const std::string& id,
82  double reactionDist) :
83  MSVehicleDevice(holder, id),
84  myReactionDist(reactionDist) {
85 #ifdef DEBUG_BLUELIGHT
86  std::cout << SIMTIME << " initialized device '" << id << "' with myReactionDist=" << myReactionDist << "\n";
87 #endif
88 }
89 
90 
92 }
93 
94 
95 bool
97  double /* newPos */, double newSpeed) {
98 #ifdef DEBUG_BLUELIGHT
99  std::cout << SIMTIME << " device '" << getID() << "' notifyMove: newSpeed=" << newSpeed << "\n";
100 #else
101  UNUSED_PARAMETER(newSpeed);
102 #endif
103  //violate red lights this only need to be done once so shift it todo
104  MSVehicle& ego = dynamic_cast<MSVehicle&>(veh);
105  MSVehicle::Influencer& redLight = ego.getInfluencer();
106  const double vMax = ego.getLane()->getVehicleMaxSpeed(&ego);
107  redLight.setSpeedMode(7);
108  if (ego.getSpeed() < 0.5 * vMax) {
109  // advance as far as possible (assume vehicles will keep moving out of the way)
112  try {
114  } catch (InvalidArgument&) {
115  // not supported by the current laneChangeModel
116  }
117  } else {
118  // restore defaults
123  try {
126  } catch (InvalidArgument&) {
127  // not supported by the current laneChangeModel
128  }
129  }
130  // build a rescue lane for all vehicles on the route of the emergency vehicle within the range of the siren
134  // use edges on the way of the emergency vehicle
135  std::vector<const MSEdge*> upcomingEdges;
136  std::set<MSVehicle*, ComparatorIdLess> upcomingVehicles;
137  std::set<std::string> lastStepInfluencedVehicles = myInfluencedVehicles;
138  std::vector<MSLink*> upcomingLinks;
139  double affectedJunctionDist = ego.getPositionOnLane() + myReactionDist;
140  for (const MSLane* const l : ego.getUpcomingLanesUntil(myReactionDist)) {
141  upcomingEdges.push_back(&l->getEdge());
142 
143  affectedJunctionDist -= l->getLength();
144  if (affectedJunctionDist > 0 && l->isInternal()) {
145  upcomingLinks.push_back(l->getIncomingLanes()[0].viaLink);
146  }
147  }
148 
149  for (const MSEdge* const e : upcomingEdges) {
150  //inform all vehicles on upcomingEdges
151  for (const SUMOVehicle* v : e->getVehicles()) {
152  upcomingVehicles.insert(dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(v)));
153  if (lastStepInfluencedVehicles.count(v->getID()) > 0) {
154  lastStepInfluencedVehicles.erase(v->getID());
155  }
156  }
157  }
158  // reset all vehicles that were in myInfluencedVehicles in the previous step but not in the current step todo refactor
159  for (std::string vehID : lastStepInfluencedVehicles) {
160  myInfluencedVehicles.erase(vehID);
161  std::map<std::string, std::string>::iterator it = myInfluencedTypes.find(vehID);
162  MSVehicle* veh2 = dynamic_cast<MSVehicle*>(vc.getVehicle(vehID));
163  if (veh2 != nullptr && it != myInfluencedTypes.end()) {
164  // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
165  resetVehicle(veh2, it->second);
166  }
167  }
168 
169  for (MSVehicle* veh2 : upcomingVehicles) {
170  assert(veh2 != nullptr);
171  if (veh2->getLane() == nullptr) {
172  continue;
173  }
174  if (std::find(upcomingEdges.begin(), upcomingEdges.end(), &veh2->getLane()->getEdge()) != upcomingEdges.end()) {
175  if (veh2->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
176  // emergency vehicles should not react
177  continue;
178  }
179  const int numLanes = (int)veh2->getLane()->getEdge().getNumLanes();
180  // make sure that vehicle are still building the a rescue lane
181  if (myInfluencedVehicles.count(veh2->getID()) > 0) {
182  // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
183  MSVehicleType& t = veh2->getSingularType();
184  // Setting the lateral alignment to build a rescue lane
186  if (veh2->getLane()->getIndex() == numLanes - 1) {
188  }
190 #ifdef DEBUG_BLUELIGHT_RESCUELANE
191  std::cout << "Refresh alignment for vehicle: " << veh2->getID()
192  << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
193  << " alignment=" << toString(align) << "\n";
194 #endif
195  }
196 
197  double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
198  //emergency vehicle has to slow down when entering the rescue lane
199  if (distanceDelta <= 10 && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) > 0 && veh2->getSpeed() < 1) {
200  // set ev speed to 20 km/h 0 5.56 m/s
201  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
202  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed()));
203  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(2), 5.56));
204  redLight.setSpeedTimeLine(speedTimeLine);
205  }
206 
207  // the perception of the sound of the siren should be around 25 meters
208  // todo only vehicles in front of the emergency vehicle should react
209  if (distanceDelta <= myReactionDist && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) == 0) {
210  // only a percentage of vehicles should react to the emergency vehicle to make the behaviour more realistic
211  double reaction = RandHelper::rand();
212  MSVehicle::Influencer& lanechange = veh2->getInfluencer();
213 
214  //other vehicle should not use the rescue lane so they should not make any lane changes
215  lanechange.setLaneChangeMode(1605);//todo change lane back
216  // the vehicles should react according to the distance to the emergency vehicle taken from real world data
217  double reactionProb = 0.189; // todo works only for one second steps
218  if (distanceDelta < 12.5) {
219  reactionProb = 0.577;
220  }
221  if (reaction < reactionProb) {
222  myInfluencedVehicles.insert(veh2->getID());
223  myInfluencedTypes.insert(std::make_pair(veh2->getID(), veh2->getVehicleType().getID()));
224 
225  // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
226  MSVehicleType& t = veh2->getSingularType();
227  // Setting the lateral alignment to build a rescue lane
229  if (veh2->getLane()->getIndex() == numLanes - 1) {
231  }
233  // disable strategic lane-changing
234 #ifdef DEBUG_BLUELIGHT_RESCUELANE
235  std::cout << SIMTIME << " device=" << getID() << " formingRescueLane=" << veh2->getID()
236  << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
237  << " alignment=" << toString(align) << "\n";
238 #endif
239  std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
240  if (std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID()) == influencedBy.end()) {
241  influencedBy.push_back(myHolder.getID());
242  const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
243  }
244  veh2->getLaneChangeModel().setParameter(toString(SUMO_ATTR_LCA_STRATEGIC_PARAM), "-1");
245  }
246  }
247 
248  } else { //if vehicle is passed all vehicles which had to react should get their state back after they leave the communication range
249  if (myInfluencedVehicles.count(veh2->getID()) > 0) {
250  double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
251  if (distanceDelta > myReactionDist && veh.getID() != veh2->getID()) {
252  myInfluencedVehicles.erase(veh2->getID());
253  std::map<std::string, std::string>::iterator it = myInfluencedTypes.find(veh2->getID());
254  if (it != myInfluencedTypes.end()) {
255  // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
256  resetVehicle(veh2, it->second);
257  }
258  }
259  }
260  }
261  }
262  // make upcoming junction foes slow down
263  for (MSLink* link : upcomingLinks) {
264  auto avi = link->getApproaching(&ego);
265  MSLink::BlockingFoes blockingFoes;
266  link->opened(avi.arrivalTime, avi.arrivalSpeed, avi.arrivalSpeed, ego.getLength(),
267  0, ego.getCarFollowModel().getMaxDecel(), ego.getWaitingTime(), ego.getLateralPositionOnLane(), &blockingFoes, true, &ego);
268  const SUMOTime timeToArrival = avi.arrivalTime - SIMSTEP;
269  for (const SUMOVehicle* foe : blockingFoes) {
270  const double dist = ego.getPosition().distanceTo2D(foe->getPosition());
271  if (dist < myReactionDist) {
272  MSVehicle* microFoe = dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(foe));
273  if (microFoe->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
274  // emergency vehicles should not react
275  continue;
276  }
277  const double timeToBrake = foe->getSpeed() / 4.5;
278  if (timeToArrival < TIME2STEPS(timeToBrake + 1)) {
279  ;
280  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
281  speedTimeLine.push_back(std::make_pair(SIMSTEP, foe->getSpeed()));
282  speedTimeLine.push_back(std::make_pair(avi.arrivalTime, 0));
283  microFoe->getInfluencer().setSpeedTimeLine(speedTimeLine);
284  //std::cout << SIMTIME << " foe=" << foe->getID() << " dist=" << dist << " timeToBrake= " << timeToBrake << " ttA=" << STEPS2TIME(timeToArrival) << "\n";
285  }
286  }
287  }
288  }
289 
290  // ego is at the end of its current lane and cannot continue
291  const double distToEnd = ego.getLane()->getLength() - ego.getPositionOnLane();
292  //std::cout << SIMTIME << " " << getID() << " lane=" << ego.getLane()->getID() << " pos=" << ego.getPositionOnLane() << " distToEnd=" << distToEnd << " conts=" << toString(ego.getBestLanesContinuation()) << " furtherEdges=" << upcomingEdges.size() << "\n";
293  if (ego.getBestLanesContinuation().size() == 1 && distToEnd <= POSITION_EPS
294  // route continues
295  && upcomingEdges.size() > 1) {
296  const MSEdge* currentEdge = &ego.getLane()->getEdge();
297  // move onto the intersection as if there was a connection from the current lane
298  const MSEdge* next = currentEdge->getInternalFollowingEdge(upcomingEdges[1]);
299  if (next == nullptr) {
300  next = upcomingEdges[1];
301  }
302  // pick the lane that causes the minimizes lateral jump
303  const std::vector<MSLane*>* allowed = next->allowedLanes(ego.getVClass());
304  MSLane* nextLane = next->getLanes().front();
305  double bestJump = std::numeric_limits<double>::max();
306  double newPosLat = 0;
307  if (allowed != nullptr) {
308  for (MSLane* nextCand : *allowed) {
309  for (auto ili : nextCand->getIncomingLanes()) {
310  if (&ili.lane->getEdge() == currentEdge) {
311  double jump = fabs(ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane());
312  if (jump < bestJump) {
313  //std::cout << SIMTIME << " nextCand=" << nextCand->getID() << " from=" << ili.lane->getID() << " jump=" << jump << "\n";
314  bestJump = jump;
315  nextLane = nextCand;
316  // stay within newLane
317  const double maxVehOffset = MAX2(0.0, nextLane->getWidth() - ego.getVehicleType().getWidth()) * 0.5;
318  newPosLat = ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane();
319  newPosLat = MAX2(-maxVehOffset, newPosLat);
320  newPosLat = MIN2(maxVehOffset, newPosLat);
321  }
322  }
323  }
324  }
325  }
326  ego.leaveLane(NOTIFICATION_JUNCTION, nextLane);
329  ego.setTentativeLaneAndPosition(nextLane, 0, newPosLat); // update position
330  ego.enterLaneAtMove(nextLane);
331  // sublane model must adapt state to the new lane
333  }
334  return true; // keep the device
335 }
336 
337 
338 void
339 MSDevice_Bluelight::resetVehicle(MSVehicle* veh2, const std::string& targetTypeID) {
340  MSVehicleType* targetType = MSNet::getInstance()->getVehicleControl().getVType(targetTypeID);
341  //targetType is nullptr if the vehicle type has already changed to its old vehicleType
342  if (targetType != nullptr) {
343 #ifdef DEBUG_BLUELIGHT_RESCUELANE
344  std::cout << SIMTIME << " device=" << getID() << " reset " << veh2->getID() << "\n";
345 #endif
346 
347  std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
348  auto it = std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID());
349  if (it != influencedBy.end()) {
350  influencedBy.erase(it);
351  const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
352  }
353  if (influencedBy.size() == 0) {
354  veh2->replaceVehicleType(targetType);
357  }
358  }
359 }
360 
361 
362 
363 bool
365  UNUSED_PARAMETER(veh);
366 #ifdef DEBUG_BLUELIGHT
367  std::cout << SIMTIME << " device '" << getID() << "' notifyEnter: reason=" << toString(reason) << " enteredLane=" << Named::getIDSecure(enteredLane) << "\n";
368 #else
369  UNUSED_PARAMETER(reason);
370  UNUSED_PARAMETER(enteredLane);
371 #endif
372  return true; // keep the device
373 }
374 
375 
376 bool
377 MSDevice_Bluelight::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* enteredLane) {
378  UNUSED_PARAMETER(veh);
379 #ifdef DEBUG_BLUELIGHT
380  std::cout << SIMTIME << " device '" << getID() << "' notifyLeave: reason=" << toString(reason) << " approachedLane=" << Named::getIDSecure(enteredLane) << "\n";
381 #else
382  UNUSED_PARAMETER(reason);
383  UNUSED_PARAMETER(enteredLane);
384 #endif
385  return true; // keep the device
386 }
387 
388 
389 void
391  if (tripinfoOut != nullptr) {
392  tripinfoOut->openTag("bluelight");
393  tripinfoOut->closeTag();
394  }
395 }
396 
397 std::string
398 MSDevice_Bluelight::getParameter(const std::string& key) const {
399  if (key == "reactiondist") {
400  return toString(myReactionDist);
401  }
402  throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
403 }
404 
405 
406 void
407 MSDevice_Bluelight::setParameter(const std::string& key, const std::string& value) {
408  double doubleValue;
409  try {
410  doubleValue = StringUtils::toDouble(value);
411  } catch (NumberFormatException&) {
412  throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
413  }
414  if (key == "reactiondist") {
415  myReactionDist = doubleValue;
416  } else {
417  throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
418  }
419 }
420 
421 
422 /****************************************************************************/
#define INFLUENCED_BY
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:281
#define SIMSTEP
Definition: SUMOTime.h:59
#define SIMTIME
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
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_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:74
T MAX2(T a, T b)
Definition: StdDefs.h:80
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
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
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.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:239
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
std::map< std::string, std::string > myInfluencedTypes
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)
~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.
MSDevice_Bluelight(SUMOVehicle &holder, const std::string &id, double reactionDist)
Constructor.
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, std::string paramName, double deflt, bool required)
Definition: MSDevice.cpp:188
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:137
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:205
A road/street connecting two junctions.
Definition: MSEdge.h:77
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
Definition: MSEdge.cpp:761
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:408
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
static bool gUseMesoSim
Definition: MSGlobals.h:94
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:519
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:556
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:174
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
Changes the wished vehicle speed / lanes.
Definition: MSVehicle.h:1308
void setLaneChangeMode(int value)
Sets lane changing behavior.
Definition: MSVehicle.cpp:778
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:767
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:392
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:75
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:5525
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:5878
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:631
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5051
void enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Definition: MSVehicle.cpp:4772
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:1142
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:5497
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:4965
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
Definition: MSVehicle.cpp:4259
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:5941
Influencer & getInfluencer()
Definition: MSVehicle.cpp:6389
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:411
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:462
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:372
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:552
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:917
The car-following model and parameter.
Definition: MSVehicleType.h:62
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.
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:90
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 *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
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:252
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:242
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:119
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)
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