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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // The class for modelling person-movements
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <vector>
31 #include <utils/common/ToString.h>
33 #include <utils/geom/GeomHelper.h>
35 #include <microsim/MSNet.h>
36 #include <microsim/MSEdge.h>
37 #include <microsim/MSLane.h>
38 #include "MSPerson.h"
42 #include <microsim/MSVehicle.h>
46 #include "MSPModel.h"
47 
48 // ===========================================================================
49 // static value definitions
50 // ===========================================================================
52 
53 /* -------------------------------------------------------------------------
54  * MSPerson::MSPersonStage_Walking - methods
55  * ----------------------------------------------------------------------- */
57  const ConstMSEdgeVector& route,
58  MSStoppingPlace* toStop,
59  SUMOTime walkingTime, double speed,
60  double departPos, double arrivalPos, double departPosLat) :
61  MSTransportable::Stage(route.back(), toStop,
62  SUMOVehicleParameter::interpretEdgePos(arrivalPos, route.back()->getLength(), SUMO_ATTR_ARRIVALPOS,
63  "person '" + personID + "' walking to " + route.back()->getID()),
64  MOVING_WITHOUT_VEHICLE),
65  myWalkingTime(walkingTime),
66  myRoute(route),
67  myCurrentInternalEdge(nullptr),
68  myDepartPos(departPos),
69  myDepartPosLat(departPosLat),
70  mySpeed(speed),
71  myPedestrianState(&myDummyState) {
72  myDepartPos = SUMOVehicleParameter::interpretEdgePos(departPos, route.front()->getLength(), SUMO_ATTR_DEPARTPOS,
73  "person '" + personID + "' walking from " + route.front()->getID());
74  if (walkingTime > 0) {
76  }
77 }
78 
79 
82  delete myPedestrianState;
83  }
84 }
85 
86 
87 const MSEdge*
89  if (myCurrentInternalEdge != nullptr) {
90  return myCurrentInternalEdge;
91  } else {
92  return *myRouteStep;
93  }
94 }
95 
96 
97 const MSEdge*
99  return myRoute.front();
100 }
101 
102 
103 double
105  return myPedestrianState == nullptr ? -1 : myPedestrianState->getEdgePos(*this, now);
106 }
107 
108 
109 Position
111  return myPedestrianState->getPosition(*this, now);
112 }
113 
114 
115 double
117  return myPedestrianState->getAngle(*this, now);
118 }
119 
120 
121 SUMOTime
123  return myPedestrianState->getWaitingTime(*this, now);
124 }
125 
126 
127 double
129  return myPedestrianState->getSpeed(*this);
130 }
131 
132 
135  return myRoute;
136 }
137 
138 
139 void
141  myDeparted = now;
142  myRouteStep = myRoute.begin();
143  if (myWalkingTime == 0) {
144  if (!person->proceed(net, now)) {
146  }
147  return;
148  }
149  if (previous->getEdgePos(now) >= 0 && previous->getEdge() == *myRouteStep) {
150  myDepartPos = previous->getEdgePos(now);
151  if (myWalkingTime > 0) {
153  }
154  }
155  myPedestrianState = MSPModel::getModel()->add(dynamic_cast<MSPerson*>(person), this, now);
156  if (myPedestrianState == nullptr) {
158  return;
159  }
160  (*myRouteStep)->addPerson(person);
161 }
162 
163 
164 void
167 }
168 
169 
170 void
172  mySpeed = speed;
173 }
174 
175 
176 double
178  return walkDistance() / STEPS2TIME(myWalkingTime + 1); // avoid systematic rounding errors
179 }
180 
181 
182 double
184  double length = 0;
185  for (const MSEdge* edge : myRoute) {
186  length += edge->getLength();
187  }
188  if (myRoute.size() > 1 && MSPModel::getModel()->usingInternalLanes()) {
189  // use lower bound for distance to pass the intersection
190  for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != myRoute.end() - 1; ++i) {
191  const MSEdge* fromEdge = *i;
192  const MSEdge* toEdge = *(i + 1);
193  const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
194  const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
195  Position fromPos;
196  Position toPos;
197  if (from != nullptr && to != nullptr) {
198  if (fromEdge->getToJunction() == toEdge->getFromJunction()) {
199  fromPos = from->getShape().back();
200  toPos = to->getShape().front();
201  } else if (fromEdge->getToJunction() == toEdge->getToJunction()) {
202  fromPos = from->getShape().back();
203  toPos = to->getShape().back();
204  } else if (fromEdge->getFromJunction() == toEdge->getFromJunction()) {
205  fromPos = from->getShape().front();
206  toPos = to->getShape().front();
207  } else if (fromEdge->getFromJunction() == toEdge->getToJunction()) {
208  fromPos = from->getShape().front();
209  toPos = to->getShape().back();
210  }
211  length += fromPos.distanceTo2D(toPos);
212  }
213  }
214  }
215  // determine walking direction for depart and arrival
216  const int departFwdArrivalDir = MSPModel::canTraverse(MSPModel::FORWARD, myRoute);
217  const int departBwdArrivalDir = MSPModel::canTraverse(MSPModel::BACKWARD, myRoute);
218  const bool mayStartForward = departFwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
219  const bool mayStartBackward = departBwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
220  const double lengthFwd = (length - myDepartPos - (
221  departFwdArrivalDir == MSPModel::BACKWARD
222  ? myArrivalPos
223  : myRoute.back()->getLength() - myArrivalPos));
224  const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
225  departBwdArrivalDir == MSPModel::BACKWARD
226  ? myArrivalPos
227  : myRoute.back()->getLength() - myArrivalPos));
228 
229  if (myRoute.size() == 1) {
230  if (myDepartPos > myArrivalPos) {
231  length = lengthBwd;
232  } else {
233  length = lengthFwd;
234  }
235  } else {
236  if (mayStartForward && mayStartBackward) {
237  length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
238  } else if (mayStartForward) {
239  length = lengthFwd;
240  } else if (mayStartBackward) {
241  length = lengthBwd;
242  } else {
243  length = lengthFwd;
244  }
245  }
246  //std::cout << SIMTIME << " route=" << toString(myRoute)
247  // << " depPos=" << myDepartPos << " arPos=" << myArrivalPos
248  // << " dFwdADir=" << departFwdArrivalDir
249  // << " dBwdADir=" << departBwdArrivalDir
250  // << " lengthFwd=" << lengthFwd
251  // << " lengthBwd=" << lengthBwd
252  // << "\n";
253 
254  return MAX2(POSITION_EPS, length);
255 }
256 
257 
258 void
260  const double distance = walkDistance();
261  const double maxSpeed = getMaxSpeed(person);
262  const SUMOTime duration = myArrived - myDeparted;
263  const SUMOTime timeLoss = myArrived == -1 ? 0 : duration - TIME2STEPS(distance / maxSpeed);
264  MSDevice_Tripinfo::addPedestrianData(distance, duration, timeLoss);
265  os.openTag("walk");
266  os.writeAttr("depart", time2string(myDeparted));
267  os.writeAttr("departPos", myDepartPos);
268  os.writeAttr("arrival", time2string(myArrived));
269  os.writeAttr("arrivalPos", myArrivalPos);
270  os.writeAttr("duration", time2string(duration));
271  os.writeAttr("routeLength", distance);
272  os.writeAttr("timeLoss", time2string(timeLoss));
273  os.writeAttr("maxSpeed", maxSpeed);
274  os.closeTag();
275 }
276 
277 
278 void
279 MSPerson::MSPersonStage_Walking::routeOutput(OutputDevice& os, const bool withRouteLength) const {
281  std::string comment = "";
282  if (myDestinationStop != nullptr) {
284  if (myDestinationStop->getMyName() != "") {
285  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
286  }
287  }
288  if (myWalkingTime > 0) {
290  } else if (mySpeed > 0) {
292  }
293  if (withRouteLength) {
294  os.writeAttr("routeLength", walkDistance());
295  }
296  os.closeTag(comment);
297 }
298 
299 
300 void
302  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "departure")
303  .writeAttr("agent", p.getID()).writeAttr("link", myRoute.front()->getID()).closeTag();
304 }
305 
306 
307 void
309  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "arrival")
310  .writeAttr("agent", p.getID()).writeAttr("link", myRoute.back()->getID()).closeTag();
311 }
312 
313 
314 bool
316  ((MSEdge*)getEdge())->removePerson(person);
317  //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
318  if (myRouteStep == myRoute.end() - 1) {
319  if (myDestinationStop != nullptr) {
321  }
322  if (!person->proceed(MSNet::getInstance(), currentTime)) {
324  }
325  //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
326  return true;
327  } else {
328  if (nextInternal == nullptr) {
329  ++myRouteStep;
330  myCurrentInternalEdge = nullptr;
331  } else {
332  myCurrentInternalEdge = nextInternal;
333  }
334  ((MSEdge*) getEdge())->addPerson(person);
335  return false;
336  }
337 }
338 
339 void
341  assert(routeOffset >= 0);
342  assert(routeOffset < (int)myRoute.size());
343  ((MSEdge*)getEdge())->removePerson(person);
344  myRouteStep = myRoute.begin() + routeOffset;
345  ((MSEdge*)getEdge())->addPerson(person);
346 }
347 
348 double
350  return mySpeed > 0 ? mySpeed : person->getVehicleType().getMaxSpeed() * person->getSpeedFactor();
351 }
352 
353 std::string
355  const std::string dest = (getDestinationStop() == nullptr ?
356  " edge '" + getDestination()->getID() + "'" :
357  " stop '" + getDestinationStop()->getID() + "'" + (
358  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
359  return "walking to " + dest;
360 }
361 
362 
363 /* -------------------------------------------------------------------------
364 * MSPerson::MSPersonStage_Driving - methods
365 * ----------------------------------------------------------------------- */
367  MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
368  const std::string& intendedVeh, SUMOTime intendedDepart) :
369  MSTransportable::Stage_Driving(destination, toStop,
370  SUMOVehicleParameter::interpretEdgePos(
371  arrivalPos, destination->getLength(), SUMO_ATTR_ARRIVALPOS, "person riding to " + destination->getID()),
372  lines,
373  intendedVeh, intendedDepart) {
374 }
375 
376 
378 
379 
380 void
382  if (previous->getDestinationStop() != nullptr) {
383  // the arrival stop may have an access point
384  myWaitingEdge = &previous->getDestinationStop()->getLane().getEdge();
387  } else {
388  myWaitingEdge = previous->getEdge();
390  myWaitingPos = previous->getEdgePos(now);
391  }
392  myWaitingSince = now;
393  SUMOVehicle* availableVehicle = net->getVehicleControl().getWaitingVehicle(myWaitingEdge, myLines, myWaitingPos, person->getID());
394  if (availableVehicle != nullptr && availableVehicle->getParameter().departProcedure == DEPART_TRIGGERED && !availableVehicle->hasDeparted()) {
395  setVehicle(availableVehicle);
396  myVehicle->addPerson(person);
400  } else {
401  net->getPersonControl().addWaiting(myWaitingEdge, person);
402  myWaitingEdge->addPerson(person);
403  }
404 }
405 
406 
407 std::string
409  return isWaiting4Vehicle() ? "waiting for " + joinToString(myLines, ",") : "driving";
410 }
411 
412 
413 std::string
415  const std::string dest = (getDestinationStop() == nullptr ?
416  " edge '" + getDestination()->getID() + "'" :
417  " stop '" + getDestinationStop()->getID() + "'" + (
418  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
419  const std::string intended = myIntendedVehicleID != "" ?
420  " (vehicle " + myIntendedVehicleID + " at time " + time2string(myIntendedDepart) + ")" :
421  "";
422  return isWaiting4Vehicle() ?
423  "waiting for " + joinToString(myLines, ",") + intended + " then drive to " + dest :
424  "driving to " + dest;
425 }
426 
427 
428 void
430  const SUMOTime waitingTime = myDeparted - myWaitingSince;
431  const SUMOTime duration = myArrived - myDeparted;
433  os.openTag("ride");
434  os.writeAttr("waitingTime", time2string(waitingTime));
435  os.writeAttr("vehicle", myVehicleID);
436  os.writeAttr("depart", time2string(myDeparted));
437  os.writeAttr("arrival", time2string(myArrived));
438  os.writeAttr("arrivalPos", toString(myArrivalPos));
439  os.writeAttr("duration", myArrived > 0 ? time2string(duration) : "-1");
440  os.writeAttr("routeLength", myVehicleDistance);
441  os.closeTag();
442 }
443 
444 
445 void
446 MSPerson::MSPersonStage_Driving::routeOutput(OutputDevice& os, const bool withRouteLength) const {
447  os.openTag("ride");
448  if (getFromEdge() != nullptr) {
450  }
452  std::string comment = "";
453  if (myDestinationStop != nullptr) {
455  if (myDestinationStop->getMyName() != "") {
456  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName()) + " -->";
457  }
458  }
460  if (myIntendedVehicleID != "") {
462  }
463  if (myIntendedDepart >= 0) {
465  }
466  if (withRouteLength) {
467  os.writeAttr("routeLength", myVehicleDistance);
468  }
469  os.closeTag(comment);
470 }
471 
472 
473 /* -------------------------------------------------------------------------
474 * MSPerson::MSPersonStage_Access - methods
475 * ----------------------------------------------------------------------- */
477  const double arrivalPos, const double dist, const bool isExit) :
478  MSTransportable::Stage(destination, toStop, arrivalPos, ACCESS),
479  myDist(dist), myAmExit(isExit) {
480  myPath.push_back(destination->getLanes()[0]->geometryPositionAtOffset(myDestinationStop->getAccessPos(destination)));
481  myPath.push_back(toStop->getLane().geometryPositionAtOffset((toStop->getEndLanePosition() + toStop->getBeginLanePosition()) / 2));
482  if (isExit) {
483  myPath = myPath.reverse();
484  }
485 }
486 
487 
489 
490 
491 void
493  myDeparted = now;
497 }
498 
499 
500 std::string
502  return "access";
503 }
504 
505 
506 std::string
508  return (myAmExit ? "access from stop '" : "access to stop '") + getDestinationStop()->getID() + "'";
509 }
510 
511 
512 Position
515 }
516 
517 
518 double
520  return myPath.angleAt2D(0);
521 }
522 
523 
524 void
526  os.openTag("access");
527  os.writeAttr("stop", getDestinationStop()->getID());
528  os.writeAttr("duration", myArrived > 0 ? time2string(myArrived - myDeparted) : "-1");
529  os.writeAttr("routeLength", myDist);
530  os.closeTag();
531 }
532 
533 
534 SUMOTime
536  myStopEdge->removePerson(myPerson);
537  if (!myPerson->proceed(MSNet::getInstance(), currentTime)) {
539  }
540  return 0;
541 }
542 
543 
544 /* -------------------------------------------------------------------------
545  * MSPerson - methods
546  * ----------------------------------------------------------------------- */
547 MSPerson::MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor) :
548  MSTransportable(pars, vtype, plan),
549  myInfluencer(nullptr), myChosenSpeedFactor(speedFactor) {
550 }
551 
552 
554 }
555 
556 
557 bool
559  MSTransportable::Stage* prior = *myStep;
560  prior->setArrived(net, this, time);
561  /*
562  if(myWriteEvents) {
563  (*myStep)->endEventOutput(*this, time, OutputDevice::getDeviceByOption("person-event-output"));
564  }
565  */
566  //if (getID() == "ego") {
567  // std::cout << time2string(time) << " person=" << getID() << " proceed priorStep=" << myStep - myPlan->begin() << " planSize=" << myPlan->size() << "\n";
568  //}
569  // must be done before increasing myStep to avoid invalid state for rendering
570  prior->getEdge()->removePerson(this);
571  myStep++;
572  if (prior->getStageType() == MOVING_WITHOUT_VEHICLE) {
573  MSStoppingPlace* const bs = prior->getDestinationStop();
574  if (bs != nullptr) {
575  const double accessDist = bs->getAccessDistance(prior->getDestination());
576  if (accessDist > 0.) {
577  myStep = myPlan->insert(myStep, new MSPersonStage_Access(prior->getDestination(), bs, bs->getAccessPos(prior->getDestination()), accessDist, false));
578  }
579  }
580  }
581  if (myStep != myPlan->end()) {
582  if ((*myStep)->getStageType() == MOVING_WITHOUT_VEHICLE && (prior->getStageType() != ACCESS || prior->getDestination() != (*myStep)->getFromEdge())) {
583  MSStoppingPlace* const prevStop = prior->getDestinationStop();
584  if (prevStop != nullptr && prior->getStageType() != TRIP) {
585  const double accessDist = prevStop->getAccessDistance((*myStep)->getFromEdge());
586  if (accessDist > 0.) {
587  myStep = myPlan->insert(myStep, new MSPersonStage_Access((*myStep)->getFromEdge(), prevStop, prevStop->getAccessPos((*myStep)->getFromEdge()), accessDist, true));
588  }
589  }
590  }
591  (*myStep)->proceed(net, this, time, prior);
592  /*
593  if(myWriteEvents) {
594  (*myStep)->beginEventOutput(*this, time, OutputDevice::getDeviceByOption("person-event-output"));
595  }
596  */
597  return true;
598  } else {
599  return false;
600  }
601 }
602 
603 
604 const std::string&
606 // if (getCurrentStageType() == MOVING_WITHOUT_VEHICLE) {
607 // MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
608 // assert(walkingStage != 0);
609 // const MSEdge* nextEdge = walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
610 // if (nextEdge != 0) {
611 // return nextEdge->getID();
612 // }
613 // }
614 // return StringUtils::emptyString;
615  const MSEdge* nextEdge = getNextEdgePtr();
616  if (nextEdge != nullptr) {
617  return nextEdge->getID();
618  }
620 }
621 
622 
623 const MSEdge*
626  MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
627  assert(walkingStage != 0);
628  return walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
629 
630  }
631  return nullptr;
632 }
633 
634 
635 
636 void
638  os.openTag("personinfo");
639  os.writeAttr("id", getID());
640  os.writeAttr("depart", time2string(getDesiredDepart()));
641  os.writeAttr("type", getVehicleType().getID());
642  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
643  (*i)->tripInfoOutput(os, this);
644  }
645  os.closeTag();
646 }
647 
648 
649 void
650 MSPerson::routeOutput(OutputDevice& os, const bool withRouteLength) const {
651  const std::string typeID = getVehicleType().getID() != DEFAULT_PEDTYPE_ID ? getVehicleType().getID() : "";
653  if (hasArrived()) {
654  os.writeAttr("arrival", time2string(MSNet::getInstance()->getCurrentTimeStep()));
655  }
656  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
657  (*i)->routeOutput(os, withRouteLength);
658  }
659  os.closeTag();
660  os.lf();
661 }
662 
663 
664 void
665 MSPerson::reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex) {
666  assert(nextIndex > firstIndex);
667  //std::cout << SIMTIME << " reroute person " << getID()
668  // << " newEdges=" << toString(newEdges)
669  // << " firstIndex=" << firstIndex
670  // << " nextIndex=" << nextIndex
671  // << " departPos=" << getEdgePos()
672  // << " arrivalPos=" << getNextStage(nextIndex - 1)->getArrivalPos()
673  // << "\n";
675  getNextStage(nextIndex - 1)->getDestinationStop(), -1,
676  -1,
677  departPos,
678  getNextStage(nextIndex - 1)->getArrivalPos(),
679  0);
680  appendStage(newStage, nextIndex);
681  // remove stages in reverse order so that proceed will only be called at the last removal
682  for (int i = nextIndex - 1; i >= firstIndex; i--) {
683  //std::cout << " removeStage=" << i << "\n";
684  removeStage(i);
685  }
686 }
687 
688 
691  if (myInfluencer == nullptr) {
692  myInfluencer = new Influencer();
693  }
694  return *myInfluencer;
695 }
696 
697 
700  return myInfluencer;
701 }
702 
703 
704 
705 /* -------------------------------------------------------------------------
706  * methods of MSPerson::Influencer
707  * ----------------------------------------------------------------------- */
709 
710 
712 
713 
714 void
715 MSPerson::Influencer::setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t) {
716  myRemoteXYPos = xyPos;
717  myRemoteLane = l;
718  myRemotePos = pos;
719  myRemotePosLat = posLat;
720  myRemoteAngle = angle;
721  myRemoteEdgeOffset = edgeOffset;
722  myRemoteRoute = route;
723  myLastRemoteAccess = t;
724 }
725 
726 
727 bool
729  return myLastRemoteAccess == MSNet::getInstance()->getCurrentTimeStep();
730 }
731 
732 
733 bool
735  return myLastRemoteAccess >= t - TIME2STEPS(10);
736 }
737 
738 
739 void
741  /*
742  std::cout << SIMTIME << " moveToXY person=" << p->getID()
743  << " xyPos=" << myRemoteXYPos
744  << " lane=" << Named::getIDSecure(myRemoteLane)
745  << " pos=" << myRemotePos
746  << " posLat=" << myRemotePosLat
747  << " angle=" << myRemoteAngle
748  << " eOf=" << myRemoteEdgeOffset
749  << " route=" << toString(myRemoteRoute)
750  << " aTime=" << time2string(myLastRemoteAccess)
751  << "\n";
752  */
753  switch (p->getStageType(0)) {
754  case MOVING_WITHOUT_VEHICLE: {
756  assert(s != 0);
757  s->getPedestrianState()->moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
758  MSNet::getInstance()->getCurrentTimeStep());
759  }
760  break;
761  default:
762  break;
763  }
764 }
765 
766 
767 /****************************************************************************/
The departure is person triggered.
Position getWaitPosition() const
Returns the next free waiting place for pedestrians / containers.
virtual const MSEdge * getNextEdge(const MSPerson::MSPersonStage_Walking &stage) const =0
return the list of internal edges if the pedestrian is on an intersection
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge ...
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:640
long long int SUMOTime
Definition: SUMOTime.h:36
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
double getBeginLanePosition() const
Returns the begin position of this stop.
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:308
~MSPersonStage_Access()
destructor
Definition: MSPerson.cpp:488
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:553
virtual double getAngle(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const =0
return the direction in which the person faces in degrees
double getArrivalPos() const
returns the final arrival pos
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
double getWaitingPositionOnLane() const
Returns the lane position corresponding to getWaitPosition()
~Influencer()
Destructor.
Definition: MSPerson.cpp:711
A lane area vehicles can halt at.
virtual SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const =0
return the time the person spent standing
std::string getStageDescription() const
returns the stage description as a string
Definition: MSPerson.cpp:501
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSPerson.cpp:650
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:381
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:244
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:199
bool hasArrived() const
return whether the person has reached the end of its plan
const MSEdge * getDestination() const
returns the destination edge
virtual const MSEdge * getEdge() const
Returns the current edge.
void postProcessRemoteControl(MSPerson *p)
Definition: MSPerson.cpp:740
virtual double getEdgePos(SUMOTime now) const
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:88
static const int FORWARD
Definition: MSPModel.h:100
static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string &line, SUMOTime waitingTime)
record tripinfo data for rides
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:110
virtual void remove(PedestrianState *state)=0
remove the specified person from the pedestrian simulation
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:715
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
T MAX2(T a, T b)
Definition: StdDefs.h:76
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:605
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:637
MSPersonStage_Driving(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
Definition: MSPerson.cpp:366
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:456
const std::set< std::string > myLines
the lines to choose from
virtual bool usingInternalLanes()=0
whether movements on intersections are modelled
PositionVector reverse() const
reverse position vector
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:525
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
virtual bool proceed(MSNet *net, SUMOTime time)=0
const std::string & getID() const
Returns the id.
Definition: Named.h:78
#define TIME2STEPS(x)
Definition: SUMOTime.h:60
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
MSTransportablePlan::iterator myStep
the iterator over the route
const MSJunction * getToJunction() const
Definition: MSEdge.h:347
const MSEdge * getFromEdge() const
const std::string & getMyName() const
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:734
The simulated network and simulation perfomer.
Definition: MSNet.h:84
The car-following model and parameter.
Definition: MSVehicleType.h:66
virtual void erase(MSTransportable *transportable)
removes a single transportable
void addTransportable(MSTransportable *p)
adds a transportable to this stop
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
virtual Position getPosition(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const =0
return the network coordinate of the person
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:172
const SUMOVehicleParameter * myParameter
the plan of the transportable
virtual PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now)=0
register the given person as a pedestrian
void removeStage(int next)
removes the nth next stage
std::string getStageSummary() const
return string summary of the current stage
Definition: MSPerson.cpp:354
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:301
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
std::string getStageSummary() const
return string summary of the current stage
Definition: MSPerson.cpp:507
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:140
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:193
A road/street connecting two junctions.
Definition: MSEdge.h:75
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:92
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
Definition: MSPerson.cpp:476
double getEndLanePosition() const
Returns the end position of this stop.
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:105
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:165
SUMOTime myArrived
the time at which this stage ended
the edges of a route
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:690
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
SUMOTime myDeparted
the time at which this stage started
Representation of a vehicle.
Definition: SUMOVehicle.h:60
static MSPModel * getModel()
Definition: MSPModel.cpp:59
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:776
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
SUMOTime getDesiredDepart() const
Returns the desired departure time.
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:134
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.h:595
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:316
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:409
virtual double getEdgePos(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const =0
return the offset from the start of the current edge measured in its natural direction ...
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:116
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSPerson.cpp:279
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:263
std::string getStageDescription() const
returns the stage description as a string
Definition: MSPerson.cpp:408
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
virtual double getSpeed(const MSPerson::MSPersonStage_Walking &stage) const =0
return the current speed of the person
SUMOVehicle * getWaitingVehicle(const MSEdge *const edge, const std::set< std::string > &lines, const double position, const std::string ridingID)
std::string myVehicleID
cached vehicle data for output after the vehicle has been removed
#define POSITION_EPS
Definition: config.h:172
const std::string & getID() const
returns the id of the transportable
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:349
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.h:599
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:196
SUMOVehicle * myVehicle
The taken vehicle.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:171
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:547
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
static std::string emptyString
An empty string.
Definition: StringUtils.h:80
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:513
Changes the wished person speed and position.
Definition: MSPerson.h:381
double computeAverageSpeed() const
Definition: MSPerson.cpp:177
Structure representing possible vehicle parameter.
double length() const
Returns the length.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:122
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex, nextIndex[
Definition: MSPerson.cpp:665
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:369
const std::string DEFAULT_PEDTYPE_ID
const double myChosenSpeedFactor
Definition: MSPerson.h:435
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
const MSJunction * getFromJunction() const
Definition: MSEdge.h:343
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:190
double getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:128
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:315
StageType getStageType() const
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:429
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:80
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat)
constructor
Definition: MSPerson.cpp:56
double angleAt2D(int pos) const
get angle in certain position of position vector
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:478
StageType getStageType(int next) const
the stage type for the nth next stage
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:206
bool proceed(MSNet *net, SUMOTime time)
Definition: MSPerson.cpp:558
virtual void addPerson(MSTransportable *person)=0
Adds a person to this vehicle.
static DummyState myDummyState
Definition: MSPerson.h:437
static const int BACKWARD
Definition: MSPModel.h:104
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:624
const MSVehicleType & getVehicleType() const
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
MSTransportablePlan * myPlan
the plan of the transportable
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:492
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:519
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:535
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSPerson.cpp:446
const MSLane & getLane() const
Returns the lane this stop is located at.
double walkDistance() const
compute total walking distance
Definition: MSPerson.cpp:183
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:433
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool isRemoteControlled() const
Definition: MSPerson.cpp:728
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:98
Influencer()
Constructor.
Definition: MSPerson.cpp:708
void unregisterOneWaiting(const bool isPerson)
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:237
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:104
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:234
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:259
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:285
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles to a given edge.
double myArrivalPos
the position at which we want to arrive
StageType getCurrentStageType() const
the current stage type of the transportable
void setRouteIndex(MSPerson *person, int routeOffset)
place person on a previously passed edge
Definition: MSPerson.cpp:340
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 person to the given position
Definition: MSPModel.h:151
std::string getStageSummary() const
return string summary of the current stage
Definition: MSPerson.cpp:414