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-2025 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 {
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);
336 }
337 if (OptionsCont::getOptions().getBool("vehroute-output.cost")) {
339 }
340 os.closeTag(comment);
341}
342
343
344bool
345MSStageWalking::moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal, const bool isReplay) {
346 ((MSEdge*)getEdge())->removeTransportable(person);
348 const bool arrived = myRouteStep == myRoute.end() - 1;
349 if (lane != nullptr) {
350 const double tl = person->getVehicleType().getLength();
351 const double lastPos = (arrived
352 ? (prevDir == MSPModel::FORWARD
353 ? getArrivalPos() + tl
354 : getArrivalPos() - tl)
355 : person->getPositionOnLane());
356 activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
357 }
358 if (myExitTimes != nullptr && nextInternal == nullptr) {
359 myExitTimes->push_back(currentTime);
360 }
361 myMoveReminders.clear();
362 myLastEdgeEntryTime = currentTime;
363 //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
364 if (myCurrentInternalEdge != nullptr) {
365 myInternalDistance += (myPState->getPathLength() == 0 ? myCurrentInternalEdge->getLength() : myPState->getPathLength());
366 }
367 if (arrived) {
368 MSPerson* p = dynamic_cast<MSPerson*>(person);
369 if (!isReplay && p->hasInfluencer() && p->getInfluencer().isRemoteControlled()) {
370 myCurrentInternalEdge = nextInternal;
371 ((MSEdge*) getEdge())->addTransportable(person);
372 return false;
373 }
374 if (myDestinationStop != nullptr) {
375 myDestinationStop->addTransportable(person);
376 }
377 if (isReplay) {
378 // cannot do this in the replay device because the person might get deleted below
380 }
381 if (!person->proceed(MSNet::getInstance(), currentTime)) {
383 }
384 //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
385 return true;
386 } else {
387 if (nextInternal == nullptr) {
388 ++myRouteStep;
389 }
390 myCurrentInternalEdge = nextInternal;
391 ((MSEdge*) getEdge())->addTransportable(person);
392 return false;
393 }
394}
395
396
397void
399 const MSLane* const nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
400 if (nextLane != nullptr) {
401 for (MSMoveReminder* const rem : nextLane->getMoveReminders()) {
402 if (rem->notifyEnter(*person, isDepart ? MSMoveReminder::NOTIFICATION_DEPARTED : MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
403 myMoveReminders.push_back(rem);
404 }
405 }
406 }
407 if (hasParameter("rerouter")) {
408 double minDist = std::numeric_limits<double>::max();
409 MSTriggeredRerouter* nearest = nullptr;
410 for (MSMoveReminder* const rem : myMoveReminders) {
411 MSTriggeredRerouter* rerouter = dynamic_cast<MSTriggeredRerouter*>(rem);
412 if (rerouter != nullptr) {
413 const double dist2 = rerouter->getPosition().distanceSquaredTo2D(person->getPosition());
414 if (dist2 < minDist) {
415 nearest = rerouter;
416 minDist = dist2;
417 }
418 }
419 }
420 if (nearest != nullptr) {
422 }
423 // TODO maybe removal of the reminders? Or can we rely on movetonextedge to clean everything up?
424 }
425}
426
427
428void
429MSStageWalking::activateMoveReminders(MSTransportable* person, double oldPos, double newPos, double newSpeed) {
430 for (std::vector<MSMoveReminder*>::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
431 if ((*rem)->notifyMove(*person, oldPos, newPos, newSpeed)) {
432 ++rem;
433 } else {
434 rem = myMoveReminders.erase(rem);
435 }
436 }
437}
438
439
440void
441MSStageWalking::activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived) {
443 for (MSMoveReminder* const rem : myMoveReminders) {
444 rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, t, t, true);
445 rem->notifyLeave(*person, lastPos, notification);
446 }
447}
448
449
450int
452 return (int)(myRouteStep - myRoute.begin());
453}
454
455
456double
458 return mySpeed >= 0 ? mySpeed : person->getMaxSpeed();
459}
460
461std::string
462MSStageWalking::getStageSummary(const bool /* isPerson */) const {
463 const std::string dest = (getDestinationStop() == nullptr ?
464 " edge '" + getDestination()->getID() + "'" :
465 " stop '" + getDestinationStop()->getID() + "'" + (
466 getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
467 return "walking to " + dest;
468}
469
470
471void
472MSStageWalking::saveState(std::ostringstream& out) {
473 out << " " << myDeparted << " " << (myRouteStep - myRoute.begin()) << " " << myLastEdgeEntryTime;
474 myPState->saveState(out);
475}
476
477
478void
479MSStageWalking::loadState(MSTransportable* transportable, std::istringstream& state) {
480 int stepIdx;
481 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
482 myRouteStep = myRoute.begin() + stepIdx;
483 myPState = MSNet::getInstance()->getPersonControl().getMovementModel()->loadState(transportable, this, state);
484 if (myPState->getLane() && !myPState->getLane()->isNormal()) {
485 myCurrentInternalEdge = &myPState->getLane()->getEdge();
486 myCurrentInternalEdge->addTransportable(transportable);
487 } else {
488 (*myRouteStep)->addTransportable(transportable);
489 }
490}
491
492
493/****************************************************************************/
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:55
#define SIMSTEP
Definition SUMOTime.h:61
#define TIME2STEPS(x)
Definition SUMOTime.h:57
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:46
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:426
const MSJunction * getFromJunction() const
Definition MSEdge.h:422
virtual void addTransportable(MSTransportable *t) const
Definition MSEdge.cpp:1198
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:323
double getLength() const
Returns the lane's length.
Definition MSLane.h:611
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:186
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1256
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:329
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:222
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition MSPerson.cpp:291
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:305
double getCosts() const
Returns the costs of the stage.
Definition MSStage.h:271
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition MSStage.h:88
bool wasSet(int what) const
Definition MSStage.h:259
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:133
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:317
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:308
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:314
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
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
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
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
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
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing 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:74
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 & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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.