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