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
100 #define MINGAP_TO_VEHICLE 0.25 129 const MSLane* lane = getSidewalk<MSEdge, MSLane>(person->
getEdge());
130 if (lane ==
nullptr) {
131 std::string error =
"Person '" + person->
getID() +
"' could not find sidewalk on edge '" + person->
getEdge()->
getID() +
"', time=" 157 const MSLane* lane =
dynamic_cast<PState*
>(state)->myLane;
159 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
161 pedestrians.erase(it);
170 double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
172 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
173 const PState& ped = **it_ped;
175 const double leaderBackDist = leaderFrontDist + ped.
getLength();
178 <<
" vehSide=" << vehSide
179 <<
" vehWidth=" << vehWidth
180 <<
" lBD=" << leaderBackDist
181 <<
" lFD=" << leaderFrontDist
184 if (leaderBackDist >= -vehWidth
185 && (leaderFrontDist < 0
190 if (collectBlockers ==
nullptr) {
193 collectBlockers->push_back(ped.
myPerson);
197 if (collectBlockers ==
nullptr) {
200 return collectBlockers->size() > 0;
224 double closest = std::numeric_limits<double>::max();
226 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
227 const PState& ped = **it_ped;
230 if (ped.
myRelX > minPos && (result.first == 0 || closest > relX2)) {
233 const bool overlap = (center + halfWidth > minRight && center - halfWidth < maxLeft);
235 std::cout <<
" nextBlocking lane=" << lane->
getID()
236 <<
" minPos=" << minPos <<
" minRight=" << minRight <<
" maxLeft=" << maxLeft
237 <<
" stopTime=" << stopTime
240 <<
" relX2=" << relX2
241 <<
" center=" << center
242 <<
" pedLeft=" << center + halfWidth
243 <<
" pedRight=" << center - halfWidth
244 <<
" overlap=" << overlap
286 if (from ==
nullptr || to ==
nullptr) {
306 const MSLane* walkingArea = getSidewalk<MSEdge, MSLane>(edge);
310 std::vector<const MSLane*> lanes;
312 for (
int j = 0; j < (int)incoming.size(); ++j) {
313 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
316 for (
int j = 0; j < (int)outgoing.size(); ++j) {
317 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
320 for (
int j = 0; j < (int)lanes.size(); ++j) {
321 for (
int k = 0; k < (int)lanes.size(); ++k) {
324 const MSLane* from = lanes[j];
325 const MSLane* to = lanes[k];
331 const double maxExtent = fromPos.
distanceTo2D(toPos) / 4;
332 const double extrapolateBy =
MIN2(maxExtent, walkingArea->
getWidth() / 2);
334 shape.push_back(fromPos);
344 if (shape.size() < 2) {
348 assert(shape.size() == 2);
356 myMinNextLengths[walkingArea] =
MIN2(myMinNextLengths[walkingArea], wap.
length);
368 std::vector<const MSLane*> lanes;
370 for (
int j = 0; j < (int)incoming.size(); ++j) {
371 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
374 for (
int j = 0; j < (int)outgoing.size(); ++j) {
375 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
377 if (lanes.size() < 1) {
378 throw ProcessError(
"Invalid walkingarea '" + walkingArea->
getID() +
"' does not allow continuation.");
389 const MSLane* nextRouteLane = getSidewalk<MSEdge, MSLane>(nextRouteEdge);
391 const MSLane* nextLane = nextRouteLane;
395 if (nextRouteLane ==
nullptr && nextRouteEdge !=
nullptr) {
396 std::string error =
"Person '" + ped.
myPerson->
getID() +
"' could not find sidewalk on edge '" + nextRouteEdge->
getID() +
"', time=" 400 nextRouteLane = nextRouteEdge->
getLanes().front();
406 if (nextRouteLane !=
nullptr) {
411 nextLane = currentLane->
getLinkCont()[0]->getViaLaneOrLane();
416 std::cout <<
" internal\n";
421 nextLane = currentLane->
getLinkCont()[0]->getLane();
426 std::cout <<
" crossing\n";
433 const double arrivalPos = (nextRouteEdge == ped.
myStage->
getRoute().back()
437 if (prevLane !=
nullptr) {
438 prohibited.push_back(&prevLane->
getEdge());
443 <<
" nre=" << nextRouteEdge->
getID()
444 <<
" nreDir=" << nextRouteEdgeDir
445 <<
" aPos=" << arrivalPos
446 <<
" crossingRoute=" <<
toString(crossingRoute)
449 if (crossingRoute.size() > 1) {
450 const MSEdge* nextEdge = crossingRoute[1];
451 nextLane = getSidewalk<MSEdge, MSLane>(crossingRoute[1]);
453 assert(nextLane != prevLane);
456 std::cout <<
" nextDir=" << nextDir <<
"\n";
472 <<
" no route from '" << (currentEdge ==
nullptr ?
"NULL" : currentEdge->
getID())
473 <<
"' to '" << (nextRouteEdge ==
nullptr ?
"NULL" : nextRouteEdge->
getID())
477 +
"' from walkingArea '" + currentEdge->
getID()
478 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
481 nextLane = nextRouteLane;
483 }
else if (currentEdge == nextRouteEdge) {
485 nextDir = -ped.
myDir;
490 if (nextLane !=
nullptr) {
493 std::cout <<
" next walkingArea " << (nextDir ==
FORWARD ?
"forward" :
"backward") <<
"\n";
502 if (link !=
nullptr) {
504 std::cout <<
" direct forward\n";
510 if (link !=
nullptr) {
512 std::cout <<
" direct backward\n";
515 if (nextLane !=
nullptr) {
517 while (nextLane->getLinkCont()[0]->getViaLaneOrLane()->isInternal()) {
518 nextLane = nextLane->getLinkCont()[0]->getViaLaneOrLane();
524 if (nextLane ==
nullptr) {
526 nextLane = nextRouteLane;
528 std::cout <<
SIMTIME <<
" no next lane found for " << currentLane->
getID() <<
" dir=" << ped.
myDir <<
"\n";
532 +
"' from edge '" + currentEdge->
getID()
533 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
538 nextLane = nextRouteLane;
545 <<
" l=" << currentLane->
getID()
546 <<
" nl=" << (nextLane ==
nullptr ?
"NULL" : nextLane->getID())
547 <<
" nrl=" << (nextRouteLane ==
nullptr ?
"NULL" : nextRouteLane->
getID())
550 <<
" pedDir=" << ped.
myDir 553 assert(nextLane != 0 || nextRouteLane == 0);
562 for (MSLinkCont::const_iterator it = links.begin(); it != links.end(); ++it) {
563 if ((*it)->getLane()->getEdge().isWalkingArea()) {
569 const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->
getIncomingLanes();
570 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
571 if ((*it).lane->getEdge().isWalkingArea()) {
572 link = (*it).viaLink;
583 const PState& ego = *pedestrians[egoIndex];
585 std::vector<bool> haveBlocker(stripes,
false);
586 for (
int index = egoIndex + 1; index < (int)pedestrians.size(); index++) {
587 const PState& p = *pedestrians[index];
594 std::cout <<
" dist=" << ego.
distanceTo(o) << std::endl;
602 haveBlocker[p.
stripe()] =
true;
605 if (!haveBlocker[p.
stripe()]) {
623 int offset = (destStripes - origStripes) / 2;
625 offset += (destStripes - origStripes) % 2;
633 MSLane* lane,
const MSLane* nextLane,
int stripes,
int nextDir,
634 double currentLength,
int currentDir) {
635 if (nextLanesObs.count(nextLane) == 0) {
642 const int offset =
getStripeOffset(nextStripes, stripes, currentDir != nextDir && nextStripes > stripes);
653 if (nextStripes < stripes) {
655 for (
int ii = 0; ii < stripes; ++ii) {
656 if (ii < offset || ii >= nextStripes + offset) {
667 if ((stripes - nextStripes) % 2 != 0) {
670 nextDir = currentDir;
672 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
673 PState& p = *pedestrians[ii];
678 const double newY = relPos.
y() + lateral_offset;
689 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(nextDir));
690 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
691 const PState& p = *pedestrians[ii];
697 if (nextDir != currentDir) {
702 const int stripe = p.
stripe(newY);
703 if (stripe >= 0 && stripe < stripes) {
707 if (otherStripe >= 0 && otherStripe < stripes) {
708 obs[otherStripe] = pObs;
723 nextLanesObs[nextLane] = obs;
725 return nextLanesObs[nextLane];
730 for (
int ii = 0; ii < (int)obs.size(); ++ii) {
734 o.
xFwd += currentLength;
735 o.
xBack += currentLength;
737 const double tmp = o.
xFwd;
738 o.
xFwd = currentLength + nextLength - o.
xBack;
739 o.
xBack = currentLength + nextLength - tmp;
743 const double tmp = o.
xFwd;
747 o.
xFwd -= nextLength;
748 o.
xBack -= nextLength;
757 if (stripe >= 0 && stripe < numStripes) {
758 if ((dir ==
FORWARD && x - width / 2. < obs[stripe].xBack) || (dir ==
BACKWARD && x + width / 2. > obs[stripe].xFwd)) {
759 obs[stripe] =
Obstacle(x, 0, type,
id, width);
767 const MSLane* lane = it_lane->first;
769 if (pedestrians.size() == 0) {
780 std::set<const WalkingAreaPath*, walkingarea_path_sorter> paths;
781 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
784 if (p->
myDir == dir) {
788 std::cout <<
SIMTIME <<
" debugging WalkingAreaPath from=" << debugPath->
from->
getID() <<
" to=" << debugPath->
to->
getID() <<
"\n";
792 for (std::set<const WalkingAreaPath*, walkingarea_path_sorter>::iterator it = paths.begin(); it != paths.end(); ++it) {
796 transformedPeds.reserve(pedestrians.size());
797 for (Pedestrians::iterator it_p = pedestrians.begin(); it_p != pedestrians.end(); ++it_p) {
802 transformedPeds.push_back(p);
803 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord=" 807 const double newY = relPos.
y() + lateral_offset;
815 toDelete.push_back(tp);
816 transformedPeds.push_back(tp);
817 if (path == debugPath) {
818 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (transformed), vecCoord=" << relPos <<
"\n";
821 if (path == debugPath) {
822 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (invalid), vecCoord=" << relPos <<
"\n";
830 for (Pedestrians::iterator it_p = toDelete.begin(); it_p != toDelete.end(); ++it_p) {
845 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
847 for (
int i = 0; i < (int)pedestrians.size(); i++) {
848 PState*
const p = pedestrians[i];
852 pedestrians.erase(pedestrians.begin() + i);
855 if (p->
myLane !=
nullptr) {
874 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
877 bool hasCrossingVehObs =
false;
880 hasCrossingVehObs =
addCrossingVehs(lane, stripes, 0, dir, crossingVehs,
true);
883 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
884 PState& p = *pedestrians[ii];
914 nextLanesObs, lane, nextLane, stripes,
933 const double passingClearanceTime = 2;
934 const double passingLength = p.
getLength() + passingClearanceTime * speed;
940 <<
" opened=" << (link ==
nullptr ?
"NULL" :
toString(link->opened(currentTime -
DELTA_T, speed, speed, passingLength, p.
getImpatience(currentTime), speed, 0, 0,
nullptr, p.
ignoreRed(link)))) <<
"\n";
976 if (hasCrossingVehObs) {
985 p.
walk(currentObs, currentTime);
992 for (
int coll = 0; coll < ii; ++coll) {
993 PState& c = *pedestrians[coll];
1000 +
"', lane='" + lane->
getID() +
"', time=" +
time2string(currentTime) +
".");
1013 bool hasCrossingVehObs =
false;
1018 if (linkLeaders.size() > 0) {
1019 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1021 const MSVehicle* veh = (*it).vehAndGap.first;
1022 if (veh !=
nullptr) {
1033 const double distToCrossBeforeVeh = (dir ==
FORWARD ? vo.xFwd : crossing->
getLength() - vo.xBack);
1034 const double bGap = (prio
1036 : veh->
getSpeed() * distToCrossBeforeVeh);
1040 if ((*it).fromLeft) {
1041 vehYmin = -(*it).vehAndGap.second + lateral_offset;
1045 vehYmax = crossing->
getWidth() + (*it).vehAndGap.second - lateral_offset;
1051 if ((dir ==
FORWARD && obs[s].xBack > vo.xBack)
1052 || (dir ==
BACKWARD && obs[s].xFwd < vo.xFwd)) {
1059 hasCrossingVehObs =
true;
1064 <<
" crossingVeh=" << veh->
getID()
1065 <<
" lane=" << crossing->
getID()
1067 <<
" latOffset=" << lateral_offset
1069 <<
" stripes=" << stripes
1070 <<
" dist=" << (*it).distToCrossing
1071 <<
" gap=" << (*it).vehAndGap.second
1072 <<
" brakeGap=" << bGap
1073 <<
" fromLeft=" << (*it).fromLeft
1074 <<
" distToCrossBefore=" << distToCrossBeforeVeh
1075 <<
" ymin=" << vehYmin
1076 <<
" ymax=" << vehYmax
1085 return hasCrossingVehObs;
1100 if (ped !=
nullptr) {
1120 const double vehNextSpeed =
MAX2(veh->
getSpeed(), 1.0);
1122 if ((dir ==
FORWARD && vehFront + clearance > minX && vehBack <= maxX + LOOKAHEAD_SAMEDIR)
1134 if (s == current && vehFront +
SAFETY_GAP < minX) {
1136 if (pRelY - pWidth < vehYmax &&
1137 pRelY + pWidth > vehYmin && dir ==
FORWARD) {
1139 std::cout <<
" ignoring vehicle on stripe " << s <<
"\n";
1150 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" obstacle on lane=" << lane->
getID()
1152 <<
" ymin=" << vehYmin
1153 <<
" ymax=" << vehYmax
1156 <<
" relY=" << pRelY
1157 <<
" current=" << current
1179 xFwd(ped.getMaxX()),
1180 xBack(ped.getMinX()),
1181 speed(ped.myDir * ped.mySpeed),
1197 myRelX(stage->getDepartPos()),
1198 myRelY(stage->getDepartPosLat()),
1201 myWaitingToEnter(true),
1203 myWalkingAreaPath(nullptr),
1206 myAngle(std::numeric_limits<double>::max()) {
1209 assert(!route.empty());
1210 if (route.size() == 1) {
1216 if (route.front()->isWalkingArea()) {
1223 std::cout <<
" initialize dir for " <<
myPerson->
getID() <<
" forward=" << mayStartForward <<
" backward=" << mayStartBackward <<
"\n";
1225 if (mayStartForward && mayStartBackward) {
1229 if (crossingRoute.size() > 1) {
1231 const MSEdge* nextEdge = crossingRoute[1];
1237 std::cout <<
" crossingRoute=" <<
toString(crossingRoute) <<
"\n";
1299 const int s =
stripe(relY);
1303 if (offset > threshold) {
1305 }
else if (offset < -threshold) {
1351 const int oldDir =
myDir;
1359 <<
" moveToNextLane old=" << oldLane->
getID()
1361 <<
" oldDir=" << oldDir
1362 <<
" newDir=" <<
myDir 1422 if (-dist > newLength) {
1429 myRelX = newLength + dist;
1435 <<
" newLength=" << newLength
1441 if (
myDir != oldDir) {
1452 <<
" od=" << oldDir <<
" nd=" <<
myDir 1453 <<
" offset=" << offset <<
"\n";
1465 myAngle = std::numeric_limits<double>::max();
1466 const int stripes = (int)obs.size();
1467 const int sMax = stripes - 1;
1471 const int current =
stripe();
1474 std::vector<double> distance(stripes);
1475 for (
int i = 0; i < stripes; ++i) {
1479 std::vector<double> utility(stripes, 0);
1481 for (
int i = 0; i < stripes; ++i) {
1487 for (
int j = 0; j <= i; ++j) {
1492 for (
int j = i; j < stripes; ++j) {
1504 for (
int i = 0; i < reserved; ++i) {
1508 for (
int i = sMax; i > sMax - reserved; --i) {
1513 for (
int i = 0; i < stripes; ++i) {
1514 if (obs[i].speed *
myDir < 0) {
1517 utility[i - 1] -= 0.5;
1519 utility[i + 1] -= 0.5;
1523 const double walkDist =
MAX2(0., distance[i]);
1527 std::cout <<
" util=" << utility[i] <<
" exp=" << expectedDist <<
" dist=" << distance[i] <<
"\n";
1529 if (expectedDist >= 0) {
1530 utility[i] += expectedDist;
1544 for (
int i = 0; i < stripes; ++i) {
1550 int chosen = current;
1551 for (
int i = 0; i < stripes; ++i) {
1552 if (utility[chosen] < utility[i]) {
1557 const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
1558 const double xDist =
MIN3(distance[current], distance[other], distance[next]);
1566 std::cout <<
" xSpeedPotential=" << xSpeed <<
"\n";
1573 (xDist == distance[current] && obs[current].type >=
OBSTACLE_END)
1574 || (xDist == distance[other] && obs[other].type >=
OBSTACLE_END)
1575 || (xDist == distance[next] && obs[next].type >=
OBSTACLE_END))
1616 ySpeed = (yDist > 0 ?
1637 <<
" cur=" << current
1638 <<
" cho=" << chosen
1642 <<
" dawdle=" << dawdle
1649 <<
"\n distance=" <<
toString(distance)
1650 <<
"\n utility=" <<
toString(utility)
1707 if (
myAngle != std::numeric_limits<double>::max()) {
1743 double lanePosLat,
double angle,
int routeOffset,
1760 if (lane !=
nullptr) {
1762 const MSLane* sidewalk = getSidewalk<MSEdge, MSLane>(&lane->
getEdge());
1763 if (lane != sidewalk) {
1768 pm->
add(
this, lane);
1770 if (edges.empty()) {
1794 const double maxX =
getMaxX(includeMinGap);
1795 const double minX =
getMinX(includeMinGap);
1799 if ((obs.
xFwd >= maxX && obs.
xBack <= maxX) || (obs.
xFwd <= maxX && obs.
xFwd >= minX)) {
1813 for (
int i = 0; i < (int)into.size(); ++i) {
1815 std::cout <<
" i=" << i
1816 <<
" into=" << into[i].description <<
" iDist=" <<
distanceTo(into[i])
1817 <<
" obs2=" << obs2[i].description <<
" oDist=" <<
distanceTo(obs2[i]) <<
"\n";
1835 for (
int i = 0; i < (int)into.size(); ++i) {
1836 int i2 = i + offset;
1837 if (i2 >= 0 && i2 < (
int)obs2.size()) {
1839 if (obs2[i2].xBack < into[i].xBack) {
1843 if (obs2[i2].xFwd > into[i].xFwd) {
1856 if (ignoreRedTime >= 0) {
1859 std::cout <<
SIMTIME <<
" ignoreRedTime=" << ignoreRedTime <<
" redDuration=" << redDuration <<
"\n";
1861 return ignoreRedTime > redDuration;
1877 std::set<MSPerson*> changedLane;
1882 for (ActiveLanes::const_iterator it_lane =
myModel->getActiveLanes().begin(); it_lane !=
myModel->getActiveLanes().end(); ++it_lane) {
1883 const MSLane* lane = it_lane->first;
1885 if (pedestrians.size() == 0) {
1890 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
1891 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 ...
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
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.
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 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
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)
PState(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, const MSLane *lane)
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.
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
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
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
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
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.
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 ...
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
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 ...
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
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
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 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
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