51 #define DEBUGCOND(PED) ((PED).myPerson->isSelected())
52 #define DEBUGCOND2(LANE) ((LANE)->isSelected())
57 for (
int i = 0; i < (int)obs.size(); ++i) {
59 <<
"(" << obs[i].description
60 <<
" x=(" << obs[i].xBack <<
"," << obs[i].xFwd
61 <<
") s=" << obs[i].speed
113 myNumActivePedestrians(0),
120 WRITE_WARNINGF(
"Pedestrian vType '%' width % is larger than pedestrian.striping.stripe-width and this may cause collisions with vehicles.",
172 const std::vector<MSLane*>& departLanes = person->
getEdge()->
getLanes();
174 if ((
int)departLanes.size() <= laneIndex || !departLanes[laneIndex]->allowsVehicleClass(transportable->
getVClass())) {
175 std::string error =
"Invalid departLane '" +
toString(laneIndex) +
"' for person '" + person->
getID() +
"'";
183 lane = departLanes[laneIndex];
186 if (lane ==
nullptr) {
187 std::string error =
"Person '" + person->
getID() +
"' could not find sidewalk on edge '" + person->
getEdge()->
getID() +
"', time="
220 const MSLane* lane =
dynamic_cast<PState*
>(state)->myLane;
222 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
224 pedestrians.erase(it);
234 double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
236 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
237 const PState& ped = **it_ped;
239 const double leaderBackDist = leaderFrontDist + ped.
getLength();
242 <<
" vehSide=" << vehSide
243 <<
" vehWidth=" << vehWidth
244 <<
" lBD=" << leaderBackDist
245 <<
" lFD=" << leaderFrontDist
248 if (leaderBackDist >= -vehWidth
249 && (leaderFrontDist < 0
254 if (collectBlockers ==
nullptr) {
257 collectBlockers->push_back(ped.
myPerson);
261 if (collectBlockers ==
nullptr) {
264 return collectBlockers->size() > 0;
288 double closest = std::numeric_limits<double>::max();
290 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
291 const PState& ped = **it_ped;
294 if (ped.
myRelX > minPos && (result.first == 0 || closest > relX2)) {
297 const bool overlap = (center + halfWidth > minRight && center - halfWidth < maxLeft);
299 std::cout <<
" nextBlocking lane=" << lane->
getID()
300 <<
" minPos=" << minPos <<
" minRight=" << minRight <<
" maxLeft=" << maxLeft
301 <<
" stopTime=" << stopTime
304 <<
" relX2=" << relX2
305 <<
" center=" << center
306 <<
" pedLeft=" << center + halfWidth
307 <<
" pedRight=" << center - halfWidth
308 <<
" overlap=" << overlap
341 if (from ==
nullptr || to ==
nullptr) {
343 }
else if (from->
getLinkTo(to) !=
nullptr) {
345 }
else if (to->
getLinkTo(from) !=
nullptr) {
363 for (
MSLink* link : lane->getLinkCont()) {
364 if (link->getWalkingAreaFoe() !=
nullptr) {
366 myWalkingAreaFoes[&link->getWalkingAreaFoe()->getEdge()].push_back(link->getLaneBefore());
369 if (link->getWalkingAreaFoeExit() !=
nullptr) {
371 myWalkingAreaFoes[&link->getWalkingAreaFoeExit()->getEdge()].push_back(link->getLaneBefore());
383 const MSLane* walkingArea = getSidewalk<MSEdge, MSLane>(edge);
387 std::vector<const MSLane*> lanes;
389 if (!in->isTazConnector()) {
390 lanes.push_back(getSidewalk<MSEdge, MSLane>(in));
391 if (lanes.back() ==
nullptr) {
392 throw ProcessError(
"Invalid connection from edge '" + in->getID() +
"' to walkingarea edge '" + edge->
getID() +
"'");
397 if (!out->isTazConnector()) {
398 lanes.push_back(getSidewalk<MSEdge, MSLane>(out));
399 if (lanes.back() ==
nullptr) {
400 throw ProcessError(
"Invalid connection from walkingarea edge '" + edge->
getID() +
"' to edge '" + out->getID() +
"'");
405 for (
int j = 0; j < (int)lanes.size(); ++j) {
406 for (
int k = 0; k < (int)lanes.size(); ++k) {
409 const MSLane*
const from = lanes[j];
410 const MSLane*
const to = lanes[k];
416 const double maxExtent = fromPos.
distanceTo2D(toPos) / 4;
417 const double extrapolateBy =
MIN2(maxExtent, walkingArea->
getWidth() / 2);
419 shape.push_back(fromPos);
420 if (extrapolateBy > POSITION_EPS) {
429 if (shape.size() < 2) {
433 assert(shape.size() == 2);
453 std::vector<const MSLane*> lanes;
455 lanes.push_back(getSidewalk<MSEdge, MSLane>(pred));
458 lanes.push_back(getSidewalk<MSEdge, MSLane>(succ));
460 if (lanes.size() < 1) {
461 throw ProcessError(
"Invalid walkingarea '" + walkingArea->
getID() +
"' does not allow continuation.");
469 const MSLane* swBefore = getSidewalk<MSEdge, MSLane>(before);
470 const MSLane* swAfter = getSidewalk<MSEdge, MSLane>(after);
473 return &pathIt->second;
477 bool useBefore = swBefore !=
nullptr && std::find(preds.begin(), preds.end(), before) != preds.end();
478 bool useAfter = swAfter !=
nullptr && std::find(succs.begin(), succs.end(), after) != succs.end();
482 }
else if (succs.size() > 0) {
484 return getWalkingAreaPath(walkingArea, swBefore, getSidewalk<MSEdge, MSLane>(succs.front()));
486 }
else if (useAfter && preds.size() > 0) {
488 return getWalkingAreaPath(walkingArea, getSidewalk<MSEdge, MSLane>(preds.front()), swAfter);
499 return &pathIt->second;
503 if (preds.size() > 0) {
505 const auto pathIt2 =
myWalkingAreaPaths.find(std::make_pair(getSidewalk<MSEdge, MSLane>(pred), after));
507 return &pathIt2->second;
523 const MSLane* nextLane = nextRouteLane;
524 const MSLink* link =
nullptr;
530 if (nextRouteLane ==
nullptr && nextRouteEdge !=
nullptr) {
531 std::string error =
"Person '" + ped.
myPerson->
getID() +
"' could not find sidewalk on edge '" + nextRouteEdge->
getID() +
"', time="
535 nextRouteLane = nextRouteEdge->
getLanes().front();
541 if (nextRouteLane !=
nullptr) {
546 nextLane = currentLane->
getLinkCont()[0]->getViaLaneOrLane();
551 std::cout <<
" internal\n";
556 nextLane = currentLane->
getLinkCont()[0]->getLane();
561 std::cout <<
" crossing\n";
568 const double arrivalPos = (nextRouteEdge == ped.
myStage->
getRoute().back()
572 if (prevLane !=
nullptr) {
573 prohibited.push_back(&prevLane->
getEdge());
578 <<
" nre=" << nextRouteEdge->
getID()
579 <<
" nreDir=" << nextRouteEdgeDir
580 <<
" aPos=" << arrivalPos
581 <<
" crossingRoute=" <<
toString(crossingRoute)
584 if (crossingRoute.size() > 1) {
585 const MSEdge* nextEdge = crossingRoute[1];
586 nextLane = getSidewalk<MSEdge, MSLane>(crossingRoute[1], ped.
myPerson->
getVClass());
588 assert(nextLane != prevLane);
591 std::cout <<
" nextDir=" << nextDir <<
"\n";
600 link = oppositeWalkingArea->
getLinkTo(nextLane);
603 assert(link !=
nullptr);
607 <<
" no route from '" << (currentEdge ==
nullptr ?
"NULL" : currentEdge->
getID())
608 <<
"' to '" << (nextRouteEdge ==
nullptr ?
"NULL" : nextRouteEdge->
getID())
612 +
"' from walkingArea '" + currentEdge->
getID()
613 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
616 nextLane = nextRouteLane;
618 }
else if (currentEdge == nextRouteEdge) {
620 nextDir = -ped.
myDir;
625 if (nextLane !=
nullptr) {
628 std::cout <<
" next walkingArea " << (nextDir ==
FORWARD ?
"forward" :
"backward") <<
"\n";
636 link = currentLane->
getLinkTo(nextRouteLane);
637 if (link !=
nullptr) {
639 std::cout <<
" direct forward\n";
644 link = nextRouteLane->
getLinkTo(currentLane);
645 if (link !=
nullptr) {
647 std::cout <<
" direct backward\n";
650 if (nextLane !=
nullptr) {
652 while (nextLane->
getLinkCont()[0]->getViaLaneOrLane()->isInternal()) {
653 nextLane = nextLane->
getLinkCont()[0]->getViaLaneOrLane();
659 if (nextLane ==
nullptr) {
661 nextLane = nextRouteLane;
663 std::cout <<
SIMTIME <<
" no next lane found for " << currentLane->
getID() <<
" dir=" << ped.
myDir <<
"\n";
667 +
"' from edge '" + currentEdge->
getID()
668 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
671 }
else if (nextLane->
getLength() <= POSITION_EPS) {
683 nextLane = nextRouteLane;
692 <<
" l=" << currentLane->
getID()
693 <<
" nl=" << (nextLane ==
nullptr ?
"NULL" : nextLane->
getID())
694 <<
" nrl=" << (nextRouteLane ==
nullptr ?
"NULL" : nextRouteLane->
getID())
697 <<
" pedDir=" << ped.
myDir
700 assert(nextLane != 0 || nextRouteLane == 0);
709 if (l->getLane()->getEdge().isWalkingArea()) {
715 const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->
getIncomingLanes();
716 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
717 if ((*it).lane->getEdge().isWalkingArea()) {
718 link = (*it).viaLink;
729 const PState& ego = *pedestrians[egoIndex];
730 const int egoStripe = ego.
stripe();
732 std::vector<bool> haveBlocker(stripes,
false);
733 for (
int index = egoIndex + 1; index < (int)pedestrians.size(); index++) {
734 const PState& p = *pedestrians[index];
736 std::cout <<
SIMTIME <<
" ped=" << ego.
getID() <<
" cur=" << egoStripe <<
" checking neighbor " << p.
getID()
742 std::cout <<
" dist=" << ego.
distanceTo(o) << std::endl;
750 haveBlocker[p.
stripe()] =
true;
761 if (!haveBlocker[p.
stripe()]) {
780 int offset = (destStripes - origStripes) / 2;
782 offset += (destStripes - origStripes) % 2;
790 MSLane* lane,
const MSLane* nextLane,
int stripes,
int nextDir,
791 double currentLength,
int currentDir) {
792 if (nextLanesObs.count(nextLane) == 0) {
799 const int offset =
getStripeOffset(nextStripes, stripes, currentDir != nextDir && nextStripes > stripes);
810 if (nextStripes < stripes) {
812 for (
int ii = 0; ii < stripes; ++ii) {
813 if (ii < offset || ii >= nextStripes + offset) {
824 if ((stripes - nextStripes) % 2 != 0) {
827 nextDir = currentDir;
829 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
830 PState& p = *pedestrians[ii];
835 const double newY = relPos.
y() + lateral_offset;
846 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(nextDir));
847 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
848 const PState& p = *pedestrians[ii];
854 if (nextDir != currentDir) {
859 const int stripe = p.
stripe(newY);
860 if (stripe >= 0 && stripe < stripes) {
864 if (otherStripe >= 0 && otherStripe < stripes) {
865 obs[otherStripe] = pObs;
880 nextLanesObs[nextLane] = obs;
882 return nextLanesObs[nextLane];
887 for (
int ii = 0; ii < (int)obs.size(); ++ii) {
891 o.
xFwd += currentLength;
892 o.
xBack += currentLength;
894 const double tmp = o.
xFwd;
895 o.
xFwd = currentLength + nextLength - o.
xBack;
896 o.
xBack = currentLength + nextLength - tmp;
900 const double tmp = o.
xFwd;
904 o.
xFwd -= nextLength;
905 o.
xBack -= nextLength;
915 if ((dir ==
FORWARD && x - width / 2. < obs[stripe].xBack) || (dir ==
BACKWARD && x + width / 2. > obs[stripe].xFwd)) {
916 obs[stripe] =
Obstacle(x, 0, type,
id, width);
924 const MSLane* lane = it_lane->first;
926 if (pedestrians.size() == 0) {
932 const double minY =
stripeWidth * - 0.5 + NUMERICAL_EPS;
937 std::set<const WalkingAreaPath*, walkingarea_path_sorter> paths;
938 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
941 if (p->
myDir == dir) {
945 std::cout <<
SIMTIME <<
" debugging WalkingAreaPath from=" << debugPath->from->getID() <<
" to=" << debugPath->to->getID() <<
" minY=" << minY <<
" maxY=" << maxY <<
" latOffset=" << lateral_offset <<
"\n";
950 for (std::set<const WalkingAreaPath*, walkingarea_path_sorter>::iterator it = paths.begin(); it != paths.end(); ++it) {
954 transformedPeds.reserve(pedestrians.size());
955 for (Pedestrians::iterator it_p = pedestrians.begin(); it_p != pedestrians.end(); ++it_p) {
958 transformedPeds.push_back(p);
959 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord="
964 transformedPeds.push_back(p);
965 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord="
975 toDelete.push_back(tp);
976 transformedPeds.push_back(tp);
977 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (semi-transformed), vecCoord="
982 const double newY = relPos.
y() + lateral_offset;
991 toDelete.push_back(tp);
992 transformedPeds.push_back(tp);
993 if (path == debugPath) {
994 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (transformed), vecCoord=" << relPos <<
"\n";
997 if (path == debugPath) {
998 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (invalid), vecCoord=" << relPos <<
"\n";
1008 for (
const MSLane* foeLane : itFoe->second) {
1014 const double centerX = (relPos.
x() + relPos2.
x()) / 2;
1018 if (angleDiff >
M_PI / 2) {
1019 angleDiff =
M_PI - angleDiff;
1023 if (b <= veh->getVehicleType().getLength()) {
1025 xWidth = sqrt(a * a + b * b);
1032 relPos.
setx(centerX);
1033 relPos2.
setx(centerX);
1034 if (relPos.
y() < relPos2.
y()) {
1035 relPos.
sety(relPos.
y() - correctY);
1036 relPos2.
sety(relPos2.
y() + correctY);
1038 relPos.
sety(relPos.
y() + correctY);
1039 relPos2.
sety(relPos2.
y() - correctY);
1041 if (path == debugPath) {
1042 std::cout <<
" veh=" << veh->
getID()
1045 <<
" shapeAngle=" <<
RAD2DEG(shapeAngle)
1046 <<
" angleDiff=" <<
RAD2DEG(angleDiff) <<
" b=" << b <<
" xWidth=" << xWidth
1047 <<
" correctY=" << correctY
1048 <<
" vecCoord=" << relPos <<
" vecCoordBack=" << relPos2 <<
"\n";
1050 const bool addFront =
addVehicleFoe(veh, lane, relPos, xWidth, 0, lateral_offset, minY, maxY, toDelete, transformedPeds);
1051 const bool addBack =
addVehicleFoe(veh, lane, relPos2, xWidth, 0, lateral_offset, minY, maxY, toDelete, transformedPeds);
1052 if (addFront && addBack) {
1056 const double relDist = dist / length;
1057 Position between = (relPos * relDist) + (relPos2 * (1 - relDist));
1058 if (path == debugPath) {
1059 std::cout <<
" vehBetween=" << veh->
getID() <<
" pos=" << between <<
"\n";
1070 for (Pedestrians::iterator it_p = toDelete.begin(); it_p != toDelete.end(); ++it_p) {
1086 const double newY = relPos.
y() + lateral_offset;
1087 if (newY >= minY && newY <= maxY) {
1090 toDelete.push_back(tp);
1091 transformedPeds.push_back(tp);
1102 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
1104 for (
int i = 0; i < (int)pedestrians.size(); i++) {
1105 PState*
const p = pedestrians[i];
1112 pedestrians.erase(pedestrians.begin() + i);
1115 if (p->
myLane !=
nullptr) {
1134 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
1137 bool hasCrossingVehObs =
false;
1140 hasCrossingVehObs =
addCrossingVehs(lane, stripes, 0, dir, crossingVehs,
true);
1143 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
1144 PState& p = *pedestrians[ii];
1174 nextLanesObs, lane, nextLane, stripes,
1193 const double passingClearanceTime = 2;
1194 const double passingLength = p.
getLength() + passingClearanceTime * speed;
1205 && !link->
opened(currentTime -
DELTA_T, speed, speed, passingLength, p.
getImpatience(currentTime), speed, 0, 0,
nullptr, p.
ignoreRed(link), p.
myPerson)) {
1242 if (hasCrossingVehObs) {
1251 p.
walk(currentObs, currentTime);
1258 for (
int coll = 0; coll < ii; ++coll) {
1259 PState& c = *pedestrians[coll];
1266 +
"', lane='" + lane->
getID() +
"', time=" +
time2string(currentTime) +
".");
1279 bool hasCrossingVehObs =
false;
1284 if (linkLeaders.size() > 0) {
1285 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1287 const MSVehicle* veh = (*it).vehAndGap.first;
1288 if (veh !=
nullptr) {
1293 voBlock.
xBack = NUMERICAL_EPS;
1300 const double bGap = (prio
1302 : veh->
getSpeed() * distToCrossBeforeVeh);
1306 if ((*it).fromLeft) {
1307 vehYmin = -(*it).vehAndGap.second + lateral_offset;
1311 vehYmax = crossing->
getWidth() + (*it).vehAndGap.second - lateral_offset;
1325 hasCrossingVehObs =
true;
1330 <<
" crossingVeh=" << veh->
getID()
1331 <<
" lane=" << crossing->
getID()
1333 <<
" latOffset=" << lateral_offset
1335 <<
" stripes=" << stripes
1336 <<
" dist=" << (*it).distToCrossing
1337 <<
" gap=" << (*it).vehAndGap.second
1338 <<
" brakeGap=" << bGap
1339 <<
" fromLeft=" << (*it).fromLeft
1340 <<
" distToCrossBefore=" << distToCrossBeforeVeh
1341 <<
" ymin=" << vehYmin
1342 <<
" ymax=" << vehYmax
1351 return hasCrossingVehObs;
1366 if (ped !=
nullptr) {
1386 const double vehNextSpeed =
MAX2(veh->
getSpeed(), 1.0);
1401 if (s == current && vehFront +
SAFETY_GAP < minX) {
1403 if (pRelY - pWidth < vehYmax &&
1404 pRelY + pWidth > vehYmin && dir ==
FORWARD) {
1406 std::cout <<
" ignoring vehicle '" << veh->
getID() <<
" on stripe " << s <<
" vehFrontSG=" << vehFront +
SAFETY_GAP <<
" minX=" << minX <<
"\n";
1417 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" obstacle on lane=" << lane->
getID()
1419 <<
" ymin=" << vehYmin
1420 <<
" ymax=" << vehYmax
1423 <<
" relY=" << pRelY
1424 <<
" current=" << current
1425 <<
" vo.xFwd=" << vo.
xFwd
1426 <<
" vo.xBack=" << vo.
xBack
1442 type(OBSTACLE_NONE),
1448 xFwd(ped.getMaxX()),
1449 xBack(ped.getMinX()),
1450 speed(ped.myDir * ped.mySpeed),
1452 description(ped.getID()) {
1464 myRelX(stage->getDepartPos()),
1465 myRelY(stage->getDepartPosLat()),
1469 myWaitingToEnter(true),
1471 myWalkingAreaPath(nullptr),
1474 myAngle(std::numeric_limits<double>::max()) {
1477 assert(!route.empty());
1478 if (route.size() == 1) {
1484 if (route.front()->isWalkingArea()) {
1491 std::cout <<
" initialize dir for " <<
myPerson->
getID() <<
" forward=" << mayStartForward <<
" backward=" << mayStartBackward <<
"\n";
1493 if (mayStartForward && mayStartBackward) {
1497 if (crossingRoute.size() > 1) {
1499 const MSEdge* nextEdge = crossingRoute[1];
1505 std::cout <<
" crossingRoute=" <<
toString(crossingRoute) <<
"\n";
1536 myWaitingToEnter(false),
1538 myWalkingAreaPath(nullptr),
1541 myAngle(std::numeric_limits<double>::max()) {
1549 myWalkingAreaPath(nullptr),
1551 myAngle(std::numeric_limits<double>::max()) {
1552 if (in !=
nullptr) {
1554 std::string wapLaneFrom;
1555 std::string wapLaneTo;
1556 std::string nextLaneID;
1557 std::string nextLinkFrom;
1558 std::string nextLinkTo;
1563 >> wapLaneFrom >> wapLaneTo
1573 throw ProcessError(
"Unknown lane '" + laneID +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1576 MSLane* nextLane =
nullptr;
1577 if (nextLaneID !=
"null") {
1579 if (nextLane ==
nullptr) {
1580 throw ProcessError(
"Unknown next lane '" + nextLaneID +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1583 const MSLink* link =
nullptr;
1584 if (nextLinkFrom !=
"null") {
1587 if (from ==
nullptr) {
1588 throw ProcessError(
"Unknown link origin lane '" + nextLinkFrom +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1590 if (to ==
nullptr) {
1591 throw ProcessError(
"Unknown link destination lane '" + nextLinkTo +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1597 if (wapLaneFrom !=
"null") {
1600 if (from ==
nullptr) {
1601 throw ProcessError(
"Unknown walkingAreaPath origin lane '" + wapLaneFrom +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1603 if (to ==
nullptr) {
1604 throw ProcessError(
"Unknown walkingAreaPath destination lane '" + wapLaneTo +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1610 throw ProcessError(
"Unknown walkingAreaPath from lane '" + wapLaneFrom +
"' to lane '" + wapLaneFrom +
"' wawhen loading walk for person '" +
myPerson->
getID() +
"' from state.");
1618 std::string wapLaneFrom =
"null";
1619 std::string wapLaneTo =
"null";
1620 if (myWalkingAreaPath !=
nullptr) {
1621 wapLaneFrom = myWalkingAreaPath->from->getID();
1622 wapLaneTo = myWalkingAreaPath->to->getID();
1624 std::string nextLaneID =
"null";
1625 std::string nextLinkFrom =
"null";
1626 std::string nextLinkTo =
"null";
1627 if (myNLI.lane !=
nullptr) {
1628 nextLaneID = myNLI.lane->getID();
1630 if (myNLI.link !=
nullptr) {
1631 nextLinkFrom = myNLI.link->getLaneBefore()->getID();
1632 nextLinkTo = myNLI.link->getViaLaneOrLane()->getID();
1634 out <<
" " << myLane->getID()
1639 <<
" " << mySpeedLat
1640 <<
" " << myWaitingToEnter
1641 <<
" " << myWaitingTime
1642 <<
" " << wapLaneFrom
1644 <<
" " << myAmJammed
1645 <<
" " << nextLaneID
1646 <<
" " << nextLinkFrom
1647 <<
" " << nextLinkTo
1648 <<
" " << myNLI.dir;
1655 return myRelX - getLength();
1657 return myRelX - (includeMinGap ? getMinGap() : 0.);
1665 return myRelX + (includeMinGap ? getMinGap() : 0.);
1667 return myRelX + getLength();
1673 return myPerson->getVehicleType().getLength();
1679 return myPerson->getVehicleType().getMinGap();
1691 const int s = stripe(relY);
1695 if (offset > threshold) {
1697 }
else if (offset < -threshold) {
1722 if (myStage->getNextRouteEdge() ==
nullptr) {
1723 return myDir * (myStage->getArrivalPos() - myRelX) - POSITION_EPS;
1725 const double length = myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length;
1726 return myDir ==
FORWARD ? length - myRelX : myRelX;
1733 double dist = distToLaneEnd();
1735 std::cout <<
SIMTIME <<
" ped=" << myPerson->getID() <<
" myRelX=" << myRelX <<
" dist=" << dist <<
"\n";
1743 const int oldDir = myDir;
1744 const MSLane* oldLane = myLane;
1745 myLane = myNLI.lane;
1747 const bool normalLane = (myLane ==
nullptr || myLane->getEdge().getFunction() ==
SumoXMLEdgeFunc::NORMAL || &myLane->getEdge() == myStage->getNextRouteEdge());
1750 <<
" ped=" << myPerson->getID()
1751 <<
" moveToNextLane old=" << oldLane->
getID()
1752 <<
" new=" << (myLane ==
nullptr ?
"NULL" : myLane->getID())
1753 <<
" oldDir=" << oldDir
1754 <<
" newDir=" << myDir
1755 <<
" myRelX=" << myRelX
1759 if (myLane ==
nullptr) {
1760 myRelX = myStage->getArrivalPos();
1763 if (myStage->getRouteStep() == myStage->getRoute().end() - 1) {
1766 const bool arrived = myStage->moveToNextEdge(myPerson, currentTime, oldDir, normalLane ?
nullptr : &myLane->getEdge());
1771 assert(myNLI.lane != oldLane);
1773 std::cout <<
" nextLane=" << (myNLI.lane ==
nullptr ?
"NULL" : myNLI.lane->getID()) <<
"\n";
1775 if (myLane->getEdge().isWalkingArea()) {
1778 assert(myWalkingAreaPath->shape.size() >= 2);
1780 std::cout <<
" mWAPath shape=" << myWalkingAreaPath->shape <<
" length=" << myWalkingAreaPath->length <<
"\n";
1786 const MSEdge* currRouteEdge = *myStage->getRouteStep();
1787 const MSEdge* nextRouteEdge = myStage->getNextRouteEdge();
1795 myStage->moveToNextEdge(myPerson, currentTime, oldDir,
nullptr);
1796 myLane = myNLI.lane;
1797 assert(myLane != 0);
1800 myWalkingAreaPath =
nullptr;
1802 throw ProcessError(
"Disconnected walk for person '" + myPerson->getID() +
"'.");
1806 myWalkingAreaPath =
nullptr;
1811 const double newLength = (myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length);
1812 if (-dist > newLength) {
1819 myRelX = newLength + dist;
1824 std::cout <<
SIMTIME <<
" update myRelX ped=" << myPerson->getID()
1825 <<
" newLength=" << newLength
1827 <<
" myRelX=" << myRelX
1831 if (myDir != oldDir) {
1838 std::cout <<
SIMTIME <<
" transformY ped=" << myPerson->getID()
1840 <<
" newY=" << myRelY
1842 <<
" od=" << oldDir <<
" nd=" << myDir
1843 <<
" offset=" << offset <<
"\n";
1846 myAngle = std::numeric_limits<double>::max();
1855 const int stripes = (int)obs.size();
1856 const int sMax = stripes - 1;
1858 const double vMax = myStage->getMaxSpeed(myPerson);
1860 const int current = stripe();
1861 const int other = otherStripe();
1863 std::vector<double> distance(stripes);
1864 for (
int i = 0; i < stripes; ++i) {
1865 distance[i] = distanceTo(obs[i], obs[i].type ==
OBSTACLE_PED);
1868 std::vector<double> utility(stripes, 0);
1870 for (
int i = 0; i < stripes; ++i) {
1872 if (i == current && (!myWaitingToEnter || stripe() != stripe(myRelY))) {
1876 for (
int j = 0; j <= i; ++j) {
1881 for (
int j = i; j < stripes; ++j) {
1890 const bool onJunction = myLane->getEdge().isWalkingArea() || myLane->getEdge().isCrossing();
1893 for (
int i = 0; i < reserved; ++i) {
1897 for (
int i = sMax; i > sMax - reserved; --i) {
1902 for (
int i = 0; i < stripes; ++i) {
1903 if (obs[i].speed * myDir < 0) {
1906 utility[i - 1] -= 0.5;
1907 }
else if (myDir ==
BACKWARD && i < sMax) {
1908 utility[i + 1] -= 0.5;
1912 const double walkDist =
MAX2(0., distance[i]);
1914 const double expectedDist =
MIN2(vMax *
LOOKAHEAD_SAMEDIR, walkDist + obs[i].speed * myDir * lookAhead);
1915 if (expectedDist >= 0) {
1916 utility[i] += expectedDist;
1923 if (myDir ==
FORWARD && obs[0].speed < 0) {
1925 }
else if (myDir ==
BACKWARD && obs[sMax].speed > 0) {
1929 if (distance[current] > 0 && myWaitingTime == 0) {
1930 for (
int i = 0; i < stripes; ++i) {
1936 for (
int i = 0; i < stripes; ++i) {
1944 int chosen = current;
1945 for (
int i = 0; i < stripes; ++i) {
1951 const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
1952 double xDist =
MIN3(distance[current], distance[other], distance[next]);
1953 if (next != chosen) {
1956 const int nextOther = chosen < current ? current - 2 : current + 2;
1957 xDist =
MIN2(xDist, distance[nextOther]);
1960 const double preferredGap = NUMERICAL_EPS;
1962 if (xSpeed < NUMERICAL_EPS) {
1966 std::cout <<
" xSpeedPotential=" << xSpeed <<
"\n";
1973 (xDist == distance[current] && obs[current].type >=
OBSTACLE_END)
1974 || (xDist == distance[other] && obs[other].type >=
OBSTACLE_END)
1975 || (xDist == distance[next] && obs[next].type >=
OBSTACLE_END))
1981 || (sMax == 0 && obs[0].speed * myDir < 0 && myWaitingTime >
jamTimeNarrow)
1987 +
"' is jammed on edge '" + myStage->getEdge()->getID()
1993 }
else if (stripe(myRelY) >= 0 && stripe(myRelY) <= sMax) {
2017 if (fabs(yDist) > NUMERICAL_EPS) {
2018 ySpeed = (yDist > 0 ?
2024 && stripe() == stripe(myRelY)
2026 && !(myLane->getEdge().isCrossing() || myLane->getEdge().isWalkingArea())) {
2028 int stepAsideDir = myDir;
2029 if (myLane->getEdge().getLanes().size() > 1 || current > sMax / 2) {
2035 ySpeed = stepAsideDir * vMax;
2041 <<
" ped=" << myPerson->getID()
2042 <<
" edge=" << myStage->getEdge()->getID()
2046 <<
" pvx=" << mySpeed
2047 <<
" cur=" << current
2048 <<
" cho=" << chosen
2052 <<
" dawdle=" << dawdle
2056 <<
" vMax=" << myStage->getMaxSpeed(myPerson)
2057 <<
" wTime=" << myStage->getWaitingTime(currentTime)
2058 <<
" jammed=" << myAmJammed
2061 for (
int i = 0; i < stripes; ++i) {
2063 std::cout <<
" util=" << utility[i] <<
" dist=" << distance[i] <<
" o=" << o.
description;
2065 std::cout <<
" xF=" << o.
xFwd <<
" xB=" << o.
xBack <<
" v=" << o.
speed;
2068 std::cout <<
" current";
2070 if (i == other && i != current) {
2071 std::cout <<
" other";
2074 std::cout <<
" chosen";
2077 std::cout <<
" next";
2085 mySpeedLat = ySpeed;
2088 myWaitingToEnter =
false;
2093 myAngle = std::numeric_limits<double>::max();
2099 return MAX2(0.,
MIN2(1., myPerson->getVehicleType().getImpatience()
2119 return myRemoteXYPos;
2121 if (myLane ==
nullptr) {
2125 const double lateral_offset = myRelY + (
stripeWidth - myLane->getWidth()) * 0.5;
2126 if (myWalkingAreaPath ==
nullptr) {
2140 return myWalkingAreaPath->shape.positionAtOffset(myRelX, lateral_offset);
2147 if (myAngle != std::numeric_limits<double>::max()) {
2150 if (myLane ==
nullptr) {
2154 const PositionVector& shp = myWalkingAreaPath ==
nullptr ? myLane->getShape() : myWalkingAreaPath->shape;
2155 double geomX = myWalkingAreaPath ==
nullptr ? myLane->interpolateLanePosToGeometryPos(myRelX) : myRelX;
2158 angle += atan2(mySpeedLat,
MAX2(mySpeed, NUMERICAL_EPS));
2160 angle -= atan2(mySpeedLat,
MAX2(mySpeed, NUMERICAL_EPS));
2172 return myWaitingTime;
2184 return myNLI.lane ==
nullptr ? nullptr : &myNLI.lane->getEdge();
2189 double lanePosLat,
double angle,
int routeOffset,
2192 assert(p == myPerson);
2193 assert(pm !=
nullptr);
2196 const double oldX = myRelX -
SPEED2DIST(mySpeed * myDir);
2197 const double tmp = myRelX;
2199 Position oldPos = getPosition(*myStage, t);
2205 #ifdef DEBUG_MOVETOXY
2209 <<
" lane=" << lane->
getID()
2210 <<
" lanePos=" << lanePos
2211 <<
" lanePosLat=" << lanePosLat
2212 <<
" angle=" << angle
2213 <<
" routeOffset=" << routeOffset
2216 <<
" path=" << (myWalkingAreaPath ==
nullptr ?
"null" : (myWalkingAreaPath->from->getID() +
"->" + myWalkingAreaPath->to->getID())) <<
"\n";
2219 if (lane != myLane && myLane !=
nullptr) {
2223 if (lane !=
nullptr &&
2226 const MSEdge* old = myStage->getEdge();
2227 const MSLane* oldLane = myLane;
2228 if (lane != myLane) {
2232 if (edges.empty()) {
2234 myStage->setRouteIndex(myPerson, routeOffset);
2236 myStage->replaceRoute(myPerson, edges, routeOffset);
2239 myStage->moveToNextEdge(myPerson, t, myDir, &lane->
getEdge());
2245 if (myWalkingAreaPath ==
nullptr || myWalkingAreaPath->lane != lane) {
2247 myWalkingAreaPath =
guessPath(&lane->
getEdge(), old, myStage->getNextRouteEdge());
2248 #ifdef DEBUG_MOVETOXY
2250 <<
" path=" << myWalkingAreaPath->from->getID() <<
"->" << myWalkingAreaPath->to->getID() <<
"\n";
2255 const Position relPos = myWalkingAreaPath->shape.transformToVectorCoordinates(pos);
2258 myRemoteXYPos = pos;
2260 myRelX = relPos.
x();
2261 myRelY = lateral_offset + relPos.
y();
2264 myWalkingAreaPath =
nullptr;
2266 myRelY = lateral_offset - lanePosLat;
2270 if (myStage->getNextRouteEdge() !=
nullptr) {
2271 if (myStage->getEdge()->getToJunction() == myStage->getNextRouteEdge()->getFromJunction() ||
2272 myStage->getEdge()->getToJunction() == myStage->getNextRouteEdge()->getToJunction()) {
2279 if (angleDiff <= 90) {
2290 if (oldLane ==
nullptr || &oldLane->
getEdge() != &myLane->getEdge()) {
2291 const MSLane* sidewalk = getSidewalk<MSEdge, MSLane>(&myLane->getEdge(), p->
getVClass());
2294 myNLI =
getNextLane(*
this, sidewalk ==
nullptr ? myLane : sidewalk,
nullptr);
2295 #ifdef DEBUG_MOVETOXY
2296 std::cout <<
" myNLI=" <<
Named::getIDSecure(myNLI.lane) <<
" link=" << (myNLI.link ==
nullptr ?
"NULL" : myNLI.link->getDescription()) <<
" dir=" << myNLI.dir <<
"\n";
2299 #ifdef DEBUG_MOVETOXY
2300 std::cout <<
" newRelPos=" <<
Position(myRelX, myRelY) <<
" edge=" << myPerson->getEdge()->getID() <<
" newPos=" << myPerson->getPosition()
2301 <<
" oldAngle=" << oldAngle <<
" angleDiff=" << angleDiff <<
" newDir=" << myDir <<
"\n";
2303 if (oldLane == myLane) {
2311 myRemoteXYPos = pos;
2331 const double maxX = getMaxX(includeMinGap);
2332 const double minX = getMinX(includeMinGap);
2336 if ((obs.
xFwd >= maxX && obs.
xBack <= maxX) || (obs.
xFwd <= maxX && obs.
xFwd >= minX)) {
2350 for (
int i = 0; i < (int)into.size(); ++i) {
2352 std::cout <<
" i=" << i <<
" maxX=" << getMaxX(
true) <<
" minX=" << getMinX(
true)
2353 <<
" into=" << into[i].description <<
" iDist=" << distanceTo(into[i], into[i].type ==
OBSTACLE_PED)
2354 <<
" obs2=" << obs2[i].description <<
" oDist=" << distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED) <<
"\n";
2356 const double dO = distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED);
2357 const double dI = distanceTo(into[i], into[i].type ==
OBSTACLE_PED);
2372 for (
int i = 0; i < (int)into.size(); ++i) {
2373 int i2 = i + offset;
2374 if (i2 >= 0 && i2 < (
int)obs2.size()) {
2376 if (obs2[i2].xBack < into[i].xBack) {
2380 if (obs2[i2].xFwd > into[i].xFwd) {
2393 if (ignoreRedTime >= 0) {
2396 std::cout <<
SIMTIME <<
" ignoreRedTime=" << ignoreRedTime <<
" redDuration=" << redDuration <<
"\n";
2398 return ignoreRedTime > redDuration;
2409 return myPerson->getID();
2414 return myPerson->getVehicleType().getWidth();
2420 return myPerson->hasInfluencer() && myPerson->getInfluencer().isRemoteControlled();
2428 myVehicle(veh), myXWidth(xWidth), myYWidth(yWidth) {
2436 return myVehicle->getID();
2460 std::set<MSPerson*> changedLane;
2461 myModel->moveInDirection(currentTime, changedLane,
FORWARD);
2462 myModel->moveInDirection(currentTime, changedLane,
BACKWARD);
2465 for (ActiveLanes::const_iterator it_lane = myModel->getActiveLanes().begin(); it_lane != myModel->getActiveLanes().end(); ++it_lane) {
2466 const MSLane* lane = it_lane->first;
2468 if (pedestrians.size() == 0) {
2473 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
2474 const PState& p = *pedestrians[ii];
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
std::pair< const MSPerson *, double > PersonDist
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_PEDTYPE_ID
@ SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME
bool gDebugFlag1
global utility flags for debugging
#define UNUSED_PARAMETER(x)
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static double naviDegree(const double angle)
static double fromNaviDegree(const double angle)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
A road/street connecting two junctions.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
bool isCrossing() const
return whether this edge is a pedestrian crossing
const MSEdgeVector & getPredecessors() const
bool isWalkingArea() const
return whether this edge is walking area
bool isNormal() const
return whether this edge is an internal edge
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSJunction * getFromJunction() const
double getLength() const
return the length of the edge
bool isInternal() const
return whether this edge is an internal edge
const MSJunction * getToJunction() const
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gCheck4Accidents
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
The base class for an intersection.
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
Representation of a lane in the micro simulation.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
double getLength() const
Returns the lane's length.
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
MSLane * getCanonicalSuccessorLane() const
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSEdge & getEdge() const
Returns the lane's edge.
const PositionVector & getShape() const
Returns this lane's shape.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
double getWidth() const
Returns the lane's width.
SUMOTime getLastStateChange() const
MSLane * getLane() const
Returns the connected lane.
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
bool havePriority() const
Returns whether this link is a major link.
const LinkLeaders getLeaderInfo(const MSVehicle *ego, double dist, std::vector< const MSPerson * > *collectBlockers=0, bool isShadowLink=false) const
Returns all potential link leaders (vehicles on foeLanes) Valid during the planMove() phase.
std::vector< LinkLeader > LinkLeaders
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr) const
Returns the information whether the link may be passed.
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool hasPedestrianNetwork() const
return whether the network contains walkingareas and crossings
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
MSPedestrianRouter & getPedestrianRouter(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
virtual MSTransportableControl & getPersonControl()
Returns the person control.
bool hasInternalLinks() const
return whether the network contains internal links
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Container for pedestrian state and individual position update function.
virtual double getMaxX(const bool includeMinGap=true) const
return the maximum position on the lane
bool isJammed() const
whether the transportable is jammed
bool myAmJammed
whether the person is jammed
Position myRemoteXYPos
remote-controlled position
bool myWaitingToEnter
whether the pedestrian is waiting to start its walk
const WalkingAreaPath * myWalkingAreaPath
the current walkingAreaPath or 0
SUMOTime getWaitingTime(const MSStageMoving &stage, SUMOTime now) const
return the time the transportable spent standing
PState()
constructor for PStateVehicle
double myRelX
the advancement along the current lane
double distToLaneEnd() const
the absolute distance to the end of the lane in walking direction (or to the arrivalPos)
int myDir
the walking direction on the current lane (1 forward, -1 backward)
double myRelY
the orthogonal shift on the current lane
void mergeObstacles(Obstacles &into, const Obstacles &obs2)
replace obstacles in the first vector with obstacles from the second if they are closer to me
bool isRemoteControlled() const
whether the person is currently being controlled via TraCI
const MSEdge * getNextEdge(const MSStageMoving &stage) const
return the list of internal edges if the transportable is on an intersection
void walk(const Obstacles &obs, SUMOTime currentTime)
perform position update
virtual double getWidth() const
return the person width
double mySpeed
the current walking speed
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
int getDirection(const MSStageMoving &stage, SUMOTime now) const
return the walking direction (FORWARD, BACKWARD)
bool ignoreRed(const MSLink *link) const
whether the pedestrian may ignore a red light
virtual double getMinX(const bool includeMinGap=true) const
return the minimum position on the lane
bool moveToNextLane(SUMOTime currentTime)
return whether this pedestrian has passed the end of the current lane and update myRelX if so
double mySpeedLat
the current lateral walking speed
double getMinGap() const
return the minimum gap of the pedestrian
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
double getSpeed(const MSStageMoving &stage) const
return the current speed of the transportable
Position getPosition(const MSStageMoving &stage, SUMOTime now) const
return the network coordinate of the transportable
NextLaneInfo myNLI
information about the upcoming lane
const MSLane * myLane
the current lane of this pedestrian
double getAngle(const MSStageMoving &stage, SUMOTime now) const
return the direction in which the transportable faces in degrees
virtual const std::string & getID() const
return the person id
double getImpatience(SUMOTime now) const
returns the impatience
SUMOTime myWaitingTime
the consecutive time spent at speed 0
double distanceTo(const Obstacle &obs, const bool includeMinGap=true) const
const MSLane * getLane() const
whether the transportable is jammed
double getEdgePos(const MSStageMoving &stage, SUMOTime now) const
abstract methods inherited from PedestrianState
double getLength() const
return the length of the pedestrian
double getWidth() const
return the person width
double getMaxX(const bool includeMinGap=true) const
return the maximum position on the lane
double getMinX(const bool includeMinGap=true) const
return the minimum position on the lane
const std::string & getID() const
return the person id
PStateVehicle(const MSVehicle *veh, const MSLane *walkingarea, double relX, double relY, double xWidth, double yWidth)
sorts the persons by position on the lane. If dir is forward, higher x positions come first.
The pedestrian following model.
static const double MIN_STARTUP_DIST
static double RESERVE_FOR_ONCOMING_FACTOR
static MinNextLengths myMinNextLengths
static bool addVehicleFoe(const MSVehicle *veh, const MSLane *walkingarea, const Position &relPos, double xWidth, double yWidth, double lateral_offset, double minY, double maxY, Pedestrians &toDelete, Pedestrians &transformedPeds)
MSTransportableStateAdapter * loadState(MSTransportable *transportable, MSStageMoving *stage, std::istringstream &in)
load the state of the given transportable
static SUMOTime jamTimeCrossing
bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
void moveInDirection(SUMOTime currentTime, std::set< MSPerson * > &changedLane, int dir)
move all pedestrians forward and advance to the next lane if applicable
static void transformToCurrentLanePositions(Obstacles &o, int currentDir, int nextDir, double currentLength, double nextLength)
static const double LOOKAHEAD_SAMEDIR
static double minGapToVehicle
static NextLaneInfo getNextLane(const PState &ped, const MSLane *currentLane, const MSLane *prevLane)
computes the successor lane for the given pedestrian and sets the link as well as the direction to us...
static void initWalkingAreaPaths(const MSNet *net)
std::vector< PState * > Pedestrians
ActiveLanes myActiveLanes
store of all lanes which have pedestrians on them
static const double LOOKAROUND_VEHICLES
static const double SQUEEZE
static SUMOTime jamTimeNarrow
static const WalkingAreaPath * getWalkingAreaPath(const MSEdge *walkingArea, const MSLane *before, const MSLane *after)
void arriveAndAdvance(Pedestrians &pedestrians, SUMOTime currentTime, std::set< MSPerson * > &changedLane, int dir)
handle arrivals and lane advancement
std::map< const MSLane *, double > MinNextLengths
static double RESERVE_FOR_ONCOMING_FACTOR_JUNCTIONS
static int getStripeOffset(int origStripes, int destStripes, bool addRemainder)
bool myAmActive
whether an event for pedestrian processing was added
static const WalkingAreaPath * guessPath(const MSEdge *walkingArea, const MSEdge *before, const MSEdge *after)
static double stripeWidth
model parameters
bool blockedAtDist(const MSLane *lane, double vehSide, double vehWidth, double oncomingGap, std::vector< const MSPerson * > *collectBlockers)
whether a pedestrian is blocking the crossing of lane for the given vehicle bondaries
static const double MAX_WAIT_TOLERANCE
static Obstacles getVehicleObstacles(const MSLane *lane, int dir, PState *ped=0)
retrieve vehicle obstacles on the given lane
static const double OBSTRUCTED_PENALTY
std::map< const MSLane *, Obstacles, lane_by_numid_sorter > NextLanesObstacles
static const MSLane * getNextWalkingArea(const MSLane *currentLane, const int dir, const MSLink *&link)
return the next walkingArea in the given direction
PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or 0
MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)
register the given person as a pedestrian
static const double DIST_OVERLAP
static const WalkingAreaPath * getArbitraryPath(const MSEdge *walkingArea)
return an arbitrary path across the given walkingArea
static const double LATERAL_PENALTY
std::vector< Obstacle > Obstacles
void remove(MSTransportableStateAdapter *state)
remove the specified person from the pedestrian simulation
static const double DIST_BEHIND
bool usingInternalLanes()
whether movements on intersections are modelled /
void moveInDirectionOnLane(Pedestrians &pedestrians, const MSLane *lane, SUMOTime currentTime, std::set< MSPerson * > &changedLane, int dir)
move pedestrians forward on one lane
MSPModel_Striping(const OptionsCont &oc, MSNet *net)
Constructor (it should not be necessary to construct more than one instance)
static bool usingInternalLanesStatic()
static Obstacles getNeighboringObstacles(const Pedestrians &pedestrians, int egoIndex, int stripes)
static Pedestrians noPedestrians
empty pedestrian vector
static void addCloserObstacle(Obstacles &obs, double x, int stripe, int numStripes, const std::string &id, double width, int dir, ObstacleType type)
Pedestrians & getPedestrians(const MSLane *lane)
retrieves the pedestian vector for the given lane (may be empty)
static int numStripes(const MSLane *lane)
return the maximum number of pedestrians walking side by side
static const double OBSTRUCTION_THRESHOLD
static bool addCrossingVehs(const MSLane *crossing, int stripes, double lateral_offset, int dir, Obstacles &crossingVehs, bool prio)
add vehicles driving across
static int connectedDirection(const MSLane *from, const MSLane *to)
returns the direction in which these lanes are connectioned or 0 if they are not
static void DEBUG_PRINT(const Obstacles &obs)
static const double LATERAL_SPEED_FACTOR
static const double INAPPROPRIATE_PENALTY
void clearState()
Resets pedestrians when quick-loading state.
static const double ONCOMING_CONFLICT_PENALTY
int myNumActivePedestrians
the total number of active pedestrians
static const double LOOKAHEAD_ONCOMING
static std::map< const MSEdge *, std::vector< const MSLane * > > myWalkingAreaFoes
const Obstacles & getNextLaneObstacles(NextLanesObstacles &nextLanesObs, const MSLane *lane, const MSLane *nextLane, int stripes, int nextDir, double currentLength, int currentDir)
static const double DIST_FAR_AWAY
std::map< std::pair< const MSLane *, const MSLane * >, const WalkingAreaPath > WalkingAreaPaths
static WalkingAreaPaths myWalkingAreaPaths
store for walkinArea elements
static const int BACKWARD
static int canTraverse(int dir, const ConstMSEdgeVector &route)
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
static const int UNDEFINED_DIRECTION
static const double SAFETY_GAP
const MSEdge * getDestination() const
returns the destination edge
virtual double getArrivalPos() const
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
virtual bool moveToNextEdge(MSTransportable *transportable, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=0)=0
move forward and return whether the transportable arrived
int getDepartLane() const
virtual const MSEdge * getNextRouteEdge() const =0
const std::vector< const MSEdge * > & getRoute() const
virtual double getMaxSpeed(const MSTransportable *const transportable=nullptr) const =0
the maximum speed of the transportable
int getNumWaitingPersons() const
get number of persons waiting at this stop
int getWaitingCapacity() const
get number of persons that can wait at this stop
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
void registerJammed()
register a jammed transportable
SUMOVehicleClass getVClass() const
Returns the object's access class.
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
bool isPerson() const
Whether it is a person.
MSStageType getCurrentStageType() const
the current stage type of the transportable
const MSEdge * getEdge() const
Returns the current edge.
abstract base class for managing callbacks to retrieve various state information from the model
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
Representation of a vehicle in the micro simulation.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
const Position getBackPosition() const
double getSpeed() const
Returns the vehicle's current speed.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getAngle() const
Returns the vehicle's direction in radians.
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getLength() const
Get vehicle's length [m].
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
double compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, std::vector< const E * > &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
void sety(double y)
set position y
double y() const
Returns the y-position.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
void push_back_noDoublePos(const Position &p)
insert in back a non double position
PositionVector reverse() const
reverse position vector
Position transformToVectorCoordinates(const Position &p, bool extend=false) const
return position p within the length-wise coordinate system defined by this position vector....
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
information regarding surround Pedestrians (and potentially other things)
double speed
speed relative to lane direction (positive means in the same direction)
double xFwd
maximal position on the current lane in forward direction
Obstacle(int dir, double dist=DIST_FAR_AWAY)
create No-Obstacle
std::string description
the id / description of the obstacle
ObstacleType type
whether this obstacle denotes a border or a pedestrian
double xBack
maximal position on the current lane in backward direction
const PositionVector shape