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(0),
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 != 0) {
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 == 0 ? -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 == 0) {
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 != 0 && to != 0) {
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(dynamic_cast<MSPerson*>(person));
262  const SUMOTime duration = myArrived - myDeparted;
263  const SUMOTime timeLoss = 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
281  std::string comment = "";
282  if (myDestinationStop != 0) {
284  if (myDestinationStop->getMyName() != "") {
285  comment = " <!-- " + myDestinationStop->getMyName() + " -->";
286  }
287  }
288  if (myWalkingTime > 0) {
290  } else if (mySpeed > 0) {
292  }
293  os.closeTag(comment);
294 }
295 
296 
297 void
299  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "departure")
300  .writeAttr("agent", p.getID()).writeAttr("link", myRoute.front()->getID()).closeTag();
301 }
302 
303 
304 void
306  os.openTag("event").writeAttr("time", time2string(t)).writeAttr("type", "arrival")
307  .writeAttr("agent", p.getID()).writeAttr("link", myRoute.back()->getID()).closeTag();
308 }
309 
310 
311 bool
313  ((MSEdge*)getEdge())->removePerson(person);
314  //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
315  if (myRouteStep == myRoute.end() - 1) {
316  if (myDestinationStop != 0) {
318  }
319  if (!person->proceed(MSNet::getInstance(), currentTime)) {
321  }
322  //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
323  return true;
324  } else {
325  if (nextInternal == 0) {
326  ++myRouteStep;
328  } else {
329  myCurrentInternalEdge = nextInternal;
330  }
331  ((MSEdge*) getEdge())->addPerson(person);
332  return false;
333  }
334 }
335 
336 void
338  assert(routeOffset >= 0);
339  assert(routeOffset < (int)myRoute.size());
340  ((MSEdge*)getEdge())->removePerson(person);
341  myRouteStep = myRoute.begin() + routeOffset;
342  ((MSEdge*)getEdge())->addPerson(person);
343 }
344 
345 double
347  return mySpeed > 0 ? mySpeed : person->getVehicleType().getMaxSpeed() * person->getSpeedFactor();
348 }
349 
350 std::string
352  const std::string dest = (getDestinationStop() == 0 ?
353  " edge '" + getDestination()->getID() + "'" :
354  " stop '" + getDestinationStop()->getID() + "'" + (
355  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
356  return "walking to " + dest;
357 }
358 
359 
360 /* -------------------------------------------------------------------------
361 * MSPerson::MSPersonStage_Driving - methods
362 * ----------------------------------------------------------------------- */
364  MSStoppingPlace* toStop, const double arrivalPos, const std::vector<std::string>& lines,
365  const std::string& intendedVeh, SUMOTime intendedDepart) :
366  MSTransportable::Stage_Driving(destination, toStop,
367  SUMOVehicleParameter::interpretEdgePos(
368  arrivalPos, destination->getLength(), SUMO_ATTR_ARRIVALPOS, "person riding to " + destination->getID()),
369  lines,
370  intendedVeh, intendedDepart) {
371 }
372 
373 
375 
376 
377 void
379  if (previous->getDestinationStop() != 0) {
380  // the arrival stop may have an access point
381  myWaitingEdge = &previous->getDestinationStop()->getLane().getEdge();
384  } else {
385  myWaitingEdge = previous->getEdge();
387  myWaitingPos = previous->getEdgePos(now);
388  }
389  myWaitingSince = now;
390  SUMOVehicle* availableVehicle = net->getVehicleControl().getWaitingVehicle(myWaitingEdge, myLines, myWaitingPos, person->getID());
391  if (availableVehicle != 0 && availableVehicle->getParameter().departProcedure == DEPART_TRIGGERED && !availableVehicle->hasDeparted()) {
392  setVehicle(availableVehicle);
393  myVehicle->addPerson(person);
397  } else {
398  net->getPersonControl().addWaiting(myWaitingEdge, person);
399  myWaitingEdge->addPerson(person);
400  }
401 }
402 
403 
404 std::string
406  return isWaiting4Vehicle() ? "waiting for " + joinToString(myLines, ",") : "driving";
407 }
408 
409 
410 std::string
412  const std::string dest = (getDestinationStop() == 0 ?
413  " edge '" + getDestination()->getID() + "'" :
414  " stop '" + getDestinationStop()->getID() + "'" + (
415  getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
416  const std::string intended = myIntendedVehicleID != "" ?
417  " (vehicle " + myIntendedVehicleID + " at time " + time2string(myIntendedDepart) + ")" :
418  "";
419  return isWaiting4Vehicle() ?
420  "waiting for " + joinToString(myLines, ",") + intended + " then drive to " + dest :
421  "driving to " + dest;
422 }
423 
424 
425 void
427  const SUMOTime waitingTime = myDeparted - myWaitingSince;
428  const SUMOTime duration = myArrived - myDeparted;
430  os.openTag("ride");
431  os.writeAttr("waitingTime", time2string(waitingTime));
432  os.writeAttr("vehicle", myVehicleID);
433  os.writeAttr("depart", time2string(myDeparted));
434  os.writeAttr("arrival", time2string(myArrived));
435  os.writeAttr("arrivalPos", toString(myArrivalPos));
436  os.writeAttr("duration", myArrived > 0 ? time2string(duration) : "-1");
437  os.writeAttr("routeLength", myVehicleDistance);
438  os.closeTag();
439 }
440 
441 
442 void
444  os.openTag("ride");
445  if (getFromEdge() != nullptr) {
447  }
449  std::string comment = "";
450  if (myDestinationStop != 0) {
452  if (myDestinationStop->getMyName() != "") {
453  comment = " <!-- " + myDestinationStop->getMyName() + " -->";
454  }
455  }
457  if (myIntendedVehicleID != "") {
459  }
460  if (myIntendedDepart >= 0) {
462  }
463  os.closeTag(comment);
464 }
465 
466 
467 /* -------------------------------------------------------------------------
468 * MSPerson::MSPersonStage_Access - methods
469 * ----------------------------------------------------------------------- */
471  const double arrivalPos, const double dist, const bool isExit) :
472  MSTransportable::Stage(destination, toStop, arrivalPos, ACCESS),
473  myDist(dist), myAmExit(isExit) {
474  myPath.push_back(destination->getLanes()[0]->geometryPositionAtOffset(myDestinationStop->getAccessPos(destination)));
475  myPath.push_back(toStop->getLane().geometryPositionAtOffset((toStop->getEndLanePosition() + toStop->getBeginLanePosition()) / 2));
476  if (isExit) {
477  myPath = myPath.reverse();
478  }
479 }
480 
481 
483 
484 
485 void
487  myDeparted = now;
491 }
492 
493 
494 std::string
496  return "access";
497 }
498 
499 
500 std::string
502  return (myAmExit ? "access from stop '" : "access to stop '") + getDestinationStop()->getID() + "'";
503 }
504 
505 
506 Position
509 }
510 
511 
512 double
514  return myPath.angleAt2D(0);
515 }
516 
517 
518 void
520  os.openTag("access");
521  os.writeAttr("stop", getDestinationStop()->getID());
522  os.writeAttr("duration", myArrived > 0 ? time2string(myArrived - myDeparted) : "-1");
523  os.writeAttr("routeLength", myDist);
524  os.closeTag();
525 }
526 
527 
528 SUMOTime
530  myStopEdge->removePerson(myPerson);
531  if (!myPerson->proceed(MSNet::getInstance(), currentTime)) {
533  }
534  return 0;
535 }
536 
537 
538 /* -------------------------------------------------------------------------
539  * MSPerson - methods
540  * ----------------------------------------------------------------------- */
541 MSPerson::MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor) :
542  MSTransportable(pars, vtype, plan),
543  myInfluencer(0), myChosenSpeedFactor(speedFactor) {
544 }
545 
546 
548 }
549 
550 
551 bool
553  MSTransportable::Stage* prior = *myStep;
554  prior->setArrived(time);
555  /*
556  if(myWriteEvents) {
557  (*myStep)->endEventOutput(*this, time, OutputDevice::getDeviceByOption("person-event-output"));
558  }
559  */
560  //if (getID() == "ego") {
561  // std::cout << time2string(time) << " person=" << getID() << " proceed priorStep=" << myStep - myPlan->begin() << " planSize=" << myPlan->size() << "\n";
562  //}
563  // must be done before increasing myStep to avoid invalid state for rendering
564  prior->getEdge()->removePerson(this);
565  myStep++;
566  if (prior->getStageType() == MOVING_WITHOUT_VEHICLE) {
567  MSStoppingPlace* const bs = prior->getDestinationStop();
568  if (bs != nullptr) {
569  const double accessDist = bs->getAccessDistance(prior->getDestination());
570  if (accessDist > 0.) {
571  myStep = myPlan->insert(myStep, new MSPersonStage_Access(prior->getDestination(), bs, bs->getAccessPos(prior->getDestination()), accessDist, false));
572  }
573  }
574  }
575  if (myStep != myPlan->end()) {
576  if ((*myStep)->getStageType() == MOVING_WITHOUT_VEHICLE && (prior->getStageType() != ACCESS || prior->getDestination() != (*myStep)->getFromEdge())) {
577  MSStoppingPlace* const prevStop = prior->getDestinationStop();
578  if (prevStop != nullptr) {
579  const double accessDist = prevStop->getAccessDistance((*myStep)->getFromEdge());
580  if (accessDist > 0.) {
581  myStep = myPlan->insert(myStep, new MSPersonStage_Access((*myStep)->getFromEdge(), prevStop, prevStop->getAccessPos((*myStep)->getFromEdge()), accessDist, true));
582  }
583  }
584  }
585  (*myStep)->proceed(net, this, time, prior);
586  /*
587  if(myWriteEvents) {
588  (*myStep)->beginEventOutput(*this, time, OutputDevice::getDeviceByOption("person-event-output"));
589  }
590  */
591  return true;
592  } else {
593  return false;
594  }
595 }
596 
597 
598 const std::string&
600 // if (getCurrentStageType() == MOVING_WITHOUT_VEHICLE) {
601 // MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
602 // assert(walkingStage != 0);
603 // const MSEdge* nextEdge = walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
604 // if (nextEdge != 0) {
605 // return nextEdge->getID();
606 // }
607 // }
608 // return StringUtils::emptyString;
609  const MSEdge* nextEdge = getNextEdgePtr();
610  if (nextEdge != 0) {
611  return nextEdge->getID();
612  }
614 }
615 
616 
617 const MSEdge*
620  MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
621  assert(walkingStage != 0);
622  return walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
623 
624  }
625  return 0;
626 }
627 
628 
629 
630 void
632  os.openTag("personinfo").writeAttr("id", getID()).writeAttr("depart", time2string(getDesiredDepart()));
633  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
634  (*i)->tripInfoOutput(os, transportable);
635  }
636  os.closeTag();
637 }
638 
639 
640 void
642  const std::string typeID = getVehicleType().getID() != DEFAULT_PEDTYPE_ID ? getVehicleType().getID() : "";
644  if (hasArrived()) {
645  os.writeAttr("arrival", time2string(MSNet::getInstance()->getCurrentTimeStep()));
646  }
647  for (MSTransportablePlan::const_iterator i = myPlan->begin(); i != myPlan->end(); ++i) {
648  (*i)->routeOutput(os);
649  }
650  os.closeTag();
651  os.lf();
652 }
653 
654 
655 void
656 MSPerson::reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex) {
657  assert(nextIndex > firstIndex);
658  //std::cout << SIMTIME << " reroute person " << getID()
659  // << " newEdges=" << toString(newEdges)
660  // << " firstIndex=" << firstIndex
661  // << " nextIndex=" << nextIndex
662  // << " departPos=" << getEdgePos()
663  // << " arrivalPos=" << getNextStage(nextIndex - 1)->getArrivalPos()
664  // << "\n";
666  getNextStage(nextIndex - 1)->getDestinationStop(), -1,
667  -1,
668  departPos,
669  getNextStage(nextIndex - 1)->getArrivalPos(),
670  0);
671  appendStage(newStage, nextIndex);
672  // remove stages in reverse order so that proceed will only be called at the last removal
673  for (int i = nextIndex - 1; i >= firstIndex; i--) {
674  //std::cout << " removeStage=" << i << "\n";
675  removeStage(i);
676  }
677 }
678 
679 
682  if (myInfluencer == 0) {
683  myInfluencer = new Influencer();
684  }
685  return *myInfluencer;
686 }
687 
688 
691  return myInfluencer;
692 }
693 
694 
695 
696 /* -------------------------------------------------------------------------
697  * methods of MSPerson::Influencer
698  * ----------------------------------------------------------------------- */
700 
701 
703 
704 
705 void
706 MSPerson::Influencer::setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t) {
707  myRemoteXYPos = xyPos;
708  myRemoteLane = l;
709  myRemotePos = pos;
710  myRemotePosLat = posLat;
711  myRemoteAngle = angle;
712  myRemoteEdgeOffset = edgeOffset;
713  myRemoteRoute = route;
714  myLastRemoteAccess = t;
715 }
716 
717 
718 bool
720  return myLastRemoteAccess == MSNet::getInstance()->getCurrentTimeStep();
721 }
722 
723 
724 bool
726  return myLastRemoteAccess >= t - TIME2STEPS(10);
727 }
728 
729 
730 void
732  /*
733  std::cout << SIMTIME << " moveToXY person=" << p->getID()
734  << " xyPos=" << myRemoteXYPos
735  << " lane=" << Named::getIDSecure(myRemoteLane)
736  << " pos=" << myRemotePos
737  << " posLat=" << myRemotePosLat
738  << " angle=" << myRemoteAngle
739  << " eOf=" << myRemoteEdgeOffset
740  << " route=" << toString(myRemoteRoute)
741  << " aTime=" << time2string(myLastRemoteAccess)
742  << "\n";
743  */
744  switch (p->getStageType(0)) {
745  case MOVING_WITHOUT_VEHICLE: {
747  assert(s != 0);
748  s->getPedestrianState()->moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
749  MSNet::getInstance()->getCurrentTimeStep());
750  }
751  break;
752  default:
753  break;
754  }
755 }
756 
757 
758 /****************************************************************************/
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
virtual void setArrived(SUMOTime now)
logs end of the step
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:617
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:305
~MSPersonStage_Access()
destructor
Definition: MSPerson.cpp:482
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:547
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
double getWaitingPositionOnLane() const
Returns the lane position corresponding to getWaitPosition()
~Influencer()
Destructor.
Definition: MSPerson.cpp:702
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:495
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:378
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:243
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:198
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:731
virtual double getEdgePos(SUMOTime now) const
double getMaxSpeed(const MSPerson *person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:346
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:67
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:706
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:160
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:599
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:363
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:449
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
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:69
#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:346
const MSEdge * getFromEdge() const
const std::string & getMyName() const
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:725
The simulated network and simulation perfomer.
Definition: MSNet.h:85
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:171
const SUMOVehicleParameter * myParameter
the plan of the transportable
virtual void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:426
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:641
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:351
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:298
virtual void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:631
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.
void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:519
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:501
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:192
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:470
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:681
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
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:279
static MSPModel * getModel()
Definition: MSPModel.cpp:59
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:748
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:590
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:309
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:402
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
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:256
std::string getStageDescription() const
returns the stage description as a string
Definition: MSPerson.cpp:405
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
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.h:594
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:195
SUMOVehicle * myVehicle
The taken vehicle.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:171
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:443
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:541
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:78
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
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:507
Changes the wished person speed and position.
Definition: MSPerson.h:379
double computeAverageSpeed() const
Definition: MSPerson.cpp:177
double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:366
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:656
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:362
const std::string DEFAULT_PEDTYPE_ID
const double myChosenSpeedFactor
Definition: MSPerson.h:433
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
const MSJunction * getFromJunction() const
Definition: MSEdge.h:342
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:189
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:312
StageType getStageType() const
~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:471
StageType getStageType(int next) const
the stage type for the nth next stage
virtual void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:259
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:205
bool proceed(MSNet *net, SUMOTime time)
Definition: MSPerson.cpp:552
virtual void addPerson(MSTransportable *person)=0
Adds a person to this vehicle.
static DummyState myDummyState
Definition: MSPerson.h:435
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:618
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:486
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:513
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:529
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:431
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool isRemoteControlled() const
Definition: MSPerson.cpp:719
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:71
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:98
Influencer()
Constructor.
Definition: MSPerson.cpp:699
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:230
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
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:274
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:337
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:411