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-2023 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 "MSPModel_Striping.h"
46#include "MSStageTrip.h"
47#include "MSPerson.h"
48#include "MSPModel.h"
49
50// ===========================================================================
51// method definitions
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, int departLane,
61 const std::string& routeID) :
62 MSStageMoving(route, routeID, toStop, speed, departPos, arrivalPos, departPosLat, departLane, MSStageType::WALKING),
63 myWalkingTime(walkingTime),
64 myExitTimes(nullptr),
65 myInternalDistance(0) {
66 myDepartPos = SUMOVehicleParameter::interpretEdgePos(departPos, route.front()->getLength(), SUMO_ATTR_DEPARTPOS,
67 "person '" + personID + "' walking from edge '" + route.front()->getID() + "'");
68 myArrivalPos = SUMOVehicleParameter::interpretEdgePos(arrivalPos, route.back()->getLength(), SUMO_ATTR_ARRIVALPOS,
69 "person '" + personID + "' walking to edge '" + route.back()->getID() + "'");
70 if (walkingTime > 0) {
72 }
73}
74
75
77 delete myExitTimes;
78}
79
80
83 std::vector<const MSEdge*> route = myRoute;
84 double departPos = myDepartPos;
85 double arrivalPos = myArrivalPos;
86 int departLane = myDepartLane;
87 if (myRouteID != "" && MSRoute::distDictionary(myRouteID) != nullptr) {
88 route = MSRoute::dictionary(myRouteID, MSRouteHandler::getParsingRNG())->getEdges();
89 if (departPos > route[0]->getLength()) {
90 WRITE_WARNINGF(TL("Adjusting departPos for cloned walk with routeDistribution '%'"), myRouteID);
91 departPos = route[0]->getLength();
92 }
93 if (arrivalPos > route.back()->getLength()) {
94 WRITE_WARNINGF(TL("Adjusting arrivalPos for cloned walk with routeDistribution '%'"), myRouteID);
95 arrivalPos = route.back()->getLength();
96 }
97 if (departLane >= route[0]->getNumLanes()) {
98 WRITE_WARNINGF(TL("Adjusting departLane for cloned walk with routeDistribution '%'"), myRouteID);
99 departLane = route[0]->getNumLanes() - 1;
100 }
101 }
102 return new MSPersonStage_Walking("dummyID", route, myDestinationStop, myWalkingTime, mySpeed, departPos, arrivalPos, myDepartPosLat, departLane, myRouteID);
103}
104
105
106void
108 myDeparted = now;
109 myRouteStep = myRoute.begin();
110 myLastEdgeEntryTime = now;
111 if (myWalkingTime == 0) {
112 if (!person->proceed(net, now)) {
114 }
115 return;
116 }
117 if (previous->getEdgePos(now) >= 0 && previous->getEdge() == *myRouteStep) {
118 myDepartPos = previous->getEdgePos(now);
119 if (myWalkingTime > 0) {
120 mySpeed = computeAverageSpeed();
121 }
122 }
123 MSTransportableControl& pControl = net->getPersonControl();
124 myState = pControl.getMovementModel()->add(person, this, now);
125 if (myState == nullptr) {
126 pControl.erase(person);
127 return;
128 }
129 const MSLane* const lane = getSidewalk<MSEdge, MSLane>(getEdge());
130 if (lane != nullptr) {
131 for (MSMoveReminder* rem : lane->getMoveReminders()) {
132 if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_DEPARTED, lane)) {
133 myMoveReminders.push_back(rem);
134 }
135 }
136 }
137 if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
138 myExitTimes = new std::vector<SUMOTime>();
139 }
140 (*myRouteStep)->addTransportable(person);
141}
142
143
144void
147}
148
149
150void
152 mySpeed = speed;
153}
154
155
156double
158 return walkDistance() / STEPS2TIME(myWalkingTime + 1); // avoid systematic rounding errors
159}
160
161
162bool
165 if (stage != nullptr) {
166 return stage->getState()->isJammed();
167 }
168 return false;
169}
170
171double
173 double length = 0;
174 auto endIt = partial && myArrived < 0 ? myRouteStep + 1 : myRoute.end();
175 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt; ++i) {
176 length += (*i)->getLength();
177 }
178 if (myRoute.size() > 1 && MSNet::getInstance()->getPersonControl().getMovementModel()->usingInternalLanes()) {
179 if (myInternalDistance > 0) {
180 length += myInternalDistance;
181 } else {
182 // use lower bound for distance to pass the intersection
183 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt - 1; ++i) {
184 const MSEdge* fromEdge = *i;
185 const MSEdge* toEdge = *(i + 1);
186 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
187 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
188 Position fromPos;
189 Position toPos;
190 if (from != nullptr && to != nullptr) {
191 if (fromEdge->getToJunction() == toEdge->getFromJunction()) {
192 fromPos = from->getShape().back();
193 toPos = to->getShape().front();
194 } else if (fromEdge->getToJunction() == toEdge->getToJunction()) {
195 fromPos = from->getShape().back();
196 toPos = to->getShape().back();
197 } else if (fromEdge->getFromJunction() == toEdge->getFromJunction()) {
198 fromPos = from->getShape().front();
199 toPos = to->getShape().front();
200 } else if (fromEdge->getFromJunction() == toEdge->getToJunction()) {
201 fromPos = from->getShape().front();
202 toPos = to->getShape().back();
203 }
204 //std::cout << " from=" << from->getID() << " to=" << to->getID() << " junctionLength=" << fromPos.distanceTo2D(toPos) << "\n";
205 length += fromPos.distanceTo2D(toPos);
206 }
207 }
208 }
209 }
210 // determine walking direction for depart and arrival
211 const int departFwdArrivalDir = MSPModel::canTraverse(MSPModel::FORWARD, myRoute);
212 const int departBwdArrivalDir = MSPModel::canTraverse(MSPModel::BACKWARD, myRoute);
213 const bool mayStartForward = departFwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
214 const bool mayStartBackward = departBwdArrivalDir != MSPModel::UNDEFINED_DIRECTION;
215 const double arrivalPos = partial && myArrived < 0 ? getEdgePos(SIMSTEP) : myArrivalPos;
216 const double lengthFwd = (length - myDepartPos - (
217 departFwdArrivalDir == MSPModel::BACKWARD
218 ? arrivalPos
219 : myRoute.back()->getLength() - arrivalPos));
220 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
221 departBwdArrivalDir == MSPModel::BACKWARD
222 ? arrivalPos
223 : myRoute.back()->getLength() - arrivalPos));
224 //std::cout << " length=" << length << " lengthFwd=" << lengthFwd << " lengthBwd=" << lengthBwd << " mayStartForward=" << mayStartForward << " mayStartBackward=" << mayStartBackward << "\n";
225
226 if (myRoute.size() == 1) {
227 if (myDepartPos > myArrivalPos) {
228 length = lengthBwd;
229 } else {
230 length = lengthFwd;
231 }
232 } else {
233 if (mayStartForward && mayStartBackward) {
234 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
235 } else if (mayStartForward) {
236 length = lengthFwd;
237 } else if (mayStartBackward) {
238 length = lengthBwd;
239 } else {
240 length = lengthFwd;
241 }
242 }
243 //std::cout << SIMTIME << " route=" << toString(myRoute)
244 // << " depPos=" << myDepartPos << " arPos=" << myArrivalPos
245 // << " dFwdADir=" << departFwdArrivalDir
246 // << " dBwdADir=" << departBwdArrivalDir
247 // << " lengthFwd=" << lengthFwd
248 // << " lengthBwd=" << lengthBwd
249 // << "\n";
250
251 return MAX2(POSITION_EPS, length);
252}
253
254
255void
257 const double distance = walkDistance(true);
258 const double maxSpeed = getMaxSpeed(person);
259 const SUMOTime duration = myArrived - myDeparted;
260 SUMOTime timeLoss = myArrived == -1 ? 0 : duration - TIME2STEPS(distance / maxSpeed);
261 if (timeLoss < 0 && timeLoss > TIME2STEPS(-0.1)) {
262 // avoid negative timeLoss due to rounding errors
263 timeLoss = 0;
264 }
265 MSDevice_Tripinfo::addPedestrianData(distance, duration, timeLoss);
266 os.openTag("walk");
267 os.writeAttr("depart", myDeparted >= 0 ? time2string(myDeparted) : "-1");
268 os.writeAttr("departPos", myDepartPos);
269 os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
270 os.writeAttr("arrivalPos", myArrived >= 0 ? toString(myArrivalPos) : "-1");
271 os.writeAttr("duration", myDeparted < 0 ? "-1" :
272 time2string(myArrived >= 0 ? duration : MSNet::getInstance()->getCurrentTimeStep() - myDeparted));
273 os.writeAttr("routeLength", myArrived >= 0 ? toString(distance) : "-1");
274 os.writeAttr("timeLoss", time2string(timeLoss));
275 os.writeAttr("maxSpeed", maxSpeed);
276 os.closeTag();
277}
278
279
280void
281MSPerson::MSPersonStage_Walking::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool withRouteLength, const MSStage* const /* previous */) const {
282 os.openTag("walk").writeAttr(SUMO_ATTR_EDGES, myRoute);
283 std::string comment = "";
284 if (myDestinationStop != nullptr) {
285 os.writeAttr(toString(myDestinationStop->getElement()), myDestinationStop->getID());
286 if (myDestinationStop->getMyName() != "") {
287 comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
288 }
289 } else if (wasSet(VEHPARS_ARRIVALPOS_SET)) {
290 os.writeAttr(SUMO_ATTR_ARRIVALPOS, myArrivalPos);
291 }
292 if (myWalkingTime > 0) {
293 os.writeAttr(SUMO_ATTR_DURATION, time2string(myWalkingTime));
294 } else if (mySpeed > 0) {
295 os.writeAttr(SUMO_ATTR_SPEED, mySpeed);
296 }
297 if (withRouteLength) {
298 if (myDeparted >= 0) {
299 os.writeAttr("routeLength", walkDistance(true));
300 } else {
301 os.writeAttr("routeLength", "-1");
302 }
303 }
304 if (myExitTimes != nullptr) {
305 std::vector<std::string> exits;
306 for (SUMOTime t : *myExitTimes) {
307 exits.push_back(time2string(t));
308 }
309 std::vector<std::string> missing(MAX2(0, (int)myRoute.size() - (int)myExitTimes->size()), "-1");
310 exits.insert(exits.end(), missing.begin(), missing.end());
311 os.writeAttr("exitTimes", exits);
312 os.writeAttr(SUMO_ATTR_STARTED, myDeparted >= 0 ? time2string(myDeparted) : "-1");
313 os.writeAttr(SUMO_ATTR_ENDED, myArrived >= 0 ? time2string(myArrived) : "-1");
314 }
315 os.closeTag(comment);
316}
317
318
319bool
320MSPerson::MSPersonStage_Walking::moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal) {
321 ((MSEdge*)getEdge())->removeTransportable(person);
322 const MSLane* lane = getSidewalk<MSEdge, MSLane>(getEdge());
323 const bool arrived = myRouteStep == myRoute.end() - 1;
324 if (lane != nullptr) {
325 const double tl = person->getVehicleType().getLength();
326 const double lastPos = (arrived
327 ? (prevDir == MSPModel::FORWARD
328 ? getArrivalPos() + tl
329 : getArrivalPos() - tl)
330 : person->getPositionOnLane());
331 activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
332 }
333 if (myExitTimes != nullptr && nextInternal == nullptr) {
334 myExitTimes->push_back(currentTime);
335 }
336 myMoveReminders.clear();
337 myLastEdgeEntryTime = currentTime;
338 //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n";
339 if (myCurrentInternalEdge != nullptr) {
340 myInternalDistance += (myState->getPathLength() == 0 ? myCurrentInternalEdge->getLength() : myState->getPathLength());
341 }
342 if (arrived) {
343 MSPerson* p = dynamic_cast<MSPerson*>(person);
345 myCurrentInternalEdge = nextInternal;
346 ((MSEdge*) getEdge())->addTransportable(person);
347 return false;
348 }
349 if (myDestinationStop != nullptr) {
350 myDestinationStop->addTransportable(person);
351 }
352 if (!person->proceed(MSNet::getInstance(), currentTime)) {
354 }
355 //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n";
356 return true;
357 } else {
358 if (nextInternal == nullptr) {
359 ++myRouteStep;
360 }
361 myCurrentInternalEdge = nextInternal;
362 ((MSEdge*) getEdge())->addTransportable(person);
363 return false;
364 }
365}
366
367
368void
369MSPerson::MSPersonStage_Walking::activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived) {
371 for (MSMoveReminder* rem : myMoveReminders) {
372 rem->updateDetector(*person, 0.0, lane->getLength(), myLastEdgeEntryTime, t, t, true);
373 rem->notifyLeave(*person, lastPos, notification);
374 }
375}
376
377
378void
380 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(getEdge());
381 if (nextLane != nullptr) {
382 for (MSMoveReminder* rem : nextLane->getMoveReminders()) {
383 if (rem->notifyEnter(*person, MSMoveReminder::NOTIFICATION_JUNCTION, nextLane)) {
384 ;
385 myMoveReminders.push_back(rem);
386 }
387 }
388 }
389}
390
391
392int
394 return (int)(myRouteStep - myRoute.begin());
395}
396
397
398double
400 return mySpeed >= 0 ? mySpeed : person->getMaxSpeed();
401}
402
403std::string
404MSPerson::MSPersonStage_Walking::getStageSummary(const bool /* isPerson */) const {
405 const std::string dest = (getDestinationStop() == nullptr ?
406 " edge '" + getDestination()->getID() + "'" :
407 " stop '" + getDestinationStop()->getID() + "'" + (
408 getDestinationStop()->getMyName() != "" ? " (" + getDestinationStop()->getMyName() + ")" : ""));
409 return "walking to " + dest;
410}
411
412
413void
415 out << " " << myDeparted << " " << (myRouteStep - myRoute.begin()) << " " << myLastEdgeEntryTime;
416 myState->saveState(out);
417}
418
419
420void
421MSPerson::MSPersonStage_Walking::loadState(MSTransportable* transportable, std::istringstream& state) {
422 int stepIdx;
423 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
424 myRouteStep = myRoute.begin() + stepIdx;
425 myState = MSNet::getInstance()->getPersonControl().getMovementModel()->loadState(transportable, this, state);
426 if (myState->getLane() && !myState->getLane()->isNormal()) {
427 myCurrentInternalEdge = &myState->getLane()->getEdge();
428 myCurrentInternalEdge->addTransportable(transportable);
429 } else {
430 (*myRouteStep)->addTransportable(transportable);
431 }
432}
433
434
435/* -------------------------------------------------------------------------
436* MSPerson::MSPersonStage_Access - methods
437* ----------------------------------------------------------------------- */
439 const double arrivalPos, const double dist, const bool isExit) :
440 MSStage(destination, toStop, arrivalPos, MSStageType::ACCESS),
441 myDist(dist), myAmExit(isExit) {
442 myPath.push_back(destination->getLanes()[0]->geometryPositionAtOffset(myDestinationStop->getAccessPos(destination)));
443 myPath.push_back(toStop->getCenterPos());
444 if (isExit) {
446 }
447}
448
449
451
452MSStage*
454 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
455}
456
457void
459 myDeparted = now;
460 myEstimatedArrival = now + TIME2STEPS(myDist / person->getMaxSpeed());
461 net->getBeginOfTimestepEvents()->addEvent(new ProceedCmd(person, &myDestinationStop->getLane().getEdge()), myEstimatedArrival);
463 myDestinationStop->getLane().getEdge().addTransportable(person);
464}
465
466
467std::string
469 return "access";
470}
471
472
473std::string
474MSPerson::MSPersonStage_Access::getStageSummary(const bool /* isPerson */) const {
475 return (myAmExit ? "access from stop '" : "access to stop '") + getDestinationStop()->getID() + "'";
476}
477
478
481 return myPath.positionAtOffset(myPath.length() * (double)(now - myDeparted) / (double)(myEstimatedArrival - myDeparted));
482}
483
484
485double
487 return myPath.angleAt2D(0);
488}
489
490
491double
493 return myDist / STEPS2TIME(MAX2((SUMOTime)1, myEstimatedArrival - myDeparted));
494}
495
496void
498 os.openTag("access");
499 os.writeAttr("stop", getDestinationStop()->getID());
500 os.writeAttr("depart", time2string(myDeparted));
501 os.writeAttr("arrival", myArrived >= 0 ? time2string(myArrived) : "-1");
502 os.writeAttr("duration", myArrived > 0 ? time2string(myArrived - myDeparted) : "-1");
503 os.writeAttr("routeLength", myDist);
504 os.closeTag();
505}
506
507
511 myStopEdge->removeTransportable(myPerson);
512 if (!myPerson->proceed(MSNet::getInstance(), currentTime)) {
514 }
515 return 0;
516}
517
518
519/* -------------------------------------------------------------------------
520 * MSPerson - methods
521 * ----------------------------------------------------------------------- */
523 MSTransportable(pars, vtype, plan, true),
524 myInfluencer(nullptr),
525 myChosenSpeedFactor(pars->speedFactor < 0 ? speedFactor : pars->speedFactor)
526{ }
527
528
530 delete myInfluencer;
531}
532
533
534bool
535MSPerson::checkAccess(const MSStage* const prior, const bool waitAtStop) {
536 MSStoppingPlace* prevStop = prior->getDestinationStop();
537 if (!waitAtStop && prior->getStageType() == MSStageType::TRIP) {
538 prevStop = dynamic_cast<const MSStageTrip*>(prior)->getOriginStop();
539 }
540 if (prevStop != nullptr) {
541 if (waitAtStop) {
542 const double accessDist = prevStop->getAccessDistance(prior->getDestination());
543 if (accessDist > 0.) {
544 const double arrivalAtBs = (prevStop->getBeginLanePosition() + prevStop->getEndLanePosition()) / 2;
545 myStep = myPlan->insert(myStep, new MSPersonStage_Access(prior->getDestination(), prevStop, arrivalAtBs, accessDist, false));
546 return true;
547 }
548 } else {
549 const double accessDist = prevStop->getAccessDistance((*myStep)->getFromEdge());
550 if (accessDist > 0.) {
551 myStep = myPlan->insert(myStep, new MSPersonStage_Access((*myStep)->getFromEdge(), prevStop, prevStop->getAccessPos((*myStep)->getFromEdge()), accessDist, true));
552 return true;
553 }
554 }
555 }
556 return false;
557}
558
559
560const std::string&
562// if (getCurrentStageType() == WALKING) {
563// MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
564// assert(walkingStage != 0);
565// const MSEdge* nextEdge = walkingStage->getPedestrianState()->getNextEdge(*walkingStage);
566// if (nextEdge != 0) {
567// return nextEdge->getID();
568// }
569// }
570// return StringUtils::emptyString;
571 const MSEdge* nextEdge = getNextEdgePtr();
572 if (nextEdge != nullptr) {
573 return nextEdge->getID();
574 }
576}
577
578
579const MSEdge*
582 MSPersonStage_Walking* walkingStage = dynamic_cast<MSPersonStage_Walking*>(*myStep);
583 assert(walkingStage != nullptr);
584 return walkingStage->getState()->getNextEdge(*walkingStage);
585 }
586 return nullptr;
587}
588
589
590
591void
592MSPerson::reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex) {
593 assert(nextIndex > firstIndex);
594 //std::cout << SIMTIME << " reroute person " << getID()
595 // << " newEdges=" << toString(newEdges)
596 // << " firstIndex=" << firstIndex
597 // << " nextIndex=" << nextIndex
598 // << " departPos=" << getEdgePos()
599 // << " arrivalPos=" << getNextStage(nextIndex - 1)->getArrivalPos()
600 // << "\n";
602 getNextStage(nextIndex - 1)->getDestinationStop(), -1,
603 -1,
604 departPos,
605 getNextStage(nextIndex - 1)->getArrivalPos(),
607 appendStage(newStage, nextIndex);
608 // remove stages in reverse order so that proceed will only be called at the last removal
609 for (int i = nextIndex - 1; i >= firstIndex; i--) {
610 //std::cout << " removeStage=" << i << "\n";
611 removeStage(i);
612 }
613}
614
615
618 if (myInfluencer == nullptr) {
619 myInfluencer = new Influencer();
620 }
621 return *myInfluencer;
622}
623
624
627 return myInfluencer;
628}
629
630
631
632/* -------------------------------------------------------------------------
633 * methods of MSPerson::Influencer
634 * ----------------------------------------------------------------------- */
636
637
639
640
641void
642MSPerson::Influencer::setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t) {
643 myRemoteXYPos = xyPos;
644 myRemoteLane = l;
645 myRemotePos = pos;
646 myRemotePosLat = posLat;
647 myRemoteAngle = angle;
648 myRemoteEdgeOffset = edgeOffset;
649 myRemoteRoute = route;
650 myLastRemoteAccess = t;
651}
652
653
654bool
656 return myLastRemoteAccess == MSNet::getInstance()->getCurrentTimeStep();
657}
658
659
660bool
662 return myLastRemoteAccess >= t - TIME2STEPS(10);
663}
664
665
666void
668 /*
669 std::cout << SIMTIME << " moveToXY person=" << p->getID()
670 << " xyPos=" << myRemoteXYPos
671 << " lane=" << Named::getIDSecure(myRemoteLane)
672 << " pos=" << myRemotePos
673 << " posLat=" << myRemotePosLat
674 << " angle=" << myRemoteAngle
675 << " eOf=" << myRemoteEdgeOffset
676 << " route=" << toString(myRemoteRoute)
677 << " aTime=" << time2string(myLastRemoteAccess)
678 << "\n";
679 */
680 switch (p->getStageType(0)) {
683 assert(s != nullptr);
684 s->getState()->moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
685 MSNet::getInstance()->getCurrentTimeStep());
686 }
687 break;
688 default:
689 break;
690 }
691}
692
693
694/****************************************************************************/
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:268
#define TL(string)
Definition: MsgHandler.h:284
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:82
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:1086
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:314
double getLength() const
Returns the lane's length.
Definition: MSLane.h:593
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:293
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:745
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:471
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:320
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1159
static const int BACKWARD
Definition: MSPModel.h:120
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:54
static const int FORWARD
Definition: MSPModel.h:119
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:121
static const double UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
Definition: MSPModel.h:130
Changes the wished person speed and position.
Definition: MSPerson.h:285
void postProcessRemoteControl(MSPerson *p)
Definition: MSPerson.cpp:667
Influencer()
Constructor.
Definition: MSPerson.cpp:635
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:642
~Influencer()
Destructor.
Definition: MSPerson.cpp:638
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:661
bool isRemoteControlled() const
Definition: MSPerson.cpp:655
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:509
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:480
double getSpeed() const
the speed of the person in this stage
Definition: MSPerson.cpp:492
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
Definition: MSPerson.cpp:438
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:497
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:458
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:486
std::string getStageDescription(const bool isPerson) const
returns the stage description as a string
Definition: MSPerson.cpp:468
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:474
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
Definition: MSPerson.cpp:281
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:256
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:151
double computeAverageSpeed() const
Definition: MSPerson.cpp:157
double walkDistance(bool partial=false) const
compute total walking distance
Definition: MSPerson.cpp:172
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:320
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:399
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
Definition: MSPerson.cpp:421
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:404
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:107
void activateEntryReminders(MSTransportable *person)
Definition: MSPerson.cpp:379
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
Definition: MSPerson.cpp:369
int getRoutePosition() const
return index of current edge within route
Definition: MSPerson.cpp:393
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:56
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:145
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
Definition: MSPerson.cpp:414
bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
Definition: MSPerson.cpp:535
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:337
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:580
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:592
double myChosenSpeedFactor
Definition: MSPerson.h:339
bool isJammed() const
whether the person is jammed as defined by the current pedestrian model
Definition: MSPerson.cpp:163
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSPerson.h:328
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:529
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:617
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:561
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:522
static SumoRNG * getParsingRNG()
get parsing RNG
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:109
static RandomDistributor< ConstMSRoutePtr > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:161
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.
Position getCenterPos() const
the position in the middle of the stop shape
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.
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:186
virtual const MSLane * getLane() const
whether the transportable is jammed
Definition: MSPModel.h:207
virtual bool isJammed() const
whether the transportable is jammed
Definition: MSPModel.h:202
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:254
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:254
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:86