Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MEVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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/****************************************************************************/
19// A vehicle from the mesoscopic point of view
20/****************************************************************************/
21#include <config.h>
22
23#include <iostream>
24#include <cassert>
34#include <microsim/MSGlobals.h>
35#include <microsim/MSEdge.h>
36#include <microsim/MSLane.h>
37#include <microsim/MSNet.h>
39#include <microsim/MSLink.h>
40#include <microsim/MSStop.h>
44#include "MELoop.h"
45#include "MEVehicle.h"
46#include "MESegment.h"
47
48
49// ===========================================================================
50// method definitions
51// ===========================================================================
53 MSVehicleType* type, const double speedFactor) :
54 MSBaseVehicle(pars, route, type, speedFactor),
55 mySegment(nullptr),
56 myQueIndex(0),
57 myEventTime(SUMOTime_MIN),
58 myLastEntryTime(SUMOTime_MIN),
59 myBlockTime(SUMOTime_MAX),
60 myInfluencer(nullptr) {
61 if (!(*myCurrEdge)->isTazConnector()) {
62 if ((*myCurrEdge)->allowedLanes(type->getVehicleClass()) == nullptr) {
63 throw ProcessError("Vehicle '" + pars->id + "' is not allowed to depart on any lane of edge '" + (*myCurrEdge)->getID() + "'.");
64 }
65 if (pars->departSpeedProcedure == DepartSpeedDefinition::GIVEN && pars->departSpeed > type->getMaxSpeed() + SPEED_EPS) {
66 throw ProcessError("Departure speed for vehicle '" + pars->id +
67 "' is too high for the vehicle type '" + type->getID() + "'.");
68 }
69 }
70}
71
72
73double
74MEVehicle::getBackPositionOnLane(const MSLane* /* lane */) const {
76}
77
78
79double
81// the following interpolation causes problems with arrivals and calibrators
82// const double fracOnSegment = MIN2(double(1), STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - myLastEntryTime) / STEPS2TIME(myEventTime - myLastEntryTime));
83 return mySegment == nullptr ? 0 : (double(mySegment->getIndex()) /* + fracOnSegment */) * mySegment->getLength();
84}
85
86
87double
89 const MSLane* const lane = getEdge()->getLanes()[0];
91}
92
93
94double
96 const MSLane* const lane = getEdge()->getLanes()[0];
98}
99
100
102MEVehicle::getPosition(const double offset) const {
103 const MSLane* const lane = getEdge()->getLanes()[0];
104 return lane->geometryPositionAtOffset(getPositionOnLane() + offset);
105}
106
107
108double
110 if (getWaitingTime() > 0 || isStopped()) {
111 return 0;
112 } else {
113 return getAverageSpeed();
114 }
115}
116
117
118double
120 return mySegment != nullptr ? MIN2(mySegment->getLength() / STEPS2TIME(myEventTime - myLastEntryTime), getEdge()->getVehicleMaxSpeed(this)) : 0;
121}
122
123
124double
127 const double v = getSpeed();
128 return MIN2(link->getViaLaneOrLane()->getVehicleMaxSpeed(this),
129 (double)sqrt(2 * link->getLength() * getVehicleType().getCarFollowModel().getMaxAccel() + v * v));
130}
131
132
133double
135 earliestArrival = MAX2(myEventTime, earliestArrival - DELTA_T); // event times have subsecond resolution
136 return mySegment->getLength() / STEPS2TIME(earliestArrival - myLastEntryTime);
137}
138
139
140bool
142 // vehicle has just entered a new edge. Position is 0
143 if (myCurrEdge == myRoute->end() - 1 || (myParameter->arrivalEdge >= 0 && getRoutePosition() >= myParameter->arrivalEdge)) { // may happen during teleport
144 return true;
145 }
146 ++myCurrEdge;
147 if ((*myCurrEdge)->isVaporizing()) {
148 return true;
149 }
150 // update via
151 if (myParameter->via.size() > 0 && (*myCurrEdge)->getID() == myParameter->via.front()) {
152 myParameter->via.erase(myParameter->via.begin());
153 }
154 return hasArrived();
155}
156
157
158bool
160 // mySegment may be 0 due to teleporting or arrival
161 return (myCurrEdge == myRoute->end() - 1 || (myParameter->arrivalEdge >= 0 && getRoutePosition() >= myParameter->arrivalEdge)) && (
162 (mySegment == nullptr)
164 || getPositionOnLane() > myArrivalPos - POSITION_EPS);
165}
166
167
168bool
170 return getSegment() != nullptr;
171}
172
173
174bool
176 return false;
177}
178
179
180void
182 if (link != nullptr) {
183 const double speed = getSpeed();
184 link->setApproaching(this, getEventTime() + (link->getState() == LINKSTATE_ALLWAY_STOP ?
185 (SUMOTime)RandHelper::rand((int)2) : 0), // tie braker
186 speed, speed, true,
187 speed, getWaitingTime(),
188 // @note: dist is not used by meso (getZipperSpeed is never called)
189 getSegment()->getLength(), 0);
190 }
191}
192
193
194bool
195MEVehicle::replaceRoute(ConstMSRoutePtr newRoute, const std::string& info, bool onInit, int offset, bool addRouteStops, bool removeStops, std::string* msgReturn) {
196 MSLink* const oldLink = mySegment != nullptr ? mySegment->getLink(this) : nullptr;
197 if (MSBaseVehicle::replaceRoute(newRoute, info, onInit, offset, addRouteStops, removeStops, msgReturn)) {
198 if (mySegment != nullptr) {
199 MSLink* const newLink = mySegment->getLink(this);
200 // update approaching vehicle information
201 if (oldLink != newLink) {
202 if (oldLink != nullptr) {
203 oldLink->removeApproaching(this);
204 }
205 setApproaching(newLink);
206 }
207 }
208 return true;
209 }
210 return false;
211}
212
213
216 const SUMOTime initialTime = time;
217 bool hadStop = false;
218 for (MSStop& stop : myStops) {
219 if (stop.joinTriggered) {
220 WRITE_WARNINGF(TL("Join stops are not available in meso yet (vehicle '%', segment '%')."),
221 getID(), mySegment->getID());
222 continue;
223 }
224 if (stop.edge != myCurrEdge || stop.segment != mySegment) {
225 break;
226 }
227 const SUMOTime cur = time;
228 if (stop.duration > 0) { // it might be a triggered stop with duration -1
229 time += stop.duration;
230 }
231 if (stop.pars.until > time) {
232 // @note: this assumes the stop is reached at time. With the way this is called in MESegment (time == entryTime),
233 // travel time is overestimated of the stop is not at the start of the segment
234 time = stop.pars.until;
235 }
236 if (MSGlobals::gUseStopEnded && stop.pars.ended >= 0) {
237 time = MAX2(cur, stop.pars.ended);
238 }
239 if (!stop.reached) {
240 stop.reached = true;
241 stop.pars.started = myLastEntryTime;
242 stop.endBoarding = stop.pars.extension >= 0 ? time + stop.pars.extension : SUMOTime_MAX;
243 if (MSStopOut::active()) {
244 if (!hadStop) {
246 } else {
247 WRITE_WARNINGF(TL("Vehicle '%' has multiple stops on segment '%', time=% (stop-output will be merged)."),
248 getID(), mySegment->getID(), time2string(time));
249 }
250 }
251 MSDevice_Taxi* taxi = static_cast<MSDevice_Taxi*>(getDevice(typeid(MSDevice_Taxi)));
252 if (taxi != nullptr) {
253 taxi->notifyMove(*this, 0, 0, 0);
254 }
255 }
256 if (stop.triggered || stop.containerTriggered || stop.joinTriggered) {
257 time = MAX2(time, cur + DELTA_T);
258 }
259 hadStop = true;
260 }
261 MSDevice_Tripinfo* tripinfo = static_cast<MSDevice_Tripinfo*>(getDevice(typeid(MSDevice_Tripinfo)));
262 if (tripinfo != nullptr) {
263 tripinfo->updateStopTime(time - initialTime);
264 }
265 return time;
266}
267
268
269bool
271 if (isStopped()) {
272 const SUMOTime now = SIMSTEP;
273 MSStop& stop = myStops.front();
274 stop.pars.ended = now;
275 for (const auto& rem : myMoveReminders) {
276 rem.first->notifyStopEnded();
277 }
278 if (MSStopOut::active()) {
280 }
281 myPastStops.push_back(stop.pars);
285 }
286 myStops.pop_front();
287 if (myEventTime > now) {
288 // if this is an aborted stop we need to change the event time of the vehicle
289 if (MSGlobals::gMesoNet->removeLeaderCar(this)) {
290 myEventTime = now + 1;
291 MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
292 }
293 }
294 return true;
295 }
296 return false;
297}
298
299
300double
303 for (const MSStop& stop : myStops) {
304 if (stop.reached) {
305 time += stop.duration;
306 if (stop.pars.until > time) {
307 // @note: this assumes the stop is reached at time. With the way this is called in MESegment (time == entryTime),
308 // travel time is overestimated of the stop is not at the start of the segment
309 time = stop.pars.until;
310 }
311 } else {
312 break;
313 }
314 }
315 return STEPS2TIME(time - myLastEntryTime);
316}
317
318
319void
321 assert(isStopped());
322 double lastPos = -1;
323 bool hadStop = false;
324 while (!myStops.empty()) {
325 MSStop& stop = myStops.front();
326 if (stop.edge != myCurrEdge || stop.segment != mySegment || stop.pars.endPos <= lastPos) {
327 break;
328 }
329 lastPos = stop.pars.endPos;
330 MSNet* const net = MSNet::getInstance();
331 SUMOTime dummy = -1; // boarding- and loading-time are not considered
332 if (net->hasPersons()) {
333 net->getPersonControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy);
334 }
335 if (net->hasContainers()) {
336 net->getContainerControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy);
337 }
338 if (hadStop && MSStopOut::active()) {
340 }
342 hadStop = true;
343 }
345}
346
347
348bool
350 if (mySegment == nullptr) {
351 return true;
352 }
353 MSNet* const net = MSNet::getInstance();
354 SUMOTime dummy = -1; // boarding- and loading-time are not considered
355 for (MSStop& stop : myStops) {
356 if (!stop.reached) {
357 break;
358 }
359 if (net->getCurrentTimeStep() > stop.endBoarding) {
360 stop.triggered = false;
361 stop.containerTriggered = false;
365 }
366 }
367 if (stop.triggered) {
369 // we could not check this on entering the segment because there may be persons who still want to leave
370 WRITE_WARNINGF(TL("Vehicle '%' ignores triggered stop on lane '%' due to capacity constraints."), getID(), stop.lane->getID());
371 stop.triggered = false;
375 }
376 } else if (!net->hasPersons() || !net->getPersonControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy)) {
380 }
381 return false;
382 }
383 }
384 if (stop.containerTriggered) {
385 if (getVehicleType().getContainerCapacity() == getContainerNumber()) {
386 // we could not check this on entering the segment because there may be containers who still want to leave
387 WRITE_WARNINGF(TL("Vehicle '%' ignores container triggered stop on lane '%' due to capacity constraints."), getID(), stop.lane->getID());
388 stop.containerTriggered = false;
392 }
393 } else if (!net->hasContainers() || !net->getContainerControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy)) {
397 }
398 return false;
399 }
400 }
401 if (stop.joinTriggered) {
402 // TODO do something useful here
403 return false;
404 }
405 }
406 return mySegment->isOpen(this);
407}
408
409
410double
412 if (mySegment == nullptr) {
413 return 0;
414 } else {
415 return STEPS2TIME(mySegment->getLinkPenalty(this));
416 }
417}
418
419
420void
422 for (MoveReminderCont::iterator i = myMoveReminders.begin(); i != myMoveReminders.end(); ++i) {
423 if (i->first == rem) {
426 getLastEntryTime(), currentTime, exitTime, false);
427#ifdef _DEBUG
428 if (myTraceMoveReminders) {
429 traceMoveReminder("notifyMove", i->first, i->second, true);
430 }
431#endif
432 return;
433 }
434 }
435}
436
437
438void
439MEVehicle::updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason) {
440 // segments of the same edge have the same reminder so no cleaning up must take place
441 const bool cleanUp = isLeave && (reason != MSMoveReminder::NOTIFICATION_SEGMENT);
442 for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
443 if (currentTime != getLastEntryTime()) {
444 rem->first->updateDetector(*this, mySegment->getIndex() * mySegment->getLength(),
446 getLastEntryTime(), currentTime, getEventTime(), cleanUp);
447#ifdef _DEBUG
448 if (myTraceMoveReminders) {
449 traceMoveReminder("notifyMove", rem->first, rem->second, true);
450 }
451#endif
452 }
453 if (!isLeave || rem->first->notifyLeave(*this, mySegment->getLength(), reason)) {
454#ifdef _DEBUG
455 if (isLeave && myTraceMoveReminders) {
456 traceMoveReminder("notifyLeave", rem->first, rem->second, true);
457 }
458#endif
459 ++rem;
460 } else {
461#ifdef _DEBUG
462 if (myTraceMoveReminders) {
463 traceMoveReminder("remove", rem->first, rem->second, false);
464 }
465#endif
466 rem = myMoveReminders.erase(rem);
467 }
468 }
471 }
472}
473
474
477 if (myInfluencer == nullptr) {
479 }
480 return *myInfluencer;
481}
482
483
488
489
490void
495
496double
497MEVehicle::getRightSideOnEdge(const MSLane* /*lane*/) const {
498 if (mySegment == nullptr || mySegment->getIndex() >= getEdge()->getNumLanes()) {
499 return 0;
500 }
501 const MSLane* lane = getEdge()->getLanes()[mySegment->getIndex()];
502 return lane->getRightSideOnEdge() + lane->getWidth() * 0.5 - 0.5 * getVehicleType().getWidth();
503
504}
505
506
507void
509 if (mySegment != nullptr && MESegment::isInvalid(mySegment)) {
510 // segment is vaporization target, do not write this vehicle
511 return;
512 }
514 assert(mySegment == nullptr || *myCurrEdge == &mySegment->getEdge());
515 std::vector<SUMOTime> internals;
516 internals.push_back(myParameter->parametersSet);
517 internals.push_back(myDeparture);
518 internals.push_back((SUMOTime)distance(myRoute->begin(), myCurrEdge));
519 internals.push_back((SUMOTime)myDepartPos * 1000); // store as mm
520 internals.push_back(mySegment == nullptr ? (SUMOTime) - 1 : (SUMOTime)mySegment->getIndex());
521 internals.push_back((SUMOTime)getQueIndex());
522 internals.push_back(myEventTime);
523 internals.push_back(myLastEntryTime);
524 internals.push_back(myBlockTime);
525 out.writeAttr(SUMO_ATTR_STATE, toString(internals));
526 // save past stops
528 stop.write(out, false);
529 // do not write started and ended twice
530 if ((stop.parametersSet & STOP_STARTED_SET) == 0) {
531 out.writeAttr(SUMO_ATTR_STARTED, time2string(stop.started));
532 }
533 if ((stop.parametersSet & STOP_ENDED_SET) == 0) {
534 out.writeAttr(SUMO_ATTR_ENDED, time2string(stop.ended));
535 }
536 out.closeTag();
537 }
538 // save upcoming stops
539 for (const MSStop& stop : myStops) {
540 stop.write(out);
541 }
542 // save parameters
544 for (MSDevice* dev : myDevices) {
545 dev->saveState(out);
546 }
547 out.closeTag();
548}
549
550
551void
553 if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
554 throw ProcessError(TL("Error: Invalid vehicles in state (may be a micro state)!"));
555 }
556 int routeOffset;
557 int segIndex;
558 int queIndex;
559 std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
561 bis >> myDeparture;
562 bis >> routeOffset;
563 bis >> myDepartPos;
564 bis >> segIndex;
565 bis >> queIndex;
566 bis >> myEventTime;
567 bis >> myLastEntryTime;
568 bis >> myBlockTime;
569 myDepartPos /= 1000.; // was stored as mm
570 if (hasDeparted()) {
571 myDeparture -= offset;
572 myEventTime -= offset;
573 myLastEntryTime -= offset;
574 myCurrEdge = myRoute->begin() + routeOffset;
575 if (segIndex >= 0) {
577 while (seg->getIndex() != (int)segIndex) {
578 seg = seg->getNextSegment();
579 assert(seg != 0);
580 }
581 setSegment(seg, queIndex);
582 if (queIndex == MESegment::PARKING_QUEUE) {
583 MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
584 }
585 } else {
586 // on teleport
587 setSegment(nullptr, 0);
588 assert(myEventTime != SUMOTime_MIN);
589 MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
590 }
591 // see MSBaseVehicle constructor
594 }
595 }
596 if (myBlockTime != SUMOTime_MAX) {
597 myBlockTime -= offset;
598 }
599 std::istringstream dis(attrs.getString(SUMO_ATTR_DISTANCE));
601}
602
603
604/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:271
#define TL(string)
Definition MsgHandler.h:287
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define SIMSTEP
Definition SUMOTime.h:61
#define SUMOTime_MAX
Definition SUMOTime.h:34
#define SUMOTime_MIN
Definition SUMOTime.h:35
@ GIVEN
The speed is given.
const int VEHPARS_FORCE_REROUTE
const int STOP_ENDED_SET
const int STOP_STARTED_SET
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_STATE
The state of a link.
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
SUMOTime changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, MSMoveReminder::Notification reason, const bool ignoreLink=false) const
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
Definition MELoop.cpp:79
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition MELoop.cpp:325
bool removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition MELoop.cpp:236
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition MELoop.cpp:223
A single mesoscopic segment (cell)
Definition MESegment.h:49
static const int PARKING_QUEUE
Definition MESegment.h:52
bool isOpen(const MEVehicle *veh) const
Returns whether the vehicle may use the next link.
SUMOTime getLinkPenalty(const MEVehicle *veh) const
Returns the penalty time for passing a link (if using gMesoTLSPenalty > 0 or gMesoMinorPenalty > 0)
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
double getLength() const
Returns the length of the segment in meters.
Definition MESegment.h:242
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition MESegment.h:359
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition MESegment.h:226
static bool isInvalid(const MESegment *segment)
whether the given segment is 0 or encodes vaporization
Definition MESegment.h:443
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition MESegment.h:234
double getConservativeSpeed(SUMOTime &earliestArrival) const
Returns the vehicle's estimated speed taking into account delays.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double getAverageSpeed() const
Returns the vehicle's estimated average speed on the segment assuming no further delays.
double getAngle() const
Returns the vehicle's direction in degrees.
Definition MEVehicle.cpp:88
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
Definition MEVehicle.cpp:74
bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
SUMOTime myEventTime
The (planned) time of leaving the segment (cell)
Definition MEVehicle.h:357
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
void updateDetectorForWriting(MSMoveReminder *rem, SUMOTime currentTime, SUMOTime exitTime)
Updates a single vehicle detector if present.
MEVehicle(SUMOVehicleParameter *pars, ConstMSRoutePtr route, MSVehicleType *type, const double speedFactor)
Constructor.
Definition MEVehicle.cpp:52
BaseInfluencer & getBaseInfluencer()
Returns the velocity/lane influencer.
double getCurrentStoppingTimeSeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
bool mayProceed()
Returns whether the vehicle is allowed to pass the next junction, checks also for triggered stops.
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle's estimated speed after driving accross the link.
void processStop()
ends the current stop and performs loading/unloading
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
SUMOTime checkStop(SUMOTime time)
Returns until when to stop at the current segment and sets the information that the stop has been rea...
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
virtual bool isIdling() const
Returns whether the vehicle is trying to re-enter the net.
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
Definition MEVehicle.h:248
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MEVehicle.cpp:80
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
Definition MEVehicle.h:360
BaseInfluencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
Definition MEVehicle.h:366
void setApproaching(MSLink *link)
registers vehicle with the given link
void saveState(OutputDevice &out)
Saves the states of a vehicle.
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition MEVehicle.h:218
MESegment * mySegment
The segment the vehicle is at.
Definition MEVehicle.h:351
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition MEVehicle.h:226
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition MEVehicle.h:271
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
Definition MEVehicle.h:209
double getCurrentLinkPenaltySeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
Definition MEVehicle.h:200
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
bool resumeFromStopping()
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
Definition MEVehicle.cpp:95
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
Definition MEVehicle.h:363
double getRightSideOnEdge(const MSLane *) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
The base class for microscopic and mesoscopic vehicles.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
std::list< MSStop > myStops
The vehicle's list of stops.
void calculateArrivalParams(bool onInit)
(Re-)Calculates the arrival position and lane from the vehicle parameters
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double myDepartPos
The real depart position.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
int getPersonNumber() const
Returns the number of persons.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
bool hasDeparted() const
Returns whether this vehicle has already departed.
ConstMSRoutePtr myRoute
This vehicle's route.
SUMOTime myDeparture
The real departure time.
std::vector< SUMOVehicleParameter::Stop > myPastStops
The list of stops that the vehicle has already reached.
int getRoutePosition() const
return index of edge within route
bool myAmRegisteredAsWaiting
Whether this vehicle is registered as waiting for a person or container (for deadlock-recognition)
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
int getContainerNumber() const
Returns the number of containers.
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.
A device which collects info on the vehicle trip (mainly on departure and arrival)
void updateStopTime(const SUMOTime time)
update stopping time for meso
Abstract in-vehicle / in-person device.
Definition MSDevice.h:61
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
double getLength() const
return the length of the edge
Definition MSEdge.h:658
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
Definition MSEdge.cpp:1343
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:109
static bool gUseStopEnded
whether the simulation should replay previous stop times
Definition MSGlobals.h:130
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:565
double getRightSideOnEdge() const
Definition MSLane.h:1167
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:545
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:293
double getWidth() const
Returns the lane's width.
Definition MSLane.h:622
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:551
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
void updateDetector(SUMOTrafficObject &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
The simulated network and simulation perfomer.
Definition MSNet.h:88
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:183
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition MSNet.cpp:1181
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:322
bool hasContainers() const
Returns whether containers are simulated.
Definition MSNet.h:413
bool hasPersons() const
Returns whether persons are simulated.
Definition MSNet.h:397
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:380
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1172
bool triggered
whether an arriving person lets the vehicle continue
Definition MSStop.h:69
bool containerTriggered
whether an arriving container lets the vehicle continue
Definition MSStop.h:71
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
Definition MSStop.h:73
const MESegment * segment
The segment to stop at (mesosim only)
Definition MSStop.h:52
MSRouteIterator edge
The edge in the route to stop at.
Definition MSStop.h:48
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition MSStop.h:65
static bool active()
Definition MSStopOut.h:54
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
Definition MSStopOut.cpp:66
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID, bool simEnd=false)
static MSStopOut * getInstance()
Definition MSStopOut.h:60
bool loadAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToLoadNext, SUMOTime &stopDuration)
load any applicable transportables Loads any person / container that is waiting on that edge for the ...
void registerOneWaiting()
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
void unregisterOneWaiting()
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
int getPersonCapacity() const
Get this vehicle type's person capacity.
const std::string & getID() const
Returns the name of the vehicle type.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition Named.h:74
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
Definition of vehicle stop (position and duration)
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
double departSpeed
(optional) The initial speed of the vehicle
std::vector< std::string > via
List of the via-edges the vehicle must visit.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
std::string id
The vehicle's id.
bool wasSet(int what) const
Returns whether the given parameter was set.
int arrivalEdge
(optional) The final edge within the route of the vehicle