SUMO - Simulation of Urban MObility
MSPModel.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // The pedestrian following model (prototype)
16 /****************************************************************************/
17 #ifndef MSPModel_h
18 #define MSPModel_h
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <string>
26 #include <limits>
27 #include <utils/common/SUMOTime.h>
28 #include <utils/common/Command.h>
30 #include <utils/geom/GeomHelper.h>
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSNet;
37 class MSLane;
38 class MSJunction;
39 
40 typedef std::pair<const MSPerson*, double> PersonDist;
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
50 class MSPModel {
51 public:
52 
53  static MSPModel* getModel();
54 
56  static void cleanup();
57 
58  virtual ~MSPModel() {};
59 
61  virtual PedestrianState* add(MSPerson* person, MSPerson::MSPersonStage_Walking* stage, SUMOTime now) = 0;
62 
64  virtual void remove(PedestrianState* state) = 0;
65 
74  virtual bool blockedAtDist(const MSLane* lane, double vehSide, double vehWidth,
75  double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
76  UNUSED_PARAMETER(lane);
77  UNUSED_PARAMETER(vehSide);
78  UNUSED_PARAMETER(vehWidth);
79  UNUSED_PARAMETER(oncomingGap);
80  UNUSED_PARAMETER(collectBlockers);
81  return false;
82  }
83 
85  virtual bool hasPedestrians(const MSLane* lane) {
86  UNUSED_PARAMETER(lane);
87  return false;
88  }
89 
91  virtual PersonDist nextBlocking(const MSLane* lane, double minPos, double minRight, double maxLeft, double stopTime = 0) {
92  UNUSED_PARAMETER(lane);
93  UNUSED_PARAMETER(minPos);
94  UNUSED_PARAMETER(minRight);
95  UNUSED_PARAMETER(maxLeft);
96  UNUSED_PARAMETER(stopTime);
97  return PersonDist((const MSPerson*)0, -1);
98  }
99 
100  virtual void cleanupHelper() {};
101 
102  // @brief walking directions
103  static const int FORWARD;
104  static const int BACKWARD;
105  static const int UNDEFINED_DIRECTION;
106 
107  // @brief the safety gap to keep between the car and the pedestrian in all directions
108  static const double SAFETY_GAP;
109 
111  static const double SIDEWALK_OFFSET;
112 
113  /* @brief return the arrival direction if the route may be traversed with the given starting direction.
114  * returns UNDEFINED_DIRECTION if the route cannot be traversed
115  */
116  static int canTraverse(int dir, const ConstMSEdgeVector& route);
117 
119  virtual bool usingInternalLanes() = 0;
120 
121 private:
122  static MSPModel* myModel;
123 
124 };
125 
126 
129 public:
130  virtual ~PedestrianState() {};
131 
133  virtual double getEdgePos(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
134 
136  virtual Position getPosition(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
137 
139  virtual double getAngle(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
140 
142  virtual SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
143 
145  virtual double getSpeed(const MSPerson::MSPersonStage_Walking& stage) const = 0;
146 
148  virtual const MSEdge* getNextEdge(const MSPerson::MSPersonStage_Walking& stage) const = 0;
149 
151  virtual void moveToXY(MSPerson* p, Position pos, MSLane* lane, double lanePos,
152  double lanePosLat, double angle, int routeOffset,
153  const ConstMSEdgeVector& edges, SUMOTime t) {
154  UNUSED_PARAMETER(p);
155  UNUSED_PARAMETER(pos);
156  UNUSED_PARAMETER(lane);
157  UNUSED_PARAMETER(lanePos);
158  UNUSED_PARAMETER(lanePosLat);
159  UNUSED_PARAMETER(angle);
160  UNUSED_PARAMETER(routeOffset);
161  UNUSED_PARAMETER(edges);
162  UNUSED_PARAMETER(t);
163  WRITE_WARNING("moveToXY is ignored by the current pedestrian model");
164  }
165 
166 };
167 
168 
169 class DummyState : public PedestrianState {
170 
171 public:
173  return 0.;
174  }
176  return Position::INVALID;
177  }
179  return 0.;
180  }
182  return 0;
183  }
185  return 0.;
186  }
188  return nullptr;
189  }
190 };
191 
192 
193 #endif /* MSPModel_h */
194 
SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking &, SUMOTime) const
return the time the person spent standing
Definition: MSPModel.h:181
virtual void cleanupHelper()
Definition: MSPModel.h:100
long long int SUMOTime
Definition: SUMOTime.h:36
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
Definition: MSPModel.h:85
virtual ~PedestrianState()
Definition: MSPModel.h:130
double getAngle(const MSPerson::MSPersonStage_Walking &, SUMOTime) const
return the direction in which the person faces in degrees
Definition: MSPModel.h:178
The base class for an intersection.
Definition: MSJunction.h:61
static const int FORWARD
Definition: MSPModel.h:100
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk ...
Definition: MSPModel.h:111
virtual bool usingInternalLanes()=0
whether movements on intersections are modelled
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
static MSPModel * myModel
Definition: MSPModel.h:122
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:33
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
The simulated network and simulation perfomer.
Definition: MSNet.h:84
virtual PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now)=0
register the given person as a pedestrian
The pedestrian following model.
Definition: MSPModel.h:50
double getSpeed(const MSPerson::MSPersonStage_Walking &) const
return the current speed of the person
Definition: MSPModel.h:184
A road/street connecting two junctions.
Definition: MSEdge.h:75
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:92
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:105
virtual bool blockedAtDist(const MSLane *lane, double vehSide, double vehWidth, double oncomingGap, std::vector< const MSPerson *> *collectBlockers)
whether a pedestrian is blocking the crossing of lane for the given vehicle bondaries ...
Definition: MSPModel.h:74
static MSPModel * getModel()
Definition: MSPModel.cpp:59
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
virtual ~MSPModel()
Definition: MSPModel.h:58
const MSEdge * getNextEdge(const MSPerson::MSPersonStage_Walking &) const
return the list of internal edges if the pedestrian is on an intersection
Definition: MSPModel.h:187
virtual PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or 0 ...
Definition: MSPModel.h:91
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:128
std::pair< const MSPerson *, double > PersonDist
Definition: MSPModel.h:38
double getEdgePos(const MSPerson::MSPersonStage_Walking &, SUMOTime) const
return the offset from the start of the current edge measured in its natural direction ...
Definition: MSPModel.h:172
static void cleanup()
remove state at simulation end
Definition: MSPModel.cpp:82
static const int BACKWARD
Definition: MSPModel.h:104
static const double SAFETY_GAP
Definition: MSPModel.h:108
Position getPosition(const MSPerson::MSPersonStage_Walking &, SUMOTime) const
return the network coordinate of the person
Definition: MSPModel.h:175
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:285
virtual void moveToXY(MSPerson *p, Position pos, MSLane *lane, double lanePos, double lanePosLat, double angle, int routeOffset, const ConstMSEdgeVector &edges, SUMOTime t)
try to move person to the given position
Definition: MSPModel.h:151