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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// A vehicle from the mesoscopic point of view
20/****************************************************************************/
21#include <config.h>
22
23#include <iostream>
24#include <cassert>
35#include <microsim/MSGlobals.h>
36#include <microsim/MSEdge.h>
37#include <microsim/MSLane.h>
38#include <microsim/MSNet.h>
40#include <microsim/MSLink.h>
41#include <microsim/MSStop.h>
45#include "MELoop.h"
46#include "MEVehicle.h"
47#include "MESegment.h"
48
49
50// ===========================================================================
51// method definitions
52// ===========================================================================
54 MSVehicleType* type, const double speedFactor) :
55 MSBaseVehicle(pars, route, type, speedFactor),
56 mySegment(nullptr),
57 myQueIndex(0),
58 myEventTime(SUMOTime_MIN),
59 myLastEntryTime(SUMOTime_MIN),
60 myBlockTime(SUMOTime_MAX),
61 myInfluencer(nullptr) {
62}
63
64
65double
66MEVehicle::getBackPositionOnLane(const MSLane* /* lane */) const {
68}
69
70
71double
73// the following interpolation causes problems with arrivals and calibrators
74// const double fracOnSegment = MIN2(double(1), STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - myLastEntryTime) / STEPS2TIME(myEventTime - myLastEntryTime));
75 return mySegment == nullptr ? 0 : (double(mySegment->getIndex()) /* + fracOnSegment */) * mySegment->getLength();
76}
77
78
79double
81 const MSLane* const lane = getEdge()->getLanes()[0];
83}
84
85
86double
88 const MSLane* const lane = getEdge()->getLanes()[0];
90}
91
92
94MEVehicle::getPosition(const double offset) const {
95 const MSLane* const lane = getEdge()->getLanes()[0];
96 return lane->geometryPositionAtOffset(getPositionOnLane() + offset);
97}
98
100MEVehicle::getBoundingBox(double offset) const {
101 double a = getAngle() + M_PI; // angle pointing backwards
102 double l = getLength();
103 Position pos = getPosition();
104 Position backPos = pos + Position(l * cos(a), l * sin(a));
105 PositionVector centerLine;
106 centerLine.push_back(pos);
107 centerLine.push_back(backPos);
108 if (offset != 0) {
109 centerLine.extrapolate2D(offset);
110 }
111 PositionVector result = centerLine;
112 result.move2side(MAX2(0.0, 0.5 * myType->getWidth() + offset));
113 centerLine.move2side(MIN2(0.0, -0.5 * myType->getWidth() - offset));
114 result.append(centerLine.reverse(), POSITION_EPS);
115 return result;
116}
117
118double
120 if (getWaitingTime() > 0 || isStopped()) {
121 return 0;
122 } else {
123 return getAverageSpeed();
124 }
125}
126
127
128double
130 if (mySegment == nullptr || myQueIndex == MESegment::PARKING_QUEUE) {
131 return 0;
132 } else {
134 getEdge()->getLanes()[myQueIndex]->getVehicleMaxSpeed(this));
135 }
136}
137
138
139double
142 const double v = getSpeed();
143 return MIN2(link->getViaLaneOrLane()->getVehicleMaxSpeed(this),
144 (double)sqrt(2 * link->getLength() * getVehicleType().getCarFollowModel().getMaxAccel() + v * v));
145}
146
147
148double
150 earliestArrival = MAX2(myEventTime, earliestArrival - DELTA_T); // event times have subsecond resolution
151 return mySegment->getLength() / STEPS2TIME(earliestArrival - myLastEntryTime);
152}
153
154
155bool
157 // vehicle has just entered a new edge. Position is 0
158 if (myCurrEdge == myRoute->end() - 1 || (myParameter->arrivalEdge >= 0 && getRoutePosition() >= myParameter->arrivalEdge)) { // may happen during teleport
159 return true;
160 }
161 ++myCurrEdge;
162 if ((*myCurrEdge)->isVaporizing()) {
163 return true;
164 }
165 // update via
166 if (myParameter->via.size() > 0 && (*myCurrEdge)->getID() == myParameter->via.front()) {
167 myParameter->via.erase(myParameter->via.begin());
168 }
169 return hasArrived();
170}
171
172
173bool
175 // mySegment may be 0 due to teleporting or arrival
176 return (myCurrEdge == myRoute->end() - 1 || (myParameter->arrivalEdge >= 0 && getRoutePosition() >= myParameter->arrivalEdge)) && (
177 (mySegment == nullptr)
179 || getPositionOnLane() > myArrivalPos - POSITION_EPS);
180}
181
182
183bool
185 return getSegment() != nullptr;
186}
187
188
189bool
191 return false;
192}
193
194
195void
197 if (link != nullptr) {
198 const double speed = getSpeed();
199 link->setApproaching(this, getEventTime() + (link->getState() == LINKSTATE_ALLWAY_STOP ?
200 (SUMOTime)RandHelper::rand((int)2) : 0), // tie braker
201 speed, speed, true,
202 speed, getWaitingTime(),
203 // @note: dist is not used by meso (getZipperSpeed is never called)
204 getSegment()->getLength(), 0);
205 }
206}
207
208
209bool
210MEVehicle::replaceRoute(ConstMSRoutePtr newRoute, const std::string& info, bool onInit, int offset, bool addRouteStops, bool removeStops, std::string* msgReturn) {
211 MSLink* const oldLink = mySegment != nullptr ? mySegment->getLink(this) : nullptr;
212 if (MSBaseVehicle::replaceRoute(newRoute, info, onInit, offset, addRouteStops, removeStops, msgReturn)) {
213 if (mySegment != nullptr) {
214 MSLink* const newLink = mySegment->getLink(this);
215 // update approaching vehicle information
216 if (oldLink != newLink) {
217 if (oldLink != nullptr) {
218 oldLink->removeApproaching(this);
219 }
220 setApproaching(newLink);
221 }
222 }
223 return true;
224 }
225 return false;
226}
227
228
231 const SUMOTime initialTime = time;
232 bool hadStop = false;
233 for (MSStop& stop : myStops) {
234 if (stop.joinTriggered) {
235 WRITE_WARNINGF(TL("Join stops are not available in meso yet (vehicle '%', segment '%')."),
236 getID(), mySegment->getID());
237 continue;
238 }
239 if (stop.edge != myCurrEdge || stop.segment != mySegment) {
240 break;
241 }
242 const SUMOTime cur = time;
243 if (stop.duration > 0) { // it might be a triggered stop with duration -1
244 time += stop.duration;
245 }
246 if (stop.pars.until > time) {
247 // @note: this assumes the stop is reached at time. With the way this is called in MESegment (time == entryTime),
248 // travel time is overestimated of the stop is not at the start of the segment
249 time = stop.pars.until;
250 }
251 if (MSGlobals::gUseStopEnded && stop.pars.ended >= 0) {
252 time = MAX2(cur, stop.pars.ended);
253 }
254 if (!stop.reached) {
255 stop.reached = true;
256 stop.pars.started = myLastEntryTime;
257 stop.endBoarding = stop.pars.extension >= 0 ? time + stop.pars.extension : SUMOTime_MAX;
258 if (MSStopOut::active()) {
259 if (!hadStop) {
261 } else {
262 WRITE_WARNINGF(TL("Vehicle '%' has multiple stops on segment '%', time=% (stop-output will be merged)."),
263 getID(), mySegment->getID(), time2string(time));
264 }
265 }
266 MSDevice_Taxi* taxi = static_cast<MSDevice_Taxi*>(getDevice(typeid(MSDevice_Taxi)));
267 if (taxi != nullptr) {
268 taxi->notifyMove(*this, 0, 0, 0);
269 }
270 }
271 if (stop.triggered || stop.containerTriggered || stop.joinTriggered) {
272 time = MAX2(time, cur + DELTA_T);
273 }
274 hadStop = true;
275 }
276 MSDevice_Tripinfo* tripinfo = static_cast<MSDevice_Tripinfo*>(getDevice(typeid(MSDevice_Tripinfo)));
277 if (tripinfo != nullptr) {
278 tripinfo->updateStopTime(time - initialTime);
279 }
280 return time;
281}
282
283
284bool
286 if (isStopped()) {
287 const SUMOTime now = SIMSTEP;
288 MSStop& stop = myStops.front();
289 stop.pars.ended = now;
290 for (const auto& rem : myMoveReminders) {
291 rem.first->notifyStopEnded();
292 }
293 if (MSStopOut::active()) {
295 }
296 myPastStops.push_back(stop.pars);
297 myPastStops.back().routeIndex = (int)(stop.edge - myRoute->begin());
301 }
302 myStops.pop_front();
303 if (myEventTime > now) {
304 // if this is an aborted stop we need to change the event time of the vehicle
305 if (MSGlobals::gMesoNet->removeLeaderCar(this)) {
306 myEventTime = now + 1;
307 MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
308 }
309 }
310 return true;
311 }
312 return false;
313}
314
315
316double
319 for (const MSStop& stop : myStops) {
320 if (stop.reached) {
321 time += stop.duration;
322 if (stop.pars.until > time) {
323 // @note: this assumes the stop is reached at time. With the way this is called in MESegment (time == entryTime),
324 // travel time is overestimated of the stop is not at the start of the segment
325 time = stop.pars.until;
326 }
327 } else {
328 break;
329 }
330 }
331 return STEPS2TIME(time - myLastEntryTime);
332}
333
334
335void
337 assert(isStopped());
338 double lastPos = -1;
339 bool hadStop = false;
340 while (!myStops.empty()) {
341 MSStop& stop = myStops.front();
342 if (stop.edge != myCurrEdge || stop.segment != mySegment || stop.pars.endPos <= lastPos) {
343 break;
344 }
345 lastPos = stop.pars.endPos;
346 MSNet* const net = MSNet::getInstance();
347 SUMOTime dummy = -1; // boarding- and loading-time are not considered
348 if (hadStop && MSStopOut::active()) {
349 stop.reached = true;
351 }
352 if (net->hasPersons()) {
353 net->getPersonControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy);
354 }
355 if (net->hasContainers()) {
356 net->getContainerControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy);
357 }
359 hadStop = true;
360 }
362}
363
364
365bool
367 if (mySegment == nullptr) {
368 return true;
369 }
370 MSNet* const net = MSNet::getInstance();
371 SUMOTime dummy = -1; // boarding- and loading-time are not considered
372 for (MSStop& stop : myStops) {
373 if (!stop.reached) {
374 break;
375 }
376 if (net->getCurrentTimeStep() > stop.endBoarding) {
377 if (stop.triggered || stop.containerTriggered) {
378 MSDevice_Taxi* taxiDevice = static_cast<MSDevice_Taxi*>(getDevice(typeid(MSDevice_Taxi)));
379 if (taxiDevice != nullptr) {
380 taxiDevice->cancelCurrentCustomers();
381 }
382 stop.triggered = false;
383 stop.containerTriggered = false;
384 }
388 }
389 }
390 if (stop.triggered) {
392 // we could not check this on entering the segment because there may be persons who still want to leave
393 WRITE_WARNINGF(TL("Vehicle '%' ignores triggered stop on lane '%' due to capacity constraints."), getID(), stop.lane->getID());
394 stop.triggered = false;
398 }
399 } else if (!net->hasPersons() || !net->getPersonControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy)) {
403 }
404 return false;
405 }
406 }
407 if (stop.containerTriggered) {
408 if (getVehicleType().getContainerCapacity() == getContainerNumber()) {
409 // we could not check this on entering the segment because there may be containers who still want to leave
410 WRITE_WARNINGF(TL("Vehicle '%' ignores container triggered stop on lane '%' due to capacity constraints."), getID(), stop.lane->getID());
411 stop.containerTriggered = false;
415 }
416 } else if (!net->hasContainers() || !net->getContainerControl().loadAnyWaiting(&mySegment->getEdge(), this, dummy, dummy)) {
420 }
421 return false;
422 }
423 }
424 if (stop.joinTriggered) {
425 // TODO do something useful here
426 return false;
427 }
428 }
429 return mySegment->isOpen(this);
430}
431
432
433double
435 if (mySegment == nullptr) {
436 return 0;
437 } else {
438 return STEPS2TIME(mySegment->getLinkPenalty(this));
439 }
440}
441
442
443void
445 for (MoveReminderCont::iterator i = myMoveReminders.begin(); i != myMoveReminders.end(); ++i) {
446 if (i->first == rem) {
449 getLastEntryTime(), currentTime, exitTime, false);
450#ifdef _DEBUG
451 if (myTraceMoveReminders) {
452 traceMoveReminder("notifyMove", i->first, i->second, true);
453 }
454#endif
455 return;
456 }
457 }
458}
459
460
461void
462MEVehicle::updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason) {
463 // segments of the same edge have the same reminder so no cleaning up must take place
464 const bool cleanUp = isLeave && (reason != MSMoveReminder::NOTIFICATION_SEGMENT);
465 for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
466 if (currentTime != getLastEntryTime()) {
467 rem->first->updateDetector(*this, mySegment->getIndex() * mySegment->getLength(),
469 getLastEntryTime(), currentTime, getEventTime(), cleanUp);
470#ifdef _DEBUG
471 if (myTraceMoveReminders) {
472 traceMoveReminder("notifyMove", rem->first, rem->second, true);
473 }
474#endif
475 }
476 if (!isLeave || rem->first->notifyLeave(*this, mySegment->getLength(), reason)) {
477#ifdef _DEBUG
478 if (isLeave && myTraceMoveReminders) {
479 traceMoveReminder("notifyLeave", rem->first, rem->second, true);
480 }
481#endif
482
483 if (isLeave) {
484 rem->second += getEdge()->getLength();
485#ifdef _DEBUG
486 if (myTraceMoveReminders) {
487 traceMoveReminder("adaptedPos", rem->first, rem->second, true);
488 }
489#endif
490 }
491 ++rem;
492 } else {
493#ifdef _DEBUG
494 if (myTraceMoveReminders) {
495 traceMoveReminder("remove", rem->first, rem->second, false);
496 }
497#endif
498 rem = myMoveReminders.erase(rem);
499 }
500 }
503 }
504}
505
506
509 if (myInfluencer == nullptr) {
511 }
512 return *myInfluencer;
513}
514
515
520
521
522void
527
528
529int
531 return getSegment() != nullptr ? getSegment()->getIndex() : -1;
532}
533
534
535double
536MEVehicle::getRightSideOnEdge(const MSLane* /*lane*/) const {
537 if (mySegment == nullptr || mySegment->getIndex() >= getEdge()->getNumLanes()) {
538 return 0;
539 }
540 const MSLane* lane = getEdge()->getLanes()[mySegment->getIndex()];
541 return lane->getRightSideOnEdge() + lane->getWidth() * 0.5 - 0.5 * getVehicleType().getWidth();
542
543}
544
545
546void
548 if (mySegment != nullptr && MESegment::isInvalid(mySegment)) {
549 // segment is vaporization target, do not write this vehicle
550 return;
551 }
553 assert(mySegment == nullptr || *myCurrEdge == &mySegment->getEdge());
554 std::vector<SUMOTime> internals;
555 internals.push_back(myParameter->parametersSet);
556 internals.push_back(myDeparture);
557 internals.push_back((SUMOTime)distance(myRoute->begin(), myCurrEdge));
558 internals.push_back((SUMOTime)myDepartPos * 1000); // store as mm
559 internals.push_back(mySegment == nullptr ? (SUMOTime) - 1 : (SUMOTime)mySegment->getIndex());
560 internals.push_back((SUMOTime)getQueIndex());
561 internals.push_back(myEventTime);
562 internals.push_back(myLastEntryTime);
563 internals.push_back(myBlockTime);
564 out.writeAttr(SUMO_ATTR_STATE, toString(internals));
565 // save past stops
567 stop.write(out, false);
568 // do not write started and ended twice
569 if ((stop.parametersSet & STOP_STARTED_SET) == 0) {
570 out.writeAttr(SUMO_ATTR_STARTED, time2string(stop.started));
571 }
572 if ((stop.parametersSet & STOP_ENDED_SET) == 0) {
573 out.writeAttr(SUMO_ATTR_ENDED, time2string(stop.ended));
574 }
575 out.closeTag();
576 }
577 // save upcoming stops
578 for (const MSStop& stop : myStops) {
579 stop.write(out);
580 }
581 // save parameters
583 for (MSDevice* dev : myDevices) {
584 dev->saveState(out);
585 }
586 out.closeTag();
587}
588
589
590void
592 if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
593 throw ProcessError(TL("Error: Invalid vehicles in state (may be a micro state)!"));
594 }
595 int routeOffset;
596 int segIndex;
597 int queIndex;
598 std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
600 bis >> myDeparture;
601 bis >> routeOffset;
602 bis >> myDepartPos;
603 bis >> segIndex;
604 bis >> queIndex;
605 bis >> myEventTime;
606 bis >> myLastEntryTime;
607 bis >> myBlockTime;
608 myDepartPos /= 1000.; // was stored as mm
609
610 // load stops
611 myStops.clear();
613
614 if (hasDeparted()) {
615 myDeparture -= offset;
616 myEventTime -= offset;
617 myLastEntryTime -= offset;
618 myCurrEdge = myRoute->begin() + routeOffset;
619 if (segIndex >= 0) {
621 while (seg->getIndex() != (int)segIndex) {
622 seg = seg->getNextSegment();
623 assert(seg != 0);
624 }
625 setSegment(seg, queIndex);
626 if (queIndex == MESegment::PARKING_QUEUE) {
627 MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
628 }
629 } else {
630 // on teleport
631 setSegment(nullptr, 0);
632 assert(myEventTime != SUMOTime_MIN);
633 MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
634 }
635 // see MSBaseVehicle constructor
638 }
639 }
640 if (myBlockTime != SUMOTime_MAX) {
641 myBlockTime -= offset;
642 }
643 std::istringstream dis(attrs.getString(SUMO_ATTR_DISTANCE));
645}
646
647
648/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
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
const long long 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:340
bool removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition MELoop.cpp:251
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition MELoop.cpp:238
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)
Definition MEVehicle.cpp:94
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:80
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
Definition MEVehicle.cpp:66
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:365
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:53
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 across the link.
void processStop()
ends the current stop and performs loading/unloading
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the duration for which the vehicle was blocked.
Definition MEVehicle.h:284
bool hasArrived() const
Returns whether this vehicle has already arrived (reached the arrivalPosition on its final edge)
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
int myQueIndex
Index of the que the vehicle is in (important for multiqueue extension)
Definition MEVehicle.h:362
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:255
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MEVehicle.cpp:72
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
Definition MEVehicle.h:368
BaseInfluencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
Definition MEVehicle.h:374
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:224
MESegment * mySegment
The segment the vehicle is at.
Definition MEVehicle.h:359
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition MEVehicle.h:233
int getSegmentIndex() const
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:215
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:206
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.
PositionVector getBoundingBox(double offset=0) const
get bounding rectangle
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
Definition MEVehicle.cpp:87
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
Definition MEVehicle.h:371
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.
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
MSVehicleType * myType
This vehicle's type.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double myDepartPos
The real depart position.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
virtual 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.
double getLength() const
Returns the vehicle's length.
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.
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr, bool addRouteStops=true)
Adds stops to the built vehicle.
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.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
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.
void cancelCurrentCustomers()
remove the persons the taxi is currently waiting for from reservations
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:62
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:685
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
Definition MSEdge.cpp:1460
static bool gCheckRoutes
Definition MSGlobals.h:91
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:112
static bool gUseStopEnded
whether the simulation should replay previous stop times
Definition MSGlobals.h:133
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:574
double getRightSideOnEdge() const
Definition MSLane.h:1194
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:554
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
double getWidth() const
Returns the lane's width.
Definition MSLane.h:635
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
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:89
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition MSNet.cpp:1199
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:320
bool hasContainers() const
Returns whether containers are simulated.
Definition MSNet.h:411
bool hasPersons() const
Returns whether persons are simulated.
Definition MSNet.h:395
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:378
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1190
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
bool reached
Information whether the stop has been reached.
Definition MSStop.h:75
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, MSTransportable *const force=nullptr)
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.
int getPersonCapacity() const
Get this vehicle type's person capacity.
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
A list of positions.
void append(const PositionVector &v, double sameThreshold=2.0)
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
PositionVector reverse() const
reverse position vector
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.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
bool wasSet(long long int what) const
Returns whether the given parameter was set.
int arrivalEdge
(optional) The final edge within the route of the vehicle
#define M_PI
Definition odrSpiral.cpp:45