Eclipse SUMO - Simulation of Urban MObility
MSPerson.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// The class for modelling person-movements
22/****************************************************************************/
23#include <config.h>
24
25#include <string>
26#include <vector>
33#include <microsim/MSNet.h>
34#include <microsim/MSEdge.h>
35#include <microsim/MSLane.h>
39#include <microsim/MSVehicle.h>
45#include "MSStageTrip.h"
46#include "MSPerson.h"
47#include "MSPModel.h"
48
49// ===========================================================================
50// method definitions
51// ===========================================================================
52/* -------------------------------------------------------------------------
53 * MSPerson::MSPersonStage_Walking - methods
54 * ----------------------------------------------------------------------- */
56 const ConstMSEdgeVector& route,
57 MSStoppingPlace* toStop,
58 SUMOTime walkingTime, double speed,
59 double departPos, double arrivalPos, double departPosLat, int departLane,
60 const std::string& routeID) :
61 MSStageMoving(route, routeID, toStop, speed, departPos, arrivalPos, departPosLat, departLane, MSStageType::WALKING),
62 myWalkingTime(walkingTime),
63 myExitTimes(nullptr) {
64 myDepartPos = SUMOVehicleParameter::interpretEdgePos(departPos, route.front()->getLength(), SUMO_ATTR_DEPARTPOS,
65 "person '" + personID + "' walking from edge '" + route.front()->getID() + "'");
66 myArrivalPos = SUMOVehicleParameter::interpretEdgePos(arrivalPos, route.back()->getLength(), SUMO_ATTR_ARRIVALPOS,
67 "person '" + personID + "' walking to edge '" + route.back()->getID() + "'");
68 if (walkingTime > 0) {
70 }
71}
72
73
75 delete myExitTimes;
76}
77
78
81 std::vector<const MSEdge*> route = myRoute;
82 double departPos = myDepartPos;
83 double arrivalPos = myArrivalPos;
84 int departLane = myDepartLane;
85 if (myRouteID != "" && MSRoute::distDictionary(myRouteID) != nullptr) {
86 route = MSRoute::dictionary(myRouteID, MSRouteHandler::getParsingRNG())->getEdges();
87 if (departPos > route[0]->getLength()) {
88 WRITE_WARNINGF(TL("Adjusting departPos for cloned walk with routeDistribution '%'"), myRouteID);
89 departPos = route[0]->getLength();
90 }
91 if (arrivalPos > route.back()->getLength()) {
92 WRITE_WARNINGF(TL("Adjusting arrivalPos for cloned walk with routeDistribution '%'"), myRouteID);
93 arrivalPos = route.back()->getLength();
94 }
95 if (departLane >= route[0]->getNumLanes()) {
96 WRITE_WARNINGF(TL("Adjusting departLane for cloned walk with routeDistribution '%'"), myRouteID);
97 departLane = route[0]->getNumLanes() - 1;
98 }
99 }
100 return new MSPersonStage_Walking("dummyID", route, myDestinationStop, myWalkingTime, mySpeed, departPos, arrivalPos, myDepartPosLat, departLane, myRouteID);
101}
102
103
104void
106 myDeparted = now;
107 myRouteStep = myRoute.begin();
108 myLastEdgeEntryTime = now;
109 if (myWalkingTime == 0) {
110 if (!person->proceed(net, now)) {
112 }
113 return;
114 }
115 if (previous->getEdgePos(now) >= 0 && previous->getEdge() == *myRouteStep) {
116 myDepartPos = previous->getEdgePos(now);
117 if (myWalkingTime > 0) {
118 mySpeed = computeAverageSpeed();
119 }
120 }
121 MSTransportableControl& pControl = net->getPersonControl();
122 myState = pControl.getMovementModel()->add(person, this, now);
123 if (myState == nullptr) {
124 pControl.erase(person);
125 return;
126 }
127 const MSLane* const lane = getSidewalk<MSEdge, MSLane>(getEdge());
128 if (lane != nullptr) {
129 for (MSMoveReminder* rem : lane->getMoveReminders()) {
130 if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_DEPARTED, lane)) {
131 myMoveReminders.push_back(rem);
132 };
133 }
134 }
135 if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
136 myExitTimes = new std::vector<SUMOTime>();
137 }
138 (*myRouteStep)->addTransportable(person);
139}
140
141
142void
145}
146
147
148void
150 mySpeed = speed;
151}
152
153
154double
156 return walkDistance() / STEPS2TIME(myWalkingTime + 1); // avoid systematic rounding errors
157}
158
159
160bool
163 if (stage != nullptr) {
164 return stage->getState()->isJammed();
165 }
166 return false;
167}
168
169double
171 double length = 0;
172 auto endIt = partial && myArrived < 0 ? myRouteStep + 1 : myRoute.end();
173 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt; ++i) {
174 length += (*i)->getLength();
175 }
176 if (myRoute.size() > 1 && MSNet::getInstance()->getPersonControl().getMovementModel()->usingInternalLanes()) {
177 // use lower bound for distance to pass the intersection
178 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt - 1; ++i) {
179 const MSEdge* fromEdge = *i;
180 const MSEdge* toEdge = *(i + 1);
181 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
182 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
183 Position fromPos;
184 Position toPos;
185 if (from != nullptr && to != nullptr) {
186 if (fromEdge->getToJunction() == toEdge->getFromJunction()) {
187 fromPos = from->getShape().back();
188 toPos = to->getShape().front();
189 } else if (fromEdge->getToJunction() == toEdge->getToJunction()) {
190 fromPos = from->getShape().back();
191 toPos = to->getShape().back();
192 } else if (fromEdge->getFromJunction() == toEdge->getFromJunction()) {
193 fromPos = from->getShape().front();
194 toPos = to->getShape().front();
195 } else if (fromEdge->getFromJunction() == toEdge->getToJunction()) {
196 fromPos = from->getShape().front();
197 toPos = to->getShape().back();
198 }
199 //std::cout << " from=" << from->getID() << " to=" << to->getID() << " junctionLength=" << fromPos.distanceTo2D(toPos) << "\n";
200 length += fromPos.distanceTo2D(toPos);
201 }
202 }
203 }
204 // determine walking direction for depart and arrival
205 const int departFwdArrivalDir = MSPModel::canTraverse(MSPModel::FORWARD, myRoute);
206 const int departBwdArrivalDir = MSPModel::canTraverse(MSPModel::BACKWARD, myRoute);
207 const bool mayStartForward = departFwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
208 const bool mayStartBackward = departBwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
209 const double arrivalPos = partial && myArrived < 0 ? getEdgePos(SIMSTEP) : myArrivalPos;
210 const double lengthFwd = (length - myDepartPos - (
211 departFwdArrivalDir == MSPModel::BACKWARD
212 ? arrivalPos
213 : myRoute.back()->getLength() - arrivalPos));
214 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
215 departBwdArrivalDir == MSPModel::BACKWARD
216 ? arrivalPos
217 : myRoute.back()->getLength() - arrivalPos));
218 //std::cout << " length=" << length << " lengthFwd=" << lengthFwd << " lengthBwd=" << lengthBwd << " mayStartForward=" << mayStartForward << " mayStartBackward=" << mayStartBackward << "\n";
219
220 if (myRoute.size() == 1) {
221 if (myDepartPos > myArrivalPos) {
222 length = lengthBwd;
223 } else {
224 length = lengthFwd;
225 }
226 } else {
227 if (mayStartForward && mayStartBackward) {
228 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
229 } else if (mayStartForward) {
230 length = lengthFwd;
231 } else if (mayStartBackward) {
232 length = lengthBwd;
233 } else {
234 length = lengthFwd;
235 }
236 }
237 //std::cout << SIMTIME << " route=" << toString(myRoute)
238 // << " depPos=" << myDepartPos << " arPos=" << myArrivalPos
239 // << " dFwdADir=" << departFwdArrivalDir
240 // << " dBwdADir=" << departBwdArrivalDir
241 // << " lengthFwd=" << lengthFwd
242 // << " lengthBwd=" << lengthBwd
243 // << "\n";
244
245 return MAX2(POSITION_EPS, length);
246}
247
248
249void
251 const double distance = walkDistance(true);
252 const double maxSpeed = getMaxSpeed(person);
253 const SUMOTime duration = myArrived - myDeparted;
254 SUMOTime timeLoss = myArrived == -1 ? 0 : duration - TIME2STEPS(distance / maxSpeed);
255 if (timeLoss < 0 && timeLoss > TIME2STEPS(-0.1)) {
256 // avoid negative timeLoss due to rounding errors
257 timeLoss = 0;
258 }
259 MSDevice_Tripinfo::addPedestrianData(distance, duration, timeLoss);
260 os.openTag("walk");
261 os.writeAttr("depart", myDeparted >= 0 ? time2string(myDeparted) : "-1");
262 os.writeAttr("departPos", myDepartPos);
263 os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
264 os.writeAttr("arrivalPos", myArrived >= 0 ? toString(myArrivalPos) : "-1");
265 os.writeAttr("duration", myDeparted < 0 ? "-1" :
266 time2string(myArrived >= 0 ? duration : MSNet::getInstance()->getCurrentTimeStep() - myDeparted));
267 os.writeAttr("routeLength", myArrived >= 0 ? toString(distance) : "-1");
268 os.writeAttr("timeLoss", time2string(timeLoss));
269 os.writeAttr("maxSpeed", maxSpeed);
270 os.closeTag();
271}
272
273
274void
275MSPerson::MSPersonStage_Walking::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool withRouteLength, const MSStage* const /* previous */) const {
276 os.openTag("walk").writeAttr(SUMO_ATTR_EDGES, myRoute);
277 std::string comment = "";
278 if (myDestinationStop != nullptr) {
279 os.writeAttr(toString(myDestinationStop->getElement()), myDestinationStop->getID());
280 if (myDestinationStop->getMyName() != "") {
281 comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
282 }
283 } else if (wasSet(VEHPARS_ARRIVALPOS_SET)) {
284 os.writeAttr(SUMO_ATTR_ARRIVALPOS, myArrivalPos);
285 }
286 if (myWalkingTime > 0) {
287 os.writeAttr(SUMO_ATTR_DURATION, time2string(myWalkingTime));
288 } else if (mySpeed > 0) {
289 os.writeAttr(SUMO_ATTR_SPEED, mySpeed);
290 }
291 if (withRouteLength) {
292 if (myDeparted >= 0) {
293 os.writeAttr("routeLength", walkDistance(true));
294 } else {
295 os.writeAttr("routeLength", "-1");
296 }
297 }
298 if (myExitTimes != nullptr) {
299 std::vector<std::string> exits;
300 for (SUMOTime t : *myExitTimes) {
301 exits.push_back(time2string(t));
302 }
303 std::vector<std::string> missing(MAX2(0, (int)myRoute.size() - (int)myExitTimes->size()), "-1");
304 exits.insert(exits.end(), missing.begin(), missing.end());
305 os.writeAttr("exitTimes", exits);
306 os.writeAttr(SUMO_ATTR_STARTED, myDeparted >= 0 ? time2string(myDeparted) : "-1");
307 os.writeAttr(SUMO_ATTR_ENDED, myArrived >= 0 ? time2string(myArrived) : "-1");
308 }
309 os.closeTag(comment);
310}
311
312
313bool
314MSPerson::MSPersonStage_Walking::moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal) {
315 ((MSEdge*)getEdge())->removeTransportable(person);
316 const MSLane* lane = getSidewalk<MSEdge, MSLane>(getEdge());
317 const bool arrived = myRouteStep == myRoute.end() - 1;
318 if (lane != nullptr) {
319 const double tl = person->getVehicleType().getLength();
320 const double lastPos = (arrived
321 ? (prevDir == MSPModel::FORWARD
322 ? getArrivalPos() + tl
323 : getArrivalPos() - tl)
324 : person->getPositionOnLane());
325 activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
326 }
327 if (myExitTimes != nullptr && nextInternal == nullptr) {
328 myExitTimes->push_back(currentTime);
329 }
330 myMoveReminders.clear();
331 myLastEdgeEntryTime = currentTime;
332 //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
333 if (arrived) {
334 MSPerson* p = dynamic_cast<MSPerson*>(person);
336 myCurrentInternalEdge = nextInternal;
337 ((MSEdge*) getEdge())->addTransportable(person);
338 return false;
339 }
340 if (myDestinationStop != nullptr) {
341 myDestinationStop->addTransportable(person);
342 }
343 if (!person->proceed(MSNet::getInstance(), currentTime)) {
345 }
346 //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
347 return true;
348 } else {
349 if (nextInternal == nullptr) {
350 ++myRouteStep;
351 }
352 myCurrentInternalEdge = nextInternal;
353 ((MSEdge*) getEdge())->addTransportable(person);
354 return false;
355 }
356}
357
358
359void
360MSPerson::MSPersonStage_Walking::activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived) {
362 for (MSMoveReminder* rem : myMoveReminders) {
363 rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, t, t, true);
364 rem->notifyLeave(*person, lastPos, notification);
365 }
366}
367
368
369void
371 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
372 if (nextLane != nullptr) {
373 for (MSMoveReminder* rem : nextLane->getMoveReminders()) {
374 if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
375 ;
376 myMoveReminders.push_back(rem);
377 }
378 }
379 }
380}
381
382
383int
385 return (int)(myRouteStep - myRoute.begin());
386}
387
388
389double
391 return mySpeed >= 0 ? mySpeed : person->getMaxSpeed();
392}
393
394std::string
395MSPerson::MSPersonStage_Walking::getStageSummary(const bool /* isPerson */) const {
396 const std::string dest = (getDestinationStop() == nullptr ?
397 " edge '" + getDestination()->getID() + "'" :
398 " stop '" + getDestinationStop()->getID() + "'" + (
399 getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
400 return "walking to " + dest;
401}
402
403
404void
406 out << " " << myDeparted << " " << (myRouteStep - myRoute.begin()) << " " << myLastEdgeEntryTime;
407 myState->saveState(out);
408}
409
410
411void
412MSPerson::MSPersonStage_Walking::loadState(MSTransportable* transportable, std::istringstream& state) {
413 int stepIdx;
414 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
415 myRouteStep = myRoute.begin() + stepIdx;
416 myState = MSNet::getInstance()->getPersonControl().getMovementModel()->loadState(transportable, this, state);
417 if (myState->getLane() && !myState->getLane()->isNormal()) {
418 myCurrentInternalEdge = &myState->getLane()->getEdge();
419 myCurrentInternalEdge->addTransportable(transportable);
420 } else {
421 (*myRouteStep)->addTransportable(transportable);
422 }
423}
424
425
426/* -------------------------------------------------------------------------
427* MSPerson::MSPersonStage_Access - methods
428* ----------------------------------------------------------------------- */
430 const double arrivalPos, const double dist, const bool isExit) :
431 MSStage(destination, toStop, arrivalPos, MSStageType::ACCESS),
432 myDist(dist), myAmExit(isExit) {
433 myPath.push_back(destination->getLanes()[0]->geometryPositionAtOffset(myDestinationStop->getAccessPos(destination)));
434 myPath.push_back(toStop->getLane().geometryPositionAtOffset((toStop->getEndLanePosition() + toStop->getBeginLanePosition()) / 2));
435 if (isExit) {
437 }
438}
439
440
442
443MSStage*
445 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
446}
447
448void
450 myDeparted = now;
451 myEstimatedArrival = now + TIME2STEPS(myDist / person->getMaxSpeed());
452 net->getBeginOfTimestepEvents()->addEvent(new ProceedCmd(person, &myDestinationStop->getLane().getEdge()), myEstimatedArrival);
453 myDestinationStop->getLane().getEdge().addTransportable(person);
454}
455
456
457std::string
459 return "access";
460}
461
462
463std::string
464MSPerson::MSPersonStage_Access::getStageSummary(const bool /* isPerson */) const {
465 return (myAmExit ? "access from stop '" : "access to stop '") + getDestinationStop()->getID() + "'";
466}
467
468
471 return myPath.positionAtOffset(myPath.length() * (double)(now - myDeparted) / (double)(myEstimatedArrival - myDeparted));
472}
473
474
475double
477 return myPath.angleAt2D(0);
478}
479
480
481double
483 return myDist / STEPS2TIME(MAX2((SUMOTime)1, myEstimatedArrival - myDeparted));
484}
485
486void
488 os.openTag("access");
489 os.writeAttr("stop", getDestinationStop()->getID());
490 os.writeAttr("depart", time2string(myDeparted));
491 os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
492 os.writeAttr("duration", myArrived > 0 ? time2string(myArrived - myDeparted) : "-1");
493 os.writeAttr("routeLength", myDist);
494 os.closeTag();
495}
496
497
500 myStopEdge->removeTransportable(myPerson);
501 if (!myPerson->proceed(MSNet::getInstance(), currentTime)) {
503 }
504 return 0;
505}
506
507
508/* -------------------------------------------------------------------------
509 * MSPerson - methods
510 * ----------------------------------------------------------------------- */
512 MSTransportable(pars, vtype, plan, true),
513 myInfluencer(nullptr),
514 myChosenSpeedFactor(pars->speedFactor < 0 ? speedFactor : pars->speedFactor)
515{ }
516
517
519 delete myInfluencer;
520}
521
522
523bool
524MSPerson::checkAccess(const MSStage* const prior, const bool waitAtStop) {
525 MSStoppingPlace* prevStop = prior->getDestinationStop();
526 if (!waitAtStop && prior->getStageType() == MSStageType::TRIP) {
527 prevStop = dynamic_cast<const MSStageTrip*>(prior)->getOriginStop();
528 }
529 if (prevStop != nullptr) {
530 if (waitAtStop) {
531 const double accessDist = prevStop->getAccessDistance(prior->getDestination());
532 if (accessDist > 0.) {
533 const double arrivalAtBs = (prevStop->getBeginLanePosition() + prevStop->getEndLanePosition()) / 2;
534 myStep = myPlan->insert(myStep, new MSPersonStage_Access(prior->getDestination(), prevStop, arrivalAtBs, accessDist, false));
535 return true;
536 }
537 } else {
538 const double accessDist = prevStop->getAccessDistance((*myStep)->getFromEdge());
539 if (accessDist > 0.) {
540 myStep = myPlan->insert(myStep, new MSPersonStage_Access((*myStep)->getFromEdge(), prevStop, prevStop->getAccessPos((*myStep)->getFromEdge()), accessDist, true));
541 return true;
542 }
543 }
544 }
545 return false;
546}
547
548
549const std::string&
551// if (getCurrentStageType() == WALKING) {
552// MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
553// assert(walkingStage != 0);
554// const MSEdge* nextEdge = walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
555// if (nextEdge != 0) {
556// return nextEdge->getID();
557// }
558// }
559// return StringUtils::emptyString;
560 const MSEdge* nextEdge = getNextEdgePtr();
561 if (nextEdge != nullptr) {
562 return nextEdge->getID();
563 }
565}
566
567
568const MSEdge*
571 MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
572 assert(walkingStage != nullptr);
573 return walkingStage->getState()->getNextEdge(*walkingStage);
574 }
575 return nullptr;
576}
577
578
579
580void
581MSPerson::reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex) {
582 assert(nextIndex > firstIndex);
583 //std::cout << SIMTIME << " reroute person " << getID()
584 // << " newEdges=" << toString(newEdges)
585 // << " firstIndex=" << firstIndex
586 // << " nextIndex=" << nextIndex
587 // << " departPos=" << getEdgePos()
588 // << " arrivalPos=" << getNextStage(nextIndex - 1)->getArrivalPos()
589 // << "\n";
591 getNextStage(nextIndex - 1)->getDestinationStop(), -1,
592 -1,
593 departPos,
594 getNextStage(nextIndex - 1)->getArrivalPos(),
596 appendStage(newStage, nextIndex);
597 // remove stages in reverse order so that proceed will only be called at the last removal
598 for (int i = nextIndex - 1; i >= firstIndex; i--) {
599 //std::cout << " removeStage=" << i << "\n";
600 removeStage(i);
601 }
602}
603
604
607 if (myInfluencer == nullptr) {
608 myInfluencer = new Influencer();
609 }
610 return *myInfluencer;
611}
612
613
616 return myInfluencer;
617}
618
619
620
621/* -------------------------------------------------------------------------
622 * methods of MSPerson::Influencer
623 * ----------------------------------------------------------------------- */
625
626
628
629
630void
631MSPerson::Influencer::setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t) {
632 myRemoteXYPos = xyPos;
633 myRemoteLane = l;
634 myRemotePos = pos;
635 myRemotePosLat = posLat;
636 myRemoteAngle = angle;
637 myRemoteEdgeOffset = edgeOffset;
638 myRemoteRoute = route;
639 myLastRemoteAccess = t;
640}
641
642
643bool
645 return myLastRemoteAccess == MSNet::getInstance()->getCurrentTimeStep();
646}
647
648
649bool
651 return myLastRemoteAccess >= t - TIME2STEPS(10);
652}
653
654
655void
657 /*
658 std::cout << SIMTIME << " moveToXY person=" << p->getID()
659 << " xyPos=" << myRemoteXYPos
660 << " lane=" << Named::getIDSecure(myRemoteLane)
661 << " pos=" << myRemotePos
662 << " posLat=" << myRemotePosLat
663 << " angle=" << myRemoteAngle
664 << " eOf=" << myRemoteEdgeOffset
665 << " route=" << toString(myRemoteRoute)
666 << " aTime=" << time2string(myLastRemoteAccess)
667 << "\n";
668 */
669 switch (p->getStageType(0)) {
672 assert(s != nullptr);
673 s->getState()->moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
674 MSNet::getInstance()->getCurrentTimeStep());
675 }
676 break;
677 default:
678 break;
679 }
680}
681
682
683/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:266
#define TL(string)
Definition: MsgHandler.h:282
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define STEPS2TIME(x)
Definition: SUMOTime.h:54
#define SIMSTEP
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
const int VEHPARS_ARRIVALPOS_SET
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_DURATION
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
A road/street connecting two junctions.
Definition: MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const MSJunction * getToJunction() const
Definition: MSEdge.h:415
const MSJunction * getFromJunction() const
Definition: MSEdge.h:411
virtual void addTransportable(MSTransportable *t) const
Definition: MSEdge.cpp:1085
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:296
double getLength() const
Returns the lane's length.
Definition: MSLane.h:575
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:506
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:713
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:533
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
The simulated network and simulation perfomer.
Definition: MSNet.h:88
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:472
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1096
static const int BACKWARD
Definition: MSPModel.h:118
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:54
static const int FORWARD
Definition: MSPModel.h:117
virtual MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)=0
register the given person as a pedestrian
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
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:119
static const double UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
Definition: MSPModel.h:128
Changes the wished person speed and position.
Definition: MSPerson.h:282
void postProcessRemoteControl(MSPerson *p)
Definition: MSPerson.cpp:656
Influencer()
Constructor.
Definition: MSPerson.cpp:624
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:631
~Influencer()
Destructor.
Definition: MSPerson.cpp:627
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:650
bool isRemoteControlled() const
Definition: MSPerson.cpp:644
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:499
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:470
double getSpeed() const
the speed of the person in this stage
Definition: MSPerson.cpp:482
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
Definition: MSPerson.cpp:429
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:487
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:449
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:476
std::string getStageDescription(const bool isPerson) const
returns the stage description as a string
Definition: MSPerson.cpp:458
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:464
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
Definition: MSPerson.cpp:275
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:250
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:149
double computeAverageSpeed() const
Definition: MSPerson.cpp:155
double walkDistance(bool partial=false) const
compute total walking distance
Definition: MSPerson.cpp:170
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:314
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:390
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
Definition: MSPerson.cpp:412
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:395
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:105
void activateEntryReminders(MSTransportable *person)
Definition: MSPerson.cpp:370
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
Definition: MSPerson.cpp:360
int getRoutePosition() const
return index of current edge within route
Definition: MSPerson.cpp:384
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat, int departLane=-1, const std::string &routeID="")
constructor
Definition: MSPerson.cpp:55
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:143
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
Definition: MSPerson.cpp:405
bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
Definition: MSPerson.cpp:524
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:334
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:569
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:581
double myChosenSpeedFactor
Definition: MSPerson.h:336
bool isJammed() const
whether the person is jammed as defined by the current pedestrian model
Definition: MSPerson.cpp:161
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSPerson.h:325
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:518
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:606
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:550
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:511
static SumoRNG * getParsingRNG()
get parsing RNG
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:118
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:170
const MSEdge * getDestination() const
returns the destination edge
Definition: MSStage.cpp:61
virtual double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:79
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition: MSStage.h:238
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSStage.h:80
MSStageType getStageType() const
Definition: MSStage.h:117
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:67
double myArrivalPos
the position at which we want to arrive
Definition: MSStage.h:241
virtual MSTransportableStateAdapter * getState() const
Definition: MSStageMoving.h:49
double mySpeed
the speed of the transportable
double myDepartPos
the depart position
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
virtual double getEdgePos() const
Return the position on the edge.
const MSLane * getLane() const
Returns the current lane (may be nullptr)
const MSEdge * getDestination() const
Returns the current destination.
MSStageType getStageType(int next) const
the stage type for the nth next stage
MSStage * getCurrentStage() const
Return the current stage.
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
MSTransportablePlan::iterator myStep
the iterator over the route
MSTransportablePlan * myPlan
the plan of the transportable
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
double getArrivalPos() const
returns the final arrival pos
double getPositionOnLane() const
Get the object's position along the lane.
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
MSStageType getCurrentStageType() const
the current stage type of the transportable
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 MSEdge * getEdge() const
Returns the current edge.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical 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:184
virtual const MSLane * getLane() const
whether the transportable is jammed
Definition: MSPModel.h:205
virtual bool isJammed() const
whether the transportable is jammed
Definition: MSPModel.h:200
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:63
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition: Named.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
PositionVector reverse() const
reverse position vector
Structure representing possible vehicle parameter.
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static std::string emptyString
An empty string.
Definition: StringUtils.h:87