48 #define DEBUGCOND(PED) ((PED).myPerson->isSelected()) 49 #define DEBUGCOND2(LANE) ((LANE)->isSelected()) 53 for (
int i = 0; i < (int)obs.size(); ++i) {
55 <<
"(" << obs[i].description
56 <<
" x=(" << obs[i].xBack <<
"," << obs[i].xFwd
57 <<
") s=" << obs[i].speed
101 #define MINGAP_TO_VEHICLE 0.25 139 const MSLane* lane = getSidewalk<MSEdge, MSLane>(person->
getEdge());
140 if (lane ==
nullptr) {
141 std::string error =
"Person '" + person->
getID() +
"' could not find sidewalk on edge '" + person->
getEdge()->
getID() +
"', time=" 167 const MSLane* lane =
dynamic_cast<PState*
>(state)->myLane;
169 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
171 pedestrians.erase(it);
180 double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
182 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
183 const PState& ped = **it_ped;
185 const double leaderBackDist = leaderFrontDist + ped.
getLength();
188 <<
" vehSide=" << vehSide
189 <<
" vehWidth=" << vehWidth
190 <<
" lBD=" << leaderBackDist
191 <<
" lFD=" << leaderFrontDist
194 if (leaderBackDist >= -vehWidth
195 && (leaderFrontDist < 0
200 if (collectBlockers ==
nullptr) {
203 collectBlockers->push_back(ped.
myPerson);
207 if (collectBlockers ==
nullptr) {
210 return collectBlockers->size() > 0;
234 double closest = std::numeric_limits<double>::max();
236 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
237 const PState& ped = **it_ped;
240 if (ped.
myRelX > minPos && (result.first == 0 || closest > relX2)) {
243 const bool overlap = (center + halfWidth > minRight && center - halfWidth < maxLeft);
245 std::cout <<
" nextBlocking lane=" << lane->
getID()
246 <<
" minPos=" << minPos <<
" minRight=" << minRight <<
" maxLeft=" << maxLeft
247 <<
" stopTime=" << stopTime
250 <<
" relX2=" << relX2
251 <<
" center=" << center
252 <<
" pedLeft=" << center + halfWidth
253 <<
" pedRight=" << center - halfWidth
254 <<
" overlap=" << overlap
297 if (from ==
nullptr || to ==
nullptr) {
319 for (
MSLink* link : lane->getLinkCont()) {
320 if (link->getWalkingAreaFoe() !=
nullptr) {
322 myWalkingAreaFoes[&link->getWalkingAreaFoe()->getEdge()].push_back(link->getLaneBefore());
325 if (link->getWalkingAreaFoeExit() !=
nullptr) {
327 myWalkingAreaFoes[&link->getWalkingAreaFoeExit()->getEdge()].push_back(link->getLaneBefore());
339 const MSLane* walkingArea = getSidewalk<MSEdge, MSLane>(edge);
343 std::vector<const MSLane*> lanes;
345 for (
int j = 0; j < (int)incoming.size(); ++j) {
346 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
349 for (
int j = 0; j < (int)outgoing.size(); ++j) {
350 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
353 for (
int j = 0; j < (int)lanes.size(); ++j) {
354 for (
int k = 0; k < (int)lanes.size(); ++k) {
357 const MSLane* from = lanes[j];
358 const MSLane* to = lanes[k];
364 const double maxExtent = fromPos.
distanceTo2D(toPos) / 4;
365 const double extrapolateBy =
MIN2(maxExtent, walkingArea->
getWidth() / 2);
367 shape.push_back(fromPos);
377 if (shape.size() < 2) {
381 assert(shape.size() == 2);
389 myMinNextLengths[walkingArea] =
MIN2(myMinNextLengths[walkingArea], wap.
length);
401 std::vector<const MSLane*> lanes;
403 for (
int j = 0; j < (int)incoming.size(); ++j) {
404 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
407 for (
int j = 0; j < (int)outgoing.size(); ++j) {
408 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
410 if (lanes.size() < 1) {
411 throw ProcessError(
"Invalid walkingarea '" + walkingArea->
getID() +
"' does not allow continuation.");
422 const MSLane* nextRouteLane = getSidewalk<MSEdge, MSLane>(nextRouteEdge);
424 const MSLane* nextLane = nextRouteLane;
428 if (nextRouteLane ==
nullptr && nextRouteEdge !=
nullptr) {
429 std::string error =
"Person '" + ped.
myPerson->
getID() +
"' could not find sidewalk on edge '" + nextRouteEdge->
getID() +
"', time=" 433 nextRouteLane = nextRouteEdge->
getLanes().front();
439 if (nextRouteLane !=
nullptr) {
444 nextLane = currentLane->
getLinkCont()[0]->getViaLaneOrLane();
449 std::cout <<
" internal\n";
454 nextLane = currentLane->
getLinkCont()[0]->getLane();
459 std::cout <<
" crossing\n";
466 const double arrivalPos = (nextRouteEdge == ped.
myStage->
getRoute().back()
470 if (prevLane !=
nullptr) {
471 prohibited.push_back(&prevLane->
getEdge());
476 <<
" nre=" << nextRouteEdge->
getID()
477 <<
" nreDir=" << nextRouteEdgeDir
478 <<
" aPos=" << arrivalPos
479 <<
" crossingRoute=" <<
toString(crossingRoute)
482 if (crossingRoute.size() > 1) {
483 const MSEdge* nextEdge = crossingRoute[1];
484 nextLane = getSidewalk<MSEdge, MSLane>(crossingRoute[1]);
486 assert(nextLane != prevLane);
489 std::cout <<
" nextDir=" << nextDir <<
"\n";
505 <<
" no route from '" << (currentEdge ==
nullptr ?
"NULL" : currentEdge->
getID())
506 <<
"' to '" << (nextRouteEdge ==
nullptr ?
"NULL" : nextRouteEdge->
getID())
510 +
"' from walkingArea '" + currentEdge->
getID()
511 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
514 nextLane = nextRouteLane;
516 }
else if (currentEdge == nextRouteEdge) {
518 nextDir = -ped.
myDir;
523 if (nextLane !=
nullptr) {
526 std::cout <<
" next walkingArea " << (nextDir ==
FORWARD ?
"forward" :
"backward") <<
"\n";
535 if (link !=
nullptr) {
537 std::cout <<
" direct forward\n";
543 if (link !=
nullptr) {
545 std::cout <<
" direct backward\n";
548 if (nextLane !=
nullptr) {
550 while (nextLane->getLinkCont()[0]->getViaLaneOrLane()->isInternal()) {
551 nextLane = nextLane->getLinkCont()[0]->getViaLaneOrLane();
557 if (nextLane ==
nullptr) {
559 nextLane = nextRouteLane;
561 std::cout <<
SIMTIME <<
" no next lane found for " << currentLane->
getID() <<
" dir=" << ped.
myDir <<
"\n";
565 +
"' from edge '" + currentEdge->
getID()
566 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
573 if ((nextLane->getCanonicalSuccessorLane() ==
nullptr 574 || !nextLane->getCanonicalSuccessorLane()->getEdge().isCrossing())
575 && (nextLane->getLogicalPredecessorLane() ==
nullptr ||
576 !nextLane->getLogicalPredecessorLane()->getEdge().isCrossing())) {
581 nextLane = nextRouteLane;
590 <<
" l=" << currentLane->
getID()
591 <<
" nl=" << (nextLane ==
nullptr ?
"NULL" : nextLane->getID())
592 <<
" nrl=" << (nextRouteLane ==
nullptr ?
"NULL" : nextRouteLane->
getID())
595 <<
" pedDir=" << ped.
myDir 598 assert(nextLane != 0 || nextRouteLane == 0);
607 for (MSLinkCont::const_iterator it = links.begin(); it != links.end(); ++it) {
608 if ((*it)->getLane()->getEdge().isWalkingArea()) {
614 const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->
getIncomingLanes();
615 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
616 if ((*it).lane->getEdge().isWalkingArea()) {
617 link = (*it).viaLink;
628 const PState& ego = *pedestrians[egoIndex];
630 std::vector<bool> haveBlocker(stripes,
false);
631 for (
int index = egoIndex + 1; index < (int)pedestrians.size(); index++) {
632 const PState& p = *pedestrians[index];
639 std::cout <<
" dist=" << ego.
distanceTo(o) << std::endl;
647 haveBlocker[p.
stripe()] =
true;
650 if (!haveBlocker[p.
stripe()]) {
668 int offset = (destStripes - origStripes) / 2;
670 offset += (destStripes - origStripes) % 2;
678 MSLane* lane,
const MSLane* nextLane,
int stripes,
int nextDir,
679 double currentLength,
int currentDir) {
680 if (nextLanesObs.count(nextLane) == 0) {
687 const int offset =
getStripeOffset(nextStripes, stripes, currentDir != nextDir && nextStripes > stripes);
698 if (nextStripes < stripes) {
700 for (
int ii = 0; ii < stripes; ++ii) {
701 if (ii < offset || ii >= nextStripes + offset) {
712 if ((stripes - nextStripes) % 2 != 0) {
715 nextDir = currentDir;
717 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
718 PState& p = *pedestrians[ii];
723 const double newY = relPos.
y() + lateral_offset;
734 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(nextDir));
735 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
736 const PState& p = *pedestrians[ii];
742 if (nextDir != currentDir) {
747 const int stripe = p.
stripe(newY);
748 if (stripe >= 0 && stripe < stripes) {
752 if (otherStripe >= 0 && otherStripe < stripes) {
753 obs[otherStripe] = pObs;
768 nextLanesObs[nextLane] = obs;
770 return nextLanesObs[nextLane];
775 for (
int ii = 0; ii < (int)obs.size(); ++ii) {
779 o.
xFwd += currentLength;
780 o.
xBack += currentLength;
782 const double tmp = o.
xFwd;
783 o.
xFwd = currentLength + nextLength - o.
xBack;
784 o.
xBack = currentLength + nextLength - tmp;
788 const double tmp = o.
xFwd;
792 o.
xFwd -= nextLength;
793 o.
xBack -= nextLength;
802 if (stripe >= 0 && stripe < numStripes) {
803 if ((dir ==
FORWARD && x - width / 2. < obs[stripe].xBack) || (dir ==
BACKWARD && x + width / 2. > obs[stripe].xFwd)) {
804 obs[stripe] =
Obstacle(x, 0, type,
id, width);
812 const MSLane* lane = it_lane->first;
814 if (pedestrians.size() == 0) {
825 std::set<const WalkingAreaPath*, walkingarea_path_sorter> paths;
826 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
829 if (p->
myDir == dir) {
833 std::cout <<
SIMTIME <<
" debugging WalkingAreaPath from=" << debugPath->
from->
getID() <<
" to=" << debugPath->
to->
getID() <<
"\n";
837 for (std::set<const WalkingAreaPath*, walkingarea_path_sorter>::iterator it = paths.begin(); it != paths.end(); ++it) {
841 transformedPeds.reserve(pedestrians.size());
842 for (Pedestrians::iterator it_p = pedestrians.begin(); it_p != pedestrians.end(); ++it_p) {
847 transformedPeds.push_back(p);
848 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord=" 852 const double newY = relPos.
y() + lateral_offset;
860 toDelete.push_back(tp);
861 transformedPeds.push_back(tp);
862 if (path == debugPath) {
863 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (transformed), vecCoord=" << relPos <<
"\n";
866 if (path == debugPath) {
867 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (invalid), vecCoord=" << relPos <<
"\n";
877 for (
const MSLane* foeLane : itFoe->second) {
883 if (
addVehicleFoe(veh, lane, relPos, lateral_offset, minY, maxY, toDelete, transformedPeds)
884 &&
addVehicleFoe(veh, lane, relPos2, lateral_offset, minY, maxY, toDelete, transformedPeds)) {
888 const double relDist = dist / length;
889 Position between = (relPos * relDist) + (relPos2 * (1 - relDist));
890 addVehicleFoe(veh, lane, between, lateral_offset, minY, maxY, toDelete, transformedPeds);
899 for (Pedestrians::iterator it_p = toDelete.begin(); it_p != toDelete.end(); ++it_p) {
915 const double newY = relPos.
y() + lateral_offset;
916 if (newY >= minY && newY <= maxY) {
919 toDelete.push_back(tp);
920 transformedPeds.push_back(tp);
931 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
933 for (
int i = 0; i < (int)pedestrians.size(); i++) {
934 PState*
const p = pedestrians[i];
938 pedestrians.erase(pedestrians.begin() + i);
941 if (p->
myLane !=
nullptr) {
960 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
963 bool hasCrossingVehObs =
false;
966 hasCrossingVehObs =
addCrossingVehs(lane, stripes, 0, dir, crossingVehs,
true);
969 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
970 PState& p = *pedestrians[ii];
1000 nextLanesObs, lane, nextLane, stripes,
1019 const double passingClearanceTime = 2;
1020 const double passingLength = p.
getLength() + passingClearanceTime * speed;
1026 <<
" opened=" << (link ==
nullptr ?
"NULL" :
toString(link->opened(currentTime -
DELTA_T, speed, speed, passingLength, p.
getImpatience(currentTime), speed, 0, 0,
nullptr, p.
ignoreRed(link)))) <<
"\n";
1062 if (hasCrossingVehObs) {
1071 p.
walk(currentObs, currentTime);
1078 for (
int coll = 0; coll < ii; ++coll) {
1079 PState& c = *pedestrians[coll];
1086 +
"', lane='" + lane->
getID() +
"', time=" +
time2string(currentTime) +
".");
1099 bool hasCrossingVehObs =
false;
1104 if (linkLeaders.size() > 0) {
1105 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1107 const MSVehicle* veh = (*it).vehAndGap.first;
1108 if (veh !=
nullptr) {
1119 const double distToCrossBeforeVeh = (dir ==
FORWARD ? vo.xFwd : crossing->
getLength() - vo.xBack);
1120 const double bGap = (prio
1122 : veh->
getSpeed() * distToCrossBeforeVeh);
1126 if ((*it).fromLeft) {
1127 vehYmin = -(*it).vehAndGap.second + lateral_offset;
1131 vehYmax = crossing->
getWidth() + (*it).vehAndGap.second - lateral_offset;
1137 if ((dir ==
FORWARD && obs[s].xBack > vo.xBack)
1138 || (dir ==
BACKWARD && obs[s].xFwd < vo.xFwd)) {
1145 hasCrossingVehObs =
true;
1150 <<
" crossingVeh=" << veh->
getID()
1151 <<
" lane=" << crossing->
getID()
1153 <<
" latOffset=" << lateral_offset
1155 <<
" stripes=" << stripes
1156 <<
" dist=" << (*it).distToCrossing
1157 <<
" gap=" << (*it).vehAndGap.second
1158 <<
" brakeGap=" << bGap
1159 <<
" fromLeft=" << (*it).fromLeft
1160 <<
" distToCrossBefore=" << distToCrossBeforeVeh
1161 <<
" ymin=" << vehYmin
1162 <<
" ymax=" << vehYmax
1171 return hasCrossingVehObs;
1186 if (ped !=
nullptr) {
1206 const double vehNextSpeed =
MAX2(veh->
getSpeed(), 1.0);
1208 if ((dir ==
FORWARD && vehFront + clearance > minX && vehBack <= maxX + LOOKAHEAD_SAMEDIR)
1221 if (s == current && vehFront +
SAFETY_GAP < minX) {
1223 if (pRelY - pWidth < vehYmax &&
1224 pRelY + pWidth > vehYmin && dir ==
FORWARD) {
1226 std::cout <<
" ignoring vehicle '" << veh->
getID() <<
" on stripe " << s <<
" vehFrontSG=" << vehFront +
SAFETY_GAP <<
" minX=" << minX <<
"\n";
1237 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" obstacle on lane=" << lane->
getID()
1239 <<
" ymin=" << vehYmin
1240 <<
" ymax=" << vehYmax
1243 <<
" relY=" << pRelY
1244 <<
" current=" << current
1245 <<
" vo.xFwd=" << vo.xFwd
1246 <<
" vo.xBack=" << vo.xBack
1268 xFwd(ped.getMaxX()),
1269 xBack(ped.getMinX()),
1270 speed(ped.myDir * ped.mySpeed),
1286 myRelX(stage->getDepartPos()),
1287 myRelY(stage->getDepartPosLat()),
1290 myWaitingToEnter(true),
1292 myWalkingAreaPath(nullptr),
1295 myAngle(std::numeric_limits<double>::max()) {
1298 assert(!route.empty());
1299 if (route.size() == 1) {
1305 if (route.front()->isWalkingArea()) {
1312 std::cout <<
" initialize dir for " <<
myPerson->
getID() <<
" forward=" << mayStartForward <<
" backward=" << mayStartBackward <<
"\n";
1314 if (mayStartForward && mayStartBackward) {
1318 if (crossingRoute.size() > 1) {
1320 const MSEdge* nextEdge = crossingRoute[1];
1326 std::cout <<
" crossingRoute=" <<
toString(crossingRoute) <<
"\n";
1360 myAngle(std::numeric_limits<double>::max()) {
1404 const int s =
stripe(relY);
1408 if (offset > threshold) {
1410 }
else if (offset < -threshold) {
1456 const int oldDir =
myDir;
1464 <<
" moveToNextLane old=" << oldLane->
getID()
1466 <<
" oldDir=" << oldDir
1467 <<
" newDir=" <<
myDir 1527 if (-dist > newLength) {
1534 myRelX = newLength + dist;
1540 <<
" newLength=" << newLength
1546 if (
myDir != oldDir) {
1557 <<
" od=" << oldDir <<
" nd=" <<
myDir 1558 <<
" offset=" << offset <<
"\n";
1570 myAngle = std::numeric_limits<double>::max();
1571 const int stripes = (int)obs.size();
1572 const int sMax = stripes - 1;
1576 const int current =
stripe();
1579 std::vector<double> distance(stripes);
1580 for (
int i = 0; i < stripes; ++i) {
1584 std::vector<double> utility(stripes, 0);
1586 for (
int i = 0; i < stripes; ++i) {
1592 for (
int j = 0; j <= i; ++j) {
1597 for (
int j = i; j < stripes; ++j) {
1609 for (
int i = 0; i < reserved; ++i) {
1613 for (
int i = sMax; i > sMax - reserved; --i) {
1618 for (
int i = 0; i < stripes; ++i) {
1619 if (obs[i].speed *
myDir < 0) {
1622 utility[i - 1] -= 0.5;
1624 utility[i + 1] -= 0.5;
1628 const double walkDist =
MAX2(0., distance[i]);
1632 std::cout <<
" util=" << utility[i] <<
" exp=" << expectedDist <<
" dist=" << distance[i] <<
"\n";
1634 if (expectedDist >= 0) {
1635 utility[i] += expectedDist;
1649 for (
int i = 0; i < stripes; ++i) {
1655 int chosen = current;
1656 for (
int i = 0; i < stripes; ++i) {
1657 if (utility[chosen] < utility[i]) {
1662 const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
1663 double xDist =
MIN3(distance[current], distance[other], distance[next]);
1664 if (next != chosen) {
1667 const int nextOther = chosen < current ? current - 2 : current + 2;
1668 xDist =
MIN2(xDist, distance[nextOther]);
1677 std::cout <<
" xSpeedPotential=" << xSpeed <<
"\n";
1684 (xDist == distance[current] && obs[current].type >=
OBSTACLE_END)
1685 || (xDist == distance[other] && obs[other].type >=
OBSTACLE_END)
1686 || (xDist == distance[next] && obs[next].type >=
OBSTACLE_END))
1727 ySpeed = (yDist > 0 ?
1748 <<
" cur=" << current
1749 <<
" cho=" << chosen
1753 <<
" dawdle=" << dawdle
1760 <<
"\n distance=" <<
toString(distance)
1761 <<
"\n utility=" <<
toString(utility)
1818 if (
myAngle != std::numeric_limits<double>::max()) {
1854 double lanePosLat,
double angle,
int routeOffset,
1871 if (lane !=
nullptr) {
1873 const MSLane* sidewalk = getSidewalk<MSEdge, MSLane>(&lane->
getEdge());
1874 if (lane != sidewalk) {
1879 pm->
add(
this, lane);
1881 if (edges.empty()) {
1905 const double maxX =
getMaxX(includeMinGap);
1906 const double minX =
getMinX(includeMinGap);
1910 if ((obs.
xFwd >= maxX && obs.
xBack <= maxX) || (obs.
xFwd <= maxX && obs.
xFwd >= minX)) {
1924 for (
int i = 0; i < (int)into.size(); ++i) {
1926 std::cout <<
" i=" << i <<
" maxX=" <<
getMaxX(
true) <<
" minX=" <<
getMinX(
true)
1928 <<
" obs2=" << obs2[i].description <<
" oDist=" <<
distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED) <<
"\n";
1946 for (
int i = 0; i < (int)into.size(); ++i) {
1947 int i2 = i + offset;
1948 if (i2 >= 0 && i2 < (
int)obs2.size()) {
1950 if (obs2[i2].xBack < into[i].xBack) {
1954 if (obs2[i2].xFwd > into[i].xFwd) {
1967 if (ignoreRedTime >= 0) {
1970 std::cout <<
SIMTIME <<
" ignoreRedTime=" << ignoreRedTime <<
" redDuration=" << redDuration <<
"\n";
1972 return ignoreRedTime > redDuration;
2028 std::set<MSPerson*> changedLane;
2033 for (ActiveLanes::const_iterator it_lane =
myModel->getActiveLanes().begin(); it_lane !=
myModel->getActiveLanes().end(); ++it_lane) {
2034 const MSLane* lane = it_lane->first;
2036 if (pedestrians.size() == 0) {
2041 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
2042 const PState& p = *pedestrians[ii];
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
bool gDebugFlag1
global utility flags for debugging
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...
double getImpatience(SUMOTime now) const
returns the impatience
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
PState()
constructor for PStateVehicle
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
void moveInDirection(SUMOTime currentTime, std::set< MSPerson *> &changedLane, int dir)
move all pedestrians forward and advance to the next lane if applicable
bool myAmActive
whether an event for pedestrian processing was added
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
double getMaxX(const bool includeMinGap=true) const
return the maximum position on the lane
static const double LATERAL_SPEED_FACTOR
static const double SQUEEZE
MSPerson::MSPersonStage_Walking * myStage
static const double DIST_BEHIND
void moveInDirectionOnLane(Pedestrians &pedestrians, const MSLane *lane, SUMOTime currentTime, std::set< MSPerson *> &changedLane, int dir)
move pedestrians forward on one lane
static const double LOOKAHEAD_ONCOMING
static int numStripes(const MSLane *lane)
return the maximum number of pedestrians walking side by side
static SUMOTime jamTimeCrossing
static Obstacles getNeighboringObstacles(const Pedestrians &pedestrians, int egoIndex, int stripes)
MSLane * getLane() const
Returns the connected lane.
Obstacle(int dir, double dist=DIST_FAR_AWAY)
create No-Obstacle
const MSEdge * getEdge() const
Returns the current edge.
double getMinGap() const
return the minimum gap of the pedestrian
sorts the persons by position on the lane. If dir is forward, higher x positions come first...
static WalkingAreaPath * getArbitraryPath(const MSEdge *walkingArea)
return an arbitrary path across the given walkingArea
static const MSLane * getNextWalkingArea(const MSLane *currentLane, const int dir, MSLink *&link)
return the next walkingArea in the given direction
bool ignoreRed(const MSLink *link) const
whether the pedestrian may ignore a red light
static int connectedDirection(const MSLane *from, const MSLane *to)
returns the direction in which these lanes are connectioned or 0 if they are not
virtual const std::string & getID() const
return the person id
WalkingAreaPath * myWalkingAreaPath
the current walkingAreaPath or 0
static const double MIN_STARTUP_DIST
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
The pedestrian following model.
information regarding surround Pedestrians (and potentially other things)
const MSEdge * getDestination() const
returns the destination edge
const MSEdgeVector & getPredecessors() const
SUMOTime getLastStateChange() const
The base class for an intersection.
double y() const
Returns the y-position.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
const MSEdge * getEdge() const
Returns the current edge.
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane...
std::string time2string(SUMOTime t)
double x() const
Returns the x-position.
virtual double getWidth() const
return the person width
const std::string & getID() const
return the person id
void registerJammed()
register a jammed transportable
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
void remove(PedestrianState *state)
remove the specified person from the pedestrian simulation
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
PositionVector reverse() const
reverse position vector
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
std::vector< const MSEdge * > ConstMSEdgeVector
bool usingInternalLanes()
whether movements on intersections are modelled /
std::map< std::pair< const MSLane *, const MSLane * >, WalkingAreaPath > WalkingAreaPaths
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double getWidth() const
return the person width
const std::string & getID() const
Returns the id.
bool moveToNextLane(SUMOTime currentTime)
return whether this pedestrian has passed the end of the current lane and update myRelX if so ...
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
void moveToXY(MSPerson *p, Position pos, MSLane *lane, double lanePos, double lanePosLat, double angle, int routeOffset, const ConstMSEdgeVector &edges, SUMOTime t)
try to move person to the given position
static bool usingInternalLanesStatic()
static MSPModel * myModel
double getLength() const
return the length of the edge
virtual double getMaxX(const bool includeMinGap=true) const
return the maximum position on the lane
static WalkingAreaPaths myWalkingAreaPaths
store for walkinArea elements
const MSJunction * getToJunction() const
double getLength() const
return the length of the pedestrian
#define MINGAP_TO_VEHICLE
static const double LATERAL_PENALTY
double getWidth() const
Returns the lane's width.
#define UNUSED_PARAMETER(x)
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 ...
double mySpeed
the current walking speed
static const double OBSTRUCTION_THRESHOLD
#define WRITE_WARNING(msg)
The simulated network and simulation perfomer.
bool myAmJammed
whether the person is jammed
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
static OptionsCont & getOptions()
Retrieves the options.
static Pedestrians noPedestrians
empty pedestrian vector
static bool gCheck4Accidents
bool hasPedestrianNetwork() const
return whether the network contains walkingareas and crossings
void mergeObstacles(Obstacles &into, const Obstacles &obs2)
replace obstacles in the first vector with obstacles from the second if they are closer to me ...
NextLaneInfo myNLI
information about the upcoming lane
static const double RESERVE_FOR_ONCOMING_FACTOR_JUNCTIONS
A road/street connecting two junctions.
const MSVehicle * myVehicle
Pedestrians & getPedestrians(const MSLane *lane)
retrieves the pedestian vector for the given lane (may be empty)
static int canTraverse(int dir, const ConstMSEdgeVector &route)
static bool addCrossingVehs(const MSLane *crossing, int stripes, double lateral_offset, int dir, Obstacles &crossingVehs, bool prio)
add vehicles driving across
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double xFwd
maximal position on the current lane in forward direction
static const int UNDEFINED_DIRECTION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SUMOTime execute(SUMOTime currentTime)
Executes the command.
static const double OBSTRUCTED_PENALTY
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, std::vector< const SUMOVehicle *> *collectFoes=0, bool ignoreRed=false, const SUMOVehicle *ego=0) const
Returns the information whether the link may be passed.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
static const double DIST_OVERLAP
static MSPModel * getModel()
virtual MSTransportableControl & getPersonControl()
Returns the person control.
void walk(const Obstacles &obs, SUMOTime currentTime)
perform position update
A point in 2D or 3D with translation and scaling methods.
static int getStripeOffset(int origStripes, int destStripes, bool addRemainder)
static Obstacles getVehicleObstacles(const MSLane *lane, int dir, PState *ped=0)
retrieve vehicle obstacles on the given lane
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...
double myRelY
the orthogonal shift on the current lane
Position myRemoteXYPos
remote-controlled position
double xBack
maximal position on the current lane in backward direction
double myRelX
the advancement along the current lane
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool havePriority() const
Returns whether this link is a major link.
double myAngle
cached angle
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
double getSpeed(const MSPerson::MSPersonStage_Walking &stage) const
return the current speed of the person
static double fromNaviDegree(const double angle)
Position getPosition(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the network coordinate of the person
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
double distToLaneEnd() const
the absolute distance to the end of the lane in walking direction (or to the arrivalPos) ...
SUMOTime string2time(const std::string &r)
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
const std::string & getID() const
returns the id of the transportable
std::vector< LinkLeader > LinkLeaders
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
bool hasInternalLinks() const
return whether the network contains internal links
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double getMinGap() const
Get the free space in front of vehicles of this class.
std::map< const MSLane *, Obstacles, lane_by_numid_sorter > NextLanesObstacles
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
double getArrivalPos() const
bool isCrossing() const
return whether this edge is a pedestrian crossing
bool isInternal() const
return whether this edge is an internal edge
SUMOTime myWaitingTime
the consecutive time spent at speed 0
const ConstMSEdgeVector & getRoute() const
int myDir
the walking direction on the current lane (1 forward, -1 backward)
static const double LOOKAHEAD_SAMEDIR
const SUMOVTypeParameter & getParameter() const
MSPedestrianRouter & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
double speed
speed relative to lane direction (positive means in the same direction)
const Obstacles & getNextLaneObstacles(NextLanesObstacles &nextLanesObs, const MSLane *lane, const MSLane *nextLane, int stripes, int nextDir, double currentLength, int currentDir)
void cleanupHelper()
remove state at simulation end
PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now)
register the given person as a pedestrian
static const double RESERVE_FOR_ONCOMING_FACTOR
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
void arriveAndAdvance(Pedestrians &pedestrians, SUMOTime currentTime, std::set< MSPerson *> &changedLane, int dir)
handle arrivals and lane advancement
static void transformToCurrentLanePositions(Obstacles &o, int currentDir, int nextDir, double currentLength, double nextLength)
abstract base class for managing callbacks to retrieve various state information from the model ...
double getMinX(const bool includeMinGap=true) const
return the minimum position on the lane
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
std::pair< const MSPerson *, double > PersonDist
bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
const std::vector< const MSEdge * >::iterator getRouteStep() const
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
std::map< const MSLane *, double > MinNextLengths
ObstacleType type
whether this obstacle denotes a border or a pedestrian
static const double DIST_FAR_AWAY
double getEdgePos(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
abstract methods inherited from PedestrianState
static const double ONCOMING_CONFLICT_PENALTY
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
const MSEdge * getNextEdge(const MSPerson::MSPersonStage_Walking &stage) const
return the list of internal edges if the pedestrian is on an intersection
static std::map< const MSEdge *, std::vector< const MSLane * > > myWalkingAreaFoes
std::vector< PState * > Pedestrians
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static double stripeWidth
model parameters
static const double INAPPROPRIATE_PENALTY
bool myWaitingToEnter
whether the pedestrian is waiting to start its walk
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
const MSJunction * getFromJunction() const
double distanceTo(const Obstacle &obs, const bool includeMinGap=true) const
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
A storage for options typed value containers)
Container for pedestrian state and individual position update function.
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
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< Obstacle > Obstacles
double getLength() const
Get vehicle's length [m].
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
PStateVehicle(const MSVehicle *veh, const MSLane *walkingarea, double relX, double relY)
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
static const int BACKWARD
bool isWalkingArea() const
return whether this edge is walking area
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
const MSEdge * getRouteEdge() const
static const double SAFETY_GAP
virtual double getMinX(const bool includeMinGap=true) const
return the minimum position on the lane
void push_back_noDoublePos(const Position &p)
insert in back a non double position
static void DEBUG_PRINT(const Obstacles &obs)
double getImpatience() const
Returns this type's impatience.
static void addCloserObstacle(Obstacles &obs, double x, int stripe, int numStripes, const std::string &id, double width, int dir, ObstacleType type)
const MSEdge * getNextRouteEdge() const
std::vector< MSEdge * > MSEdgeVector
const Position getBackPosition() const
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
int myNumActivePedestrians
the total number of active pedestrians
double getAngle(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the direction in which the person faces in degrees
static MinNextLengths myMinNextLengths
double getSpeed() const
Returns the vehicle's current speed.
std::string description
the id / description of the obstacle
SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the time the person spent standing
static void initWalkingAreaPaths(const MSNet *net)
MSPModel_Striping(const OptionsCont &oc, MSNet *net)
Constructor (it should not be necessary to construct more than one instance)
const std::string & getID() const
Returns the name of the vehicle.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const double MAX_WAIT_TOLERANCE
Representation of a lane in the micro simulation.
static const MSLane * getInternalFollowingLane(const MSLane *fromLane, const MSLane *followerAfterInternal)
ActiveLanes myActiveLanes
store of all lanes which have pedestrians on them
const MSLane * myLane
the current lane of this pedestrian
static bool addVehicleFoe(const MSVehicle *veh, const MSLane *walkingarea, const Position &relPos, double lateral_offset, double minY, double maxY, Pedestrians &toDelete, Pedestrians &transformedPeds)
Position transformToVectorCoordinates(const Position &p, bool extend=false) const
return position p within the length-wise coordinate system defined by this position vector...
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 ...
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
static const Position INVALID
used to indicate that a position is valid
static const double LOOKAROUND_VEHICLES
StageType getCurrentStageType() const
the current stage type of the transportable
void setRouteIndex(MSPerson *person, int routeOffset)
place person on a previously passed edge