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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The pedestrian following model (prototype)
18 /****************************************************************************/
19 #ifndef MSPModel_h
20 #define MSPModel_h
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
32 #include <limits>
33 #include <utils/common/SUMOTime.h>
34 #include <utils/common/Command.h>
35 #include <utils/geom/GeomHelper.h>
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class MSNet;
42 class MSLane;
43 class MSJunction;
44 
45 typedef std::pair<const MSPerson*, double> PersonDist;
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
55 class MSPModel {
56 public:
57 
58  static MSPModel* getModel();
59 
61  static void cleanup();
62 
63  virtual ~MSPModel() {};
64 
66  virtual PedestrianState* add(MSPerson* person, MSPerson::MSPersonStage_Walking* stage, SUMOTime now) = 0;
67 
69  virtual void remove(PedestrianState* state) = 0;
70 
79  virtual bool blockedAtDist(const MSLane* lane, double vehSide, double vehWidth,
80  double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
81  UNUSED_PARAMETER(lane);
82  UNUSED_PARAMETER(vehSide);
83  UNUSED_PARAMETER(vehWidth);
84  UNUSED_PARAMETER(oncomingGap);
85  UNUSED_PARAMETER(collectBlockers);
86  return false;
87  }
88 
90  virtual bool hasPedestrians(const MSLane* lane) {
91  UNUSED_PARAMETER(lane);
92  return false;
93  }
94 
96  virtual PersonDist nextBlocking(const MSLane* lane, double minPos, double minRight, double maxLeft, double stopTime = 0) {
97  UNUSED_PARAMETER(lane);
98  UNUSED_PARAMETER(minPos);
99  UNUSED_PARAMETER(minRight);
100  UNUSED_PARAMETER(maxLeft);
101  UNUSED_PARAMETER(stopTime);
102  return PersonDist((const MSPerson*)0, -1);
103  }
104 
105  virtual void cleanupHelper() {};
106 
107  // @brief walking directions
108  static const int FORWARD;
109  static const int BACKWARD;
110  static const int UNDEFINED_DIRECTION;
111 
112  // @brief the safety gap to keep between the car and the pedestrian in all directions
113  static const double SAFETY_GAP;
114 
116  static const double SIDEWALK_OFFSET;
117 
119  static bool canTraverse(int dir, const ConstMSEdgeVector& route);
120 
122  virtual bool usingInternalLanes() = 0;
123 
124 private:
125  static MSPModel* myModel;
126 
127 };
128 
129 
132 public:
133  virtual ~PedestrianState() {};
134 
136  virtual double getEdgePos(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
137 
139  virtual Position getPosition(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
140 
142  virtual double getAngle(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
143 
145  virtual SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
146 
148  virtual double getSpeed(const MSPerson::MSPersonStage_Walking& stage) const = 0;
149 
151  virtual const MSEdge* getNextEdge(const MSPerson::MSPersonStage_Walking& stage) const = 0;
152 
154  virtual void moveToXY(MSPerson* p, Position pos, MSLane* lane, double lanePos,
155  double lanePosLat, double angle, int routeOffset,
156  const ConstMSEdgeVector& edges, SUMOTime t) {
157  UNUSED_PARAMETER(p);
158  UNUSED_PARAMETER(pos);
159  UNUSED_PARAMETER(lane);
160  UNUSED_PARAMETER(lanePos);
161  UNUSED_PARAMETER(lanePosLat);
162  UNUSED_PARAMETER(angle);
163  UNUSED_PARAMETER(routeOffset);
164  UNUSED_PARAMETER(edges);
165  UNUSED_PARAMETER(t);
166  }
167 
168 };
169 
170 
171 
172 #endif /* MSPModel_h */
173 
virtual void cleanupHelper()
Definition: MSPModel.h:105
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
Definition: MSPModel.h:90
virtual ~PedestrianState()
Definition: MSPModel.h:133
The base class for an intersection.
Definition: MSJunction.h:64
static const int FORWARD
Definition: MSPModel.h:105
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk ...
Definition: MSPModel.h:116
virtual bool usingInternalLanes()=0
whether movements on intersections are modelled
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
static MSPModel * myModel
Definition: MSPModel.h:125
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
The simulated network and simulation perfomer.
Definition: MSNet.h:90
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:55
A road/street connecting two junctions.
Definition: MSEdge.h:80
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:110
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:79
static MSPModel * getModel()
Definition: MSPModel.cpp:65
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
virtual ~MSPModel()
Definition: MSPModel.h:63
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:96
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:131
std::pair< const MSPerson *, double > PersonDist
Definition: MSPModel.h:43
static void cleanup()
remove state at simulation end
Definition: MSPModel.cpp:88
static const int BACKWARD
Definition: MSPModel.h:109
static const double SAFETY_GAP
Definition: MSPModel.h:113
long long int SUMOTime
Definition: TraCIDefs.h:51
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
static bool canTraverse(int dir, const ConstMSEdgeVector &route)
return whether the route may traversed with the given starting direction
Definition: MSPModel.cpp:98
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:154