SUMO - Simulation of Urban MObility
MSPModel.h
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-2017 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 #ifndef MSPModel_h
21 #define MSPModel_h
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <limits>
34 #include <utils/common/SUMOTime.h>
35 #include <utils/common/Command.h>
36 #include <utils/geom/GeomHelper.h>
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class MSNet;
43 class MSLane;
44 class MSJunction;
45 
46 typedef std::pair<const MSPerson*, double> PersonDist;
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
56 class MSPModel {
57 public:
58 
59  static MSPModel* getModel();
60 
62  static void cleanup();
63 
64  virtual ~MSPModel() {};
65 
67  virtual PedestrianState* add(MSPerson* person, MSPerson::MSPersonStage_Walking* stage, SUMOTime now) = 0;
68 
70  virtual void remove(PedestrianState* state) = 0;
71 
80  virtual bool blockedAtDist(const MSLane* lane, double vehSide, double vehWidth,
81  double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
82  UNUSED_PARAMETER(lane);
83  UNUSED_PARAMETER(vehSide);
84  UNUSED_PARAMETER(vehWidth);
85  UNUSED_PARAMETER(oncomingGap);
86  UNUSED_PARAMETER(collectBlockers);
87  return false;
88  }
89 
91  virtual bool hasPedestrians(const MSLane* lane) {
92  UNUSED_PARAMETER(lane);
93  return false;
94  }
95 
97  virtual PersonDist nextBlocking(const MSLane* lane, double minPos, double minRight, double maxLeft, double stopTime = 0) {
98  UNUSED_PARAMETER(lane);
99  UNUSED_PARAMETER(minPos);
100  UNUSED_PARAMETER(minRight);
101  UNUSED_PARAMETER(maxLeft);
102  UNUSED_PARAMETER(stopTime);
103  return PersonDist((const MSPerson*)0, -1);
104  }
105 
106  virtual void cleanupHelper() {};
107 
108  // @brief walking directions
109  static const int FORWARD;
110  static const int BACKWARD;
111  static const int UNDEFINED_DIRECTION;
112 
113  // @brief the safety gap to keep between the car and the pedestrian in all directions
114  static const double SAFETY_GAP;
115 
117  static const double SIDEWALK_OFFSET;
118 
120  static bool canTraverse(int dir, const ConstMSEdgeVector& route);
121 
122 private:
123  static MSPModel* myModel;
124 
125 };
126 
127 
130 public:
131  virtual ~PedestrianState() {};
132 
134  virtual double getEdgePos(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
135 
137  virtual Position getPosition(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
138 
140  virtual double getAngle(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
141 
143  virtual SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const = 0;
144 
146  virtual double getSpeed(const MSPerson::MSPersonStage_Walking& stage) const = 0;
147 
149  virtual const MSEdge* getNextEdge(const MSPerson::MSPersonStage_Walking& stage) const = 0;
150 };
151 
152 
153 
154 #endif /* MSPModel_h */
155 
virtual void cleanupHelper()
Definition: MSPModel.h:106
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
Definition: MSPModel.h:91
virtual ~PedestrianState()
Definition: MSPModel.h:131
The base class for an intersection.
Definition: MSJunction.h:64
static const int FORWARD
Definition: MSPModel.h:106
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk ...
Definition: MSPModel.h:117
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
static MSPModel * myModel
Definition: MSPModel.h:123
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:40
The simulated network and simulation perfomer.
Definition: MSNet.h:89
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:56
A road/street connecting two junctions.
Definition: MSEdge.h:81
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:111
static MSPModel * getModel()
Definition: MSPModel.cpp:66
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual ~MSPModel()
Definition: MSPModel.h:64
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:97
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:129
std::pair< const MSPerson *, double > PersonDist
Definition: MSPModel.h:44
static void cleanup()
remove state at simulation end
Definition: MSPModel.cpp:89
static const int BACKWARD
Definition: MSPModel.h:110
static const double SAFETY_GAP
Definition: MSPModel.h:114
long long int SUMOTime
Definition: TraCIDefs.h:52
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:80
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
static bool canTraverse(int dir, const ConstMSEdgeVector &route)
return whether the route may traversed with the given starting direction
Definition: MSPModel.cpp:99