Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSStageWalking.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-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// A stage performing walking on a sequence of edges.
22/****************************************************************************/
23#include <config.h>
24
25#include <string>
26#include <vector>
33#include <microsim/MSNet.h>
34#include <microsim/MSEdge.h>
35#include <microsim/MSLane.h>
39#include <microsim/MSVehicle.h>
46#include "MSPModel_Striping.h"
47#include "MSStageTrip.h"
48#include "MSPerson.h"
49#include "MSStageWalking.h"
50
51
52// ===========================================================================
53// static member definition
54// ===========================================================================
56
57
58// ===========================================================================
59// method definitions
60// ===========================================================================
61MSStageWalking::MSStageWalking(const std::string& personID,
62 const ConstMSEdgeVector& route,
63 MSStoppingPlace* toStop,
64 SUMOTime walkingTime, double speed,
65 double departPos, double arrivalPos, double departPosLat, int departLane,
66 const std::string& routeID) :
67 MSStageMoving(MSStageType::WALKING, route, routeID, toStop, speed, departPos, arrivalPos, departPosLat, departLane),
68 myWalkingTime(walkingTime),
69 myExitTimes(nullptr),
71 myDepartPos = SUMOVehicleParameter::interpretEdgePos(departPos, route.front()->getLength(), SUMO_ATTR_DEPARTPOS,
72 "person '" + personID + "' walking from edge '" + route.front()->getID() + "'");
73 myArrivalPos = SUMOVehicleParameter::interpretEdgePos(arrivalPos, route.back()->getLength(), SUMO_ATTR_ARRIVALPOS,
74 "person '" + personID + "' walking to edge '" + route.back()->getID() + "'");
75 if (walkingTime > 0) {
77 }
78}
79
80
84
85
88 std::vector<const MSEdge*> route = myRoute;
89 double departPos = myDepartPos;
90 double arrivalPos = myArrivalPos;
91 int departLane = myDepartLane;
92 if (myRouteID != "" && MSRoute::distDictionary(myRouteID) != nullptr) {
94 if (departPos > route[0]->getLength()) {
95 WRITE_WARNINGF(TL("Adjusting departPos for cloned walk with routeDistribution '%'"), myRouteID);
96 departPos = route[0]->getLength();
97 }
98 if (arrivalPos > route.back()->getLength()) {
99 WRITE_WARNINGF(TL("Adjusting arrivalPos for cloned walk with routeDistribution '%'"), myRouteID);
100 arrivalPos = route.back()->getLength();
101 }
102 if (departLane >= route[0]->getNumLanes()) {
103 WRITE_WARNINGF(TL("Adjusting departLane for cloned walk with routeDistribution '%'"), myRouteID);
104 departLane = route[0]->getNumLanes() - 1;
105 }
106 }
107 MSStage* clon = new MSStageWalking("dummyID", route, myDestinationStop, myWalkingTime, mySpeed, departPos, arrivalPos, myDepartPosLat, departLane, myRouteID);
108 clon->setParameters(*this);
109 return clon;
110}
111
112
113void
115 myDeparted = now;
116 myRouteStep = myRoute.begin();
118 if (myWalkingTime == 0) {
119 if (!person->proceed(net, now)) {
121 }
122 return;
123 }
125 if (previous->getEdgePos(now) >= 0 && previous->getEdge() == *myRouteStep) {
126 // we need to adapt to the arrival position of the vehicle unless we have an explicit access
127 myDepartPos = previous->getEdgePos(now);
128 if (oc.getString("pedestrian.model") == "jupedsim") {
129 myDepartPosLat = previous->getEdgePosLat(now);
130 }
131 if (myWalkingTime > 0) {
133 }
134 }
135 MSTransportableControl& pControl = net->getPersonControl();
136 myPState = pControl.getMovementModel()->add(person, this, now);
137 if (myPState == nullptr) {
138 pControl.erase(person);
139 return;
140 }
141 if (previous->getStageType() != MSStageType::WALKING || previous->getEdge() != getEdge()) {
142 // we only need new move reminders if we are walking a different edge (else it is probably a rerouting)
143 activateEntryReminders(person, true);
144 }
145 if (oc.getBool("vehroute-output.exit-times")) {
146 myExitTimes = new std::vector<SUMOTime>();
147 }
148 (*myRouteStep)->addTransportable(person);
149}
150
151
152void
156
157
158void
160 mySpeed = speed;
161}
162
163
164double
166 return walkDistance() / STEPS2TIME(myWalkingTime + 1); // avoid systematic rounding errors
167}
168
169
170bool
172 MSStageWalking* stage = dynamic_cast<MSStageWalking*>(getCurrentStage());
173 if (stage != nullptr) {
174 return stage->getPState()->isJammed();
175 }
176 return false;
177}
178
179
180double
181MSStageWalking::walkDistance(bool partial) const {
182 double length = 0;
183 auto endIt = partial && myArrived < 0 ? myRouteStep + 1 : myRoute.end();
184 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt; ++i) {
185 length += (*i)->getLength();
186 }
187 if (myRoute.size() > 1 && MSNet::getInstance()->getPersonControl().getMovementModel()->usingInternalLanes()) {
188 if (myInternalDistance > 0) {
189 length += myInternalDistance;
190 } else {
191 // use lower bound for distance to pass the intersection
192 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt - 1; ++i) {
193 const MSEdge* fromEdge = *i;
194 const MSEdge* toEdge = *(i + 1);
195 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
196 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
197 Position fromPos;
198 Position toPos;
199 if (from != nullptr && to != nullptr) {
200 if (fromEdge->getToJunction() == toEdge->getFromJunction()) {
201 fromPos = from->getShape().back();
202 toPos = to->getShape().front();
203 } else if (fromEdge->getToJunction() == toEdge->getToJunction()) {
204 fromPos = from->getShape().back();
205 toPos = to->getShape().back();
206 } else if (fromEdge->getFromJunction() == toEdge->getFromJunction()) {
207 fromPos = from->getShape().front();
208 toPos = to->getShape().front();
209 } else if (fromEdge->getFromJunction() == toEdge->getToJunction()) {
210 fromPos = from->getShape().front();
211 toPos = to->getShape().back();
212 }
213 //std::cout << " from=" << from->getID() << " to=" << to->getID() << " junctionLength=" << fromPos.distanceTo2D(toPos) << "\n";
214 length += fromPos.distanceTo2D(toPos);
215 }
216 }
217 }
218 }
219 // determine walking direction for depart and arrival
220 int dummy = 0;
221 const int departFwdArrivalDir = MSPModel::canTraverse(MSPModel::FORWARD, myRoute, dummy);
222 const int departBwdArrivalDir = MSPModel::canTraverse(MSPModel::BACKWARD, myRoute, dummy);
223 const bool mayStartForward = departFwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
224 const bool mayStartBackward = departBwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
225 const double arrivalPos = partial && myArrived < 0 ? getEdgePos(SIMSTEP) : myArrivalPos;
226 const double lengthFwd = (length - myDepartPos - (
227 departFwdArrivalDir == MSPModel::BACKWARD
228 ? arrivalPos
229 : myRoute.back()->getLength() - arrivalPos));
230 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
231 departBwdArrivalDir == MSPModel::BACKWARD
232 ? arrivalPos
233 : myRoute.back()->getLength() - arrivalPos));
234 //std::cout << " length=" << length << " lengthFwd=" << lengthFwd << " lengthBwd=" << lengthBwd << " mayStartForward=" << mayStartForward << " mayStartBackward=" << mayStartBackward << "\n";
235
236 if (myRoute.size() == 1) {
238 length = lengthBwd;
239 } else {
240 length = lengthFwd;
241 }
242 } else {
243 if (mayStartForward && mayStartBackward) {
244 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
245 } else if (mayStartForward) {
246 length = lengthFwd;
247 } else if (mayStartBackward) {
248 length = lengthBwd;
249 } else {
250 length = lengthFwd;
251 }
252 }
253 //std::cout << SIMTIME << " route=" << toString(myRoute)
254 // << " depPos=" << myDepartPos << " arPos=" << myArrivalPos
255 // << " dFwdADir=" << departFwdArrivalDir
256 // << " dBwdADir=" << departBwdArrivalDir
257 // << " lengthFwd=" << lengthFwd
258 // << " lengthBwd=" << lengthBwd
259 // << "\n";
260
261 return MAX2(POSITION_EPS, length);
262}
263
264
266MSStageWalking::getTimeLoss(const MSTransportable* transportable) const {
267 SUMOTime timeLoss = myArrived == -1 ? 0 : getDuration() - TIME2STEPS(walkDistance(true) / getMaxSpeed(transportable));
268 if (timeLoss < 0 && timeLoss > TIME2STEPS(-0.1)) {
269 // avoid negative timeLoss due to rounding errors
270 timeLoss = 0;
271 }
272 return timeLoss;
273}
274
275
276void
278 if (!myWarnedInvalidTripinfo && MSNet::getInstance()->getPersonControl().getMovementModel()->usingShortcuts()) {
279 WRITE_WARNING(TL("The pedestrian model uses infrastructure which is not in the network, timeLoss and routeLength may be invalid."));
281 }
282 const double distance = walkDistance(true);
283 const double maxSpeed = getMaxSpeed(person);
284 const SUMOTime duration = myArrived - myDeparted;
285 const SUMOTime timeLoss = getTimeLoss(person);
286 MSDevice_Tripinfo::addPedestrianData(distance, duration, timeLoss);
287 os.openTag("walk");
288 os.writeAttr("depart", myDeparted >= 0 ? time2string(myDeparted) : "-1");
289 os.writeAttr("departPos", myDepartPos);
290 os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
291 os.writeAttr("arrivalPos", myArrived >= 0 ? toString(myArrivalPos) : "-1");
292 os.writeAttr("duration", myDeparted < 0 ? "-1" :
293 time2string(myArrived >= 0 ? duration : MSNet::getInstance()->getCurrentTimeStep() - myDeparted));
294 os.writeAttr("routeLength", myArrived >= 0 ? toString(distance) : "-1");
295 os.writeAttr("timeLoss", time2string(timeLoss));
296 os.writeAttr("maxSpeed", maxSpeed);
297 os.writeAttr("waitingTime", time2string(getTotalWaitingTime()));
298 os.closeTag();
299}
300
301
302void
303MSStageWalking::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool withRouteLength, const MSStage* const /* previous */, const bool withTiming, const bool saveState) const {
305 std::string comment = "";
306 if (myDestinationStop != nullptr) {
307 os.writeAttr(toString(myDestinationStop->getElement()), myDestinationStop->getID());
308 if (myDestinationStop->getMyName() != "") {
309 comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
310 }
311 } else if (wasSet(VEHPARS_ARRIVALPOS_SET)) {
313 }
314 if (myWalkingTime > 0) {
316 } else if (mySpeed > 0) {
318 }
319 if (withRouteLength) {
320 if (myDeparted >= 0) {
321 os.writeAttr("routeLength", walkDistance(true));
322 } else {
323 os.writeAttr("routeLength", "-1");
324 }
325 }
326 if (myExitTimes != nullptr) {
327 std::vector<std::string> exits;
328 for (SUMOTime t : *myExitTimes) {
329 exits.push_back(time2string(t));
330 }
331 std::vector<std::string> missing(MAX2(0, (int)myRoute.size() - (int)myExitTimes->size()), "-1");
332 exits.insert(exits.end(), missing.begin(), missing.end());
333 os.writeAttr("exitTimes", exits);
334 }
335 if (withTiming) {
338 }
339 if (OptionsCont::getOptions().getBool("vehroute-output.cost")) {
341 }
342 if (saveState && getTotalWaitingTime() > 0) {
343 os.writeAttr("waitingTime", time2string(getTotalWaitingTime()));
344 }
345 os.closeTag(comment);
346}
347
348
349bool
350MSStageWalking::moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal, const bool isReplay) {
351 ((MSEdge*)getEdge())->removeTransportable(person);
353 const bool arrived = myRouteStep == myRoute.end() - 1;
354 if (lane != nullptr) {
355 const double tl = person->getVehicleType().getLength();
356 const double lastPos = (arrived
357 ? (prevDir == MSPModel::FORWARD
358 ? getArrivalPos() + tl
359 : getArrivalPos() - tl)
360 : person->getPositionOnLane());
361 activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
362 }
363 if (myExitTimes != nullptr && nextInternal == nullptr) {
364 myExitTimes->push_back(currentTime);
365 }
366 myMoveReminders.clear();
367 myLastEdgeEntryTime = currentTime;
368 //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
369 if (myCurrentInternalEdge != nullptr) {
370 myInternalDistance += (myPState->getPathLength() == 0 ? myCurrentInternalEdge->getLength() : myPState->getPathLength());
371 }
372 if (arrived) {
373 MSPerson* p = dynamic_cast<MSPerson*>(person);
374 if (!isReplay && p->hasInfluencer() && p->getInfluencer().isRemoteControlled()) {
375 myCurrentInternalEdge = nextInternal;
376 ((MSEdge*) getEdge())->addTransportable(person);
377 return false;
378 }
379 if (myDestinationStop != nullptr) {
380 myDestinationStop->addTransportable(person);
381 }
382 if (isReplay) {
383 // cannot do this in the replay device because the person might get deleted below
385 }
386 if (!person->proceed(MSNet::getInstance(), currentTime)) {
388 }
389 //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
390 return true;
391 } else {
392 if (nextInternal == nullptr) {
393 ++myRouteStep;
394 }
395 myCurrentInternalEdge = nextInternal;
396 ((MSEdge*) getEdge())->addTransportable(person);
397 return false;
398 }
399}
400
401
402void
404 const MSLane* const nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
405 if (nextLane != nullptr) {
406 for (MSMoveReminder* const rem : nextLane->getMoveReminders()) {
407 if (rem->notifyEnter(*person, isDepart ? MSMoveReminder::NOTIFICATION_DEPARTED : MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
408 myMoveReminders.push_back(rem);
409 }
410 }
411 }
412 if (hasParameter("rerouter")) {
413 double minDist = std::numeric_limits<double>::max();
414 MSTriggeredRerouter* nearest = nullptr;
415 for (MSMoveReminder* const rem : myMoveReminders) {
416 MSTriggeredRerouter* rerouter = dynamic_cast<MSTriggeredRerouter*>(rem);
417 if (rerouter != nullptr) {
418 const double dist2 = rerouter->getPosition().distanceSquaredTo2D(person->getPosition());
419 if (dist2 < minDist) {
420 nearest = rerouter;
421 minDist = dist2;
422 }
423 }
424 }
425 if (nearest != nullptr) {
427 }
428 // TODO maybe removal of the reminders? Or can we rely on movetonextedge to clean everything up?
429 }
430}
431
432
433void
434MSStageWalking::activateMoveReminders(MSTransportable* person, double oldPos, double newPos, double newSpeed) {
435 for (std::vector<MSMoveReminder*>::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
436 if ((*rem)->notifyMove(*person, oldPos, newPos, newSpeed)) {
437 ++rem;
438 } else {
439 rem = myMoveReminders.erase(rem);
440 }
441 }
442}
443
444
445void
446MSStageWalking::activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived) {
448 for (MSMoveReminder* const rem : myMoveReminders) {
449 rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, t, t, true);
450 rem->notifyLeave(*person, lastPos, notification);
451 }
452}
453
454
455int
457 return (int)(myRouteStep - myRoute.begin());
458}
459
460
461double
463 return mySpeed >= 0 ? mySpeed : person->getMaxSpeed();
464}
465
466std::string
467MSStageWalking::getStageSummary(const bool /* isPerson */) const {
468 const std::string dest = (getDestinationStop() == nullptr ?
469 " edge '" + getDestination()->getID() + "'" :
470 " stop '" + getDestinationStop()->getID() + "'" + (
471 getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
472 return "walking to " + dest;
473}
474
475
476void
477MSStageWalking::saveState(std::ostringstream& out, MSTransportable* /*transportable*/) {
478 out << " " << myDeparted << " " << (myRouteStep - myRoute.begin()) << " " << myLastEdgeEntryTime;
479 if (myExitTimes != nullptr) {
480 out << " " << myExitTimes->size();
481 for (SUMOTime t : *myExitTimes) {
482 out << " " << t;
483 }
484 } else {
485 out << " " << -1;
486 }
487 myPState->saveState(out);
488}
489
490
491void
492MSStageWalking::loadState(MSTransportable* transportable, std::istringstream& state) {
493 int stepIdx;
494 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
495 int exitTimesSize;
496 state >> exitTimesSize;
497 if (exitTimesSize >= 0) {
498 myExitTimes = new std::vector<SUMOTime>();
499 SUMOTime t;
500 for (int i = 0; i < exitTimesSize; i++) {
501 state >> t;
502 myExitTimes->push_back(t);
503 }
504 if (!OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
505 delete myExitTimes;
506 myExitTimes = nullptr;
507 }
508 }
509 myRouteStep = myRoute.begin() + stepIdx;
510 myPState = MSNet::getInstance()->getPersonControl().getMovementModel()->loadState(transportable, this, state);
511 if (myPState->getLane() && !myPState->getLane()->isNormal()) {
512 myCurrentInternalEdge = &myPState->getLane()->getEdge();
513 myCurrentInternalEdge->addTransportable(transportable);
514 } else {
515 (*myRouteStep)->addTransportable(transportable);
516 }
517}
518
519
520/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
const L * getSidewalk(const E *edge, SUMOVehicleClass svc=SVC_PEDESTRIAN)
MSStageType
Definition MSStage.h:55
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SIMSTEP
Definition SUMOTime.h:64
#define TIME2STEPS(x)
Definition SUMOTime.h:60
const long long int VEHPARS_ARRIVALPOS_SET
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_COST
@ SUMO_ATTR_DURATION
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
A road/street connecting two junctions.
Definition MSEdge.h:77
const MSJunction * getToJunction() const
Definition MSEdge.h:427
const MSJunction * getFromJunction() const
Definition MSEdge.h:423
virtual void addTransportable(MSTransportable *t) const
Definition MSEdge.cpp:1222
Representation of a lane in the micro simulation.
Definition MSLane.h:84
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition MSLane.h:324
double getLength() const
Returns the lane's length.
Definition MSLane.h:617
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted).
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network).
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
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:199
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1291
static const int BACKWARD
Definition MSPModel.h:55
static int canTraverse(int dir, const ConstMSEdgeVector &route, int &passedEdges)
Definition MSPModel.cpp:54
static const int FORWARD
Definition MSPModel.h:54
virtual MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)=0
register the given person as a pedestrian
virtual MSTransportableStateAdapter * loadState(MSTransportable *transportable, MSStageMoving *stage, std::istringstream &state)
load the state of the given transportable
Definition MSPModel.h:76
virtual void remove(MSTransportableStateAdapter *state)=0
remove the specified person from the pedestrian simulation
static const int UNDEFINED_DIRECTION
Definition MSPModel.h:56
bool isRemoteControlled() const
Definition MSPerson.cpp:346
bool isJammed() const
whether the person is jammed as defined by the current pedestrian model
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition MSPerson.h:230
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition MSPerson.cpp:308
static SumoRNG * getParsingRNG()
get parsing RNG
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition MSRoute.cpp:116
static RandomDistributor< ConstMSRoutePtr > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition MSRoute.cpp:168
const MSEdge * getDestination() const
returns the destination edge
Definition MSStage.cpp:65
virtual double getEdgePos(SUMOTime now) const
Definition MSStage.cpp:83
virtual double getEdgePosLat(SUMOTime now) const
Definition MSStage.cpp:89
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:309
double getCosts() const
Returns the costs of the stage.
Definition MSStage.h:275
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition MSStage.h:88
bool wasSet(int what) const
Definition MSStage.h:263
MSStageType getStageType() const
Definition MSStage.h:138
MSStage(const MSStageType type, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double arrivalPosLat=0.0, const std::string &group="")
constructor
Definition MSStage.cpp:47
virtual SUMOTime getDuration() const
Definition MSStage.cpp:140
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:321
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition MSStage.cpp:71
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:312
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:318
std::string myRouteID
The original route id.
double getEdgePos(SUMOTime now) const
Returns the offset from the start of the current edge measured in its natural direction.
double myDepartPosLat
the lateral depart position
std::vector< constMSEdge * >::iterator myRouteStep
current step
double mySpeed
the speed of the transportable
int myDepartLane
the depart lane or -1
MSEdge * myCurrentInternalEdge
The current internal edge this transportable is on or nullptr.
const MSEdge * getEdge() const
Returns the current edge.
MSTransportableStateAdapter * myPState
state that is to be manipulated by MSPModel
MSTransportableStateAdapter * getPState() const
SUMOTime getTotalWaitingTime() const
Returns the cumulative time the transportable spent waiting.
MSStageMoving(const MSStageType type, const std::vector< const MSEdge * > &route, const std::string &routeID, MSStoppingPlace *toStop, const double speed, const double departPos, const double arrivalPos, const double departPosLat, const int departLane)
constructor
std::vector< const MSEdge * > myRoute
The route of the container.
double myDepartPos
the depart position
double myInternalDistance
distance walked on non-normal edges (i.e. walkingareas)
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)
move forward and return whether the person arrived
int getRoutePosition() const
return index of current edge within route
double walkDistance(bool partial=false) const
compute total walking distance
void saveState(std::ostringstream &out, MSTransportable *transportable)
Saves the current state into the given stream.
std::vector< MSMoveReminder * > myMoveReminders
the MoveReminders encountered while walking
void abort(MSTransportable *)
abort this stage (TraCI)
void activateMoveReminders(MSTransportable *person, double oldPos, double newPos, double newSpeed)
SUMOTime myLastEdgeEntryTime
the time the person entered the edge
MSStageWalking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat, int departLane=-1, const std::string &routeID="")
constructor
double getArrivalPos() const
SUMOTime myWalkingTime
the time the person is walking
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous, const bool withTiming, const bool saveState=false) const
Called on writing vehroute output.
MSStage * clone() const
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
static bool myWarnedInvalidTripinfo
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
~MSStageWalking()
destructor
double computeAverageSpeed() const
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
void activateEntryReminders(MSTransportable *person, const bool isDepart=false)
add the move reminders for the current lane on entry
SUMOTime getTimeLoss(const MSTransportable *transportable) const
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
std::vector< SUMOTime > * myExitTimes
optional exit time tracking for vehroute output
A lane area vehicles can halt at.
const std::string & getMyName() const
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
virtual void erase(MSTransportable *transportable)
removes a single transportable
Position getPosition(const double) const override
Return current position (x/y, cartesian).
double getPositionOnLane() const override
Get the object's position along the lane.
MSStage * getCurrentStage() const
Return the current stage.
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
double getMaxSpeed() const override
Returns the maximum speed (the minimum of desired and physical maximum speed).
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
virtual bool isJammed() const
whether the transportable is jammed
Definition MSPModel.h:210
Reroutes traffic objects passing an edge.
bool triggerRouting(SUMOTrafficObject &veh, MSMoveReminder::Notification reason)
const Position & getPosition()
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition Named.h:73
A storage for options typed value containers).
Definition OptionsCont.h:89
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String).
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool).
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
void setParameters(const Parameterised &params)
set the given key/value map in map<string, string> format
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.