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
115 myNumActivePedestrians(0),
123 WRITE_WARNINGF(
TL(
"Pedestrian vType '%' width % is larger than pedestrian.striping.stripe-width and this may cause collisions with vehicles."),
176 if (lane ==
nullptr) {
177 std::string error =
"Person '" + person->
getID() +
"' could not find sidewalk on edge '" + person->
getEdge()->
getID() +
"', time="
210 const MSLane* lane =
dynamic_cast<PState*
>(state)->myLane;
212 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
214 pedestrians.erase(it);
224 double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
226 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
227 const PState& ped = **it_ped;
229 const double leaderBackDist = leaderFrontDist + ped.
getLength();
232 <<
" vehSide=" << vehSide
233 <<
" vehWidth=" << vehWidth
234 <<
" lBD=" << leaderBackDist
235 <<
" lFD=" << leaderFrontDist
238 if (leaderBackDist >= -vehWidth
239 && (leaderFrontDist < 0
244 if (collectBlockers ==
nullptr) {
247 collectBlockers->push_back(ped.
myPerson);
251 if (collectBlockers ==
nullptr) {
254 return collectBlockers->size() > 0;
279 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
280 const PState& ped = **it_ped;
283 double dist = ((relX2 - minPos) * (bidi ? -1 : 1)
285 const bool aheadOfVehicle = bidi ? ped.
myRelX < minPos : ped.
myRelX > minPos;
286 if (aheadOfVehicle && dist < result.second) {
289 const bool overlap = (center + halfWidth > minRight && center - halfWidth < maxLeft);
291 std::cout <<
" nextBlocking lane=" << lane->
getID() <<
" bidi=" << bidi
292 <<
" minPos=" << minPos <<
" minRight=" << minRight <<
" maxLeft=" << maxLeft
293 <<
" stopTime=" << stopTime
296 <<
" relX2=" << relX2
297 <<
" center=" << center
298 <<
" pedLeft=" << center + halfWidth
299 <<
" pedRight=" << center - halfWidth
300 <<
" overlap=" << overlap
305 result.second = dist;
332 if (from ==
nullptr || to ==
nullptr) {
334 }
else if (from->
getLinkTo(to) !=
nullptr) {
336 }
else if (to->
getLinkTo(from) !=
nullptr) {
354 for (
MSLink* link : lane->getLinkCont()) {
355 if (link->getWalkingAreaFoe() !=
nullptr) {
357 myWalkingAreaFoes[&link->getWalkingAreaFoe()->getEdge()].push_back(link->getLaneBefore());
360 if (link->getWalkingAreaFoeExit() !=
nullptr) {
362 myWalkingAreaFoes[&link->getWalkingAreaFoeExit()->getEdge()].push_back(link->getLaneBefore());
374 const MSLane* walkingArea = getSidewalk<MSEdge, MSLane>(edge);
378 std::vector<const MSLane*> lanes;
380 if (!in->isTazConnector()) {
381 lanes.push_back(getSidewalk<MSEdge, MSLane>(in));
382 if (lanes.back() ==
nullptr) {
383 throw ProcessError(
"Invalid connection from edge '" + in->getID() +
"' to walkingarea edge '" + edge->
getID() +
"'");
388 if (!out->isTazConnector()) {
389 lanes.push_back(getSidewalk<MSEdge, MSLane>(out));
390 if (lanes.back() ==
nullptr) {
391 throw ProcessError(
"Invalid connection from walkingarea edge '" + edge->
getID() +
"' to edge '" + out->getID() +
"'");
396 for (
int j = 0; j < (int)lanes.size(); ++j) {
397 for (
int k = 0; k < (int)lanes.size(); ++k) {
400 const MSLane*
const from = lanes[j];
401 const MSLane*
const to = lanes[k];
407 const double maxExtent = fromPos.
distanceTo2D(toPos) / 4;
408 const double extrapolateBy =
MIN2(maxExtent, walkingArea->
getWidth() / 2);
410 shape.push_back(fromPos);
411 if (extrapolateBy > POSITION_EPS) {
420 if (shape.size() < 2) {
424 assert(shape.size() == 2);
446 std::vector<const MSLane*> lanes;
448 lanes.push_back(getSidewalk<MSEdge, MSLane>(pred));
451 lanes.push_back(getSidewalk<MSEdge, MSLane>(succ));
453 if (lanes.size() < 1) {
454 throw ProcessError(
"Invalid walkingarea '" + walkingArea->
getID() +
"' does not allow continuation.");
462 const MSLane* swBefore = getSidewalk<MSEdge, MSLane>(before);
463 const MSLane* swAfter = getSidewalk<MSEdge, MSLane>(after);
466 return &pathIt->second;
470 bool useBefore = swBefore !=
nullptr && std::find(preds.begin(), preds.end(), before) != preds.end();
471 bool useAfter = swAfter !=
nullptr && std::find(succs.begin(), succs.end(), after) != succs.end();
475 }
else if (succs.size() > 0) {
477 return getWalkingAreaPath(walkingArea, swBefore, getSidewalk<MSEdge, MSLane>(succs.front()));
479 }
else if (useAfter && preds.size() > 0) {
481 return getWalkingAreaPath(walkingArea, getSidewalk<MSEdge, MSLane>(preds.front()), swAfter);
492 return &pathIt->second;
496 if (preds.size() > 0) {
498 const auto pathIt2 =
myWalkingAreaPaths.find(std::make_pair(getSidewalk<MSEdge, MSLane>(pred), after));
500 return &pathIt2->second;
516 const MSLane* nextLane = nextRouteLane;
517 const MSLink* link =
nullptr;
523 if (nextRouteLane ==
nullptr && nextRouteEdge !=
nullptr) {
524 std::string error =
"Person '" + ped.
myPerson->
getID() +
"' could not find sidewalk on edge '" + nextRouteEdge->
getID() +
"', time="
528 nextRouteLane = nextRouteEdge->
getLanes().front();
534 if (nextRouteLane !=
nullptr) {
539 nextLane = currentLane->
getLinkCont()[0]->getViaLaneOrLane();
544 std::cout <<
" internal\n";
549 nextLane = currentLane->
getLinkCont()[0]->getLane();
554 std::cout <<
" crossing\n";
561 const double arrivalPos = (nextRouteEdge == ped.
myStage->
getRoute().back()
565 if (prevLane !=
nullptr) {
566 prohibited.push_back(&prevLane->
getEdge());
571 <<
" nre=" << nextRouteEdge->
getID()
572 <<
" nreDir=" << nextRouteEdgeDir
573 <<
" aPos=" << arrivalPos
574 <<
" crossingRoute=" <<
toString(crossingRoute)
577 if (crossingRoute.size() > 1) {
578 const MSEdge* nextEdge = crossingRoute[1];
579 nextLane = getSidewalk<MSEdge, MSLane>(crossingRoute[1], ped.
myPerson->
getVClass());
581 assert(nextLane != prevLane);
584 std::cout <<
" nextDir=" << nextDir <<
"\n";
593 link = oppositeWalkingArea->
getLinkTo(nextLane);
596 assert(link !=
nullptr);
600 <<
" no route from '" << (currentEdge ==
nullptr ?
"NULL" : currentEdge->
getID())
601 <<
"' to '" << (nextRouteEdge ==
nullptr ?
"NULL" : nextRouteEdge->
getID())
605 +
"' from walkingArea '" + currentEdge->
getID()
606 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
609 nextLane = nextRouteLane;
611 }
else if (currentEdge == nextRouteEdge) {
613 nextDir = -ped.
myDir;
618 if (nextLane !=
nullptr) {
621 std::cout <<
" next walkingArea " << (nextDir ==
FORWARD ?
"forward" :
"backward") <<
"\n";
629 link = currentLane->
getLinkTo(nextRouteLane);
630 if (link !=
nullptr) {
632 std::cout <<
" direct forward\n";
637 link = nextRouteLane->
getLinkTo(currentLane);
638 if (link !=
nullptr) {
640 std::cout <<
" direct backward\n";
643 if (nextLane !=
nullptr) {
645 while (nextLane->
getLinkCont()[0]->getViaLaneOrLane()->isInternal()) {
646 nextLane = nextLane->
getLinkCont()[0]->getViaLaneOrLane();
652 if (nextLane ==
nullptr) {
654 nextLane = nextRouteLane;
656 std::cout <<
SIMTIME <<
" no next lane found for " << currentLane->
getID() <<
" dir=" << ped.
myDir <<
"\n";
660 +
"' from edge '" + currentEdge->
getID()
661 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
664 }
else if (nextLane->
getLength() <= POSITION_EPS) {
676 nextLane = nextRouteLane;
685 <<
" l=" << currentLane->
getID()
686 <<
" nl=" << (nextLane ==
nullptr ?
"NULL" : nextLane->
getID())
687 <<
" nrl=" << (nextRouteLane ==
nullptr ?
"NULL" : nextRouteLane->
getID())
690 <<
" pedDir=" << ped.
myDir
693 assert(nextLane != 0 || nextRouteLane == 0);
702 if (l->getLane()->getEdge().isWalkingArea()) {
708 const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->
getIncomingLanes();
709 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
710 if ((*it).lane->getEdge().isWalkingArea()) {
711 link = (*it).viaLink;
722 const PState& ego = *pedestrians[egoIndex];
723 const int egoStripe = ego.
stripe();
725 std::vector<bool> haveBlocker(stripes,
false);
726 for (
int index = egoIndex + 1; index < (int)pedestrians.size(); index++) {
727 const PState& p = *pedestrians[index];
729 std::cout <<
SIMTIME <<
" ped=" << ego.
getID() <<
" cur=" << egoStripe <<
" checking neighbor " << p.
getID()
735 std::cout <<
" dist=" << ego.
distanceTo(o) << std::endl;
743 haveBlocker[p.
stripe()] =
true;
754 if (!haveBlocker[p.
stripe()]) {
773 int offset = (destStripes - origStripes) / 2;
775 offset += (destStripes - origStripes) % 2;
783 MSLane* lane,
const MSLane* nextLane,
int stripes,
int nextDir,
784 double currentLength,
int currentDir) {
785 if (nextLanesObs.count(nextLane) == 0) {
792 const int offset =
getStripeOffset(nextStripes, stripes, currentDir != nextDir && nextStripes > stripes);
803 if (nextStripes < stripes) {
805 for (
int ii = 0; ii < stripes; ++ii) {
806 if (ii < offset || ii >= nextStripes + offset) {
817 if ((stripes - nextStripes) % 2 != 0) {
820 nextDir = currentDir;
822 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
823 PState& p = *pedestrians[ii];
828 const double newY = relPos.
y() + lateral_offset;
839 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(nextDir));
840 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
841 const PState& p = *pedestrians[ii];
847 if (nextDir != currentDir) {
852 const int stripe = p.
stripe(newY);
853 if (stripe >= 0 && stripe < stripes) {
857 if (otherStripe >= 0 && otherStripe < stripes) {
858 obs[otherStripe] = pObs;
873 nextLanesObs[nextLane] = obs;
875 return nextLanesObs[nextLane];
880 for (
int ii = 0; ii < (int)obs.size(); ++ii) {
884 o.
xFwd += currentLength;
885 o.
xBack += currentLength;
887 const double tmp = o.
xFwd;
888 o.
xFwd = currentLength + nextLength - o.
xBack;
889 o.
xBack = currentLength + nextLength - tmp;
893 const double tmp = o.
xFwd;
897 o.
xFwd -= nextLength;
898 o.
xBack -= nextLength;
908 if ((dir ==
FORWARD && x - width / 2. < obs[stripe].xBack) || (dir ==
BACKWARD && x + width / 2. > obs[stripe].xFwd)) {
909 obs[stripe] =
Obstacle(x, 0, type,
id, width);
917 const MSLane* lane = it_lane->first;
919 if (pedestrians.size() == 0) {
925 const double minY =
stripeWidth * - 0.5 + NUMERICAL_EPS;
930 std::set<const WalkingAreaPath*, walkingarea_path_sorter> paths;
931 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
934 if (p->
myDir == dir) {
938 std::cout <<
SIMTIME <<
" debugging WalkingAreaPath from=" << debugPath->from->getID() <<
" to=" << debugPath->to->getID() <<
" minY=" << minY <<
" maxY=" << maxY <<
" latOffset=" << lateral_offset <<
"\n";
943 for (std::set<const WalkingAreaPath*, walkingarea_path_sorter>::iterator it = paths.begin(); it != paths.end(); ++it) {
947 transformedPeds.reserve(pedestrians.size());
948 for (Pedestrians::iterator it_p = pedestrians.begin(); it_p != pedestrians.end(); ++it_p) {
951 transformedPeds.push_back(p);
952 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord="
957 transformedPeds.push_back(p);
958 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord="
968 toDelete.push_back(tp);
969 transformedPeds.push_back(tp);
970 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (semi-transformed), vecCoord="
975 const double newY = relPos.
y() + lateral_offset;
984 toDelete.push_back(tp);
985 transformedPeds.push_back(tp);
986 if (path == debugPath) {
987 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (transformed), vecCoord=" << relPos <<
"\n";
990 if (path == debugPath) {
991 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (invalid), vecCoord=" << relPos <<
"\n";
1001 for (
const MSLane* foeLane : itFoe->second) {
1007 const double centerX = (relPos.
x() + relPos2.
x()) / 2;
1011 if (angleDiff >
M_PI / 2) {
1012 angleDiff =
M_PI - angleDiff;
1016 if (b <= veh->getVehicleType().getLength()) {
1018 xWidth = sqrt(a * a + b * b);
1025 relPos.
setx(centerX);
1026 relPos2.
setx(centerX);
1027 if (relPos.
y() < relPos2.
y()) {
1028 relPos.
sety(relPos.
y() - correctY);
1029 relPos2.
sety(relPos2.
y() + correctY);
1031 relPos.
sety(relPos.
y() + correctY);
1032 relPos2.
sety(relPos2.
y() - correctY);
1034 if (path == debugPath) {
1035 std::cout <<
" veh=" << veh->
getID()
1038 <<
" shapeAngle=" <<
RAD2DEG(shapeAngle)
1039 <<
" angleDiff=" <<
RAD2DEG(angleDiff) <<
" b=" << b <<
" xWidth=" << xWidth
1040 <<
" correctY=" << correctY
1041 <<
" vecCoord=" << relPos <<
" vecCoordBack=" << relPos2 <<
"\n";
1043 const bool addFront =
addVehicleFoe(veh, lane, relPos, xWidth, 0, lateral_offset, minY, maxY, toDelete, transformedPeds);
1044 const bool addBack =
addVehicleFoe(veh, lane, relPos2, xWidth, 0, lateral_offset, minY, maxY, toDelete, transformedPeds);
1045 if (addFront && addBack) {
1049 const double relDist = dist / length;
1050 Position between = (relPos * relDist) + (relPos2 * (1 - relDist));
1051 if (path == debugPath) {
1052 std::cout <<
" vehBetween=" << veh->
getID() <<
" pos=" << between <<
"\n";
1063 for (Pedestrians::iterator it_p = toDelete.begin(); it_p != toDelete.end(); ++it_p) {
1079 const double newY = relPos.
y() + lateral_offset;
1080 if (newY >= minY && newY <= maxY) {
1083 toDelete.push_back(tp);
1084 transformedPeds.push_back(tp);
1095 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
1097 for (
int i = 0; i < (int)pedestrians.size(); i++) {
1098 PState*
const p = pedestrians[i];
1105 pedestrians.erase(pedestrians.begin() + i);
1108 if (p->
myLane !=
nullptr) {
1127 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
1130 bool hasCrossingVehObs =
false;
1133 hasCrossingVehObs =
addCrossingVehs(lane, stripes, 0, dir, crossingVehs,
true);
1136 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
1137 PState& p = *pedestrians[ii];
1167 nextLanesObs, lane, nextLane, stripes,
1186 const double passingClearanceTime = 2;
1187 const double passingLength = p.
getLength() + passingClearanceTime * speed;
1198 && !link->
opened(currentTime -
DELTA_T, speed, speed, passingLength, p.
getImpatience(currentTime), speed, 0, 0,
nullptr, p.
ignoreRed(link), p.
myPerson)) {
1235 if (hasCrossingVehObs) {
1244 p.
walk(currentObs, currentTime);
1251 for (
int coll = 0; coll < ii; ++coll) {
1252 PState& c = *pedestrians[coll];
1259 +
"', lane='" + lane->
getID() +
"', time=" +
time2string(currentTime) +
".");
1272 bool hasCrossingVehObs =
false;
1277 if (linkLeaders.size() > 0) {
1278 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1280 const MSVehicle* veh = (*it).vehAndGap.first;
1281 if (veh !=
nullptr) {
1286 voBlock.
xBack = NUMERICAL_EPS;
1293 const double bGap = (prio
1295 : veh->
getSpeed() * distToCrossBeforeVeh);
1299 if ((*it).fromLeft) {
1300 vehYmin = -(*it).vehAndGap.second + lateral_offset;
1304 vehYmax = crossing->
getWidth() + (*it).vehAndGap.second - lateral_offset;
1318 hasCrossingVehObs =
true;
1323 <<
" crossingVeh=" << veh->
getID()
1324 <<
" lane=" << crossing->
getID()
1326 <<
" latOffset=" << lateral_offset
1328 <<
" stripes=" << stripes
1329 <<
" dist=" << (*it).distToCrossing
1330 <<
" gap=" << (*it).vehAndGap.second
1331 <<
" brakeGap=" << bGap
1332 <<
" fromLeft=" << (*it).fromLeft
1333 <<
" distToCrossBefore=" << distToCrossBeforeVeh
1334 <<
" ymin=" << vehYmin
1335 <<
" ymax=" << vehYmax
1344 return hasCrossingVehObs;
1359 if (ped !=
nullptr) {
1380 const double vehNextSpeed =
MAX2(veh->
getSpeed(), 1.0);
1385 double vehXMaxCheck;
1386 double vehXMinCheck;
1390 vehXMin = vehFront - clearance;
1392 vehXMaxCheck = vehBack + NUMERICAL_EPS;
1396 vehXMinCheck = vehFront - clearance;
1399 vehXMax = vehFront + clearance;
1402 vehXMaxCheck = vehFront + clearance;
1406 vehXMinCheck = vehBack - NUMERICAL_EPS;
1410 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" check obstacle on lane=" << lane->
getID()
1412 <<
" vehXMin=" << vehXMin
1413 <<
" vehXMax=" << vehXMax
1414 <<
" vehXMinC=" << vehXMinCheck
1415 <<
" vehXMaxC=" << vehXMaxCheck
1419 <<
" vFront=" << vehFront
1420 <<
" vBack=" << vehBack
1423 if (vehXMaxCheck > minX && vehXMinCheck && vehXMinCheck <= maxX) {
1436 if (s == current && vehFront +
SAFETY_GAP < minX) {
1438 if (pRelY - pWidth < vehYmax &&
1439 pRelY + pWidth > vehYmin && dir ==
FORWARD) {
1441 std::cout <<
" ignoring vehicle '" << veh->
getID() <<
" on stripe " << s <<
" vehFrontSG=" << vehFront +
SAFETY_GAP <<
" minX=" << minX <<
"\n";
1452 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" obstacle on lane=" << lane->
getID()
1454 <<
" ymin=" << vehYmin
1455 <<
" ymax=" << vehYmax
1458 <<
" relY=" << pRelY
1459 <<
" current=" << current
1460 <<
" vo.xFwd=" << vo.
xFwd
1461 <<
" vo.xBack=" << vo.
xBack
1462 <<
" vFront=" << vehFront
1463 <<
" vBack=" << vehBack
1479 type(OBSTACLE_NONE),
1485 xFwd(ped.getMaxX()),
1486 xBack(ped.getMinX()),
1487 speed(ped.myDir * ped.mySpeed),
1488 type(ped.getOType()),
1489 description(ped.getID()) {
1501 myRelX(stage->getDepartPos()),
1502 myRelY(stage->getDepartPosLat()),
1506 myWaitingToEnter(true),
1508 myWalkingAreaPath(nullptr),
1511 myAngle(
std::numeric_limits<double>::max()) {
1514 assert(!route.empty());
1515 if (route.size() == 1) {
1521 if (route.front()->isWalkingArea()) {
1528 std::cout <<
" initialize dir for " <<
myPerson->
getID() <<
" forward=" << mayStartForward <<
" backward=" << mayStartBackward <<
"\n";
1530 if (mayStartForward && mayStartBackward) {
1534 if (crossingRoute.size() > 1) {
1536 const MSEdge* nextEdge = crossingRoute[1];
1542 std::cout <<
" crossingRoute=" <<
toString(crossingRoute) <<
"\n";
1584 myWaitingToEnter(false),
1586 myWalkingAreaPath(nullptr),
1589 myAngle(
std::numeric_limits<double>::max()) {
1597 myWalkingAreaPath(nullptr),
1599 myAngle(
std::numeric_limits<double>::max()) {
1600 if (in !=
nullptr) {
1602 std::string wapLaneFrom;
1603 std::string wapLaneTo;
1604 std::string nextLaneID;
1605 std::string nextLinkFrom;
1606 std::string nextLinkTo;
1611 >> wapLaneFrom >> wapLaneTo
1621 throw ProcessError(
"Unknown lane '" + laneID +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1624 MSLane* nextLane =
nullptr;
1625 if (nextLaneID !=
"null") {
1627 if (nextLane ==
nullptr) {
1628 throw ProcessError(
"Unknown next lane '" + nextLaneID +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1631 const MSLink* link =
nullptr;
1632 if (nextLinkFrom !=
"null") {
1635 if (from ==
nullptr) {
1636 throw ProcessError(
"Unknown link origin lane '" + nextLinkFrom +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1638 if (to ==
nullptr) {
1639 throw ProcessError(
"Unknown link destination lane '" + nextLinkTo +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1645 if (wapLaneFrom !=
"null") {
1648 if (from ==
nullptr) {
1649 throw ProcessError(
"Unknown walkingAreaPath origin lane '" + wapLaneFrom +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1651 if (to ==
nullptr) {
1652 throw ProcessError(
"Unknown walkingAreaPath destination lane '" + wapLaneTo +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1658 throw ProcessError(
"Unknown walkingAreaPath from lane '" + wapLaneFrom +
"' to lane '" + wapLaneTo +
"' when loading walk for person '" +
myPerson->
getID() +
"' from state.");
1666 std::string wapLaneFrom =
"null";
1667 std::string wapLaneTo =
"null";
1668 if (myWalkingAreaPath !=
nullptr) {
1669 wapLaneFrom = myWalkingAreaPath->from->getID();
1670 wapLaneTo = myWalkingAreaPath->to->getID();
1672 std::string nextLaneID =
"null";
1673 std::string nextLinkFrom =
"null";
1674 std::string nextLinkTo =
"null";
1675 if (myNLI.lane !=
nullptr) {
1676 nextLaneID = myNLI.lane->getID();
1678 if (myNLI.link !=
nullptr) {
1679 nextLinkFrom = myNLI.link->getLaneBefore()->getID();
1680 nextLinkTo = myNLI.link->getViaLaneOrLane()->getID();
1682 out <<
" " << myLane->getID()
1687 <<
" " << mySpeedLat
1688 <<
" " << myWaitingToEnter
1689 <<
" " << myWaitingTime
1690 <<
" " << wapLaneFrom
1692 <<
" " << myAmJammed
1693 <<
" " << nextLaneID
1694 <<
" " << nextLinkFrom
1695 <<
" " << nextLinkTo
1696 <<
" " << myNLI.dir;
1703 return myRelX - getLength();
1705 return myRelX - (includeMinGap ? getMinGap() : 0.);
1713 return myRelX + (includeMinGap ? getMinGap() : 0.);
1715 return myRelX + getLength();
1721 return myPerson->getVehicleType().getLength();
1727 return myPerson->getVehicleType().getMinGap();
1739 const int s = stripe(relY);
1743 if (offset > threshold) {
1745 }
else if (offset < -threshold) {
1770 if (myStage->getNextRouteEdge() ==
nullptr) {
1771 return myDir * (myStage->getArrivalPos() - myRelX) - POSITION_EPS - (
1772 (myWaitingTime >
DELTA_T && (myStage->getDestinationStop() ==
nullptr ||
1773 myStage->getDestinationStop()->getWaitingCapacity() > myStage->getDestinationStop()->getNumWaitingPersons()))
1776 const double length = myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length;
1777 return myDir ==
FORWARD ? length - myRelX : myRelX;
1784 double dist = distToLaneEnd();
1786 std::cout <<
SIMTIME <<
" ped=" << myPerson->getID() <<
" myRelX=" << myRelX <<
" dist=" << dist <<
"\n";
1794 const int oldDir = myDir;
1795 const MSLane* oldLane = myLane;
1796 myLane = myNLI.lane;
1798 const bool normalLane = (myLane ==
nullptr || myLane->getEdge().getFunction() ==
SumoXMLEdgeFunc::NORMAL || &myLane->getEdge() == myStage->getNextRouteEdge());
1801 <<
" ped=" << myPerson->getID()
1802 <<
" moveToNextLane old=" << oldLane->
getID()
1803 <<
" new=" << (myLane ==
nullptr ?
"NULL" : myLane->getID())
1804 <<
" oldDir=" << oldDir
1805 <<
" newDir=" << myDir
1806 <<
" myRelX=" << myRelX
1810 if (myLane ==
nullptr) {
1811 myRelX = myStage->getArrivalPos();
1814 if (myStage->getRouteStep() == myStage->getRoute().end() - 1) {
1817 const bool arrived = myStage->moveToNextEdge(myPerson, currentTime, oldDir, normalLane ?
nullptr : &myLane->getEdge());
1823 myStage->activateEntryReminders(myPerson);
1824 assert(myNLI.lane != oldLane);
1826 std::cout <<
" nextLane=" << (myNLI.lane ==
nullptr ?
"NULL" : myNLI.lane->getID()) <<
"\n";
1828 if (myLane->getEdge().isWalkingArea()) {
1831 assert(myWalkingAreaPath->shape.size() >= 2);
1833 std::cout <<
" mWAPath shape=" << myWalkingAreaPath->shape <<
" length=" << myWalkingAreaPath->length <<
"\n";
1839 const MSEdge* currRouteEdge = *myStage->getRouteStep();
1840 const MSEdge* nextRouteEdge = myStage->getNextRouteEdge();
1848 myStage->moveToNextEdge(myPerson, currentTime, oldDir,
nullptr);
1849 myLane = myNLI.lane;
1850 assert(myLane != 0);
1853 myWalkingAreaPath =
nullptr;
1855 throw ProcessError(
"Disconnected walk for person '" + myPerson->getID() +
"'.");
1859 myWalkingAreaPath =
nullptr;
1864 const double newLength = (myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length);
1865 if (-dist > newLength) {
1872 myRelX = newLength + dist;
1877 std::cout <<
SIMTIME <<
" update myRelX ped=" << myPerson->getID()
1878 <<
" newLength=" << newLength
1880 <<
" myRelX=" << myRelX
1884 if (myDir != oldDir) {
1891 std::cout <<
SIMTIME <<
" transformY ped=" << myPerson->getID()
1893 <<
" newY=" << myRelY
1895 <<
" od=" << oldDir <<
" nd=" << myDir
1896 <<
" offset=" << offset <<
"\n";
1899 myAngle = std::numeric_limits<double>::max();
1908 const int stripes = (int)obs.size();
1909 const int sMax = stripes - 1;
1913 const double vMax = (myStage->getConfiguredSpeed() >= 0
1914 ? myStage->getConfiguredSpeed()
1915 : (myLane->isNormal() || myLane->isInternal()
1916 ? myLane->getVehicleMaxSpeed(myPerson)
1917 : myStage->getMaxSpeed(myPerson)));
1919 const int current = stripe();
1920 const int other = otherStripe();
1922 std::vector<double> distance(stripes);
1923 for (
int i = 0; i < stripes; ++i) {
1924 distance[i] = distanceTo(obs[i], obs[i].type ==
OBSTACLE_PED);
1927 std::vector<double> utility(stripes, 0);
1929 for (
int i = 0; i < stripes; ++i) {
1931 if (i == current && (!myWaitingToEnter || stripe() != stripe(myRelY))) {
1935 for (
int j = 0; j <= i; ++j) {
1940 for (
int j = i; j < stripes; ++j) {
1949 const bool onJunction = myLane->getEdge().isWalkingArea() || myLane->getEdge().isCrossing();
1952 for (
int i = 0; i < reserved; ++i) {
1956 for (
int i = sMax; i > sMax - reserved; --i) {
1961 for (
int i = 0; i < stripes; ++i) {
1962 if (obs[i].speed * myDir < 0) {
1965 utility[i - 1] -= 0.5;
1966 }
else if (myDir ==
BACKWARD && i < sMax) {
1967 utility[i + 1] -= 0.5;
1971 const double walkDist =
MAX2(0., distance[i]);
1973 const double expectedDist =
MIN2(vMax *
LOOKAHEAD_SAMEDIR, walkDist + obs[i].speed * myDir * lookAhead);
1974 if (expectedDist >= 0) {
1975 utility[i] += expectedDist;
1982 if (myDir ==
FORWARD && obs[0].speed < 0) {
1984 }
else if (myDir ==
BACKWARD && obs[sMax].speed > 0) {
1988 if (distance[current] > 0 && myWaitingTime == 0) {
1989 for (
int i = 0; i < stripes; ++i) {
1995 for (
int i = 0; i < stripes; ++i) {
2003 int chosen = current;
2004 for (
int i = 0; i < stripes; ++i) {
2010 const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
2011 double xDist =
MIN3(distance[current], distance[other], distance[next]);
2012 if (next != chosen) {
2015 const int nextOther = chosen < current ? current - 2 : current + 2;
2016 xDist =
MIN2(xDist, distance[nextOther]);
2019 const double preferredGap = NUMERICAL_EPS;
2021 if (xSpeed < NUMERICAL_EPS) {
2025 std::cout <<
" xSpeedPotential=" << xSpeed <<
"\n";
2032 (xDist == distance[current] && obs[current].type >=
OBSTACLE_END)
2033 || (xDist == distance[other] && obs[other].type >=
OBSTACLE_END)
2034 || (xDist == distance[next] && obs[next].type >=
OBSTACLE_END))
2039 if (myWaitingTime > ((myLane->getEdge().isCrossing()
2041 || (myLane->getEdge().isWalkingArea() && obs[current].type ==
OBSTACLE_VEHICLE
2043 || (sMax == 0 && obs[0].speed * myDir < 0 && myWaitingTime >
jamTimeNarrow)
2054 }
else if (myAmJammed && stripe(myRelY) >= 0 && stripe(myRelY) <= sMax && xDist >=
MIN_STARTUP_DIST) {
2078 if (fabs(yDist) > NUMERICAL_EPS) {
2079 ySpeed = (yDist > 0 ?
2085 && stripe() == stripe(myRelY)
2087 && !(myLane->getEdge().isCrossing() || myLane->getEdge().isWalkingArea())) {
2089 int stepAsideDir = myDir;
2090 if (myLane->getEdge().getLanes().size() > 1 || current > sMax / 2) {
2096 ySpeed = stepAsideDir * vMax;
2102 <<
" ped=" << myPerson->getID()
2103 <<
" edge=" << myStage->getEdge()->getID()
2107 <<
" pvx=" << mySpeed
2108 <<
" cur=" << current
2109 <<
" cho=" << chosen
2113 <<
" dawdle=" << dawdle
2118 <<
" wTime=" << myStage->getWaitingTime(currentTime)
2119 <<
" jammed=" << myAmJammed
2122 for (
int i = 0; i < stripes; ++i) {
2124 std::cout <<
" util=" << utility[i] <<
" dist=" << distance[i] <<
" o=" << o.
description;
2126 std::cout <<
" xF=" << o.
xFwd <<
" xB=" << o.
xBack <<
" v=" << o.
speed;
2129 std::cout <<
" current";
2131 if (i == other && i != current) {
2132 std::cout <<
" other";
2135 std::cout <<
" chosen";
2138 std::cout <<
" next";
2146 mySpeedLat = ySpeed;
2149 myWaitingToEnter =
false;
2154 myAngle = std::numeric_limits<double>::max();
2160 return MAX2(0.,
MIN2(1., myPerson->getVehicleType().getImpatience()
2180 return myRemoteXYPos;
2182 if (myLane ==
nullptr) {
2186 const double lateral_offset = myRelY + (
stripeWidth - myLane->getWidth()) * 0.5;
2187 if (myWalkingAreaPath ==
nullptr) {
2201 return myWalkingAreaPath->shape.positionAtOffset(myRelX, lateral_offset);
2208 if (myAngle != std::numeric_limits<double>::max()) {
2211 if (myLane ==
nullptr) {
2215 const PositionVector& shp = myWalkingAreaPath ==
nullptr ? myLane->getShape() : myWalkingAreaPath->shape;
2216 double geomX = myWalkingAreaPath ==
nullptr ? myLane->interpolateLanePosToGeometryPos(myRelX) : myRelX;
2219 angle += atan2(mySpeedLat,
MAX2(mySpeed, NUMERICAL_EPS));
2221 angle -= atan2(mySpeedLat,
MAX2(mySpeed, NUMERICAL_EPS));
2233 return myWaitingTime;
2245 return myNLI.lane ==
nullptr ? nullptr : &myNLI.lane->getEdge();
2252 int routeOffset = 0;
2253 bool laneOnRoute =
false;
2255 for (
const MSEdge* edge : myStage->getRoute()) {
2258 || edge->getFromJunction() == laneOnJunction) {
2265 throw ProcessError(
"Lane '" + lane->
getID() +
"' is not on the route of person '" + getID() +
"'.");
2268 if (lane->
getEdge().
isWalkingArea() && (myWalkingAreaPath ==
nullptr || myWalkingAreaPath->lane != lane)) {
2270 const MSEdge* prevEdge = myStage->getRoute()[routeOffset];
2271 const MSEdge* nextEdge = routeOffset + 1 < (int)myStage->getRoute().size() ? myStage->getRoute()[routeOffset + 1] :
nullptr;
2273 const double maxPos = guessed->
shape.
length() - NUMERICAL_EPS;
2274 if (lanePos > maxPos + POSITION_EPS || lanePos < -POSITION_EPS) {
2276 +
"' (fromLane='" + guessed->
from->
getID()
2277 +
"' toLane='" + guessed->
to->
getID() +
"') for person '" + getID() +
"' time=" +
time2string(t) +
".");
2280 lanePos =
MIN2(maxPos,
MAX2(NUMERICAL_EPS, lanePos));
2284 moveToXY(p, pos, lane, lanePos, lanePosLat, angle, routeOffset, newEdges, t);
2290 double lanePosLat,
double angle,
int routeOffset,
2293 assert(p == myPerson);
2294 assert(pm !=
nullptr);
2297 const double oldX = myRelX -
SPEED2DIST(mySpeed * myDir);
2298 const double tmp = myRelX;
2300 Position oldPos = getPosition(*myStage, t);
2306#ifdef DEBUG_MOVETOXY
2310 <<
" lane=" << lane->
getID()
2311 <<
" lanePos=" << lanePos
2312 <<
" lanePosLat=" << lanePosLat
2313 <<
" angle=" << angle
2314 <<
" routeOffset=" << routeOffset
2317 <<
" path=" << (myWalkingAreaPath ==
nullptr ?
"null" : (myWalkingAreaPath->from->getID() +
"->" + myWalkingAreaPath->to->getID())) <<
"\n";
2320 if (lane != myLane && myLane !=
nullptr) {
2324 if (lane !=
nullptr &&
2327 const MSEdge* old = myStage->getEdge();
2328 const MSLane* oldLane = myLane;
2329 if (lane != myLane) {
2333 if (edges.empty()) {
2335 myStage->setRouteIndex(myPerson, routeOffset);
2337 myStage->replaceRoute(myPerson, edges, routeOffset);
2340 myStage->moveToNextEdge(myPerson, t, myDir, &lane->
getEdge());
2346 if (myWalkingAreaPath ==
nullptr || myWalkingAreaPath->lane != lane) {
2348 myWalkingAreaPath =
guessPath(&lane->
getEdge(), old, myStage->getNextRouteEdge());
2349#ifdef DEBUG_MOVETOXY
2351 <<
" path=" << myWalkingAreaPath->from->getID() <<
"->" << myWalkingAreaPath->to->getID() <<
"\n";
2356 const Position relPos = myWalkingAreaPath->shape.transformToVectorCoordinates(pos);
2359 +
"' (fromLane='" + myWalkingAreaPath->from->getID()
2360 +
"' toLane='" + myWalkingAreaPath->to->getID() +
"') for person '" + getID() +
"' time=" +
time2string(t) +
".");
2361 myRemoteXYPos = pos;
2363 myRelX = relPos.
x();
2364 myRelY = lateral_offset + relPos.
y();
2367 myWalkingAreaPath =
nullptr;
2369 myRelY = lateral_offset - lanePosLat;
2373 if (myStage->getNextRouteEdge() !=
nullptr) {
2374 if (myStage->getEdge()->getToJunction() == myStage->getNextRouteEdge()->getFromJunction() ||
2375 myStage->getEdge()->getToJunction() == myStage->getNextRouteEdge()->getToJunction()) {
2382 if (angleDiff <= 90) {
2393 if (oldLane ==
nullptr || &oldLane->
getEdge() != &myLane->getEdge()) {
2394 const MSLane* sidewalk = getSidewalk<MSEdge, MSLane>(&myLane->getEdge(), p->
getVClass());
2397 myNLI =
getNextLane(*
this, sidewalk ==
nullptr ? myLane : sidewalk,
nullptr);
2398 myStage->activateEntryReminders(myPerson);
2399#ifdef DEBUG_MOVETOXY
2400 std::cout <<
" myNLI=" <<
Named::getIDSecure(myNLI.lane) <<
" link=" << (myNLI.link ==
nullptr ?
"NULL" : myNLI.link->getDescription()) <<
" dir=" << myNLI.dir <<
"\n";
2403#ifdef DEBUG_MOVETOXY
2404 std::cout <<
" newRelPos=" <<
Position(myRelX, myRelY) <<
" edge=" << myPerson->getEdge()->getID() <<
" newPos=" << myPerson->getPosition()
2405 <<
" oldAngle=" << oldAngle <<
" angleDiff=" << angleDiff <<
" newDir=" << myDir <<
"\n";
2407 if (oldLane == myLane) {
2415 myRemoteXYPos = pos;
2435 const double maxX = getMaxX(includeMinGap);
2436 const double minX = getMinX(includeMinGap);
2440 if ((obs.
xFwd >= maxX && obs.
xBack <= maxX) || (obs.
xFwd <= maxX && obs.
xFwd >= minX)) {
2454 for (
int i = 0; i < (int)into.size(); ++i) {
2456 std::cout <<
" i=" << i <<
" maxX=" << getMaxX(
true) <<
" minX=" << getMinX(
true)
2457 <<
" into=" << into[i].description <<
" iDist=" << distanceTo(into[i], into[i].type ==
OBSTACLE_PED)
2458 <<
" obs2=" << obs2[i].description <<
" oDist=" << distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED) <<
"\n";
2460 const double dO = distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED);
2461 const double dI = distanceTo(into[i], into[i].type ==
OBSTACLE_PED);
2476 for (
int i = 0; i < (int)into.size(); ++i) {
2477 int i2 = i + offset;
2478 if (i2 >= 0 && i2 < (
int)obs2.size()) {
2480 if (obs2[i2].xBack < into[i].xBack) {
2484 if (obs2[i2].xFwd > into[i].xFwd) {
2497 if (ignoreRedTime >= 0) {
2500 std::cout <<
SIMTIME <<
" ignoreRedTime=" << ignoreRedTime <<
" redDuration=" << redDuration <<
"\n";
2502 return ignoreRedTime > redDuration;
2513 return myPerson->getID();
2518 return myPerson->getVehicleType().getWidth();
2524 return myPerson->hasInfluencer() && myPerson->getInfluencer().isRemoteControlled();
2532 myVehicle(veh), myXWidth(xWidth), myYWidth(yWidth) {
2540 return myVehicle->getID();
2564 std::set<MSPerson*> changedLane;
2565 myModel->moveInDirection(currentTime, changedLane,
FORWARD);
2566 myModel->moveInDirection(currentTime, changedLane,
BACKWARD);
2569 for (ActiveLanes::const_iterator it_lane = myModel->getActiveLanes().begin(); it_lane != myModel->getActiveLanes().end(); ++it_lane) {
2570 const MSLane* lane = it_lane->first;
2572 if (pedestrians.size() == 0) {
2577 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
2578 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.
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
bool isWalkingArea() const
return whether this edge is walking area
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool isNormal() const
return whether this edge is an internal edge
const MSJunction * getToJunction() const
double getLength() const
return the length of the edge
const MSJunction * getFromJunction() const
bool isInternal() const
return whether this edge is an internal edge
const MSEdgeVector & getPredecessors() 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.
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.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
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
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 {.
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
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
MSEdge & getEdge() const
Returns the lane's edge.
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
SUMOTime getLastStateChange() const
MSLane * getLane() const
Returns the connected lane.
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
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
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.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
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).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool hasPedestrianNetwork() const
return whether the network contains walkingareas and crossings
MSPedestrianRouter & getPedestrianRouter(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
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
void moveTo(MSPerson *p, MSLane *lane, double lanePos, double lanePosLat, 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 int myWalkingAreaDetail
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, bool bidi=false)
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 bool myLegacyPosLat
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 RANDOM_POS_LAT
magic value to encode randomized lateral offset for persons when starting a walk
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 UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
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 const MSEdge * getNextRouteEdge() const =0
static const MSLane * checkDepartLane(const MSEdge *edge, SUMOVehicleClass svc, int laneIndex, const std::string &id)
interpret custom depart lane
virtual bool moveToNextEdge(MSTransportable *transportable, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=0)=0
move forward and return whether the transportable arrived
const std::vector< const MSEdge * > & getRoute() const
int getDepartLane() 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.
bool isPerson() const
Whether it is a person.
Position getPosition(const double) const
Return current position (x/y, cartesian)
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
MSStageType getCurrentStageType() const
the current stage type of the transportable
const MSEdge * getEdge() const
Returns the current edge.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical maximum speed)
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.
const MSLane * getLane() const
Returns the lane the vehicle is on.
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 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)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
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.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
void sety(double y)
set position y
double y() const
Returns the y-position.
double length() const
Returns the length.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
PositionVector bezier(int numPoints)
return a bezier interpolation
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