Eclipse SUMO - Simulation of Urban MObility
MSPerson.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 // The class for modelling person-movements
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>
36 #include "MSPerson.h"
40 #include <microsim/MSVehicle.h>
45 #include "MSPModel.h"
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 /* -------------------------------------------------------------------------
51  * MSPerson::MSPersonStage_Walking - methods
52  * ----------------------------------------------------------------------- */
54  const ConstMSEdgeVector& route,
55  MSStoppingPlace* toStop,
56  SUMOTime walkingTime, double speed,
57  double departPos, double arrivalPos, double departPosLat, int departLane) :
58  MSStageMoving(route, toStop, speed, departPos, arrivalPos, departPosLat, departLane, MSStageType::WALKING),
59  myWalkingTime(walkingTime),
60  myExitTimes(nullptr) {
61  myDepartPos = SUMOVehicleParameter::interpretEdgePos(departPos, route.front()->getLength(), SUMO_ATTR_DEPARTPOS,
62  "person '" + personID + "' walking from " + route.front()->getID());
63  myArrivalPos = SUMOVehicleParameter::interpretEdgePos(arrivalPos, route.back()->getLength(), SUMO_ATTR_ARRIVALPOS,
64  "person '" + personID + "' walking to " + route.back()->getID());
65  if (walkingTime > 0) {
67  }
68 }
69 
70 
72  delete myExitTimes;
73 }
74 
75 
76 MSStage*
78  return new MSPersonStage_Walking("dummyID", myRoute, myDestinationStop, myWalkingTime, mySpeed, myDepartPos, myArrivalPos, myDepartPosLat);
79 }
80 
81 
82 void
84  myDeparted = now;
85  myRouteStep = myRoute.begin();
86  myLastEdgeEntryTime = now;
87  if (myWalkingTime == 0) {
88  if (!person->proceed(net, now)) {
90  }
91  return;
92  }
93  if (previous->getEdgePos(now) >= 0 && previous->getEdge() == *myRouteStep) {
94  myDepartPos = previous->getEdgePos(now);
95  if (myWalkingTime > 0) {
96  mySpeed = computeAverageSpeed();
97  }
98  }
99  MSTransportableControl& pControl = net->getPersonControl();
100  myState = pControl.getMovementModel()->add(person, this, now);
101  if (myState == nullptr) {
102  pControl.erase(person);
103  return;
104  }
105  const MSLane* const lane = getSidewalk<MSEdge, MSLane>(getEdge());
106  if (lane != nullptr) {
107  for (MSMoveReminder* rem : lane->getMoveReminders()) {
108  if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_DEPARTED, lane)) {
109  myMoveReminders.push_back(rem);
110  };
111  }
112  }
113  if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
114  myExitTimes = new std::vector<SUMOTime>();
115  }
116  (*myRouteStep)->addPerson(person);
117 }
118 
119 
120 void
123 }
124 
125 
126 void
128  mySpeed = speed;
129 }
130 
131 
132 double
134  return walkDistance() / STEPS2TIME(myWalkingTime + 1); // avoid systematic rounding errors
135 }
136 
137 
138 double
140  double length = 0;
141  for (const MSEdge* edge : myRoute) {
142  length += edge->getLength();
143  }
144  if (myRoute.size() > 1 && MSNet::getInstance()->getPersonControl().getMovementModel()->usingInternalLanes()) {
145  // use lower bound for distance to pass the intersection
146  for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != myRoute.end() - 1; ++i) {
147  const MSEdge* fromEdge = *i;
148  const MSEdge* toEdge = *(i + 1);
149  const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
150  const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
151  Position fromPos;
152  Position toPos;
153  if (from != nullptr && to != nullptr) {
154  if (fromEdge->getToJunction() == toEdge->getFromJunction()) {
155  fromPos = from->getShape().back();
156  toPos = to->getShape().front();
157  } else if (fromEdge->getToJunction() == toEdge->getToJunction()) {
158  fromPos = from->getShape().back();
159  toPos = to->getShape().back();
160  } else if (fromEdge->getFromJunction() == toEdge->getFromJunction()) {
161  fromPos = from->getShape().front();
162  toPos = to->getShape().front();
163  } else if (fromEdge->getFromJunction() == toEdge->getToJunction()) {
164  fromPos = from->getShape().front();
165  toPos = to->getShape().back();
166  }
167  length += fromPos.distanceTo2D(toPos);
168  }
169  }
170  }
171  // determine walking direction for depart and arrival
172  const int departFwdArrivalDir = MSPModel::canTraverse(MSPModel::FORWARD, myRoute);
173  const int departBwdArrivalDir = MSPModel::canTraverse(MSPModel::BACKWARD, myRoute);
174  const bool mayStartForward = departFwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
175  const bool mayStartBackward = departBwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
176  const double lengthFwd = (length - myDepartPos - (
177  departFwdArrivalDir == MSPModel::BACKWARD
178  ? myArrivalPos
179  : myRoute.back()->getLength() - myArrivalPos));
180  const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
181  departBwdArrivalDir == MSPModel::BACKWARD
182  ? myArrivalPos
183  : myRoute.back()->getLength() - myArrivalPos));
184 
185  if (myRoute.size() == 1) {
186  if (myDepartPos > myArrivalPos) {
187  length = lengthBwd;
188  } else {
189  length = lengthFwd;
190  }
191  } else {
192  if (mayStartForward && mayStartBackward) {
193  length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
194  } else if (mayStartForward) {
195  length = lengthFwd;
196  } else if (mayStartBackward) {
197  length = lengthBwd;
198  } else {
199  length = lengthFwd;
200  }
201  }
202  //std::cout << SIMTIME << " route=" << toString(myRoute)
203  // << " depPos=" << myDepartPos << " arPos=" << myArrivalPos
204  // << " dFwdADir=" << departFwdArrivalDir
205  // << " dBwdADir=" << departBwdArrivalDir
206  // << " lengthFwd=" << lengthFwd
207  // << " lengthBwd=" << lengthBwd
208  // << "\n";
209 
210  return MAX2(POSITION_EPS, length);
211 }
212 
213 
214 void
216  const double distance = walkDistance();
217  const double maxSpeed = getMaxSpeed(person);
218  const SUMOTime duration = myArrived - myDeparted;
219  SUMOTime timeLoss = myArrived == -1 ? 0 : duration - TIME2STEPS(distance / maxSpeed);
220  if (timeLoss < 0 && timeLoss > TIME2STEPS(-0.1)) {
221  // avoid negative timeLoss due to rounding errors
222  timeLoss = 0;
223  }
224  MSDevice_Tripinfo::addPedestrianData(distance, duration, timeLoss);
225  os.openTag("walk");
226  os.writeAttr("depart", myDeparted >= 0 ? time2string(myDeparted) : "-1");
227  os.writeAttr("departPos", myDepartPos);
228  os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
229  os.writeAttr("arrivalPos", myArrived >= 0 ? toString(myArrivalPos) : "-1");
230  os.writeAttr("duration", myDeparted < 0 ? "-1" :
231  time2string(myArrived >= 0 ? duration : MSNet::getInstance()->getCurrentTimeStep() - myDeparted));
232  os.writeAttr("routeLength", myArrived >= 0 ? toString(distance) : "-1");
233  os.writeAttr("timeLoss", time2string(timeLoss));
234  os.writeAttr("maxSpeed", maxSpeed);
235  os.closeTag();
236 }
237 
238 
239 void
240 MSPerson::MSPersonStage_Walking::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool withRouteLength, const MSStage* const /* previous */) const {
241  os.openTag("walk").writeAttr(SUMO_ATTR_EDGES, myRoute);
242  std::string comment = "";
243  if (myDestinationStop != nullptr) {
244  os.writeAttr(toString(myDestinationStop->getElement()), myDestinationStop->getID());
245  if (myDestinationStop->getMyName() != "") {
246  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
247  }
248  }
249  if (myWalkingTime > 0) {
250  os.writeAttr(SUMO_ATTR_DURATION, time2string(myWalkingTime));
251  } else if (mySpeed > 0) {
252  os.writeAttr(SUMO_ATTR_SPEED, mySpeed);
253  }
254  if (withRouteLength) {
255  os.writeAttr("routeLength", walkDistance());
256  }
257  if (myExitTimes != nullptr) {
258  std::vector<std::string> exits;
259  for (SUMOTime t : *myExitTimes) {
260  exits.push_back(time2string(t));
261  }
262  std::vector<std::string> missing(MAX2(0, (int)myRoute.size() - (int)myExitTimes->size()), "-1");
263  exits.insert(exits.end(), missing.begin(), missing.end());
264  os.writeAttr("exitTimes", exits);
265  os.writeAttr(SUMO_ATTR_STARTED, myDeparted >= 0 ? time2string(myDeparted) : "-1");
266  os.writeAttr(SUMO_ATTR_ENDED, myArrived >= 0 ? time2string(myArrived) : "-1");
267  }
268  os.closeTag(comment);
269 }
270 
271 
272 bool
273 MSPerson::MSPersonStage_Walking::moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal) {
274  ((MSEdge*)getEdge())->removePerson(person);
275  const MSLane* lane = getSidewalk<MSEdge, MSLane>(getEdge());
276  const bool arrived = myRouteStep == myRoute.end() - 1;
277  if (lane != nullptr) {
278  const double tl = person->getVehicleType().getLength();
279  const double lastPos = (arrived
280  ? (prevDir == MSPModel::FORWARD
281  ? getArrivalPos() + tl
282  : getArrivalPos() - tl)
283  : (prevDir == MSPModel::FORWARD
284  ? lane->getLength() + tl
285  : -tl));
286  for (MSMoveReminder* rem : myMoveReminders) {
287  rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, currentTime, currentTime, true);
288  rem->notifyLeave(*person, lastPos, arrived ? MSMoveReminder::NOTIFICATION_ARRIVED : MSMoveReminder::NOTIFICATION_JUNCTION);
289  }
290  }
291  if (myExitTimes != nullptr && nextInternal == nullptr) {
292  myExitTimes->push_back(currentTime);
293  }
294  myMoveReminders.clear();
295  myLastEdgeEntryTime = currentTime;
296  //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
297  if (arrived) {
298  MSPerson* p = dynamic_cast<MSPerson*>(person);
299  if (p->hasInfluencer() && p->getInfluencer().isRemoteControlled()) {
300  myCurrentInternalEdge = nextInternal;
301  ((MSEdge*) getEdge())->addPerson(person);
302  return false;
303  }
304  if (myDestinationStop != nullptr) {
305  myDestinationStop->addTransportable(person);
306  }
307  if (!person->proceed(MSNet::getInstance(), currentTime)) {
309  }
310  //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
311  return true;
312  } else {
313  if (nextInternal == nullptr) {
314  ++myRouteStep;
315  }
316  myCurrentInternalEdge = nextInternal;
317  const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
318  if (nextLane != nullptr) {
319  for (MSMoveReminder* rem : nextLane->getMoveReminders()) {
320  if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
321  ;
322  myMoveReminders.push_back(rem);
323  }
324  }
325  }
326  ((MSEdge*) getEdge())->addPerson(person);
327  return false;
328  }
329 }
330 
331 double
333  return mySpeed >= 0 ? mySpeed : person->getVehicleType().getMaxSpeed() * person->getSpeedFactor();
334 }
335 
336 std::string
337 MSPerson::MSPersonStage_Walking::getStageSummary(const bool /* isPerson */) const {
338  const std::string dest = (getDestinationStop() == nullptr ?
339  " edge '" + getDestination()->getID() + "'" :
340  " stop '" + getDestinationStop()->getID() + "'" + (
341  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
342  return "walking to " + dest;
343 }
344 
345 
346 void
348  out << " " << myDeparted << " " << (myRouteStep - myRoute.begin()) << " " << myLastEdgeEntryTime;
349  myState->saveState(out);
350 }
351 
352 
353 void
354 MSPerson::MSPersonStage_Walking::loadState(MSTransportable* transportable, std::istringstream& state) {
355  int stepIdx;
356  state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
357  myRouteStep = myRoute.begin() + stepIdx;
358  myState = MSNet::getInstance()->getPersonControl().getMovementModel()->loadState(transportable, this, state);
359  (*myRouteStep)->addPerson(transportable);
360 }
361 
362 
363 /* -------------------------------------------------------------------------
364 * MSPerson::MSPersonStage_Access - methods
365 * ----------------------------------------------------------------------- */
367  const double arrivalPos, const double dist, const bool isExit) :
368  MSStage(destination, toStop, arrivalPos, MSStageType::ACCESS),
369  myDist(dist), myAmExit(isExit) {
370  myPath.push_back(destination->getLanes()[0]->geometryPositionAtOffset(myDestinationStop->getAccessPos(destination)));
371  myPath.push_back(toStop->getLane().geometryPositionAtOffset((toStop->getEndLanePosition() + toStop->getBeginLanePosition()) / 2));
372  if (isExit) {
373  myPath = myPath.reverse();
374  }
375 }
376 
377 
379 
380 MSStage*
382  return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
383 }
384 
385 void
387  myDeparted = now;
388  myEstimatedArrival = now + TIME2STEPS(myDist / person->getVehicleType().getMaxSpeed());
389  net->getBeginOfTimestepEvents()->addEvent(new ProceedCmd(person, &myDestinationStop->getLane().getEdge()), myEstimatedArrival);
390  myDestinationStop->getLane().getEdge().addPerson(person);
391 }
392 
393 
394 std::string
395 MSPerson::MSPersonStage_Access::getStageDescription(const bool /* isPerson */) const {
396  return "access";
397 }
398 
399 
400 std::string
401 MSPerson::MSPersonStage_Access::getStageSummary(const bool /* isPerson */) const {
402  return (myAmExit ? "access from stop '" : "access to stop '") + getDestinationStop()->getID() + "'";
403 }
404 
405 
406 Position
408  return myPath.positionAtOffset(myPath.length() * (now - myDeparted) / (myEstimatedArrival - myDeparted));
409 }
410 
411 
412 double
414  return myPath.angleAt2D(0);
415 }
416 
417 
418 void
420  os.openTag("access");
421  os.writeAttr("stop", getDestinationStop()->getID());
422  os.writeAttr("depart", time2string(myDeparted));
423  os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
424  os.writeAttr("duration", myArrived > 0 ? time2string(myArrived - myDeparted) : "-1");
425  os.writeAttr("routeLength", myDist);
426  os.closeTag();
427 }
428 
429 
430 SUMOTime
432  myStopEdge->removePerson(myPerson);
433  if (!myPerson->proceed(MSNet::getInstance(), currentTime)) {
435  }
436  return 0;
437 }
438 
439 
440 /* -------------------------------------------------------------------------
441  * MSPerson - methods
442  * ----------------------------------------------------------------------- */
443 MSPerson::MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor) :
444  MSTransportable(pars, vtype, plan, true),
445  myInfluencer(nullptr), myChosenSpeedFactor(speedFactor) {
446 }
447 
448 
450 }
451 
452 
453 bool
454 MSPerson::checkAccess(const MSStage* const prior, const bool waitAtStop) {
455  MSStoppingPlace* prevStop = prior->getDestinationStop();
456  if (!waitAtStop && prior->getStageType() == MSStageType::TRIP) {
457  prevStop = dynamic_cast<const MSStageTrip*>(prior)->getOriginStop();
458  }
459  if (prevStop != nullptr) {
460  if (waitAtStop) {
461  const double accessDist = prevStop->getAccessDistance(prior->getDestination());
462  if (accessDist > 0.) {
463  const double arrivalAtBs = (prevStop->getBeginLanePosition() + prevStop->getEndLanePosition()) / 2;
464  myStep = myPlan->insert(myStep, new MSPersonStage_Access(prior->getDestination(), prevStop, arrivalAtBs, accessDist, false));
465  return true;
466  }
467  } else {
468  const double accessDist = prevStop->getAccessDistance((*myStep)->getFromEdge());
469  if (accessDist > 0.) {
470  myStep = myPlan->insert(myStep, new MSPersonStage_Access((*myStep)->getFromEdge(), prevStop, prevStop->getAccessPos((*myStep)->getFromEdge()), accessDist, true));
471  return true;
472  }
473  }
474  }
475  return false;
476 }
477 
478 
479 const std::string&
481 // if (getCurrentStageType() == WALKING) {
482 // MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
483 // assert(walkingStage != 0);
484 // const MSEdge* nextEdge = walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
485 // if (nextEdge != 0) {
486 // return nextEdge->getID();
487 // }
488 // }
489 // return StringUtils::emptyString;
490  const MSEdge* nextEdge = getNextEdgePtr();
491  if (nextEdge != nullptr) {
492  return nextEdge->getID();
493  }
495 }
496 
497 
498 const MSEdge*
501  MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
502  assert(walkingStage != nullptr);
503  return walkingStage->getState()->getNextEdge(*walkingStage);
504  }
505  return nullptr;
506 }
507 
508 
509 
510 void
511 MSPerson::reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex) {
512  assert(nextIndex > firstIndex);
513  //std::cout << SIMTIME << " reroute person " << getID()
514  // << " newEdges=" << toString(newEdges)
515  // << " firstIndex=" << firstIndex
516  // << " nextIndex=" << nextIndex
517  // << " departPos=" << getEdgePos()
518  // << " arrivalPos=" << getNextStage(nextIndex - 1)->getArrivalPos()
519  // << "\n";
521  getNextStage(nextIndex - 1)->getDestinationStop(), -1,
522  -1,
523  departPos,
524  getNextStage(nextIndex - 1)->getArrivalPos(),
525  0);
526  appendStage(newStage, nextIndex);
527  // remove stages in reverse order so that proceed will only be called at the last removal
528  for (int i = nextIndex - 1; i >= firstIndex; i--) {
529  //std::cout << " removeStage=" << i << "\n";
530  removeStage(i);
531  }
532 }
533 
534 
537  if (myInfluencer == nullptr) {
538  myInfluencer = new Influencer();
539  }
540  return *myInfluencer;
541 }
542 
543 
546  return myInfluencer;
547 }
548 
549 
550 
551 /* -------------------------------------------------------------------------
552  * methods of MSPerson::Influencer
553  * ----------------------------------------------------------------------- */
555 
556 
558 
559 
560 void
561 MSPerson::Influencer::setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t) {
562  myRemoteXYPos = xyPos;
563  myRemoteLane = l;
564  myRemotePos = pos;
565  myRemotePosLat = posLat;
566  myRemoteAngle = angle;
567  myRemoteEdgeOffset = edgeOffset;
568  myRemoteRoute = route;
569  myLastRemoteAccess = t;
570 }
571 
572 
573 bool
575  return myLastRemoteAccess == MSNet::getInstance()->getCurrentTimeStep();
576 }
577 
578 
579 bool
581  return myLastRemoteAccess >= t - TIME2STEPS(10);
582 }
583 
584 
585 void
587  /*
588  std::cout << SIMTIME << " moveToXY person=" << p->getID()
589  << " xyPos=" << myRemoteXYPos
590  << " lane=" << Named::getIDSecure(myRemoteLane)
591  << " pos=" << myRemotePos
592  << " posLat=" << myRemotePosLat
593  << " angle=" << myRemoteAngle
594  << " eOf=" << myRemoteEdgeOffset
595  << " route=" << toString(myRemoteRoute)
596  << " aTime=" << time2string(myLastRemoteAccess)
597  << "\n";
598  */
599  switch (p->getStageType(0)) {
600  case MSStageType::WALKING: {
602  assert(s != nullptr);
603  s->getState()->moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
604  MSNet::getInstance()->getCurrentTimeStep());
605  }
606  break;
607  default:
608  break;
609  }
610 }
611 
612 
613 /****************************************************************************/
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
@ 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_DURATION
T MAX2(T a, T b)
Definition: StdDefs.h:80
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 std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const MSJunction * getFromJunction() const
Definition: MSEdge.h:397
const MSJunction * getToJunction() const
Definition: MSEdge.h:401
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:268
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
Something on a lane to be noticed about vehicle movement.
@ 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:88
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:469
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1059
static const int BACKWARD
Definition: MSPModel.h:109
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:52
static const int FORWARD
Definition: MSPModel.h:108
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:110
Changes the wished person speed and position.
Definition: MSPerson.h:287
void postProcessRemoteControl(MSPerson *p)
Definition: MSPerson.cpp:586
Influencer()
Constructor.
Definition: MSPerson.cpp:554
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:561
~Influencer()
Destructor.
Definition: MSPerson.cpp:557
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:580
bool isRemoteControlled() const
Definition: MSPerson.cpp:574
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:431
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:407
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
Definition: MSPerson.cpp:366
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:419
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:386
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:413
std::string getStageDescription(const bool isPerson) const
returns the stage description as a string
Definition: MSPerson.cpp:395
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:401
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
Definition: MSPerson.cpp:240
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:215
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat, int departLane=-1)
constructor
Definition: MSPerson.cpp:53
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:127
double computeAverageSpeed() const
Definition: MSPerson.cpp:133
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:273
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:332
double walkDistance() const
compute total walking distance
Definition: MSPerson.cpp:139
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
Definition: MSPerson.cpp:354
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:337
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:83
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:121
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
Definition: MSPerson.cpp:347
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:339
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:499
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex,...
Definition: MSPerson.cpp:511
double myChosenSpeedFactor
Definition: MSPerson.h:341
bool checkAccess(const MSStage *const prior, const bool isDisembark=true)
Definition: MSPerson.cpp:454
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSPerson.h:330
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:449
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:536
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:480
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:443
const MSEdge * getDestination() const
returns the destination edge
Definition: MSStage.cpp:70
virtual double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:88
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition: MSStage.h:224
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSStage.h:80
MSStageType getStageType() const
Definition: MSStage.h:117
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:76
double myArrivalPos
the position at which we want to arrive
Definition: MSStage.h:227
virtual MSTransportableStateAdapter * getState() const
Definition: MSStage.h:478
double mySpeed
the speed of the transportable
Definition: MSStage.h:557
double myDepartPos
the depart position
Definition: MSStage.h:560
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
virtual void erase(MSTransportable *transportable)
removes a single transportable
MSStageType getStageType(int next) const
the stage type for the nth next stage
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
MSTransportablePlan::iterator myStep
the iterator over the route
MSTransportablePlan * myPlan
the plan of the transportable
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
double getArrivalPos() const
returns the final arrival pos
MSStageType getCurrentStageType() const
the current stage type of the transportable
const MSEdge * getEdge() const
Returns the current edge.
MSStage * getCurrentStage() const
Return the current stage.
MSStage * getNextStage(int next) const
Return the current stage.
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
const MSLane * getLane() const
Returns the current lane (may be nullptr)
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
const MSEdge * getDestination() const
Returns the current destination.
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
double getMaxSpeed() const
Returns the object's maximum speed.
virtual void moveToXY(MSPerson *p, Position pos, MSLane *lane, double lanePos, double lanePosLat, double angle, int routeOffset, const ConstMSEdgeVector &edges, SUMOTime t)
try to move transportable to the given position
Definition: MSPModel.h:159
virtual const MSEdge * getNextEdge(const MSStageMoving &stage) const =0
return the list of internal edges if the transportable is on an intersection
The car-following model and parameter.
Definition: MSVehicleType.h:62
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition: Named.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
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:248
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
PositionVector reverse() const
reverse position vector
Structure representing possible vehicle parameter.
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.
static std::string emptyString
An empty string.
Definition: StringUtils.h:84