SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.dlr.de/
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 1
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->getNumSuccessors(); ++j) {
206  lanes.push_back(getSidewalk(edge->getSuccessor(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_noDoublePos(fromDir == FORWARD ? fromShp.back() : fromShp.front());
228  PositionVector nextShp = to->getShape();
229  nextShp.extrapolate(extrapolateBy);
230  shape.push_back_noDoublePos(toDir == FORWARD ? nextShp.front() : nextShp.back());
231  }
232  shape.push_back_noDoublePos(toPos);
233  if (shape.size() < 2) {
234  PositionVector fromShp = from->getShape();
235  fromShp.extrapolate(1.5 * POSITION_EPS); // noDoublePos requires a difference of POSITION_EPS in at least one coordinate
236  shape.push_back_noDoublePos(fromDir == FORWARD ? fromShp.back() : fromShp.front());
237  assert(shape.size() == 2);
238  }
239  if (fromDir == BACKWARD) {
240  // will be walking backward on walkingArea
241  shape = shape.reverse();
242  }
243  myWalkingAreaPaths[std::make_pair(from, to)] = WalkingAreaPath(from, walkingArea, to, shape);
244  }
245  }
246  }
247  }
248  }
249 }
250 
251 
253 MSPModel_Striping::getNextLane(const PState& ped, const MSLane* currentLane, const MSLane* prevLane) {
254  const MSEdge* currentEdge = &currentLane->getEdge();
255  const MSJunction* junction = ped.myDir == FORWARD ? currentEdge->getToJunction() : currentEdge->getFromJunction();
256  const MSEdge* nextRouteEdge = ped.myStage->getNextRouteEdge();
257  const MSLane* nextRouteLane = getSidewalk(nextRouteEdge);
258  // result values
259  const MSLane* nextLane = nextRouteLane;
260  MSLink* link = 0;
261  int nextDir = UNDEFINED_DIRECTION;
262 
263  if (nextRouteLane != 0) {
264  if (currentEdge->isInternal()) {
265  assert(junction == currentEdge->getFromJunction());
266  nextDir = junction == nextRouteEdge->getFromJunction() ? FORWARD : BACKWARD;
267  if DEBUGCOND(ped.myPerson->getID()) {
268  std::cout << " internal\n";
269  }
270  } else if (currentEdge->isCrossing()) {
271  nextDir = ped.myDir;
272  if (ped.myDir == FORWARD) {
273  nextLane = currentLane->getLinkCont()[0]->getLane();
274  } else {
275  nextLane = currentLane->getLogicalPredecessorLane();
276  }
277  if DEBUGCOND(ped.myPerson->getID()) {
278  std::cout << " crossing\n";
279  }
280  } else if (currentEdge->isWalkingArea()) {
281  std::vector<const MSEdge*> crossingRoute;
282  // departPos can be 0 because the direction of the walkingArea does not matter
283  // for the arrivalPos, we need to make sure that the route does not deviate across other junctions
284  const int nextRouteEdgeDir = nextRouteEdge->getFromJunction() == junction ? FORWARD : BACKWARD;
285  const SUMOReal arrivalPos = (nextRouteEdge == ped.myStage->getRoute().back()
286  ? ped.myStage->getArrivalPos()
287  : (nextRouteEdgeDir == FORWARD ? 0 : nextRouteEdge->getLength()));
288  std::vector<MSEdge*> prohibited;
289  prohibited.push_back(&prevLane->getEdge());
290  MSNet::getInstance()->getPedestrianRouter(prohibited).compute(currentEdge, nextRouteEdge, 0, arrivalPos, ped.myStage->getMaxSpeed(), 0, junction, crossingRoute, true);
291  if DEBUGCOND(ped.myPerson->getID()) {
292  std::cout
293  << " nreDir=" << nextRouteEdgeDir
294  << " aPos=" << arrivalPos
295  << " crossingRoute=" << toString(crossingRoute)
296  << "\n";
297  }
298  if (crossingRoute.size() > 1) {
299  const MSEdge* nextEdge = crossingRoute[1];
300  nextLane = getSidewalk(crossingRoute[1]);
301  assert((nextEdge->getFromJunction() == junction || nextEdge->getToJunction() == junction));
302  assert(nextLane != prevLane);
303  nextDir = connectedDirection(currentLane, nextLane);
304  if DEBUGCOND(ped.myPerson->getID()) {
305  std::cout << " nextDir=" << nextDir << "\n";
306  }
307  assert(nextDir != UNDEFINED_DIRECTION);
308  if (nextDir == FORWARD) {
309  link = MSLinkContHelper::getConnectingLink(*currentLane, *nextLane);
310  } else if (nextEdge->isCrossing()) {
311  const MSLane* oppositeWalkingArea = nextLane->getLogicalPredecessorLane();
312  link = MSLinkContHelper::getConnectingLink(*oppositeWalkingArea, *nextLane);
313  } else {
314  link = MSLinkContHelper::getConnectingLink(*nextLane, *currentLane);
315  }
316  assert(link != 0);
317  } else {
318  if DEBUGCOND(ped.myPerson->getID()) {
319  std::cout << SIMTIME
320  << " no route from '" << (currentEdge == 0 ? "NULL" : currentEdge->getID())
321  << "' to '" << (nextRouteEdge == 0 ? "NULL" : nextRouteEdge->getID())
322  << "\n";
323  }
324  nextDir = FORWARD; // fallback
325  }
326  } else {
327  // normal edge. by default use next / previous walking area
328  nextDir = ped.myDir;
329  nextLane = getNextWalkingArea(currentLane, ped.myDir, link);
330  if (nextLane != 0) {
331  // walking area found
332  if DEBUGCOND(ped.myPerson->getID()) {
333  std::cout << " next walkingArea " << (nextDir == FORWARD ? "forward" : "backward") << "\n";
334  }
335  } else {
336  // try to use a direct link as fallback
337  // direct links only exist if built explicitly. They are used to model tl-controlled links if there are no crossings
338  if (ped.myDir == FORWARD) {
339  link = MSLinkContHelper::getConnectingLink(*currentLane, *nextRouteLane);
340 #ifdef HAVE_INTERNAL_LANES
341  if (link != 0) {
342  if DEBUGCOND(ped.myPerson->getID()) {
343  std::cout << " direct forward\n";
344  }
345  nextLane = MSLinkContHelper::getInternalFollowingLane(currentLane, nextRouteLane);
346  }
347 #endif
348  } else {
349  link = MSLinkContHelper::getConnectingLink(*nextRouteLane, *currentLane);
350 #ifdef HAVE_INTERNAL_LANES
351  if (link != 0) {
352  if DEBUGCOND(ped.myPerson->getID()) {
353  std::cout << " direct backward\n";
354  }
355  nextLane = MSLinkContHelper::getInternalFollowingLane(nextRouteLane, currentLane);
356  }
357 #endif
358  }
359  }
360  if (nextLane == 0) {
361  // no internal lane found
362  nextLane = nextRouteLane;
363  if DEBUGCOND(ped.myPerson->getID()) {
364  std::cout << SIMTIME << " no next lane found for " << currentLane->getID() << " dir=" << ped.myDir << "\n";
365  }
366  } else if (nextLane->getLength() <= POSITION_EPS) {
367  // internal lane too short
368  nextLane = nextRouteLane;
369  }
370  }
371  }
372  if DEBUGCOND(ped.myPerson->getID()) {
373  std::cout << SIMTIME
374  << " p=" << ped.myPerson->getID()
375  << " l=" << currentLane->getID()
376  << " nl=" << (nextLane == 0 ? "NULL" : nextLane->getID())
377  << " nrl=" << (nextRouteLane == 0 ? "NULL" : nextRouteLane->getID())
378  << " d=" << nextDir
379  << " link=" << (link == 0 ? "NULL" : link->getViaLaneOrLane()->getID())
380  << " pedDir=" << ped.myDir
381  << "\n";
382  }
383  return NextLaneInfo(nextLane, link, nextDir);
384 }
385 
386 
387 const MSLane*
388 MSPModel_Striping::getNextWalkingArea(const MSLane* currentLane, const int dir, MSLink*& link) {
389  if (dir == FORWARD) {
390  const MSLinkCont& links = currentLane->getLinkCont();
391  for (MSLinkCont::const_iterator it = links.begin(); it != links.end(); ++it) {
392  if ((*it)->getLane()->getEdge().isWalkingArea()) {
393  link = *it;
394  return (*it)->getLane();
395  }
396  }
397  } else {
398  const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->getIncomingLanes();
399  for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
400  if ((*it).lane->getEdge().isWalkingArea()) {
401  link = (*it).viaLink;
402  return (*it).lane;
403  }
404  }
405  }
406  return 0;
407 }
408 
409 
411 MSPModel_Striping::mergeObstacles(const Obstacles& obs1, const Obstacles& obs2, int dir) {
412  Obstacles result(obs1.begin(), obs1.end());
413  for (int i = 0; i < (int)obs1.size(); ++i) {
414  if ((obs2[i].x - obs1[i].x) * dir < 0) {
415  result[i] = obs2[i];
416  }
417  }
418  return result;
419 }
420 
421 
423 MSPModel_Striping::getNeighboringObstacles(const Pedestrians& pedestrians, int egoIndex, int stripes) {
424  const PState& ego = *pedestrians[egoIndex];
425  const SUMOReal egoBack = ego.myRelX - ego.myDir * ego.getLength();
426  int index = egoIndex + 1;
427  Obstacles obs(stripes, Obstacle(ego.myDir));
428  while (index < (int)pedestrians.size() && ego.myDir * (pedestrians[index]->myRelX - egoBack) > 0) {
429  const PState& p = *pedestrians[index];
430  if (!p.myWaitingToEnter) {
431  Obstacle o(p, ego.myDir);
432  obs[p.stripe()] = o;
433  obs[p.otherStripe()] = o;
434  }
435  index++;
436  }
437  if DEBUGCOND(ego.myPerson->getID()) {
438  std::cout << SIMTIME << " ped=" << ego.myPerson->getID() << " neighObs=";
439  DEBUG_PRINT(obs);
440  }
441  return obs;
442 }
443 
444 
446 MSPModel_Striping::getNextLaneObstacles(NextLanesObstacles& nextLanesObs, const MSLane* nextLane, int stripes, SUMOReal nextLength, int nextDir,
447  SUMOReal currentLength, int currentDir) {
448  if (nextLanesObs.count(nextLane) == 0) {
449  //std::cout << SIMTIME << " getNextLaneObstacles"
450  // << " nextLane=" << nextLane->getID()
451  // << " nextLength=" << nextLength
452  // << " nextDir=" << nextDir
453  // << " currentLength=" << currentLength
454  // << " currentDir=" << currentDir
455  // << "\n";
456 
457  // figure out the which pedestrians are ahead on the next lane
458  const int offset = (stripes - numStripes(nextLane)) / 2;
459  Obstacles obs(stripes, Obstacle(nextDir));
460  Pedestrians& pedestrians = getPedestrians(nextLane);
461  // XXX consider waitingToEnter on nextLane
462  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(nextDir));
463  for (int ii = 0; ii < (int)pedestrians.size(); ++ii) {
464  const PState& p = *pedestrians[ii];
465  if (p.myWaitingToEnter) {
466  continue;
467  }
468  Obstacle o(p, nextDir);
469  int mappedStripe = p.stripe() + offset;
470  if (mappedStripe >= 0 && mappedStripe < stripes) {
471  obs[mappedStripe] = o;
472  }
473  mappedStripe = p.otherStripe() + offset;
474  if (mappedStripe >= 0 && mappedStripe < stripes) {
475  obs[mappedStripe] = o;
476  }
477  }
478  for (int ii = 0; ii < stripes; ++ii) {
479  Obstacle& o = obs[ii];
480  if (nextDir == BACKWARD) {
481  o.x = nextLength - o.x;
482  }
483  if (currentDir == FORWARD) {
484  o.x += currentLength;
485  } else {
486  o.x *= -1;
487  }
488  }
489  nextLanesObs[nextLane] = obs;
490  }
491  return nextLanesObs[nextLane];
492 }
493 
494 
495 void
496 MSPModel_Striping::moveInDirection(SUMOTime currentTime, std::set<MSPerson*>& changedLane, int dir) {
497  for (ActiveLanes::iterator it_lane = myActiveLanes.begin(); it_lane != myActiveLanes.end(); ++it_lane) {
498  const MSLane* lane = it_lane->first;
499  const int stripes = numStripes(lane);
500  Pedestrians& pedestrians = it_lane->second;
501  //std::cout << SIMTIME << ">>> lane=" << lane->getID() << " numPeds=" << pedestrians.size() << "\n";
502 
503  // move forward
504  Obstacles obs(stripes, Obstacle(dir)); // continously updated
505  NextLanesObstacles nextLanesObs; // continously updated
506  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(dir));
507  for (int ii = 0; ii < (int)pedestrians.size(); ++ii) {
508  PState& p = *pedestrians[ii];
509  //std::cout << SIMTIME << "CHECKING" << p.myPerson->getID() << "\n";
510  Obstacles currentObs = obs;
511  if (p.myDir != dir || changedLane.count(p.myPerson) != 0) {
512  if (!p.myWaitingToEnter) {
513  Obstacle o(p, dir);
514  obs[p.stripe()] = o;
515  obs[p.otherStripe()] = o;
516  }
517  continue;
518  }
519  if DEBUGCOND(p.myPerson->getID()) {
520  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " currentObs=";
521  DEBUG_PRINT(currentObs);
522  }
523  const MSLane* nextLane = p.myNLI.lane;
524  const MSLink* link = p.myNLI.link;
525  const SUMOReal dist = p.distToLaneEnd();
526  const SUMOReal speed = p.myStage->getMaxSpeed();
527  if (nextLane != 0) {
528  const SUMOReal currentLength = (p.myWalkingAreaPath == 0 ? lane->getLength() : p.myWalkingAreaPath->length);
529  const SUMOReal nextLength = nextLane->getLength(); // XXX what to do if nextLane is a walkingArea?
530  const Obstacles& nextObs = getNextLaneObstacles(
531  nextLanesObs, nextLane, stripes,
532  nextLength, p.myNLI.dir,
533  currentLength, dir);
534 
535  if DEBUGCOND(p.myPerson->getID()) {
536  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " nextObs=";
537  DEBUG_PRINT(nextObs);
538  }
539  currentObs = mergeObstacles(currentObs, nextObs, dir);
540  }
541  if DEBUGCOND(p.myPerson->getID()) {
542  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " obsWithNext=";
543  DEBUG_PRINT(currentObs);
544  }
545  currentObs = mergeObstacles(currentObs, getNeighboringObstacles(pedestrians, ii, stripes), dir);
546  if DEBUGCOND(p.myPerson->getID()) {
547  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " obsWithNeigh=";
548  DEBUG_PRINT(currentObs);
549  }
550  // check link state
551  if (link != 0
552  && dist < speed // only check close before junction
553  && (!link->opened(currentTime, speed, speed, p.getLength(), p.getImpatience(currentTime), speed, 0)
554  // XXX check for presence of vehicles blocking the path
555  )) {
556  // prevent movement passed a closed link
557  Obstacles closedLink(stripes, Obstacle(p.myRelX + dir * dist - POSITION_EPS, 0, "closedLink"));
558  currentObs = mergeObstacles(currentObs, closedLink, dir);
559  if DEBUGCOND(p.myPerson->getID()) {
560  std::cout << SIMTIME << " ped=" << p.myPerson->getID() << " obsWitTLS=";
561  DEBUG_PRINT(currentObs);
562  }
563  // consider rerouting over another crossing
564  if (p.myWalkingAreaPath != 0) {
565  // XXX actually another path would be needed starting at the current position
567  }
568  }
569  p.walk(currentObs, currentTime);
570  if (!p.myWaitingToEnter) {
571  Obstacle o(p, dir);
572  obs[p.stripe()] = o;
573  obs[p.otherStripe()] = o;
574  }
575  //std::cout << SIMTIME << p.myPerson->getID() << " lane=" << lane->getID() << " x=" << p.myRelX << "\n";
576  }
577 
578  // advance to the next lane / arrive at destination
579  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(dir));
580  for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end();) {
581  PState* p = *it;
582  if (p->myDir != dir) {
583  ++it;
584  } else if (p->moveToNextLane(currentTime)) {
585  it = pedestrians.erase(it);
586  if (p->myLane != 0) {
587  changedLane.insert(p->myPerson);
588  myActiveLanes[p->myLane].push_back(p);
589  } else {
590  delete p;
592  }
593  } else {
594  ++it;
595  }
596  }
597  }
598 }
599 
600 // ===========================================================================
601 // MSPModel_Striping::Obstacle method definitions
602 // ===========================================================================
604  x(dir* FAR_AWAY), // far away when seen in dir
605  speed(0),
606  description("")
607 {}
608 
609 
611  description(ped.myPerson->getID()) {
612  assert(!ped.myWaitingToEnter);
613  if (dir == ped.myDir) {
614  speed = ped.mySpeed;
615  x = ped.myRelX - dir * ped.getLength();
616  } else {
617  speed = -ped.mySpeed;
618  x = ped.myRelX;
619  }
620 }
621 
622 
623 // ===========================================================================
624 // MSPModel_Striping::PState method definitions
625 // ===========================================================================
626 
627 
629  myPerson(person),
630  myStage(stage),
631  myLane(lane),
632  myRelX(stage->getDepartPos()),
633  myRelY(0),
634  myDir(FORWARD),
635  mySpeed(0),
636  myBlockedByOncoming(false),
637  myWaitingToEnter(true),
638  myWaitingTime(0),
639  myWalkingAreaPath(0) {
640  const MSEdge* currentEdge = &lane->getEdge();
641  assert(!currentEdge->isWalkingArea());
642  const std::vector<const MSEdge*>& route = myStage->getRoute();
643  if (route.size() == 1) {
644  // only a single edge, move towards end pos
646  } else {
647  const bool mayStartForward = canTraverse(FORWARD, route);
648  const bool mayStartBackward = canTraverse(BACKWARD, route);
649  if DEBUGCOND(myPerson->getID()) {
650  std::cout << " initialize dir for " << myPerson->getID() << " forward=" << mayStartForward << " backward=" << mayStartBackward << "\n";
651  }
652  if (mayStartForward && mayStartBackward) {
653  // figure out the best direction via routing
654  std::vector<const MSEdge*> crossingRoute;
655  MSNet::getInstance()->getPedestrianRouter().compute(currentEdge, route.back(), myRelX, myStage->getArrivalPos(), myStage->getMaxSpeed(), 0, 0, crossingRoute, true);
656  if (crossingRoute.size() > 1) {
657  // route found
658  const MSEdge* nextEdge = crossingRoute[1];
659  if (nextEdge->getFromJunction() == currentEdge->getFromJunction() || nextEdge->getToJunction() == currentEdge->getFromJunction()) {
660  myDir = BACKWARD;
661  }
662  }
663  if DEBUGCOND(myPerson->getID()) {
664  std::cout << " crossingRoute=" << toString(crossingRoute) << "\n";
665  }
666  } else {
667  myDir = !mayStartBackward ? FORWARD : BACKWARD;
668  }
669  }
670  if (myDir == FORWARD) {
671  // start at the right side of the sidewalk
672  myRelY = stripeWidth * (numStripes(lane) - 1);
673  }
674  if DEBUGCOND(myPerson->getID()) {
675  std::cout << " added new pedestrian " << myPerson->getID() << " on " << lane->getID() << " myRelX=" << myRelX << " myRelY=" << myRelY << " dir=" << myDir << " route=" << toString(myStage->getRoute()) << "\n";
676  }
677 
678  myNLI = getNextLane(*this, lane, 0);
679 }
680 
681 
682 SUMOReal
684  return myPerson->getVehicleType().getLength();
685 }
686 
687 
688 int
690  const int max = numStripes(myLane) - 1;
691  return MIN2(MAX2(0, (int)floor((myRelY + 0.5 * stripeWidth) / stripeWidth)), max);
692 }
693 
694 
695 int
697  const int max = numStripes(myLane) - 1;
698  const int s = stripe();
699  const SUMOReal offset = myRelY - s * stripeWidth;
700  const SUMOReal threshold = MAX2(NUMERICAL_EPS, stripeWidth - SQUEEZE * myPerson->getVehicleType().getWidth());
701  int result;
702  if (offset > threshold) {
703  result = s + 1;
704  } else if (offset < -threshold) {
705  result = s - 1;
706  } else {
707  result = s;
708  }
709  std::cout.setf(std::ios::fixed , std::ios::floatfield);
710  std::cout << std::setprecision(5);
711  //if DEBUGCOND(myPerson->getID()) std::cout << " otherStripe " << myPerson->getID() << " offset=" << offset << " threshold=" << threshold << " rawResult=" << result << "\n";
712  return MIN2(MAX2(0, result), max);
713 }
714 
715 
716 SUMOReal
718  if (myStage->getNextRouteEdge() == 0) {
719  return myDir * (myStage->getArrivalPos() - myRelX);
720  } else {
721  const SUMOReal length = myWalkingAreaPath == 0 ? myLane->getLength() : myWalkingAreaPath->length;
722  return myDir == FORWARD ? length - myRelX : myRelX;
723  }
724 }
725 
726 
727 bool
729  const SUMOReal dist = distToLaneEnd();
730  if (myPerson->getID() == DEBUG1) {
731  std::cout << SIMTIME << " myRelX=" << myRelX << " dist=" << dist << "\n";
732  }
733  if (dist <= 0) {
734  //if (ped.myPerson->getID() == DEBUG1) {
735  // std::cout << SIMTIME << " addToLane x=" << ped.myRelX << " newDir=" << newDir << " newLane=" << newLane->getID() << " walkingAreaShape=" << walkingAreaShape << "\n";
736  //}
737  //std::cout << " changing to " << newLane->getID() << " myRelY=" << ped.myRelY << " oldStripes=" << oldStripes << " newStripes=" << numStripes(newLane);
738  //std::cout << " newY=" << ped.myRelY << " myDir=" << ped.myDir << " newDir=" << newDir;
739  const int oldStripes = numStripes(myLane);
740  const int oldDir = myDir;
741  const MSLane* oldLane = myLane;
742  myLane = myNLI.lane;
743  myDir = myNLI.dir;
744  const bool normalLane = (myLane == 0 || myLane->getEdge().getPurpose() == MSEdge::EDGEFUNCTION_NORMAL);
745  if DEBUGCOND(myPerson->getID()) {
746  std::cout << SIMTIME
747  << " ped=" << myPerson->getID()
748  << " moveToNextLane old=" << oldLane->getID()
749  << " new=" << (myLane == 0 ? "NULL" : myLane->getID())
750  << "\n";
751  }
752  myStage->moveToNextEdge(myPerson, currentTime, normalLane ? 0 : &myLane->getEdge());
753  if (myLane != 0) {
754  assert(myDir != UNDEFINED_DIRECTION);
755  myNLI = getNextLane(*this, myLane, oldLane);
756  if DEBUGCOND(myPerson->getID()) {
757  std::cout << " nextLane=" << (myNLI.lane == 0 ? "NULL" : myNLI.lane->getID()) << "\n";
758  }
759  if (myLane->getEdge().isWalkingArea()) {
760  myWalkingAreaPath = &myWalkingAreaPaths[std::make_pair(oldLane, myNLI.lane)];
761  assert(myWalkingAreaPath->from != 0);
762  assert(myWalkingAreaPath->to != 0);
763  assert(myWalkingAreaPath->shape.size() >= 2);
764  if DEBUGCOND(myPerson->getID()) {
765  std::cout << " mWAPath shape=" << myWalkingAreaPath->shape << " length=" << myWalkingAreaPath->length << "\n";
766  }
767  } else {
768  myWalkingAreaPath = 0;
769  }
770  // adapt x to fit onto the new lane
771  if (myDir == BACKWARD) {
772  const SUMOReal newLength = (myWalkingAreaPath == 0 ? myLane->getLength() : myWalkingAreaPath->length);
773  myRelX = newLength + dist;
774  } else {
775  myRelX = -dist;
776  }
777  // adjust to change in direction
778  if (myDir != oldDir) {
779  myRelY = (numStripes(oldLane) - 1) * stripeWidth - myRelY;
780  }
781  // adjust to differences in sidewalk width
782  myRelY += 0.5 * stripeWidth * (numStripes(myLane) - oldStripes);
783  }
784  return true;
785  } else {
786  return false;
787  }
788 }
789 
790 
791 void
793  const int stripes = (int)obs.size();
794  const int sMax = stripes - 1;
795  assert(stripes == numStripes(myLane));
796  const SUMOReal vMax = myStage->getMaxSpeed();
797  // ultimate goal is to chose the prefered stripe (chosen)
798  const int current = stripe();
799  const int other = otherStripe();
800  int chosen = current;
801  // compute utility for all stripes
802  std::vector<SUMOReal> utility(stripes, 0);
803 
804  // penalize lateral movement (may increase jamming)
805  for (int i = 0; i < stripes; ++i) {
806  utility[i] += abs(i - current) * LATERAL_PENALTY;
807  }
808  // compute distances
809  std::vector<SUMOReal> distance(stripes);
810  for (int i = 0; i < stripes; ++i) {
811  distance[i] += myDir * (obs[i].x - myRelX);
812  }
813  // forbid stripes which are blocked and also all stripes behind them
814  for (int i = 0; i < stripes; ++i) {
815  if (distance[i] <= 0) {
816  if (i < current) {
817  for (int j = 0; j <= i; ++j) {
818  utility[j] = 2 * BLOCKED_STRIPE;
819  }
820  } else {
821  for (int j = i; j < stripes; ++j) {
822  utility[j] = 2 * BLOCKED_STRIPE;
823  }
824  }
825  }
826  }
827  // forbid a portion of the leftmost stripes (in walking direction).
828  // lanes with stripes less than 1 / RESERVE_FOR_ONCOMING_FACTOR
829  // may still deadlock in heavy pedestrian traffic
830  const int reserved = (int)floor(stripes * RESERVE_FOR_ONCOMING_FACTOR);
831  if (myDir == FORWARD) {
832  for (int i = 0; i < reserved; ++i) {
833  utility[i] = BLOCKED_STRIPE;
834  }
835  } else {
836  for (int i = sMax; i > sMax - reserved; --i) {
837  utility[i] = BLOCKED_STRIPE;
838  }
839  }
840  // adapt utility based on obstacles
841  for (int i = 0; i < stripes; ++i) {
842  if (obs[i].speed < 0) {
843  // penalize evasion to the left
844  if (myDir == FORWARD && i > 0) {
845  utility[i - 1] -= 0.5;
846  } else if (myDir == BACKWARD && i < sMax) {
847  utility[i + 1] -= 0.5;
848  }
849  }
850  // compute expected distance achievable by staying on this stripe for a time horizon
851  const SUMOReal lookAhead = obs[i].speed >= 0 ? LOOKAHEAD_SAMEDIR : LOOKAHEAD_ONCOMING;
852  const SUMOReal expectedDist = MIN2(vMax * LOOKAHEAD_SAMEDIR, distance[i] + obs[i].speed * lookAhead);
853  if (DEBUGCOND(myPerson->getID())) {
854  std::cout << " util=" << utility[i] << " exp=" << expectedDist << "\n";
855  }
856  if (expectedDist >= 0) {
857  utility[i] += expectedDist;
858  } else {
859  // let only the distance count
860  utility[i] += ONCOMING_CONFLICT + distance[i];
861  }
862  }
863  // bonus to remain on the rightmost lane (in walking direction) if there
864  // are oncoming
865  if (((myDir == FORWARD && current == sMax)
866  || (myDir == BACKWARD && current == 0))
867  && obs[current].speed < 0) {
868  utility[current] -= ONCOMING_CONFLICT;
869  }
870  // bonus to leave the leftmost lane (in walking direction) if there
871  // are oncoming
872  if (((myDir == BACKWARD && current == sMax)
873  || (myDir == FORWARD && current == 0))
874  && obs[current].speed < 0) {
875  utility[current] += ONCOMING_CONFLICT;
876  }
877 
878  // select best stripe
879  for (int i = 0; i < stripes; ++i) {
880  if (utility[chosen] < utility[i]) {
881  chosen = i;
882  }
883  }
884  // compute speed components along both axes
885  const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
886  const SUMOReal xDist = MIN3(distance[current], distance[other], distance[next]);
887  // XXX preferred gap differs between approaching a standing obstacle or a moving obstacle
888  const SUMOReal preferredGap = myPerson->getVehicleType().getMinGap() + xDist * 0.5;
889  SUMOReal xSpeed = MIN2(vMax, MAX2((SUMOReal)0, xDist - preferredGap));
890  // avoid tiny steps
891  // XXX pressure from behind?
892  if (DEBUGCOND(myPerson->getID())) {
893  std::cout << " xSpeedPotential=" << xSpeed << "\n";
894  }
895  if (mySpeed == 0 && xSpeed < 0.5 * vMax) {
896  xSpeed = 0;
897  }
898  // dawdling
899  const SUMOReal dawdle = MIN2(xSpeed, RandHelper::rand() * vMax * dawdling);
900  xSpeed -= dawdle;
901 
902  // XXX ensure that diagonal speed <= vMax
903  // avoid deadlocks on narrow sidewalks
904  //if (oncoming && xSpeed == 0 && myStage->getWaitingTime(currentTime) > TIME2STEPS(ONCOMIN_PATIENCE)) {
905  // if DEBUGCOND(myPerson->getID()) std::cout << " stepping asside to resolve oncoming deadlock\n";
906  // xSpeed = POSITION_EPS; // reset myWaitingTime
907  // if (myDir == FORWARD && chosen < sMax) {
908  // chosen += 1;
909  // } else if (myDir == BACKWARD && chosen > 0) {
910  // chosen -= 1;
911  // }
912  //}
913  const SUMOReal maxYSpeed = MAX2(vMax * LATERAL_SPEED_FACTOR, vMax - xSpeed);
914  SUMOReal ySpeed = 0;
915  const SUMOReal yDist = (chosen * stripeWidth) - myRelY;
916  if (fabs(yDist) > NUMERICAL_EPS) {
917  ySpeed = (yDist > 0 ?
918  MIN2(maxYSpeed, yDist) :
919  MAX2(-maxYSpeed, yDist));
920  }
921  // DEBUG
922  if DEBUGCOND(myPerson->getID()) {
923  std::cout << SIMTIME
924  << " ped=" << myPerson->getID()
925  << " edge=" << myStage->getEdge()->getID()
926  << " x=" << myRelX
927  << " y=" << myRelY
928  << " d=" << myDir
929  << " pvx=" << mySpeed
930  << " cur=" << current
931  << " cho=" << chosen
932  << " oth=" << other
933  << " nxt=" << next
934  << " vx=" << xSpeed
935  << " dawdle=" << dawdle
936  << " vy=" << ySpeed
937  << " xd=" << xDist
938  << " yd=" << yDist
939  << " vMax=" << myStage->getMaxSpeed()
940  << " wTime=" << myStage->getWaitingTime(currentTime)
941  << "\n distance=" << toString(distance)
942  << " utility=" << toString(utility)
943  << "\n";
944  DEBUG_PRINT(obs);
945  }
946  myRelX += SPEED2DIST(xSpeed * myDir);
947  myRelY += SPEED2DIST(ySpeed);
948  mySpeed = xSpeed;
949  if (xSpeed > 0) {
950  myWaitingToEnter = false;
951  myWaitingTime = 0;
952  } else {
953  myWaitingTime += DELTA_T;
954  }
955 }
956 
957 
958 SUMOReal
960  return MAX2((SUMOReal)0, MIN2(SUMOReal(1),
961  myPerson->getVehicleType().getImpatience()
962  + STEPS2TIME(myStage->getWaitingTime(now)) / MAX_WAIT_TOLERANCE));
963 }
964 
965 
966 SUMOReal
968  return myRelX;
969 }
970 
971 
972 Position
974  if (myLane == 0) {
975  // pedestrian has already finished
976  return Position::INVALID;
977  }
978  const SUMOReal lateral_offset = myRelY + (stripeWidth - myLane->getWidth()) * 0.5;
979  if (myWalkingAreaPath == 0) {
980  return stage.getLanePosition(myLane, myRelX, lateral_offset);
981  } else {
982  return myWalkingAreaPath->shape.positionAtOffset(myRelX, lateral_offset);
983  }
984 }
985 
986 
987 SUMOReal
989  if (myLane == 0) {
990  // pedestrian has already finished
991  return 0;
992  }
993  const PositionVector& shp = myWalkingAreaPath == 0 ? myLane->getShape() : myWalkingAreaPath->shape;
994  SUMOReal angle = -shp.rotationDegreeAtOffset(myRelX) + (myDir == MSPModel::BACKWARD ? 180 : 0);
995  if (angle > 180) {
996  angle -= 360;
997  }
998  return angle;
999 }
1000 
1001 
1002 SUMOTime
1004  return myWaitingTime;
1005 }
1006 
1007 
1008 SUMOReal
1010  return mySpeed;
1011 }
1012 
1013 // ===========================================================================
1014 // MSPModel_Striping::MovePedestrians method definitions
1015 // ===========================================================================
1016 //
1017 
1018 SUMOTime
1020  std::set<MSPerson*> changedLane;
1021  myModel->moveInDirection(currentTime, changedLane, FORWARD);
1022  myModel->moveInDirection(currentTime, changedLane, BACKWARD);
1023  // DEBUG
1024 #ifdef LOG_ALL
1025  for (ActiveLanes::const_iterator it_lane = myModel->getActiveLanes().begin(); it_lane != myModel->getActiveLanes().end(); ++it_lane) {
1026  const MSLane* lane = it_lane->first;
1027  Pedestrians pedestrians = it_lane->second;
1028  if (pedestrians.size() == 0) {
1029  continue;
1030  }
1031  sort(pedestrians.begin(), pedestrians.end(), by_xpos_sorter(FORWARD));
1032  std::cout << SIMTIME << " lane=" << lane->getID();
1033  for (int ii = 0; ii < (int)pedestrians.size(); ++ii) {
1034  const PState& p = *pedestrians[ii];
1035  std::cout << " (" << p.myPerson->getID() << " " << p.myRelX << "," << p.myRelY << " " << p.myDir << ")";
1036  }
1037  std::cout << "\n";
1038  }
1039 #endif
1040  return DELTA_T;
1041 }
1042 
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&#39;s edge.
Definition: MSLane.h:455
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
#define DEBUG1
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&#39;s length.
Definition: MSLane.h:370
The base class for an intersection.
Definition: MSJunction.h:59
StageType getCurrentStageType() const
Definition: MSPerson.h:584
#define BLOCKED_STRIPE
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:237
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&#39;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:156
T MAX2(T a, T b)
Definition: StdDefs.h:74
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&#39;t already in the dictionary...
Definition: MSEdge.cpp:523
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:230
static WalkingAreaPaths myWalkingAreaPaths
store for walkinArea elements
const MSEdge * getSuccessor(unsigned int n) const
Returns the n-th of the following edges.
Definition: MSEdge.h:301
#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:75
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.h:514
MSLane * getLogicalPredecessorLane() const
Definition: MSLane.cpp:1351
#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.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:354
SUMOReal getLength() const
return the length of the pedestrian
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:68
#define POSITION_EPS
Definition: config.h:189
Position getPosition(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const
return the network coordinate of the person
std::map< const MSLane *, Obstacles, lane_by_numid_sorter > NextLanesObstacles
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:227
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:284
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:88
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:557
A storage for options typed value containers)
Definition: OptionsCont.h:108
Container for pedestrian state and individual position update function.
std::vector< Obstacle > Obstacles
int SUMOTime
Definition: SUMOTime.h:43
static const SUMOReal BLOCKER_LOOKAHEAD
static const int BACKWARD
Definition: MSPModel.h:77
const PositionVector & getShape() const
Returns this lane&#39;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:218
SUMOReal myRelY
the orthogonal shift on the current lane
static const SUMOReal MAX_WAIT_TOLERANCE
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:232
unsigned int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
Definition: MSEdge.h:292
SUMOReal myRelX
the advancement along the current lane
const MSJunction * getFromJunction() const
Definition: MSEdge.h:324
T MIN3(T a, T b, T c)
Definition: StdDefs.h:81
MovePedestrians * myCommand
the MovePedestrians command that is registered
#define NUMERICAL_EPS
Definition: config.h:162
void push_back_noDoublePos(const Position &p)
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:1039
static SUMOReal dawdling
int myNumActivePedestrians
the total number of active pedestrians
SUMOReal speed
speed relative to ego direction (positive means in the same direction)
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:580
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:777
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
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:328