Eclipse SUMO - Simulation of Urban MObility
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-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 /****************************************************************************/
21 // A stage performing walking on a sequence of edges.
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <string>
26 #include <vector>
29 #include <utils/common/ToString.h>
31 #include <utils/geom/GeomHelper.h>
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 // ===========================================================================
61 MSStageWalking::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),
70  myInternalDistance(0) {
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 
82  delete myExitTimes;
83 }
84 
85 
86 MSStage*
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 
113 void
115  myDeparted = now;
116  myRouteStep = myRoute.begin();
117  myLastEdgeEntryTime = now;
118  if (myWalkingTime == 0) {
119  if (!person->proceed(net, now)) {
121  }
122  return;
123  }
124  if (previous->getEdgePos(now) >= 0 && previous->getEdge() == *myRouteStep) {
125  // we need to adapt to the arrival position of the vehicle unless we have an explicit access
126  myDepartPos = previous->getEdgePos(now);
127  const OptionsCont& oc = OptionsCont::getOptions();
128  const std::string model = oc.getString("pedestrian.model");
129  if (model != "jupedsim") {
130  if (previous->getStageType() == MSStageType::ACCESS) {
131  const Position& lastPos = previous->getPosition(now);
132  // making a wild guess on where we actually want to depart laterally
133  const double possibleDepartPosLat = lastPos.distanceTo(previous->getEdgePosition(previous->getEdge(), myDepartPos, 0.));
134  const Position& newPos = previous->getEdgePosition(previous->getEdge(), myDepartPos, -possibleDepartPosLat); // Minus sign is here for legacy reasons.
135  if (lastPos.almostSame(newPos)) {
136  myDepartPosLat = possibleDepartPosLat;
137  } else if (lastPos.almostSame(previous->getEdgePosition(previous->getEdge(), myDepartPos, possibleDepartPosLat))) {
138  // maybe the other side of the street
139  myDepartPosLat = -possibleDepartPosLat;
140  }
141  }
142  } else {
143  myDepartPosLat = previous->getEdgePosLat(now);
144  }
145  if (myWalkingTime > 0) {
147  }
148  }
149  MSTransportableControl& pControl = net->getPersonControl();
150  myPState = pControl.getMovementModel()->add(person, this, now);
151  if (myPState == nullptr) {
152  pControl.erase(person);
153  return;
154  }
155  if (previous->getStageType() != MSStageType::WALKING || previous->getEdge() != getEdge()) {
156  // we only need new move reminders if we are walking a different edge (else it is probably a rerouting)
157  activateEntryReminders(person, true);
158  }
159  if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
160  myExitTimes = new std::vector<SUMOTime>();
161  }
162  (*myRouteStep)->addTransportable(person);
163 }
164 
165 
166 void
169 }
170 
171 
172 void
174  mySpeed = speed;
175 }
176 
177 
178 double
180  return walkDistance() / STEPS2TIME(myWalkingTime + 1); // avoid systematic rounding errors
181 }
182 
183 
184 bool
186  MSStageWalking* stage = dynamic_cast<MSStageWalking*>(getCurrentStage());
187  if (stage != nullptr) {
188  return stage->getPState()->isJammed();
189  }
190  return false;
191 }
192 
193 
194 double
195 MSStageWalking::walkDistance(bool partial) const {
196  double length = 0;
197  auto endIt = partial && myArrived < 0 ? myRouteStep + 1 : myRoute.end();
198  for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt; ++i) {
199  length += (*i)->getLength();
200  }
202  if (myInternalDistance > 0) {
203  length += myInternalDistance;
204  } else {
205  // use lower bound for distance to pass the intersection
206  for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt - 1; ++i) {
207  const MSEdge* fromEdge = *i;
208  const MSEdge* toEdge = *(i + 1);
209  const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
210  const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
211  Position fromPos;
212  Position toPos;
213  if (from != nullptr && to != nullptr) {
214  if (fromEdge->getToJunction() == toEdge->getFromJunction()) {
215  fromPos = from->getShape().back();
216  toPos = to->getShape().front();
217  } else if (fromEdge->getToJunction() == toEdge->getToJunction()) {
218  fromPos = from->getShape().back();
219  toPos = to->getShape().back();
220  } else if (fromEdge->getFromJunction() == toEdge->getFromJunction()) {
221  fromPos = from->getShape().front();
222  toPos = to->getShape().front();
223  } else if (fromEdge->getFromJunction() == toEdge->getToJunction()) {
224  fromPos = from->getShape().front();
225  toPos = to->getShape().back();
226  }
227  //std::cout << " from=" << from->getID() << " to=" << to->getID() << " junctionLength=" << fromPos.distanceTo2D(toPos) << "\n";
228  length += fromPos.distanceTo2D(toPos);
229  }
230  }
231  }
232  }
233  // determine walking direction for depart and arrival
234  int dummy = 0;
235  const int departFwdArrivalDir = MSPModel::canTraverse(MSPModel::FORWARD, myRoute, dummy);
236  const int departBwdArrivalDir = MSPModel::canTraverse(MSPModel::BACKWARD, myRoute, dummy);
237  const bool mayStartForward = departFwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
238  const bool mayStartBackward = departBwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
239  const double arrivalPos = partial && myArrived < 0 ? getEdgePos(SIMSTEP) : myArrivalPos;
240  const double lengthFwd = (length - myDepartPos - (
241  departFwdArrivalDir == MSPModel::BACKWARD
242  ? arrivalPos
243  : myRoute.back()->getLength() - arrivalPos));
244  const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
245  departBwdArrivalDir == MSPModel::BACKWARD
246  ? arrivalPos
247  : myRoute.back()->getLength() - arrivalPos));
248  //std::cout << " length=" << length << " lengthFwd=" << lengthFwd << " lengthBwd=" << lengthBwd << " mayStartForward=" << mayStartForward << " mayStartBackward=" << mayStartBackward << "\n";
249 
250  if (myRoute.size() == 1) {
251  if (myDepartPos > myArrivalPos) {
252  length = lengthBwd;
253  } else {
254  length = lengthFwd;
255  }
256  } else {
257  if (mayStartForward && mayStartBackward) {
258  length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
259  } else if (mayStartForward) {
260  length = lengthFwd;
261  } else if (mayStartBackward) {
262  length = lengthBwd;
263  } else {
264  length = lengthFwd;
265  }
266  }
267  //std::cout << SIMTIME << " route=" << toString(myRoute)
268  // << " depPos=" << myDepartPos << " arPos=" << myArrivalPos
269  // << " dFwdADir=" << departFwdArrivalDir
270  // << " dBwdADir=" << departBwdArrivalDir
271  // << " lengthFwd=" << lengthFwd
272  // << " lengthBwd=" << lengthBwd
273  // << "\n";
274 
275  return MAX2(POSITION_EPS, length);
276 }
277 
278 
279 SUMOTime
280 MSStageWalking::getTimeLoss(const MSTransportable* transportable) const {
281  SUMOTime timeLoss = myArrived == -1 ? 0 : getDuration() - TIME2STEPS(walkDistance(true) / getMaxSpeed(transportable));
282  if (timeLoss < 0 && timeLoss > TIME2STEPS(-0.1)) {
283  // avoid negative timeLoss due to rounding errors
284  timeLoss = 0;
285  }
286  return timeLoss;
287 }
288 
289 
290 void
292  if (!myWarnedInvalidTripinfo && MSNet::getInstance()->getPersonControl().getMovementModel()->usingShortcuts()) {
293  WRITE_WARNING(TL("The pedestrian model uses infrastructure which is not in the network, timeLoss and routeLength may be invalid."));
295  }
296  const double distance = walkDistance(true);
297  const double maxSpeed = getMaxSpeed(person);
298  const SUMOTime duration = myArrived - myDeparted;
299  const SUMOTime timeLoss = getTimeLoss(person);
300  MSDevice_Tripinfo::addPedestrianData(distance, duration, timeLoss);
301  os.openTag("walk");
302  os.writeAttr("depart", myDeparted >= 0 ? time2string(myDeparted) : "-1");
303  os.writeAttr("departPos", myDepartPos);
304  os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
305  os.writeAttr("arrivalPos", myArrived >= 0 ? toString(myArrivalPos) : "-1");
306  os.writeAttr("duration", myDeparted < 0 ? "-1" :
307  time2string(myArrived >= 0 ? duration : MSNet::getInstance()->getCurrentTimeStep() - myDeparted));
308  os.writeAttr("routeLength", myArrived >= 0 ? toString(distance) : "-1");
309  os.writeAttr("timeLoss", time2string(timeLoss));
310  os.writeAttr("maxSpeed", maxSpeed);
311  os.closeTag();
312 }
313 
314 
315 void
316 MSStageWalking::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool withRouteLength, const MSStage* const /* previous */) const {
318  std::string comment = "";
319  if (myDestinationStop != nullptr) {
321  if (myDestinationStop->getMyName() != "") {
322  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
323  }
324  } else if (wasSet(VEHPARS_ARRIVALPOS_SET)) {
326  }
327  if (myWalkingTime > 0) {
329  } else if (mySpeed > 0) {
331  }
332  if (withRouteLength) {
333  if (myDeparted >= 0) {
334  os.writeAttr("routeLength", walkDistance(true));
335  } else {
336  os.writeAttr("routeLength", "-1");
337  }
338  }
339  if (myExitTimes != nullptr) {
340  std::vector<std::string> exits;
341  for (SUMOTime t : *myExitTimes) {
342  exits.push_back(time2string(t));
343  }
344  std::vector<std::string> missing(MAX2(0, (int)myRoute.size() - (int)myExitTimes->size()), "-1");
345  exits.insert(exits.end(), missing.begin(), missing.end());
346  os.writeAttr("exitTimes", exits);
349  }
350  if (OptionsCont::getOptions().getBool("vehroute-output.cost")) {
352  }
353  os.closeTag(comment);
354 }
355 
356 
357 bool
358 MSStageWalking::moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal) {
359  ((MSEdge*)getEdge())->removeTransportable(person);
360  const MSLane* lane = getSidewalk<MSEdge, MSLane>(getEdge());
361  const bool arrived = myRouteStep == myRoute.end() - 1;
362  if (lane != nullptr) {
363  const double tl = person->getVehicleType().getLength();
364  const double lastPos = (arrived
365  ? (prevDir == MSPModel::FORWARD
366  ? getArrivalPos() + tl
367  : getArrivalPos() - tl)
368  : person->getPositionOnLane());
369  activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
370  }
371  if (myExitTimes != nullptr && nextInternal == nullptr) {
372  myExitTimes->push_back(currentTime);
373  }
374  myMoveReminders.clear();
375  myLastEdgeEntryTime = currentTime;
376  //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
377  if (myCurrentInternalEdge != nullptr) {
379  }
380  if (arrived) {
381  MSPerson* p = dynamic_cast<MSPerson*>(person);
382  if (p->hasInfluencer() && p->getInfluencer().isRemoteControlled()) {
383  myCurrentInternalEdge = nextInternal;
384  ((MSEdge*) getEdge())->addTransportable(person);
385  return false;
386  }
387  if (myDestinationStop != nullptr) {
389  }
390  if (!person->proceed(MSNet::getInstance(), currentTime)) {
392  }
393  //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
394  return true;
395  } else {
396  if (nextInternal == nullptr) {
397  ++myRouteStep;
398  }
399  myCurrentInternalEdge = nextInternal;
400  ((MSEdge*) getEdge())->addTransportable(person);
401  return false;
402  }
403 }
404 
405 
406 void
407 MSStageWalking::activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived) {
409  for (MSMoveReminder* const rem : myMoveReminders) {
410  rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, t, t, true);
411  rem->notifyLeave(*person, lastPos, notification);
412  }
413 }
414 
415 
416 void
418  const MSLane* const nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
419  if (nextLane != nullptr) {
420  for (MSMoveReminder* const rem : nextLane->getMoveReminders()) {
421  if (rem->notifyEnter(*person, isDepart ? MSMoveReminder::NOTIFICATION_DEPARTED : MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
422  myMoveReminders.push_back(rem);
423  }
424  }
425  }
426  if (hasParameter("rerouter")) {
427  double minDist = std::numeric_limits<double>::max();
428  MSTriggeredRerouter* nearest = nullptr;
429  for (MSMoveReminder* const rem : myMoveReminders) {
430  MSTriggeredRerouter* rerouter = dynamic_cast<MSTriggeredRerouter*>(rem);
431  if (rerouter != nullptr) {
432  const double dist2 = rerouter->getPosition().distanceSquaredTo2D(person->getPosition());
433  if (dist2 < minDist) {
434  nearest = rerouter;
435  minDist = dist2;
436  }
437  }
438  }
439  if (nearest != nullptr) {
441  }
442  // TODO maybe removal of the reminders? Or can we rely on movetonextedge to clean everything up?
443  }
444 }
445 
446 
447 int
449  return (int)(myRouteStep - myRoute.begin());
450 }
451 
452 
453 double
454 MSStageWalking::getMaxSpeed(const MSTransportable* const person) const {
455  return mySpeed >= 0 ? mySpeed : person->getMaxSpeed();
456 }
457 
458 std::string
459 MSStageWalking::getStageSummary(const bool /* isPerson */) const {
460  const std::string dest = (getDestinationStop() == nullptr ?
461  " edge '" + getDestination()->getID() + "'" :
462  " stop '" + getDestinationStop()->getID() + "'" + (
463  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
464  return "walking to " + dest;
465 }
466 
467 
468 void
469 MSStageWalking::saveState(std::ostringstream& out) {
470  out << " " << myDeparted << " " << (myRouteStep - myRoute.begin()) << " " << myLastEdgeEntryTime;
471  myPState->saveState(out);
472 }
473 
474 
475 void
476 MSStageWalking::loadState(MSTransportable* transportable, std::istringstream& state) {
477  int stepIdx;
478  state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
479  myRouteStep = myRoute.begin() + stepIdx;
480  myPState = MSNet::getInstance()->getPersonControl().getMovementModel()->loadState(transportable, this, state);
481  if (myPState->getLane() && !myPState->getLane()->isNormal()) {
483  myCurrentInternalEdge->addTransportable(transportable);
484  } else {
485  (*myRouteStep)->addTransportable(transportable);
486  }
487 }
488 
489 
490 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
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 TIME2STEPS(x)
Definition: SUMOTime.h:57
const 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:82
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 * getFromJunction() const
Definition: MSEdge.h:411
double getLength() const
return the length of the edge
Definition: MSEdge.h:662
const MSJunction * getToJunction() const
Definition: MSEdge.h:415
virtual void addTransportable(MSTransportable *t) const
Definition: MSEdge.cpp:1124
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
bool isNormal() const
Definition: MSLane.cpp:2512
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:756
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:315
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:182
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1173
static const int BACKWARD
Definition: MSPModel.h:120
static int canTraverse(int dir, const ConstMSEdgeVector &route, int &passedEdges)
Definition: MSPModel.cpp:54
static const int FORWARD
Definition: MSPModel.h:119
virtual MSTransportableStateAdapter * loadState(MSTransportable *transportable, MSStageMoving *stage, std::istringstream &state)
load the state of the given transportable
Definition: MSPModel.h:60
virtual bool usingInternalLanes()=0
whether movements on intersections are modelled
virtual void remove(MSTransportableStateAdapter *state)=0
remove the specified person from the pedestrian simulation
virtual MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)=0
register the given person as a pedestrian
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:121
bool isRemoteControlled() const
Definition: MSPerson.cpp:313
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:219
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:275
static SumoRNG * getParsingRNG()
get parsing RNG
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:109
static RandomDistributor< ConstMSRoutePtr > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:161
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:272
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSStage.h:84
double getCosts() const
Returns the costs of the stage.
Definition: MSStage.h:255
virtual Position getPosition(SUMOTime now) const =0
returns the position of the transportable
bool wasSet(int what) const
Definition: MSStage.h:243
MSStageType getStageType() const
Definition: MSStage.h:126
virtual SUMOTime getDuration() const
Definition: MSStage.cpp:139
SUMOTime myArrived
the time at which this stage ended
Definition: MSStage.h:284
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:275
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition: MSStage.cpp:172
SUMOTime myDeparted
the time at which this stage started
Definition: MSStage.h:281
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
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
std::vector< const MSEdge * > myRoute
The route of the container.
MSTransportableStateAdapter * getPState() const
Definition: MSStageMoving.h:49
double myDepartPos
the depart position
std::vector< const MSEdge * >::iterator myRouteStep
current step
double myInternalDistance
distance walked on non-normal edges (i.e. walkingareas)
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)
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
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
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.
SumoXMLTag getElement() const
return the type of this stopping place
const std::string & getMyName() const
bool addTransportable(const MSTransportable *p)
adds a transportable to this stop
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
virtual void erase(MSTransportable *transportable)
removes a single transportable
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
Position getPosition(const double) const
Return current position (x/y, cartesian)
double getPositionOnLane() const
Get the object's position along the lane.
MSStage * getCurrentStage() const
Return the current stage.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical maximum speed)
virtual bool isJammed() const
whether the transportable is jammed
Definition: MSPModel.h:208
virtual const MSLane * getLane() const
the current lane of the transportable
Definition: MSPModel.h:218
virtual void saveState(std::ostringstream &out)
Saves the current state into the given stream.
Definition: MSPModel.h:229
virtual double getPathLength() const
return the total length of the current lane (in particular for on a walkingarea)
Definition: MSPModel.h:223
Reroutes traffic objects passing an edge.
const Position & getPosition()
bool triggerRouting(SUMOTrafficObject &veh, MSMoveReminder::Notification reason)
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)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
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 inner 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:276
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:271
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:261
bool almostSame(const Position &p2, double maxDiv=POSITION_EPS) const
check if two position is almost the sme as other
Definition: Position.h:256
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.