Eclipse SUMO - Simulation of Urban MObility
MEVehicle.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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A vehicle from the mesoscopic point of view
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <iostream>
24 #include <cassert>
25 #include <utils/common/StdDefs.h>
33 #include <microsim/MSGlobals.h>
34 #include <microsim/MSEdge.h>
35 #include <microsim/MSLane.h>
36 #include <microsim/MSNet.h>
37 #include <microsim/MSVehicleType.h>
38 #include <microsim/MSLink.h>
42 #include "MELoop.h"
43 #include "MEVehicle.h"
44 #include "MESegment.h"
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
51  MSVehicleType* type, const double speedFactor) :
52  MSBaseVehicle(pars, route, type, speedFactor),
53  mySegment(nullptr),
54  myQueIndex(0),
55  myEventTime(SUMOTime_MIN),
56  myLastEntryTime(SUMOTime_MIN),
57  myBlockTime(SUMOTime_MAX) {
58  if (!(*myCurrEdge)->isTazConnector()) {
59  if ((*myCurrEdge)->allowedLanes(type->getVehicleClass()) == nullptr) {
60  throw ProcessError("Vehicle '" + pars->id + "' is not allowed to depart on any lane of its first edge.");
61  }
62  if (pars->departSpeedProcedure == DEPART_SPEED_GIVEN && pars->departSpeed > type->getMaxSpeed()) {
63  throw ProcessError("Departure speed for vehicle '" + pars->id +
64  "' is too high for the vehicle type '" + type->getID() + "'.");
65  }
66  }
67 }
68 
69 
70 double
71 MEVehicle::getBackPositionOnLane(const MSLane* /* lane */) const {
73 }
74 
75 
76 double
78 // the following interpolation causes problems with arrivals and calibrators
79 // const double fracOnSegment = MIN2(double(1), STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - myLastEntryTime) / STEPS2TIME(myEventTime - myLastEntryTime));
80  return mySegment == nullptr ? 0 : (double(mySegment->getIndex()) /* + fracOnSegment */) * mySegment->getLength();
81 }
82 
83 
84 double
86  const MSLane* const lane = getEdge()->getLanes()[0];
88 }
89 
90 
91 double
93  const MSLane* const lane = getEdge()->getLanes()[0];
95 }
96 
97 
99 MEVehicle::getPosition(const double offset) const {
100  const MSLane* const lane = getEdge()->getLanes()[0];
101  return lane->geometryPositionAtOffset(getPositionOnLane() + offset);
102 }
103 
104 
105 double
107  if (getWaitingTime() > 0) {
108  return 0;
109  } else {
110  return getAverageSpeed();
111  }
112 }
113 
114 
115 double
118 }
119 
120 
121 double
124  const double v = getSpeed();
125  return MIN2(link->getViaLaneOrLane()->getVehicleMaxSpeed(this),
126  (double)sqrt(2 * link->getLength() * getVehicleType().getCarFollowModel().getMaxAccel() + v * v));
127 }
128 
129 
130 double
131 MEVehicle::getConservativeSpeed(SUMOTime& earliestArrival) const {
132  earliestArrival = MAX2(myEventTime, earliestArrival - DELTA_T); // event times have subsecond resolution
133  return mySegment->getLength() / STEPS2TIME(earliestArrival - myLastEntryTime);
134 }
135 
136 
137 bool
139  // vehicle has just entered a new edge. Position is 0
140  if (myCurrEdge == myRoute->end() - 1) { // may happen during teleport
141  return true;
142  }
143  ++myCurrEdge;
144  if ((*myCurrEdge)->isVaporizing()) {
145  return true;
146  }
147  // update via
148  if (myParameter->via.size() > 0 && (*myCurrEdge)->getID() == myParameter->via.front()) {
149  myParameter->via.erase(myParameter->via.begin());
150  }
151  return hasArrived();
152 }
153 
154 
155 bool
157  // mySegment may be 0 due to teleporting or arrival
158  return myCurrEdge == myRoute->end() - 1 && (
159  (mySegment == nullptr)
162 }
163 
164 bool
166  return getSegment() != nullptr;
167 }
168 
169 
170 bool
172  return false; // parking attribute of a stop is not yet evaluated /implemented
173 }
174 
175 
176 bool
177 MEVehicle::replaceRoute(const MSRoute* newRoute, const std::string& info, bool onInit, int offset, bool addStops, bool removeStops) {
178  UNUSED_PARAMETER(addStops); // @todo recheck!
179  UNUSED_PARAMETER(removeStops); // @todo recheck!
180  const ConstMSEdgeVector& edges = newRoute->getEdges();
181  // assert the vehicle may continue (must not be "teleported" or whatever to another position)
182  if (!onInit && !newRoute->contains(*myCurrEdge)) {
183  return false;
184  }
185  MSLink* oldLink = nullptr;
186  MSLink* newLink = nullptr;
187  if (mySegment != nullptr) {
188  oldLink = mySegment->getLink(this);
189  }
190  // rebuild in-vehicle route information
191  if (onInit) {
192  myCurrEdge = newRoute->begin();
193  } else {
194  myCurrEdge = std::find(edges.begin() + offset, edges.end(), *myCurrEdge);
195  }
196  // check whether the old route may be deleted (is not used by anyone else)
197  newRoute->addReference();
198  myRoute->release();
199  // assign new route
200  myRoute = newRoute;
201  if (mySegment != nullptr) {
202  newLink = mySegment->getLink(this);
203  }
204  // update approaching vehicle information
205  if (oldLink != nullptr && oldLink != newLink) {
206  oldLink->removeApproaching(this);
207  MELoop::setApproaching(this, newLink);
208  }
209  // update arrival definition
211  // save information that the vehicle was rerouted
215  return true;
216 }
217 
218 
219 bool
220 MEVehicle::addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& /*errorMsg*/, SUMOTime untilOffset, bool /*collision*/,
221  MSRouteIterator* /* searchStart */) {
222  const MSEdge* const edge = MSEdge::dictionary(stopPar.lane.substr(0, stopPar.lane.rfind('_')));
223  assert(edge != 0);
224  MESegment* stopSeg = MSGlobals::gMesoNet->getSegmentForEdge(*edge, stopPar.endPos);
225  std::vector<SUMOVehicleParameter::Stop>& segmentStops = myStops[stopSeg];
226  bool cyclicRoute = (myStopEdges.size() > 0 && myStopEdges.back() == edge
227  && segmentStops.size() > 0 && segmentStops.back().endPos > stopPar.endPos
228  && stopPar.index != STOP_INDEX_FIT);
229  segmentStops.push_back(stopPar);
230  if (segmentStops.back().until >= 0) {
231  segmentStops.back().until += untilOffset;
232  }
233  if (myStopEdges.empty() || myStopEdges.back() != edge || cyclicRoute) {
234  myStopEdges.push_back(edge);
235  }
236  return true;
237 }
238 
239 
240 bool
242  return myStops.find(mySegment) != myStops.end();
243 }
244 
245 
246 bool
248  return false;
249 }
250 
251 
252 bool
253 MEVehicle::isStoppedInRange(const double /* pos */, const double /* tolerance */) const {
254  return isStopped();
255 }
256 
257 
258 SUMOTime
259 MEVehicle::getStoptime(const MESegment* const seg, SUMOTime time) const {
260  if (myStops.find(seg) != myStops.end()) {
261  for (const SUMOVehicleParameter::Stop& stop : myStops.find(seg)->second) {
262  time += stop.duration;
263  if (stop.until > time) {
264  // @note: this assumes the stop is reached at time. With the way this is called in MESegment (time == entryTime),
265  // travel time is overestimated of the stop is not at the start of the segment
266  time = stop.until;
267  }
268  }
269  }
270  return time;
271 }
272 
273 
274 double
277 }
278 
279 
280 const ConstMSEdgeVector
281 MEVehicle::getStopEdges(double& firstPos, double& lastPos) const {
282  if (myStopEdges.size() > 0) {
283  // always try to skip
284  firstPos = myStopEdges.front()->getLength();
285  lastPos = 0;
286  }
287  return myStopEdges;
288 }
289 
290 
291 std::vector<std::pair<int, double> >
293  std::vector<std::pair<int, double> > result;
294  auto it = myCurrEdge;
295  for (const MSEdge* e : myStopEdges) {
296  auto it2 = std::find(it, myRoute->end(), e);
297  if (it2 != myRoute->end()) {
298  result.push_back(std::make_pair((int)(it2 - myRoute->begin()), 0));
299  it = it2;
300  }
301  }
302  return result;
303 }
304 
305 void
307  assert(isStopped());
308  MSEdge* edge = const_cast<MSEdge*>(getEdge());
309  auto segStopsIt = myStops.find(mySegment);
310  std::vector<SUMOVehicleParameter::Stop>& stops = segStopsIt->second;
311  double lastPos = 0;
312  for (auto it = stops.begin(); it != stops.end();) {
313  SUMOVehicleParameter::Stop stop = *it;
314  if (stop.endPos <= lastPos) {
315  break;
316  }
317  lastPos = stop.endPos;
318  if (MSStopOut::active()) {
320  }
321  MSNet* const net = MSNet::getInstance();
322  SUMOTime dummy = -1; // boarding- and loading-time are not considered
323  if (net->hasPersons()) {
324  net->getPersonControl().boardAnyWaiting(edge, this, stop, dummy, dummy);
325  }
326  if (net->hasContainers()) {
327  net->getContainerControl().loadAnyWaiting(edge, this, stop, dummy, dummy);
328  }
329  MSDevice_Vehroutes* vehroutes = static_cast<MSDevice_Vehroutes*>(getDevice(typeid(MSDevice_Vehroutes)));
330  if (vehroutes != nullptr) {
331  vehroutes->stopEnded(stop);
332  }
333  if (MSStopOut::active()) {
335  }
336  it = stops.erase(it);
337  }
339  // clean up stops
340  if (stops.size() == 0) {
341  myStops.erase(segStopsIt);
342  }
343  bool removeStopEdge = true;
344  // remove the current stop edge if there are no stops on further segments of this edge
345  for (MESegment* next = mySegment->getNextSegment(); next != nullptr; next = next->getNextSegment()) {
346  if (myStops.count(next) != 0) {
347  removeStopEdge = false;
348  break;
349  }
350  }
351  if (removeStopEdge) {
352  if (myStopEdges.size() > 0) {
353  myStopEdges.erase(myStopEdges.begin());
354  } else {
355  assert(false);
356  }
357  }
358 }
359 
360 
361 bool
363  return mySegment == nullptr || mySegment->isOpen(this);
364 }
365 
366 
367 double
369  if (mySegment == nullptr) {
370  return 0;
371  } else {
372  return STEPS2TIME(mySegment->getLinkPenalty(this));
373  }
374 }
375 
376 
377 void
379  for (MoveReminderCont::iterator i = myMoveReminders.begin(); i != myMoveReminders.end(); ++i) {
380  if (i->first == rem) {
382  (mySegment->getIndex() + 1) * mySegment->getLength(),
383  getLastEntryTime(), currentTime, exitTime, false);
384 #ifdef _DEBUG
385  if (myTraceMoveReminders) {
386  traceMoveReminder("notifyMove", i->first, i->second, true);
387  }
388 #endif
389  return;
390  }
391  }
392 }
393 
394 
395 void
396 MEVehicle::updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason) {
397  // segments of the same edge have the same reminder so no cleaning up must take place
398  const bool cleanUp = isLeave && (reason != MSMoveReminder::NOTIFICATION_SEGMENT);
399  for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
400  if (currentTime != getLastEntryTime()) {
401  rem->first->updateDetector(*this, mySegment->getIndex() * mySegment->getLength(),
402  (mySegment->getIndex() + 1) * mySegment->getLength(),
403  getLastEntryTime(), currentTime, getEventTime(), cleanUp);
404 #ifdef _DEBUG
405  if (myTraceMoveReminders) {
406  traceMoveReminder("notifyMove", rem->first, rem->second, true);
407  }
408 #endif
409  }
410  if (!isLeave || rem->first->notifyLeave(*this, mySegment->getLength(), reason)) {
411 #ifdef _DEBUG
412  if (isLeave && myTraceMoveReminders) {
413  traceMoveReminder("notifyLeave", rem->first, rem->second, true);
414  }
415 #endif
416  ++rem;
418  myOdometer += getEdge()->getLength();
419  }
420  } else {
421 #ifdef _DEBUG
422  if (myTraceMoveReminders) {
423  traceMoveReminder("remove", rem->first, rem->second, false);
424  }
425 #endif
426  rem = myMoveReminders.erase(rem);
427  }
428  }
429 }
430 
431 
432 void
434  if (mySegment != nullptr && MESegment::isInvalid(mySegment)) {
435  // segment is vaporization target, do not write this vehicle
436  return;
437  }
439  assert(mySegment == 0 || *myCurrEdge == &mySegment->getEdge());
440  std::vector<SUMOTime> internals;
441  internals.push_back(myDeparture);
442  internals.push_back((SUMOTime)distance(myRoute->begin(), myCurrEdge));
443  internals.push_back((SUMOTime)myDepartPos * 1000); // store as mm
444  internals.push_back(mySegment == nullptr ? (SUMOTime) - 1 : (SUMOTime)mySegment->getIndex());
445  internals.push_back((SUMOTime)getQueIndex());
446  internals.push_back(myEventTime);
447  internals.push_back(myLastEntryTime);
448  internals.push_back(myBlockTime);
449  out.writeAttr(SUMO_ATTR_STATE, toString(internals));
450  // save stops and parameters
451  for (const auto& it : myStops) {
452  for (const SUMOVehicleParameter::Stop& stop : it.second) {
453  stop.write(out);
454  }
455  }
456  myParameter->writeParams(out);
457  for (MSDevice* dev : myDevices) {
458  dev->saveState(out);
459  }
460  out.closeTag();
461 }
462 
463 
464 void
465 MEVehicle::loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) {
466  if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
467  throw ProcessError("Error: Invalid vehicles in state (may be a micro state)!");
468  }
469  int routeOffset;
470  int segIndex;
471  int queIndex;
472  std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
473  bis >> myDeparture;
474  bis >> routeOffset;
475  bis >> myDepartPos;
476  bis >> segIndex;
477  bis >> queIndex;
478  bis >> myEventTime;
479  bis >> myLastEntryTime;
480  bis >> myBlockTime;
481  myDepartPos *= 1000; // was stored as mm
482  if (hasDeparted()) {
483  myDeparture -= offset;
484  myEventTime -= offset;
485  myLastEntryTime -= offset;
486  myCurrEdge += routeOffset;
487  if (segIndex >= 0) {
489  while (seg->getIndex() != (int)segIndex) {
490  seg = seg->getNextSegment();
491  assert(seg != 0);
492  }
493  setSegment(seg, queIndex);
494  } else {
495  // on teleport
496  setSegment(nullptr, 0);
497  assert(myEventTime != SUMOTime_MIN);
498  MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
499  }
500  }
501  if (myBlockTime != SUMOTime_MAX) {
502  myBlockTime -= offset;
503  }
504 }
505 
506 
507 /****************************************************************************/
508 
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:65
MSTransportableControl::boardAnyWaiting
bool boardAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
Definition: MSTransportableControl.cpp:153
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
MSRoute::release
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:100
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:93
MSBaseVehicle::hasDeparted
bool hasDeparted() const
Returns whether this vehicle has already departed.
Definition: MSBaseVehicle.cpp:379
SUMOSAXAttributes::hasAttribute
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
MSStopOut.h
MSNet::hasContainers
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:369
MSBaseVehicle::getContainerNumber
int getContainerNumber() const
Returns the number of containers.
Definition: MSBaseVehicle.cpp:633
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
SUMOSAXAttributes::getString
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SUMOVehicleParameter::Stop::lane
std::string lane
The lane to stop at.
Definition: SUMOVehicleParameter.h:586
MESegment
A single mesoscopic segment (cell)
Definition: MESegment.h:49
MEVehicle::updateDetectorForWriting
void updateDetectorForWriting(MSMoveReminder *rem, SUMOTime currentTime, SUMOTime exitTime)
Updates a single vehicle detector if present.
Definition: MEVehicle.cpp:378
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSBaseVehicle::myDeparture
SUMOTime myDeparture
The real departure time.
Definition: MSBaseVehicle.h:551
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
MSRoute::end
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:75
MSRouteIterator
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:57
MEVehicle::getAverageSpeed
double getAverageSpeed() const
Returns the vehicle's estimated average speed on the segment assuming no further delays.
Definition: MEVehicle.cpp:116
MSStopOut::getInstance
static MSStopOut * getInstance()
Definition: MSStopOut.h:62
SUMOVehicleParameter::departSpeed
double departSpeed
(optional) The initial speed of the vehicle
Definition: SUMOVehicleParameter.h:506
MEVehicle::saveState
void saveState(OutputDevice &out)
Saves the states of a vehicle.
Definition: MEVehicle.cpp:433
MEVehicle::myStopEdges
ConstMSEdgeVector myStopEdges
edges to stop
Definition: MEVehicle.h:385
MSNet::getContainerControl
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:818
MSBaseVehicle::myDevices
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
Definition: MSBaseVehicle.h:542
MSNet::informVehicleStateListener
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
Definition: MSNet.cpp:894
MESegment::getEdge
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:265
MsgHandler.h
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
FileHelpers.h
MEVehicle::getPositionOnLane
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MEVehicle.cpp:77
MEVehicle::getLastEntryTime
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
Definition: MEVehicle.h:271
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSBaseVehicle::myRoute
const MSRoute * myRoute
This vehicle's route.
Definition: MSBaseVehicle.h:515
PositionVector::slopeDegreeAtOffset
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
Definition: PositionVector.cpp:325
MEVehicle::getPosition
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MEVehicle.cpp:99
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
MEVehicle::myBlockTime
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
Definition: MEVehicle.h:379
MSNet::hasPersons
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:353
MEVehicle::getCurrentStoppingTimeSeconds
double getCurrentStoppingTimeSeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
Definition: MEVehicle.cpp:275
MSRoute::getEdges
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:120
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
MSEdge.h
MESegment::isOpen
bool isOpen(const MEVehicle *veh) const
Returns whether the vehicle may use the next link.
Definition: MESegment.cpp:405
MSEdge::getLength
double getLength() const
return the length of the edge
Definition: MSEdge.h:589
MSNet::VEHICLE_STATE_NEWROUTE
@ VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
Definition: MSNet.h:547
MSRoute
Definition: MSRoute.h:66
MSTransportableControl::loadAnyWaiting
bool loadAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
Definition: MSTransportableControl.cpp:198
MSDevice.h
MEVehicle::moveRoutePointer
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
Definition: MEVehicle.cpp:138
Parameterised::writeParams
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
Definition: Parameterised.cpp:154
MSBaseVehicle::calculateArrivalParams
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
Definition: MSBaseVehicle.cpp:512
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:66
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
MSVehicleType.h
MSBaseVehicle::myParameter
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
Definition: MSBaseVehicle.h:512
MSBaseVehicle::myArrivalPos
double myArrivalPos
The position on the destination lane where the vehicle stops.
Definition: MSBaseVehicle.h:557
MESegment.h
SUMOTime_MIN
#define SUMOTime_MIN
Definition: SUMOTime.h:36
MSBaseVehicle::getEdge
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
Definition: MSBaseVehicle.cpp:181
MEVehicle::updateDetectors
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
Definition: MEVehicle.cpp:396
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
MEVehicle::getEventTime
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves his current cell.
Definition: MEVehicle.h:229
BinaryInputDevice.h
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
MEVehicle::getSlope
double getSlope() const
Returns the slope of the road at vehicle's position.
Definition: MEVehicle.cpp:92
MELoop::addLeaderCar
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:197
MSBaseVehicle::saveState
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
Definition: MSBaseVehicle.cpp:575
MSMoveReminder::updateDetector
void updateDetector(SUMOTrafficObject &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
Definition: MSMoveReminder.cpp:47
MEVehicle::isStopped
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MEVehicle.cpp:241
MEVehicle::addStop
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
Definition: MEVehicle.cpp:220
MEVehicle::loadState
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
Definition: MEVehicle.cpp:465
MEVehicle::getAngle
double getAngle() const
Returns the vehicle's direction in degrees.
Definition: MEVehicle.cpp:85
MSTransportableControl.h
DEPART_SPEED_GIVEN
@ DEPART_SPEED_GIVEN
The speed is given.
Definition: SUMOVehicleParameter.h:196
MEVehicle::mayProceed
bool mayProceed() const
Returns whether the vehicle is allowed to pass the next junction.
Definition: MEVehicle.cpp:362
MSEdge::dictionary
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:765
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
STOP_INDEX_FIT
const int STOP_INDEX_FIT
Definition: SUMOVehicleParameter.h:72
SUMOVehicleParameter::id
std::string id
The vehicle's id.
Definition: SUMOVehicleParameter.h:468
MSBaseVehicle::myDepartPos
double myDepartPos
The real depart position.
Definition: MSBaseVehicle.h:554
MSLane::interpolateLanePosToGeometryPos
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:498
MEVehicle::isStoppedTriggered
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
Definition: MEVehicle.cpp:247
MELoop::getSegmentForEdge
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:292
MEVehicle::getBackPositionOnLane
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
Definition: MEVehicle.cpp:71
OutputDevice.h
MESegment::getLink
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
Definition: MESegment.cpp:376
MSStopOut::active
static bool active()
Definition: MSStopOut.h:56
MSDevice
Abstract in-vehicle / in-person device.
Definition: MSDevice.h:63
ProcessError
Definition: UtilExceptions.h:39
MEVehicle::getStoptime
SUMOTime getStoptime(const MESegment *const seg, SUMOTime time) const
Returns until when to stop at the given segment.
Definition: MEVehicle.cpp:259
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
MEVehicle::isOnRoad
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MEVehicle.cpp:165
MEVehicle::MEVehicle
MEVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
Definition: MEVehicle.cpp:50
MSGlobals.h
SUMOVehicleParameter::Stop::write
void write(OutputDevice &dev) const
Writes the stop as XML.
Definition: SUMOVehicleParameter.cpp:175
MESegment::getNextSegment
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition: MESegment.h:151
MEVehicle::processStop
void processStop()
ends the current stop and performs loading/unloading
Definition: MEVehicle.cpp:306
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
SUMOVehicleParameter::Stop::endPos
double endPos
The stopping position end.
Definition: SUMOVehicleParameter.h:604
MSBaseVehicle::getVehicleType
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Definition: MSBaseVehicle.h:123
MEVehicle::getStopIndices
std::vector< std::pair< int, double > > getStopIndices() const
return list of route indices for the remaining stops
Definition: MEVehicle.cpp:292
SUMO_ATTR_POSITION
@ SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:660
MELoop::setApproaching
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:204
MSMoveReminder::NOTIFICATION_SEGMENT
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
Definition: MSMoveReminder.h:97
MSBaseVehicle::myNumberReroutes
int myNumberReroutes
The number of reroutings.
Definition: MSBaseVehicle.h:563
MEVehicle::estimateLeaveSpeed
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle's estimated speed after driving accross the link.
Definition: MEVehicle.cpp:122
MSBaseVehicle::addStops
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Definition: MSBaseVehicle.cpp:593
MSDevice_Vehroutes::stopEnded
void stopEnded(const SUMOVehicleParameter::Stop &stop)
Definition: MSDevice_Vehroutes.cpp:170
MEVehicle::getWaitingTime
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition: MEVehicle.h:294
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
MSLane::getShape
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:477
MEVehicle::getCurrentLinkPenaltySeconds
double getCurrentLinkPenaltySeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
Definition: MEVehicle.cpp:368
SUMO_ATTR_STATE
@ SUMO_ATTR_STATE
The state of a link.
Definition: SUMOXMLDefinitions.h:708
MESegment::isInvalid
static bool isInvalid(const MESegment *segment)
whether the given segment is 0 or encodes vaporization
Definition: MESegment.h:341
MEVehicle::getSegment
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition: MEVehicle.h:247
MEVehicle::replaceRoute
bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
Definition: MEVehicle.cpp:177
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSNet::getPersonControl
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:810
MSGlobals::gMesoNet
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:105
MSBaseVehicle::myCurrEdge
MSRouteIterator myCurrEdge
Iterator to current route-edge.
Definition: MSBaseVehicle.h:521
MSDevice_Vehroutes
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Vehroutes.h:52
SUMOVehicleParameter::via
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Definition: SUMOVehicleParameter.h:659
MESegment::getLength
double getLength() const
Returns the length of the segment in meters.
Definition: MESegment.h:159
MEVehicle::mySegment
MESegment * mySegment
The segment the vehicle is at.
Definition: MEVehicle.h:367
SUMOVehicleParameter::Stop::index
int index
at which position in the stops list
Definition: SUMOVehicleParameter.h:649
MEVehicle::myLastEntryTime
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
Definition: MEVehicle.h:376
MEVehicle::isParking
bool isParking() const
Returns whether the vehicle is parking.
Definition: MEVehicle.cpp:171
MEVehicle::getSpeed
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
Definition: MEVehicle.cpp:106
MEVehicle::getConservativeSpeed
double getConservativeSpeed(SUMOTime &earliestArrival) const
Returns the vehicle's estimated speed taking into account delays.
Definition: MEVehicle.cpp:131
PositionVector::rotationAtOffset
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Definition: PositionVector.cpp:294
MEVehicle::isStoppedInRange
bool isStoppedInRange(const double pos, const double tolerance) const
return whether the given position is within range of the current stop
Definition: MEVehicle.cpp:253
MSVehicleType::getLength
double getLength() const
Get vehicle's length [m].
Definition: MSVehicleType.h:109
MEVehicle::hasArrived
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
Definition: MEVehicle.cpp:156
MSStopOut::stopStarted
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
Definition: MSStopOut.cpp:63
MEVehicle::setSegment
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
Definition: MEVehicle.h:238
MSBaseVehicle::getPersonNumber
int getPersonNumber() const
Returns the number of persons.
Definition: MSBaseVehicle.cpp:617
MEVehicle::getStopEdges
const ConstMSEdgeVector getStopEdges(double &firstPos, double &lastPos) const
Returns the list of still pending stop edges.
Definition: MEVehicle.cpp:281
SUMOSAXAttributes.h
MSBaseVehicle
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
MEVehicle.h
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:167
MSDevice_Vehroutes.h
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:161
MEVehicle::getQueIndex
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition: MEVehicle.h:255
MSRoute::begin
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:69
config.h
StdDefs.h
MSLane::geometryPositionAtOffset
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:504
MELoop.h
MESegment::getLinkPenalty
SUMOTime getLinkPenalty(const MEVehicle *veh) const
Returns the penalty time for passing a link (if using gMesoTLSPenalty > 0 or gMesoMinorPenalty > 0)
Definition: MESegment.cpp:710
SUMOTime_MAX
#define SUMOTime_MAX
Definition: SUMOTime.h:35
MSRoute::addReference
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:94
MSLane.h
MSLane::getVehicleMaxSpeed
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:518
MSEdge::removeWaiting
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
Definition: MSEdge.cpp:1115
MSVehicleType::getVehicleClass
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
Definition: MSVehicleType.h:184
MSBaseVehicle::myOdometer
double myOdometer
A simple odometer to keep track of the length of the route already driven.
Definition: MSBaseVehicle.h:566
MSRoute::contains
bool contains(const MSEdge *const edge) const
Definition: MSRoute.h:102
MSStopOut::stopEnded
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID)
Definition: MSStopOut.cpp:98
MESegment::getIndex
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition: MESegment.h:143
MSBaseVehicle::getDevice
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
Definition: MSBaseVehicle.cpp:564
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
MSBaseVehicle::myMoveReminders
MoveReminderCont myMoveReminders
Currently relevant move reminders.
Definition: MSBaseVehicle.h:538
MSVehicleControl.h
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
POSITION_EPS
#define POSITION_EPS
Definition: config.h:172
MSMoveReminder::NOTIFICATION_JUNCTION
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
Definition: MSMoveReminder.h:95
MEVehicle::myStops
std::map< const MESegment *const, std::vector< SUMOVehicleParameter::Stop > > myStops
where to stop
Definition: MEVehicle.h:382
MEVehicle::myEventTime
SUMOTime myEventTime
The (planned) time of leaving the segment (cell)
Definition: MEVehicle.h:373
MSMoveReminder::NOTIFICATION_TELEPORT
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
Definition: MSMoveReminder.h:103
SUMOVehicleParameter::departSpeedProcedure
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
Definition: SUMOVehicleParameter.h:509
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:572