SUMO - Simulation of Urban MObility
MSBaseVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A base class for vehicle implementations
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
33 #include <cassert>
34 #include <utils/common/StdDefs.h>
38 #include "MSGlobals.h"
39 #include "MSTransportable.h"
40 #include "MSVehicleControl.h"
41 #include "MSVehicleType.h"
42 #include "MSEdge.h"
43 #include "MSLane.h"
44 #include "MSMoveReminder.h"
45 #include "MSBaseVehicle.h"
46 #include "MSNet.h"
47 #include "devices/MSDevice.h"
49 #include "MSInsertionControl.h"
50 
51 // ===========================================================================
52 // static members
53 // ===========================================================================
55 #ifdef _DEBUG
56 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
57 #endif
58 
59 // ===========================================================================
60 // method definitions
61 // ===========================================================================
62 
63 double
65  throw ProcessError("getPreviousSpeed() is not available for non-MSVehicles.");
66 }
67 
68 
70  MSVehicleType* type, const double speedFactor) :
71  myParameter(pars),
72  myRoute(route),
73  myType(type),
74  myCurrEdge(route->begin()),
75  myChosenSpeedFactor(speedFactor),
76  myMoveReminders(0),
78  myDepartPos(-1),
79  myArrivalPos(-1),
80  myArrivalLane(-1),
82 #ifdef _DEBUG
83  , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
84 #endif
85 {
86  if ((*myRoute->begin())->isTazConnector() || myRoute->getLastEdge()->isTazConnector()) {
88  }
89  // init devices
91  //
92  for (std::vector< MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
93  myMoveReminders.push_back(std::make_pair(*dev, 0.));
94  }
96  if (!pars->wasSet(VEHPARS_FORCE_REROUTE)) {
99  std::string msg;
100  if (!hasValidRoute(msg)) {
101  throw ProcessError("Vehicle '" + pars->id + "' has no valid route. " + msg);
102  }
103  }
104  }
105 }
106 
107 
109  myRoute->release();
110  if (myParameter->repetitionNumber == 0) {
112  }
113  for (std::vector< MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
114  delete *dev;
115  }
116  delete myParameter;
117 }
118 
119 
120 const std::string&
122  return myParameter->id;
123 }
124 
125 
128  return *myParameter;
129 }
130 
131 
132 double
134  return myType->getMaxSpeed();
135 }
136 
137 
138 const MSEdge*
139 MSBaseVehicle::succEdge(int nSuccs) const {
140  if (myCurrEdge + nSuccs < myRoute->end() && std::distance(myCurrEdge, myRoute->begin()) <= nSuccs) {
141  return *(myCurrEdge + nSuccs);
142  } else {
143  return 0;
144  }
145 }
146 
147 
148 const MSEdge*
150  return *myCurrEdge;
151 }
152 
153 
154 void
155 MSBaseVehicle::reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit, const bool withTaz) {
156  // check whether to reroute
157  const MSEdge* source = withTaz && onInit ? MSEdge::dictionary(myParameter->fromTaz + "-source") : getRerouteOrigin();
158  if (source == 0) {
159  source = getRerouteOrigin();
160  }
161  const MSEdge* sink = withTaz ? MSEdge::dictionary(myParameter->toTaz + "-sink") : myRoute->getLastEdge();
162  if (sink == 0) {
163  sink = myRoute->getLastEdge();
164  }
165  ConstMSEdgeVector edges;
166  ConstMSEdgeVector stops;
167  if (myParameter->via.size() == 0) {
168  stops = getStopEdges();
169  } else {
170  // via takes precedence over stop edges
171  // XXX check for inconsistencies #2275
172  for (std::vector<std::string>::const_iterator it = myParameter->via.begin(); it != myParameter->via.end(); ++it) {
173  MSEdge* viaEdge = MSEdge::dictionary(*it);
174  assert(viaEdge != 0);
175  if (viaEdge->allowedLanes(getVClass()) == 0) {
176  throw ProcessError("Vehicle '" + getID() + "' is not allowed on any lane of via edge '" + viaEdge->getID() + "'.");
177  }
178  stops.push_back(viaEdge);
179  }
180  }
181 
182  for (MSRouteIterator s = stops.begin(); s != stops.end(); ++s) {
183  if (*s != source) {
184  // !!! need to adapt t here
185  ConstMSEdgeVector into;
186  router.compute(source, *s, this, t, into);
187  if (into.size() > 0) {
188  into.pop_back();
189  edges.insert(edges.end(), into.begin(), into.end());
190  } else {
191  std::string error = "Vehicle '" + getID() + "' has no valid route from edge '" + source->getID() + "' to stop edge '" + (*s)->getID() + "'.";
193  throw ProcessError(error);
194  } else {
195  WRITE_WARNING(error);
196  edges.push_back(source);
197  }
198  }
199  source = *s;
200  }
201  }
202  router.compute(source, sink, this, t, edges);
203  if (!edges.empty() && edges.front()->isTazConnector()) {
204  edges.erase(edges.begin());
205  }
206  if (!edges.empty() && edges.back()->isTazConnector()) {
207  edges.pop_back();
208  }
209  replaceRouteEdges(edges, onInit);
210  // this must be called even if the route could not be replaced
211  if (onInit) {
212  if (edges.empty()) {
214  throw ProcessError("Vehicle '" + getID() + "' has no valid route.");
215  } else if (source->isTazConnector()) {
216  WRITE_WARNING("Removing vehicle '" + getID() + "' which has no valid route.");
218  return;
219  }
220  }
222  }
223 }
224 
225 
226 bool
227 MSBaseVehicle::replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit, bool check, bool removeStops) {
228  if (edges.empty()) {
229  WRITE_WARNING("No route for vehicle '" + getID() + "' found.");
230  return false;
231  }
232  // build a new id, first
233  std::string id = getID();
234  if (id[0] != '!') {
235  id = "!" + id;
236  }
237  if (myRoute->getID().find("!var#") != std::string::npos) {
238  id = myRoute->getID().substr(0, myRoute->getID().rfind("!var#") + 5) + toString(getNumberReroutes() + 1);
239  } else {
240  id = id + "!var#1";
241  }
242  int oldSize = (int)edges.size();
243  if (!onInit) {
244  const MSEdge* const origin = getRerouteOrigin();
245  if (origin != *myCurrEdge && edges.front() == origin) {
246  edges.insert(edges.begin(), *myCurrEdge);
247  oldSize = (int)edges.size();
248  }
249  edges.insert(edges.begin(), myRoute->begin(), myCurrEdge);
250  }
251  if (edges == myRoute->getEdges()) {
252  return true;
253  }
254  const RGBColor& c = myRoute->getColor();
255  MSRoute* newRoute = new MSRoute(id, edges, false, &c == &RGBColor::DEFAULT_COLOR ? 0 : new RGBColor(c), std::vector<SUMOVehicleParameter::Stop>());
256  if (!MSRoute::dictionary(id, newRoute)) {
257  delete newRoute;
258  return false;
259  }
260 
261  std::string msg;
262  if (check && !hasValidRoute(msg, newRoute)) {
263  WRITE_WARNING("Invalid route replacement for vehicle '" + getID() + "'. " + msg);
265  newRoute->addReference();
266  newRoute->release();
267  return false;
268  }
269  }
270  if (!replaceRoute(newRoute, onInit, (int)edges.size() - oldSize, false, removeStops)) {
271  newRoute->addReference();
272  newRoute->release();
273  return false;
274  }
275  return true;
276 }
277 
278 
279 double
281  return 0;
282 }
283 
284 
285 double
287  return 0;
288 }
289 
290 
291 void
296 }
297 
298 
299 bool
301  return myDeparture != NOT_YET_DEPARTED;
302 }
303 
304 
305 bool
307  return succEdge(1) == 0;
308 }
309 
310 void
312  throw ProcessError("Person '" + person->getID() + "' cannot ride in vehicle '" + getID() + "' in the mesoscopic simulation.");
313 }
314 
315 void
317  throw ProcessError("Container '" + container->getID() + "' cannot ride in vehicle '" + getID() + "' in the mesoscopic simulation.");
318 }
319 
320 bool
321 MSBaseVehicle::hasValidRoute(std::string& msg, const MSRoute* route) const {
322  MSRouteIterator start = myCurrEdge;
323  if (route == 0) {
324  route = myRoute;
325  } else {
326  start = route->begin();
327  }
328  MSRouteIterator last = route->end() - 1;
329  // check connectivity, first
330  for (MSRouteIterator e = start; e != last; ++e) {
331  if ((*e)->allowedLanes(**(e + 1), myType->getVehicleClass()) == 0) {
332  msg = "No connection between edge '" + (*e)->getID() + "' and edge '" + (*(e + 1))->getID() + "'.";
333  return false;
334  }
335  }
336  last = route->end();
337  // check usable lanes, then
338  for (MSRouteIterator e = start; e != last; ++e) {
339  if ((*e)->prohibits(this)) {
340  msg = "Edge '" + (*e)->getID() + "' prohibits.";
341  return false;
342  }
343  }
344  return true;
345 }
346 
347 
348 void
350 #ifdef _DEBUG
351  if (myTraceMoveReminders) {
352  traceMoveReminder("add", rem, 0, true);
353  }
354 #endif
355  myMoveReminders.push_back(std::make_pair(rem, 0.));
356 }
357 
358 
359 void
361  for (MoveReminderCont::iterator r = myMoveReminders.begin(); r != myMoveReminders.end(); ++r) {
362  if (r->first == rem) {
363 #ifdef _DEBUG
364  if (myTraceMoveReminders) {
365  traceMoveReminder("remove", rem, 0, false);
366  }
367 #endif
368  myMoveReminders.erase(r);
369  return;
370  }
371  }
372 }
373 
374 
375 void
377  for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
378  if (rem->first->notifyEnter(*this, reason, enteredLane)) {
379 #ifdef _DEBUG
380  if (myTraceMoveReminders) {
381  traceMoveReminder("notifyEnter", rem->first, rem->second, true);
382  }
383 #endif
384  ++rem;
385  } else {
386 #ifdef _DEBUG
387  if (myTraceMoveReminders) {
388  traceMoveReminder("notifyEnter", rem->first, rem->second, false);
389  }
390 #endif
391  rem = myMoveReminders.erase(rem);
392  }
393  }
394 }
395 
396 
397 void
399  if (myRoute->getLastEdge()->isTazConnector()) {
400  return;
401  }
402  const std::vector<MSLane*>& lanes = myRoute->getLastEdge()->getLanes();
403  const double lastLaneLength = lanes[0]->getLength();
404  switch (myParameter->arrivalPosProcedure) {
405  case ARRIVAL_POS_GIVEN:
406  if (fabs(myParameter->arrivalPos) > lastLaneLength) {
407  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive at the given position!");
408  }
409  // Maybe we should warn the user about invalid inputs!
410  myArrivalPos = MIN2(myParameter->arrivalPos, lastLaneLength);
411  if (myArrivalPos < 0) {
412  myArrivalPos = MAX2(myArrivalPos + lastLaneLength, 0.);
413  }
414  break;
415  case ARRIVAL_POS_RANDOM:
416  myArrivalPos = RandHelper::rand(0., lastLaneLength);
417  break;
418  default:
419  myArrivalPos = lastLaneLength;
420  break;
421  }
423  if (myParameter->arrivalLane >= (int)lanes.size() || !lanes[myParameter->arrivalLane]->allowsVehicleClass(myType->getVehicleClass())) {
424  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive at the given lane '" + myRoute->getLastEdge()->getID() + "_" + toString(myParameter->arrivalLane) + "'!");
425  }
426  myArrivalLane = MIN2(myParameter->arrivalLane, (int)(lanes.size() - 1));
427  }
429  for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
430  if (myParameter->arrivalSpeed <= (*l)->getVehicleMaxSpeed(this)) {
431  return;
432  }
433  }
434  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive with the given speed!");
435  }
436 }
437 
438 
439 double
441  return MAX2(0., MIN2(1., getVehicleType().getImpatience() +
443 }
444 
445 
446 MSDevice*
447 MSBaseVehicle::getDevice(const std::type_info& type) const {
448  for (std::vector<MSDevice*>::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
449  if (typeid(**dev) == type) {
450  return *dev;
451  }
452  }
453  return 0;
454 }
455 
456 
457 void
459  // this saves lots of departParameters which are only needed for vehicles that did not yet depart
460  // the parameters may hold the name of a vTypeDistribution but we are interested in the actual type
462  // params and stops must be written in child classes since they may wish to add additional attributes first
465  out.writeAttr(SUMO_ATTR_REROUTE, true);
466  }
467  // here starts the vehicle internal part (see loading)
468  // @note: remember to close the vehicle tag when calling this in a subclass!
469 }
470 
471 
472 void
473 MSBaseVehicle::addStops(const bool ignoreStopErrors) {
474  for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myRoute->getStops().begin(); i != myRoute->getStops().end(); ++i) {
475  std::string errorMsg;
476  if (!addStop(*i, errorMsg, myParameter->depart) && !ignoreStopErrors) {
477  throw ProcessError(errorMsg);
478  }
479  if (errorMsg != "") {
480  WRITE_WARNING(errorMsg);
481  }
482  }
484  for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myParameter->stops.begin(); i != myParameter->stops.end(); ++i) {
485  std::string errorMsg;
486  if (!addStop(*i, errorMsg, untilOffset) && !ignoreStopErrors) {
487  throw ProcessError(errorMsg);
488  }
489  if (errorMsg != "") {
490  WRITE_WARNING(errorMsg);
491  }
492  }
493 }
494 
495 
496 bool
497 MSBaseVehicle::hasDevice(const std::string& deviceName) const {
498  for (std::vector<MSDevice* >::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
499  if ((*dev)->deviceName() == deviceName) {
500  return true;
501  }
502  }
503  return false;
504 }
505 
506 
507 void
508 MSBaseVehicle::createDevice(const std::string& deviceName) {
509  if (!hasDevice(deviceName)) {
510  if (deviceName == "rerouting") {
511  ((SUMOVehicleParameter*)myParameter)->setParameter("has." + deviceName + ".device", "true");
513  if (hasDeparted()) {
514  // vehicle already departed: disable pre-insertion rerouting and enable regular routing behavior
515  MSDevice_Routing* routingDevice = static_cast<MSDevice_Routing*>(getDevice(typeid(MSDevice_Routing)));
516  assert(routingDevice != 0);
517  routingDevice->notifyEnter(*this, MSMoveReminder::NOTIFICATION_DEPARTED);
518  }
519  } else {
520  throw InvalidArgument("Creating device of type '" + deviceName + "' is not supported");
521  }
522  }
523 }
524 
525 
526 std::string
527 MSBaseVehicle::getDeviceParameter(const std::string& deviceName, const std::string& key) const {
528  for (std::vector<MSDevice* >::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
529  if ((*dev)->deviceName() == deviceName) {
530  return (*dev)->getParameter(key);
531  }
532  }
533  throw InvalidArgument("No device of type '" + deviceName + "' exists");
534 }
535 
536 
537 void
538 MSBaseVehicle::setDeviceParameter(const std::string& deviceName, const std::string& key, const std::string& value) {
539  for (std::vector<MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
540  if ((*dev)->deviceName() == deviceName) {
541  (*dev)->setParameter(key, value);
542  return;
543  }
544  }
545  throw InvalidArgument("No device of type '" + deviceName + "' exists");
546 }
547 
548 
549 void
551  if (myType->isVehicleSpecific()) {
553  }
554  myType = type;
555 }
556 
557 
560  if (myType->isVehicleSpecific()) {
561  return *myType;
562  }
563  MSVehicleType* type = myType->buildSingularType(myType->getID() + "@" + getID());
564  replaceVehicleType(type);
565  return *type;
566 }
567 
568 
569 #ifdef _DEBUG
570 void
571 MSBaseVehicle::initMoveReminderOutput(const OptionsCont& oc) {
572  if (oc.isSet("movereminder-output.vehicles")) {
573  const std::vector<std::string> vehicles = oc.getStringVector("movereminder-output.vehicles");
574  myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
575  }
576 }
577 
578 
579 void
580 MSBaseVehicle::traceMoveReminder(const std::string& type, MSMoveReminder* rem, double pos, bool keep) const {
581  OutputDevice& od = OutputDevice::getDeviceByOption("movereminder-output");
582  od.openTag("movereminder");
583  od.writeAttr(SUMO_ATTR_TIME, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()));
584  od.writeAttr("veh", getID());
586  od.writeAttr("type", type);
587  od.writeAttr("pos", toString(pos));
588  od.writeAttr("keep", toString(keep));
589  od.closeTag();
590 }
591 #endif
592 
593 /****************************************************************************/
594 
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, ConstMSEdgeVector::const_iterator *searchStart=0)=0
Adds a stop.
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:260
const int VEHPARS_FORCE_REROUTE
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:127
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
bool hasDeparted() const
Returns whether this vehicle has already departed.
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:104
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
The speed is given.
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)=0
Replaces the current route by the given one.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:64
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
double myArrivalPos
The position on the destination lane where the vehicle stops.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
Notification
Definition of a vehicle state.
A device that performs vehicle rerouting based on current edge speeds.
int repetitionsDone
The number of times the vehicle was already inserted.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:357
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:295
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:167
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
T MAX2(T a, T b)
Definition: StdDefs.h:73
virtual ~MSBaseVehicle()
Destructor.
MSBaseVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
const MSRoute * myRoute
This vehicle&#39;s route.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:744
const MSEdge * getLastEdge() const
returns the destination edge
Definition: MSRoute.cpp:91
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
int myArrivalLane
The destination lane where the vehicle stops.
const SUMOVehicleParameter * myParameter
This vehicle&#39;s parameter.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
The arrival position is given.
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:85
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
The car-following model and parameter.
Definition: MSVehicleType.h:72
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
std::string toTaz
The vehicle&#39;s destination zone (district)
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice.cpp:81
double getMaxSpeed() const
Returns the maximum speed.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
A road/street connecting two junctions.
Definition: MSEdge.h:80
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static SUMOTime gTimeToImpatience
Definition: MSGlobals.h:72
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
virtual const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
double myDepartPos
The real depart position.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
void createDevice(const std::string &deviceName)
create device of the given type
std::string routeid
The vehicle&#39;s route id.
static bool gCheckRoutes
Definition: MSGlobals.h:85
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
#define SUMOTime_MAX
Definition: TraCIDefs.h:52
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:191
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:306
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:64
void removeVType(const MSVehicleType *vehType)
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
SUMOTime depart
The vehicle&#39;s departure time.
#define STEPS2TIME(x)
Definition: SUMOTime.h:64
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:253
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
T MIN2(T a, T b)
Definition: StdDefs.h:67
const std::string & getID() const
returns the id of the transportable
std::string fromTaz
The vehicle&#39;s origin zone (district)
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
double getImpatience() const
Returns this vehicles impatience.
virtual const ConstMSEdgeVector getStopEdges() const =0
Returns the list of still pending stop edges.
Something on a lane to be noticed about vehicle movement.
double arrivalPos
(optional) The position the vehicle shall arrive on
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Abstract in-vehicle device.
Definition: MSDevice.h:70
trigger: the time of the step
SUMOVehicleClass getVClass() const
Returns the vehicle&#39;s access class.
The vehicle has departed (was inserted into the network)
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Structure representing possible vehicle parameter.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
bool isTazConnector() const
Definition: MSEdge.h:252
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
virtual double getAcceleration() const
Returns the vehicle&#39;s acceleration.
const std::string & getDescription() const
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:359
MSVehicleType * myType
This vehicle&#39;s type.
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
void onDepart()
Called when the vehicle is inserted into the network.
virtual double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
A storage for options typed value containers)
Definition: OptionsCont.h:98
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
const std::string & getID() const
Returns the name of the vehicle type.
The arrival lane is given.
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:98
int myNumberReroutes
The number of reroutings.
virtual SUMOTime getWaitingTime() const =0
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
bool wasSet(int what) const
Returns whether the given parameter was set.
description of a vehicle
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
long long int SUMOTime
Definition: TraCIDefs.h:51
MSRouteIterator myCurrEdge
Iterator to current route-edge.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:73
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle&#39;s departure.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const std::string & getID() const
Returns the name of the vehicle.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
std::vector< MSDevice * > myDevices
The devices this vehicle has.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
Definition: MSRoute.cpp:189
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:366
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:79
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double getPreviousSpeed() const
Returns the vehicle&#39;s previous speed.
SUMOTime myDeparture
The real departure time.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static const SUMOTime NOT_YET_DEPARTED
std::string id
The vehicle&#39;s id.
double myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit. ...
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:117
The arrival position is chosen randomly.