SUMO - Simulation of Urban MObility
MSPModel_Striping.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The pedestrian following model (prototype)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2014-2014 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <math.h>
31 #include <algorithm>
34 #include <microsim/MSNet.h>
35 #include <microsim/MSEdge.h>
36 #include <microsim/MSLane.h>
37 #include <microsim/MSJunction.h>
38 #include "MSPModel_Striping.h"
39 
40 
41 // ===========================================================================
42 // DEBUGGING HELPERS
43 // ===========================================================================
44 //
45 #define DEBUG1 "disabled"
46 #define DEBUG2 "disabled"
47 #define DEBUGCOND(PEDID) (PEDID == DEBUG1 || PEDID == DEBUG2)
48 #define LOG_ALL false
49 
51  for (int i = 0; i < (int)obs.size(); ++i) {
52  std::cout
53  << "(" << obs[i].description
54  << " x=" << obs[i].x
55  << " s=" << obs[i].speed
56  << ") ";
57  }
58  std::cout << "\n";
59 }
60 
61 // ===========================================================================
62 // named (internal) constants
63 // ===========================================================================
64 
65 
66 // need to be able to subtract without underflow
67 #define BLOCKED_STRIPE -10000
68 #define FAR_AWAY 10000
69 #define ONCOMING_CONFLICT -1000
70 
71 // ===========================================================================
72 // static members
73 // ===========================================================================
74 
77 
78 
79 // model parameters (static to simplify access from class PState
83 const SUMOReal MSPModel_Striping::LOOKAHEAD_ONCOMING(10.0); // seconds
88 const SUMOReal MSPModel_Striping::MAX_WAIT_TOLERANCE(120.); // seconds
90 
91 
92 // ===========================================================================
93 // MSPModel_Striping method definitions
94 // ===========================================================================
95 
97  myNumActivePedestrians(0) {
98  myCommand = new MovePedestrians(this);
101  // configurable parameters
102  stripeWidth = oc.getFloat("pedestrian.striping.stripe-width");
103  dawdling = oc.getFloat("pedestrian.striping.dawdling");
104 }
105 
106 
108 }
109 
110 
113  assert(person->getCurrentStageType() == MSPerson::WALKING);
114  const MSLane* lane = getSidewalk(person->getEdge());
115  PState* ped = new PState(person, stage, lane);
116  myActiveLanes[lane].push_back(ped);
118  return ped;
119 }
120 
121 
122 bool
123 MSPModel_Striping::blockedAtDist(const MSLane* lane, SUMOReal distToCrossing, std::vector<const MSPerson*>* collectBlockers) {
124  const Pedestrians& pedestrians = getPedestrians(lane);
125  for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
126  const PState& ped = **it_ped;
127  const SUMOReal halfVehicleWidth = 1.0; // @note could get the actual value from the vehicle
128  const SUMOReal leaderBackDist = (ped.myDir == FORWARD
129  ? distToCrossing - (ped.myRelX - ped.getLength() - MSPModel::SAFETY_GAP - halfVehicleWidth)
130  : (ped.myRelX + ped.getLength() + MSPModel::SAFETY_GAP + halfVehicleWidth) - distToCrossing);
131  //std::cout << SIMTIME << " foe=" << foeLane->getID() << " dir=" << p.myDir << " pX=" << ped.myRelX << " pL=" << ped.getLength() << " fDTC=" << distToCrossing << " lBD=" << leaderBackDist << "\n";
132  if (leaderBackDist >= 0 && leaderBackDist <= BLOCKER_LOOKAHEAD) {
133  // found one pedestrian that is not completely past the crossing point
134  //std::cout << SIMTIME << " blocking pedestrian foeLane=" << lane->getID() << " ped=" << ped.myPerson->getID() << " dir=" << ped.myDir << " pX=" << ped.myRelX << " pL=" << ped.getLength() << " fDTC=" << distToCrossing << " lBD=" << leaderBackDist << "\n";
135  if (collectBlockers == 0) {
136  return true;
137  } else {
138  collectBlockers->push_back(ped.myPerson);
139  }
140  }
141  }
142  if (collectBlockers == 0) {
143  return false;
144  } else {
145  return collectBlockers->size() > 0;
146  }
147 }
148 
149 
152  ActiveLanes::iterator it = myActiveLanes.find(lane);
153  if (it != myActiveLanes.end()) {
154  //std::cout << " found lane=" << lane->getID() << " n=" << it->second.size() << "\n";
155  return (it->second);
156  } else {
157  return noPedestrians;
158  }
159 }
160 
161 
162 void
164  myActiveLanes.clear();
166  myWalkingAreaPaths.clear(); // need to recompute when lane pointers change
167 }
168 
169 
170 int
172  return (int)floor(lane->getWidth() / stripeWidth);
173 }
174 
175 int
177  if (from == 0 || to == 0) {
178  return UNDEFINED_DIRECTION;
179  } else if (MSLinkContHelper::getConnectingLink(*from, *to)) {
180  return FORWARD;
181  } else if (MSLinkContHelper::getConnectingLink(*to, *from)) {
182  return BACKWARD;
183  } else {
184  return UNDEFINED_DIRECTION;
185  }
186 }
187 
188 
189 void
191  if (myWalkingAreaPaths.size() > 0) {
192  return;
193  }
194  for (size_t i = 0; i < MSEdge::dictSize(); ++i) {
195  const MSEdge* edge = MSEdge::dictionary(i);
196  if (edge->isWalkingArea()) {
197  const MSLane* walkingArea = getSidewalk(edge);
198  // build all possible paths across this walkingArea
199  // gather all incident lanes
200  std::vector<MSLane*> lanes;
201  const std::vector<MSEdge*>& incoming = edge->getIncomingEdges();
202  for (int j = 0; j < (int)incoming.size(); ++j) {
203  lanes.push_back(getSidewalk(incoming[j]));
204  }
205  for (int j = 0; j < (int)edge->getNoFollowing(); ++j) {
206  lanes.push_back(getSidewalk(edge->getFollower(j)));
207  }
208  // build all combinations
209  for (int j = 0; j < (int)lanes.size(); ++j) {
210  for (int k = 0; k < (int)lanes.size(); ++k) {
211  if (j != k) {
212  // build the walkingArea
213  const MSLane* from = lanes[j];
214  const MSLane* to = lanes[k];
215  const int fromDir = MSLinkContHelper::getConnectingLink(*from, *walkingArea) != 0 ? FORWARD : BACKWARD;
216  const int toDir = MSLinkContHelper::getConnectingLink(*walkingArea, *to) != 0 ? FORWARD : BACKWARD;
217  PositionVector shape;
218  Position fromPos = from->getShape()[fromDir == FORWARD ? -1 : 0];
219  Position toPos = to->getShape()[toDir == FORWARD ? 0 : -1];
220  const SUMOReal maxExtent = fromPos.distanceTo2D(toPos) / 4; // prevent sharp corners
221  const SUMOReal extrapolateBy = MIN2(maxExtent, walkingArea->getWidth() / 2);
222  // assemble shape
223  shape.push_back(fromPos);
224  if (extrapolateBy > POSITION_EPS) {
225  PositionVector fromShp = from->getShape();
226  fromShp.extrapolate(extrapolateBy);
227  shape.push_back(fromDir == FORWARD ? fromShp.back() : fromShp.front());
228  PositionVector nextShp = to->getShape();
229  nextShp.extrapolate(extrapolateBy);
230  shape.push_back(toDir == FORWARD ? nextShp.front() : nextShp.back());
231  }
232  shape.push_back(toPos);
233  if (fromDir == BACKWARD) {
234  // will be walking backward on walkingArea
235  shape = shape.reverse();
236  }
237  myWalkingAreaPaths[std::make_pair(from, to)] = WalkingAreaPath(from, walkingArea, to, shape);
238  }
239  }
240  }
241  }
242  }
243 }
244 
245 
247 MSPModel_Striping::getNextLane(const PState& ped, const MSLane* currentLane, const MSLane* prevLane) {
248  const MSEdge* currentEdge = &currentLane->getEdge();
249  const MSJunction* junction = ped.myDir == FORWARD ? currentEdge->getToJunction() : currentEdge->getFromJunction();
250  const MSEdge* nextRouteEdge = ped.myStage->getNextRouteEdge();
251  const MSLane* nextRouteLane = getSidewalk(nextRouteEdge);
252  // result values
253  const MSLane* nextLane = nextRouteLane;
254  MSLink* link = 0;
255  int nextDir = UNDEFINED_DIRECTION;
256 
257  if (nextRouteLane != 0) {
258  if (currentEdge->isInternal()) {
259  assert(junction == currentEdge->getFromJunction());
260  nextDir = junction == nextRouteEdge->getFromJunction() ? FORWARD : BACKWARD;
261  if DEBUGCOND(ped.myPerson->getID()) {
262  std::cout << " internal\n";
263  }
264  } else if (currentEdge->isCrossing()) {
265  nextDir = ped.myDir;
266  if (ped.myDir == FORWARD) {
267  nextLane = currentLane->getLinkCont()[0]->getLane();
268  } else {
269  nextLane = currentLane->getLogicalPredecessorLane();
270  }
271  if DEBUGCOND(ped.myPerson->getID()) {
272  std::cout << " crossing\n";
273  }
274  } else if (currentEdge->isWalkingArea()) {
275  std::vector<const MSEdge*> crossingRoute;
276  // departPos can be 0 because the direction of the walkingArea does not matter
277  // for the arrivalPos, we need to make sure that the route does not deviate across other junctions
278  const int nextRouteEdgeDir = nextRouteEdge->getFromJunction() == junction ? FORWARD : BACKWARD;
279  const SUMOReal arrivalPos = (nextRouteEdge == ped.myStage->getRoute().back()
280  ? ped.myStage->getArrivalPos()
281  : (nextRouteEdgeDir == FORWARD ? 0 : nextRouteEdge->getLength()));
282  std::vector<MSEdge*> prohibited;
283  prohibited.push_back(&prevLane->getEdge());
284  MSNet::getInstance()->getPedestrianRouter(prohibited).compute(currentEdge, nextRouteEdge, 0, arrivalPos, ped.myStage->getMaxSpeed(), 0, junction, crossingRoute, true);
285  if DEBUGCOND(ped.myPerson->getID()) {
286  std::cout
287  << " nreDir=" << nextRouteEdgeDir
288  << " aPos=" << arrivalPos
289  << " crossingRoute=" << toString(crossingRoute)
290  << "\n";
291  }
292  if (crossingRoute.size() > 1) {
293  const MSEdge* nextEdge = crossingRoute[1];
294  nextLane = getSidewalk(crossingRoute[1]);
295  assert((nextEdge->getFromJunction() == junction || nextEdge->getToJunction() == junction));
296  assert(nextLane != prevLane);
297  nextDir = connectedDirection(currentLane, nextLane);
298  if DEBUGCOND(ped.myPerson->getID()) {
299  std::cout << " nextDir=" << nextDir << "\n";
300  }
301  assert(nextDir != UNDEFINED_DIRECTION);
302  if (nextDir == FORWARD) {
303  link = MSLinkContHelper::getConnectingLink(*currentLane, *nextLane);
304  } else if (nextEdge->isCrossing()) {
305  const MSLane* oppositeWalkingArea = nextLane->getLogicalPredecessorLane();
306  link = MSLinkContHelper::getConnectingLink(*oppositeWalkingArea, *nextLane);
307  } else {
308  link = MSLinkContHelper::getConnectingLink(*nextLane, *currentLane);
309  }
310  assert(link != 0);
311  } else {
312  if DEBUGCOND(ped.myPerson->getID()) {
313  std::cout << SIMTIME
314  << " no route from '" << (currentEdge == 0 ? "NULL" : currentEdge->getID())
315  << "' to '" << (nextRouteEdge == 0 ? "NULL" : nextRouteEdge->getID())
316  << "\n";
317  }
318  nextDir = FORWARD; // fallback
319  }
320  } else {
321  // normal edge. by default use next / previous walking area
322  nextDir = ped.myDir;
323  nextLane = getNextWalkingArea(currentLane, ped.myDir, link);
324  if (nextLane != 0) {
325  // walking area found
326  if DEBUGCOND(ped.myPerson->getID()) {
327  std::cout << " next walkingArea " << (nextDir == FORWARD ? "forward" : "backward") << "\n";
328  }
329  } else {
330  // try to use a direct link as fallback
331  // direct links only exist if built explicitly. They are used to model tl-controlled links if there are no crossings
332  if (ped.myDir == FORWARD) {
333  link = MSLinkContHelper::getConnectingLink(*currentLane, *nextRouteLane);
334 #ifdef HAVE_INTERNAL_LANES
335  if (link != 0) {
336  if DEBUGCOND(ped.myPerson->getID()) {
337  std::cout << " direct forward\n";
338  }
339  nextLane = MSLinkContHelper::getInternalFollowingLane(currentLane, nextRouteLane);
340  }
341 #endif
342  } else {
343  link = MSLinkContHelper::getConnectingLink(*nextRouteLane, *currentLane);
344 #ifdef HAVE_INTERNAL_LANES
345  if (link != 0) {
346  if DEBUGCOND(ped.myPerson->getID()) {
347  std::cout << " direct backward\n";
348  }
349  nextLane = MSLinkContHelper::getInternalFollowingLane(nextRouteLane, currentLane);
350  }
351 #endif
352  }
353  }
354  if (nextLane == 0) {
355  // no internal lane found
356  nextLane = nextRouteLane;
357  if DEBUGCOND(ped.myPerson->getID()) {
358  std::cout << SIMTIME << " no next lane found for " << currentLane->getID() << " dir=" << ped.myDir << "\n";
359  }
360  } else if (nextLane->getLength() <= POSITION_EPS) {
361  // internal lane too short
362  nextLane = nextRouteLane;
363  }
364  }
365  }
366  if DEBUGCOND(ped.myPerson->getID()) {
367  std::cout << SIMTIME
368  << " p=" << ped.myPerson->getID()
369  << " l=" << currentLane->getID()
370  << " nl=" << (nextLane == 0 ? "NULL" : nextLane->getID())
371  << " nrl=" << (nextRouteLane == 0 ? "NULL" : nextRouteLane->getID())
372  << " d=" << nextDir
373  << " link=" << (link == 0 ? "NULL" : link->getViaLaneOrLane()->getID())
374  << " pedDir=" << ped.myDir
375  << "\n";
376  }
377  return NextLaneInfo(nextLane, link, nextDir);
378 }
379 
380 
381 const MSLane*
382 MSPModel_Striping::getNextWalkingArea(const MSLane* currentLane, const int dir, MSLink*& link) {
383  if (dir == FORWARD) {
384  const MSLinkCont& links = currentLane->getLinkCont();
385  for (MSLinkCont::const_iterator it = links.begin(); it != links.end(); ++it) {
386  if ((*it)->getLane()->getEdge().isWalkingArea()) {
387  link = *it;
388  return (*it)->getLane();
389  }
390  }
391  } else {
392  const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->getIncomingLanes();
393  for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
394  if ((*it).lane->getEdge().isWalkingArea()) {
395  link = (*it).viaLink;
396  return (*it).lane;
397  }
398  }
399  }
400  return 0;
401 }
402 
403 
405 MSPModel_Striping::mergeObstacles(const Obstacles& obs1, const Obstacles& obs2, int dir) {
406  Obstacles result(obs1.begin(), obs1.end());
407  for (int i = 0; i < (int)obs1.size(); ++i) {
408  if ((obs2[i].x - obs1[i].x) * dir < 0) {
409  result[i] = obs2[i];
410  }
411  }
412  return result;
413 }
414 
415 
417 MSPModel_Striping::getNeighboringObstacles(const Pedestrians& pedestrians, int egoIndex, int stripes) {
418  const PState& ego = *pedestrians[egoIndex];
419  const SUMOReal egoBack = ego.myRelX - ego.myDir * ego.getLength();
420  int index = egoIndex + 1;
421  Obstacles obs(stripes, Obstacle(ego.myDir));
422  while (index < (int)pedestrians.size() && ego.myDir * (pedestrians[index]->myRelX - egoBack) > 0) {
423  const PState& p = *pedestrians[index];
424  if (!p.myWaitingToEnter) {
425  Obstacle o(p, ego.myDir);
426  obs[p.stripe()] = o;
427  obs[p.otherStripe()] = o;
428  }
429  index++;
430  }
431  if DEBUGCOND(ego.myPerson->getID()) {
432  std::cout << SIMTIME << " ped=" << ego.myPerson->getID() << " neighObs=";
433  DEBUG_PRINT(obs);
434  }
435  return obs;
436 }
437 
438 
440 MSPModel_Striping::getNextLaneObstacles(NextLanesObstacles& nextLanesObs, const MSLane* nextLane, int stripes, SUMOReal nextLength, int nextDir,
441  SUMOReal currentLength, int currentDir) {
442  if (nextLanesObs.count(nextLane) == 0) {
443  //std::cout << SIMTIME << " getNextLaneObstacles"
444  // << " nextLane=" << nextLane->getID()
445  // << " nextLength=" << nextLength
446  // << " nextDir=" << nextDir
447  // << " currentLength=" << currentLength
448  // << " currentDir=" << currentDir
449  // << "\n";
450 
451  // figure out the which pedestrians are ahead on the next lane
452  const int offset = (stripes - numStripes(nextLane)) / 2;
453  Obstacles obs(stripes, Obstacle(nextDir));
454  Pedestrians& pedestrians = getPedestrians(nextLane);
455  // XXX consider waitingToEnter on nextLane
456  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(nextDir));
457  for (int ii = 0; ii < (int)pedestrians.size(); ++ii) {
458  const PState& p = *pedestrians[ii];
459  if (p.myWaitingToEnter) {
460  continue;
461  }
462  Obstacle o(p, nextDir);
463  int mappedStripe = p.stripe() + offset;
464  if (mappedStripe >= 0 && mappedStripe < stripes) {
465  obs[mappedStripe] = o;
466  }
467  mappedStripe = p.otherStripe() + offset;
468  if (mappedStripe >= 0 && mappedStripe < stripes) {
469  obs[mappedStripe] = o;
470  }
471  }
472  for (int ii = 0; ii < stripes; ++ii) {
473  Obstacle& o = obs[ii];
474  if (nextDir == BACKWARD) {
475  o.x = nextLength - o.x;
476  }
477  if (currentDir == FORWARD) {
478  o.x += currentLength;
479  } else {
480  o.x *= -1;
481  }
482  }
483  nextLanesObs[nextLane] = obs;
484  }
485  return nextLanesObs[nextLane];
486 }
487 
488 
489 void
490 MSPModel_Striping::moveInDirection(SUMOTime currentTime, std::set<MSPerson*>& changedLane, int dir) {
491  for (ActiveLanes::iterator it_lane = myActiveLanes.begin(); it_lane != myActiveLanes.end(); ++it_lane) {
492  const MSLane* lane = it_lane->first;
493  const int stripes = numStripes(lane);
494  Pedestrians& pedestrians = it_lane->second;
495  //std::cout << SIMTIME << ">>> lane=" << lane->getID() << " numPeds=" << pedestrians.size() << "\n";
496 
497  // move forward
498  Obstacles obs(stripes, Obstacle(dir)); // continously updated
499  NextLanesObstacles nextLanesObs; // continously updated
500  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(dir));
501  for (int ii = 0; ii < (int)pedestrians.size(); ++ii) {
502  PState& p = *pedestrians[ii];
503  //std::cout << SIMTIME << "CHECKING" << p.myPerson->getID() << "\n";
504  Obstacles currentObs = obs;
505  if (p.myDir != dir || changedLane.count(p.myPerson) != 0) {
506  if (!p.myWaitingToEnter) {
507  Obstacle o(p, dir);
508  obs[p.stripe()] = o;
509  obs[p.otherStripe()] = o;
510  }
511  continue;
512  }
513  if DEBUGCOND(p.myPerson->getID()) {
514  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " currentObs=";
515  DEBUG_PRINT(currentObs);
516  }
517  const MSLane* nextLane = p.myNLI.lane;
518  const MSLink* link = p.myNLI.link;
519  const SUMOReal dist = p.distToLaneEnd();
520  const SUMOReal speed = p.myStage->getMaxSpeed();
521  if (nextLane != 0) {
522  const SUMOReal currentLength = (p.myWalkingAreaPath == 0 ? lane->getLength() : p.myWalkingAreaPath->length);
523  const SUMOReal nextLength = nextLane->getLength(); // XXX what to do if nextLane is a walkingArea?
524  const Obstacles& nextObs = getNextLaneObstacles(
525  nextLanesObs, nextLane, stripes,
526  nextLength, p.myNLI.dir,
527  currentLength, dir);
528 
529  if DEBUGCOND(p.myPerson->getID()) {
530  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " nextObs=";
531  DEBUG_PRINT(nextObs);
532  }
533  currentObs = mergeObstacles(currentObs, nextObs, dir);
534  }
535  if DEBUGCOND(p.myPerson->getID()) {
536  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " obsWithNext=";
537  DEBUG_PRINT(currentObs);
538  }
539  currentObs = mergeObstacles(currentObs, getNeighboringObstacles(pedestrians, ii, stripes), dir);
540  if DEBUGCOND(p.myPerson->getID()) {
541  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " obsWithNeigh=";
542  DEBUG_PRINT(currentObs);
543  }
544  // check link state
545  if (link != 0
546  && dist < speed // only check close before junction
547  && (!link->opened(currentTime, speed, speed, p.getLength(), p.getImpatience(currentTime), speed, 0)
548  // XXX check for presence of vehicles blocking the path
549  )) {
550  // prevent movement passed a closed link
551  Obstacles closedLink(stripes, Obstacle(p.myRelX + dir * dist - POSITION_EPS, 0, "closedLink"));
552  currentObs = mergeObstacles(currentObs, closedLink, dir);
553  if DEBUGCOND(p.myPerson->getID()) {
554  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " obsWitTLS=";
555  DEBUG_PRINT(currentObs);
556  }
557  // consider rerouting over another crossing
558  if (p.myWalkingAreaPath != 0) {
559  // XXX actually another path would be needed starting at the current position
561  }
562  }
563  p.walk(currentObs, currentTime);
564  if (!p.myWaitingToEnter) {
565  Obstacle o(p, dir);
566  obs[p.stripe()] = o;
567  obs[p.otherStripe()] = o;
568  }
569  //std::cout << SIMTIME << p.myPerson->getID() << " lane=" << lane->getID() << " x=" << p.myRelX << "\n";
570  }
571 
572  // advance to the next lane
573  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(dir));
574  bool checkAdvance = true;
575  while (checkAdvance) {
576  checkAdvance = false;;
577  if (pedestrians.size() > 0) {
578  PState* p = pedestrians.front();
579  if (p->myDir != dir) {
580  continue;
581  }
582  if (p->moveToNextLane(currentTime)) {
583  pedestrians.erase(pedestrians.begin());
584  checkAdvance = true;
585  if (p->myLane != 0) {
586  changedLane.insert(p->myPerson);
587  myActiveLanes[p->myLane].push_back(p);
588  } else {
589  delete p;
591  }
592  }
593  }
594  }
595  }
596 }
597 
598 // ===========================================================================
599 // MSPModel_Striping::Obstacle method definitions
600 // ===========================================================================
602  x(dir* FAR_AWAY), // far away when seen in dir
603  speed(0),
604  description("")
605 {}
606 
607 
609  description(ped.myPerson->getID()) {
610  assert(!ped.myWaitingToEnter);
611  if (dir == ped.myDir) {
612  speed = ped.mySpeed;
613  x = ped.myRelX - dir * ped.getLength();
614  } else {
615  speed = -ped.mySpeed;
616  x = ped.myRelX;
617  }
618 }
619 
620 
621 // ===========================================================================
622 // MSPModel_Striping::PState method definitions
623 // ===========================================================================
624 
625 
627  myPerson(person),
628  myStage(stage),
629  myLane(lane),
630  myRelX(stage->getDepartPos()),
631  myRelY(0),
632  myDir(FORWARD),
633  mySpeed(0),
634  myBlockedByOncoming(false),
635  myWaitingToEnter(true),
636  myWaitingTime(0),
637  myWalkingAreaPath(0) {
638  const MSEdge* currentEdge = &lane->getEdge();
639  assert(!currentEdge->isWalkingArea());
640  const std::vector<const MSEdge*>& route = myStage->getRoute();
641  if (route.size() == 1) {
642  // only a single edge, move towards end pos
644  } else {
645  const bool mayStartForward = canTraverse(FORWARD, route);
646  const bool mayStartBackward = canTraverse(BACKWARD, route);
647  if DEBUGCOND(myPerson->getID()) {
648  std::cout << " initialize dir for " << myPerson->getID() << " forward=" << mayStartForward << " backward=" << mayStartBackward << "\n";
649  }
650  if (mayStartForward && mayStartBackward) {
651  // figure out the best direction via routing
652  std::vector<const MSEdge*> crossingRoute;
653  MSNet::getInstance()->getPedestrianRouter().compute(currentEdge, route.back(), myRelX, myStage->getArrivalPos(), myStage->getMaxSpeed(), 0, 0, crossingRoute, true);
654  if (crossingRoute.size() > 1) {
655  // route found
656  const MSEdge* nextEdge = crossingRoute[1];
657  if (nextEdge->getFromJunction() == currentEdge->getFromJunction() || nextEdge->getToJunction() == currentEdge->getFromJunction()) {
658  myDir = BACKWARD;
659  }
660  }
661  if DEBUGCOND(myPerson->getID()) {
662  std::cout << " crossingRoute=" << toString(crossingRoute) << "\n";
663  }
664  } else {
665  myDir = !mayStartBackward ? FORWARD : BACKWARD;
666  }
667  }
668  if (myDir == FORWARD) {
669  // start at the right side of the sidewalk
670  myRelY = stripeWidth * (numStripes(lane) - 1);
671  }
672  if DEBUGCOND(myPerson->getID()) {
673  std::cout << " added new pedestrian " << myPerson->getID() << " on " << lane->getID() << " myRelX=" << myRelX << " myRelY=" << myRelY << " dir=" << myDir << " route=" << toString(myStage->getRoute()) << "\n";
674  }
675 
676  myNLI = getNextLane(*this, lane, 0);
677 }
678 
679 
680 SUMOReal
682  return myPerson->getVehicleType().getLength();
683 }
684 
685 
686 int
688  const int max = numStripes(myLane) - 1;
689  return MIN2(MAX2(0, (int)floor((myRelY + 0.5 * stripeWidth) / stripeWidth)), max);
690 }
691 
692 
693 int
695  const int max = numStripes(myLane) - 1;
696  const int s = stripe();
697  const SUMOReal offset = myRelY - s * stripeWidth;
698  const SUMOReal threshold = MAX2(NUMERICAL_EPS, stripeWidth - SQUEEZE * myPerson->getVehicleType().getWidth());
699  int result;
700  if (offset > threshold) {
701  result = s + 1;
702  } else if (offset < -threshold) {
703  result = s - 1;
704  } else {
705  result = s;
706  }
707  std::cout.setf(std::ios::fixed , std::ios::floatfield);
708  std::cout << std::setprecision(5);
709  //if DEBUGCOND(myPerson->getID()) std::cout << " otherStripe " << myPerson->getID() << " offset=" << offset << " threshold=" << threshold << " rawResult=" << result << "\n";
710  return MIN2(MAX2(0, result), max);
711 }
712 
713 
714 SUMOReal
716  if (myStage->getNextRouteEdge() == 0) {
717  return myDir * (myStage->getArrivalPos() - myRelX);
718  } else {
719  const SUMOReal length = myWalkingAreaPath == 0 ? myLane->getLength() : myWalkingAreaPath->length;
720  return myDir == FORWARD ? length - myRelX : myRelX;
721  }
722 }
723 
724 
725 bool
727  const SUMOReal dist = distToLaneEnd();
728  //if (myPerson->getID() == DEBUG1) {
729  // std::cout << SIMTIME << " myRelX=" << myRelX << " dist=" << dist << "\n";
730  //}
731  if (dist <= 0) {
732  //if (ped.myPerson->getID() == DEBUG1) {
733  // std::cout << SIMTIME << " addToLane x=" << ped.myRelX << " newDir=" << newDir << " newLane=" << newLane->getID() << " walkingAreaShape=" << walkingAreaShape << "\n";
734  //}
735  //std::cout << " changing to " << newLane->getID() << " myRelY=" << ped.myRelY << " oldStripes=" << oldStripes << " newStripes=" << numStripes(newLane);
736  //std::cout << " newY=" << ped.myRelY << " myDir=" << ped.myDir << " newDir=" << newDir;
737  const int oldStripes = numStripes(myLane);
738  const int oldDir = myDir;
739  const MSLane* oldLane = myLane;
740  myLane = myNLI.lane;
741  myDir = myNLI.dir;
742  const bool normalLane = (myLane == 0 || myLane->getEdge().getPurpose() == MSEdge::EDGEFUNCTION_NORMAL);
743  if DEBUGCOND(myPerson->getID()) {
744  std::cout << SIMTIME
745  << " ped=" << myPerson->getID()
746  << " moveToNextLane old=" << oldLane->getID()
747  << " new=" << (myLane == 0 ? "NULL" : myLane->getID())
748  << "\n";
749  }
750  myStage->moveToNextEdge(myPerson, currentTime, normalLane ? 0 : &myLane->getEdge());
751  if (myLane != 0) {
752  assert(myDir != UNDEFINED_DIRECTION);
753  myNLI = getNextLane(*this, myLane, oldLane);
754  if DEBUGCOND(myPerson->getID()) {
755  std::cout << " nextLane=" << (myNLI.lane == 0 ? "NULL" : myNLI.lane->getID()) << "\n";
756  }
757  if (myLane->getEdge().isWalkingArea()) {
758  myWalkingAreaPath = &myWalkingAreaPaths[std::make_pair(oldLane, myNLI.lane)];
759  assert(myWalkingAreaPath->from != 0);
760  assert(myWalkingAreaPath->to != 0);
761  assert(myWalkingAreaPath->shape.size() >= 2);
762  if DEBUGCOND(myPerson->getID()) {
763  std::cout << " mWAPath shape=" << myWalkingAreaPath->shape << " length=" << myWalkingAreaPath->length << "\n";
764  }
765  } else {
766  myWalkingAreaPath = 0;
767  }
768  // adapt x to fit onto the new lane
769  if (myDir == BACKWARD) {
770  const SUMOReal newLength = (myWalkingAreaPath == 0 ? myLane->getLength() : myWalkingAreaPath->length);
771  myRelX = newLength + dist;
772  } else {
773  myRelX = -dist;
774  }
775  // adjust to change in direction
776  if (myDir != oldDir) {
777  myRelY = (numStripes(oldLane) - 1) * stripeWidth - myRelY;
778  }
779  // adjust to differences in sidewalk width
780  myRelY += 0.5 * stripeWidth * (numStripes(myLane) - oldStripes);
781  }
782  return true;
783  } else {
784  return false;
785  }
786 }
787 
788 
789 void
791  const int stripes = (int)obs.size();
792  const int sMax = stripes - 1;
793  assert(stripes == numStripes(myLane));
794  const SUMOReal vMax = myStage->getMaxSpeed();
795  // ultimate goal is to chose the prefered stripe (chosen)
796  const int current = stripe();
797  const int other = otherStripe();
798  int chosen = current;
799  // compute utility for all stripes
800  std::vector<SUMOReal> utility(stripes, 0);
801 
802  // penalize lateral movement (may increase jamming)
803  for (int i = 0; i < stripes; ++i) {
804  utility[i] += abs(i - current) * LATERAL_PENALTY;
805  }
806  // compute distances
807  std::vector<SUMOReal> distance(stripes);
808  for (int i = 0; i < stripes; ++i) {
809  distance[i] += myDir * (obs[i].x - myRelX);
810  }
811  // forbid stripes which are blocked and also all stripes behind them
812  for (int i = 0; i < stripes; ++i) {
813  if (distance[i] <= 0) {
814  if (i < current) {
815  for (int j = 0; j <= i; ++j) {
816  utility[j] = 2 * BLOCKED_STRIPE;
817  }
818  } else {
819  for (int j = i; j < stripes; ++j) {
820  utility[j] = 2 * BLOCKED_STRIPE;
821  }
822  }
823  }
824  }
825  // forbid a portion of the leftmost stripes (in walking direction).
826  // lanes with stripes less than 1 / RESERVE_FOR_ONCOMING_FACTOR
827  // may still deadlock in heavy pedestrian traffic
828  const int reserved = (int)floor(stripes * RESERVE_FOR_ONCOMING_FACTOR);
829  if (myDir == FORWARD) {
830  for (int i = 0; i < reserved; ++i) {
831  utility[i] = BLOCKED_STRIPE;
832  }
833  } else {
834  for (int i = sMax; i > sMax - reserved; --i) {
835  utility[i] = BLOCKED_STRIPE;
836  }
837  }
838  // adapt utility based on obstacles
839  for (int i = 0; i < stripes; ++i) {
840  if (obs[i].speed < 0) {
841  // penalize evasion to the left
842  if (myDir == FORWARD && i > 0) {
843  utility[i - 1] -= 0.5;
844  } else if (myDir == BACKWARD && i < sMax) {
845  utility[i + 1] -= 0.5;
846  }
847  }
848  // compute expected distance achievable by staying on this stripe for a time horizon
849  const SUMOReal lookAhead = obs[i].speed >= 0 ? LOOKAHEAD_SAMEDIR : LOOKAHEAD_ONCOMING;
850  const SUMOReal expectedDist = MIN2(vMax * LOOKAHEAD_SAMEDIR, distance[i] + obs[i].speed * lookAhead);
851  if (DEBUGCOND(myPerson->getID())) {
852  std::cout << " util=" << utility[i] << " exp=" << expectedDist << "\n";
853  }
854  if (expectedDist >= 0) {
855  utility[i] += expectedDist;
856  } else {
857  // let only the distance count
858  utility[i] += ONCOMING_CONFLICT + distance[i];
859  }
860  }
861  // bonus to remain on the rightmost lane (in walking direction) if there
862  // are oncoming
863  if (((myDir == FORWARD && current == sMax)
864  || (myDir == BACKWARD && current == 0))
865  && obs[current].speed < 0) {
866  utility[current] -= ONCOMING_CONFLICT;
867  }
868  // bonus to leave the leftmost lane (in walking direction) if there
869  // are oncoming
870  if (((myDir == BACKWARD && current == sMax)
871  || (myDir == FORWARD && current == 0))
872  && obs[current].speed < 0) {
873  utility[current] += ONCOMING_CONFLICT;
874  }
875 
876  // select best stripe
877  for (int i = 0; i < stripes; ++i) {
878  if (utility[chosen] < utility[i]) {
879  chosen = i;
880  }
881  }
882  // compute speed components along both axes
883  const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
884  const SUMOReal xDist = MIN3(distance[current], distance[other], distance[next]);
885  // XXX preferred gap differs between approaching a standing obstacle or a moving obstacle
886  const SUMOReal preferredGap = myPerson->getVehicleType().getMinGap() + xDist * 0.5;
887  SUMOReal xSpeed = MIN2(vMax, MAX2((SUMOReal)0, xDist - preferredGap));
888  // avoid tiny steps
889  // XXX pressure from behind?
890  if (DEBUGCOND(myPerson->getID())) {
891  std::cout << " xSpeedPotential=" << xSpeed << "\n";
892  }
893  if (mySpeed == 0 && xSpeed < 0.5 * vMax) {
894  xSpeed = 0;
895  }
896  // dawdling
897  const SUMOReal dawdle = MIN2(xSpeed, RandHelper::rand() * vMax * dawdling);
898  xSpeed -= dawdle;
899 
900  // XXX ensure that diagonal speed <= vMax
901  // avoid deadlocks on narrow sidewalks
902  //if (oncoming && xSpeed == 0 && myStage->getWaitingTime(currentTime) > TIME2STEPS(ONCOMIN_PATIENCE)) {
903  // if DEBUGCOND(myPerson->getID()) std::cout << " stepping asside to resolve oncoming deadlock\n";
904  // xSpeed = POSITION_EPS; // reset myWaitingTime
905  // if (myDir == FORWARD && chosen < sMax) {
906  // chosen += 1;
907  // } else if (myDir == BACKWARD && chosen > 0) {
908  // chosen -= 1;
909  // }
910  //}
911  const SUMOReal maxYSpeed = MAX2(vMax * LATERAL_SPEED_FACTOR, vMax - xSpeed);
912  SUMOReal ySpeed = 0;
913  const SUMOReal yDist = (chosen * stripeWidth) - myRelY;
914  if (fabs(yDist) > NUMERICAL_EPS) {
915  ySpeed = (yDist > 0 ?
916  MIN2(maxYSpeed, yDist) :
917  MAX2(-maxYSpeed, yDist));
918  }
919  // DEBUG
920  if (true && DEBUGCOND(myPerson->getID())) {
921  std::cout << SIMTIME
922  << " ped=" << myPerson->getID()
923  << " edge=" << myStage->getEdge()->getID()
924  << " x=" << myRelX
925  << " y=" << myRelY
926  << " d=" << myDir
927  << " pvx=" << mySpeed
928  << " cur=" << current
929  << " cho=" << chosen
930  << " oth=" << other
931  << " nxt=" << next
932  << " vx=" << xSpeed
933  << " dawdle=" << dawdle
934  << " vy=" << ySpeed
935  << " xd=" << xDist
936  << " yd=" << yDist
937  << " vMax=" << myStage->getMaxSpeed()
938  << " wTime=" << myStage->getWaitingTime(currentTime)
939  << "\n distance=" << toString(distance)
940  << " utility=" << toString(utility)
941  << "\n";
942  DEBUG_PRINT(obs);
943  }
944  myRelX += SPEED2DIST(xSpeed * myDir);
945  myRelY += SPEED2DIST(ySpeed);
946  mySpeed = xSpeed;
947  if (xSpeed > 0) {
948  myWaitingToEnter = false;
949  myWaitingTime = 0;
950  } else {
951  myWaitingTime += DELTA_T;
952  }
953 }
954 
955 
956 SUMOReal
958  return MAX2((SUMOReal)0, MIN2(SUMOReal(1),
959  myPerson->getVehicleType().getImpatience()
960  + STEPS2TIME(myStage->getWaitingTime(now)) / MAX_WAIT_TOLERANCE));
961 }
962 
963 
964 SUMOReal
966  return myRelX;
967 }
968 
969 
970 Position
972  if (myLane == 0) {
973  // pedestrian has already finished
974  return Position::INVALID;
975  }
976  const SUMOReal lateral_offset = myRelY + (stripeWidth - myLane->getWidth()) * 0.5;
977  if (myWalkingAreaPath == 0) {
978  return stage.getLanePosition(myLane, myRelX, lateral_offset);
979  } else {
980  return myWalkingAreaPath->shape.positionAtOffset(myRelX, lateral_offset);
981  }
982 }
983 
984 
985 SUMOReal
987  if (myLane == 0) {
988  // pedestrian has already finished
989  return 0;
990  }
991  const PositionVector& shp = myWalkingAreaPath == 0 ? myLane->getShape() : myWalkingAreaPath->shape;
992  SUMOReal angle = -shp.rotationDegreeAtOffset(myRelX) + (myDir == MSPModel::BACKWARD ? 180 : 0);
993  if (angle > 180) {
994  angle -= 360;
995  }
996  return angle;
997 }
998 
999 
1000 SUMOTime
1002  return myWaitingTime;
1003 }
1004 
1005 
1006 SUMOReal
1008  return mySpeed;
1009 }
1010 
1011 // ===========================================================================
1012 // MSPModel_Striping::MovePedestrians method definitions
1013 // ===========================================================================
1014 //
1015 
1016 SUMOTime
1018  std::set<MSPerson*> changedLane;
1019  myModel->moveInDirection(currentTime, changedLane, FORWARD);
1020  myModel->moveInDirection(currentTime, changedLane, BACKWARD);
1021  // DEBUG
1022  if (LOG_ALL) {
1023  for (ActiveLanes::const_iterator it_lane = myModel->getActiveLanes().begin(); it_lane != myModel->getActiveLanes().end(); ++it_lane) {
1024  const MSLane* lane = it_lane->first;
1025  Pedestrians pedestrians = it_lane->second;
1026  if (pedestrians.size() == 0) {
1027  continue;
1028  }
1029  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(FORWARD));
1030  std::cout << SIMTIME << " lane=" << lane->getID();
1031  for (int ii = 0; ii < (int)pedestrians.size(); ++ii) {
1032  const PState& p = *pedestrians[ii];
1033  std::cout << " (" << p.myPerson->getID() << " " << p.myRelX << "," << p.myRelY << " " << p.myDir << ")";
1034  }
1035  std::cout << "\n";
1036  }
1037  }
1038  return DELTA_T;
1039 }
1040 
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...
const std::string & getID() const
returns the person id
Definition: MSPerson.cpp:551
bool blockedAtDist(const MSLane *lane, SUMOReal distToCrossing, std::vector< const MSPerson * > *collectBlockers)
whether a pedestrian is blocking the crossing of lane at offset distToCrossing
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:454
static const SUMOReal SAFETY_GAP
Definition: MSPModel.h:81
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:269
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
SUMOReal distToLaneEnd() const
the absolute distance to the end of the lane in walking direction (or to the arrivalPos) ...
MSPerson::MSPersonStage_Walking * myStage
Position getLanePosition(const MSLane *lane, SUMOReal at, SUMOReal offset) const
get position on lane at length at with orthogonal offset
Definition: MSPerson.cpp:102
static SUMOReal stripeWidth
model parameters
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)
SUMOReal mySpeed
the current walking speed
static const MSLane * getNextWalkingArea(const MSLane *currentLane, const int dir, MSLink *&link)
return the next walkingArea in the given direction
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
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.h:559
information regarding surround Pedestrians (and potentially other things)
SUMOReal getLength() const
Returns the lane's length.
Definition: MSLane.h:370
The base class for an intersection.
Definition: MSJunction.h:58
StageType getCurrentStageType() const
Definition: MSPerson.h:584
#define BLOCKED_STRIPE
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:230
PState(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, const MSLane *lane)
static const int FORWARD
Definition: MSPModel.h:73
#define ONCOMING_CONFLICT
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
SUMOReal getWidth() const
Returns the lane's width.
Definition: MSLane.h:386
#define DEBUGCOND(PEDID)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
T MAX2(T a, T b)
Definition: StdDefs.h:72
static MSLane * getSidewalk(const MSEdge *edge)
return the appropriate lane to walk on
Definition: MSPModel.cpp:93
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
Definition: MSEdge.cpp:473
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
std::map< std::pair< const MSLane *, const MSLane * >, WalkingAreaPath > WalkingAreaPaths
bool moveToNextLane(SUMOTime currentTime)
return whether this pedestrian has passed the end of the current lane and update myRelX if so ...
#define FAR_AWAY
static MSPModel * myModel
Definition: MSPModel.h:90
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:216
static WalkingAreaPaths myWalkingAreaPaths
store for walkinArea elements
#define abs(a)
Definition: polyfonts.c:67
The simulated network and simulation perfomer.
Definition: MSNet.h:91
#define SIMTIME
Definition: SUMOTime.h:96
static Pedestrians noPedestrians
empty pedestrian vector
static const SUMOReal RESERVE_FOR_ONCOMING_FACTOR
PositionVector reverse() const
void moveInDirection(SUMOTime currentTime, std::set< MSPerson * > &changedLane, int dir)
move all pedestrians forward and advance to the next lane if applicable
static bool canTraverse(int dir, const std::vector< const MSEdge * > &route)
return whether the route may traversed with the given starting direction
Definition: MSPModel.cpp:109
NextLaneInfo myNLI
information about the upcoming lane
const std::vector< const MSEdge * > & getRoute() const
Definition: MSPerson.h:272
static const SUMOReal SQUEEZE
const std::string & getID() const
Returns the id.
Definition: Named.h:60
A road/street connecting two junctions.
Definition: MSEdge.h:74
Pedestrians & getPedestrians(const MSLane *lane)
retrieves the pedestian vector for the given lane (may be empty)
static const SUMOReal LOOKAHEAD_SAMEDIR
void compute(const E *from, const E *to, SUMOReal departPos, SUMOReal arrivalPos, SUMOReal 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...
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:78
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.cpp:576
MSLane * getLogicalPredecessorLane() const
Definition: MSLane.cpp:1226
#define max(a, b)
Definition: polyfonts.c:65
const Obstacles & getNextLaneObstacles(NextLanesObstacles &nextLanesObs, const MSLane *nextLane, int stripes, SUMOReal nextLength, int nextDir, SUMOReal currentLength, int currentDir)
static const SUMOReal LATERAL_SPEED_FACTOR
SUMOTime execute(SUMOTime currentTime)
Executes the command.
void walk(const Obstacles &obs, SUMOTime currentTime)
perform position update
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
static const SUMOReal LOOKAHEAD_ONCOMING
A list of positions.
SUMOReal getLength() const
return the length of the pedestrian
unsigned int getNoFollowing() const
Returns the number of edges that may be reached from this edge.
Definition: MSEdge.h:279
SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the time the person spent standing
static Obstacles mergeObstacles(const Obstacles &obs1, const Obstacles &obs2, int dir)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
T MIN2(T a, T b)
Definition: StdDefs.h:66
#define POSITION_EPS
Definition: config.h:186
Position getPosition(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the network coordinate of the person
SUMOReal getAngle(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the direction in which the person faces in degrees
SUMOReal x
position on the current lane
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:220
int myDir
the walking direction on the current lane (1 forward, -1 backward)
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
SUMOReal getEdgePos(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
abstract methods inherited from PedestrianState
SUMOReal getSpeed(const MSPerson::MSPersonStage_Walking &stage) const
return the current speed of the person
void cleanupHelper()
remove state at simulation end
PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now)
register the given person as a pedestrian
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:96
void extrapolate(SUMOReal val)
SUMOReal getArrivalPos() const
Definition: MSPerson.h:262
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
const std::vector< MSEdge * > & getIncomingEdges() const
Returns the list of edges from which this edge may be reached.
Definition: MSEdge.h:271
SUMOReal getImpatience(SUMOTime now) const
returns the impatience
std::vector< PState * > Pedestrians
bool myWaitingToEnter
whether the pedestrian is waiting to start its walk
The edge is a normal street.
Definition: MSEdge.h:87
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:507
A storage for options typed value containers)
Definition: OptionsCont.h:108
Container for pedestrian state and individual position update function.
std::vector< Obstacle > Obstacles
static const SUMOReal BLOCKER_LOOKAHEAD
const MSEdge * getFollower(unsigned int n) const
Returns the n-th of the following edges.
Definition: MSEdge.h:288
static const int BACKWARD
Definition: MSPModel.h:77
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:323
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:240
Patch the time in a way that it is at least as high as the simulation begin time. ...
#define SUMOReal
Definition: config.h:215
SUMOReal myRelY
the orthogonal shift on the current lane
std::map< const MSLane *, Obstacles > NextLanesObstacles
static const SUMOReal MAX_WAIT_TOLERANCE
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:225
SUMOReal myRelX
the advancement along the current lane
const MSJunction * getFromJunction() const
Definition: MSEdge.h:293
T MIN3(T a, T b, T c)
Definition: StdDefs.h:79
MovePedestrians * myCommand
the MovePedestrians command that is registered
#define NUMERICAL_EPS
Definition: config.h:159
static void DEBUG_PRINT(const Obstacles &obs)
#define DELTA_T
Definition: SUMOTime.h:50
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:997
static SUMOReal dawdling
int myNumActivePedestrians
the total number of active pedestrians
SUMOReal speed
speed relative to ego direction (positive means in the same direction)
MSEventControl & getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:340
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:581
SUMOReal getMaxSpeed() const
accessors to be used by MSPModel
Definition: MSPerson.h:256
static void initWalkingAreaPaths(const MSNet *net)
MSPedestrianRouterDijkstra & getPedestrianRouter(const std::vector< MSEdge * > &prohibited=std::vector< MSEdge * >()) const
Definition: MSNet.cpp:766
MSPModel_Striping(const OptionsCont &oc, MSNet *net)
Constructor (it should not be necessary to construct more than one instance)
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
ActiveLanes myActiveLanes
store of all lanes which have pedestrians on them
const MSLane * myLane
the current lane of this pedestrian
#define LOG_ALL
static const SUMOReal LATERAL_PENALTY
Obstacle(int dir)
create No-Obstacle
static const Position INVALID
Definition: Position.h:262
const MSJunction * getToJunction() const
Definition: MSEdge.h:297