Eclipse 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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The pedestrian following model (prototype)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <string>
24 #include <limits>
25 #include <utils/common/SUMOTime.h>
26 #include <utils/common/Command.h>
28 #include <utils/geom/GeomHelper.h>
30 #ifdef HAVE_FOX
32 #endif
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MSNet;
38 class MSLane;
39 class MSJunction;
40 
41 typedef std::pair<const MSPerson*, double> PersonDist;
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51 class MSPModel {
52 public:
53 
54  virtual ~MSPModel() {};
55 
57  virtual MSTransportableStateAdapter* add(MSTransportable* transportable, MSStageMoving* stage, SUMOTime now) = 0;
58 
60  virtual MSTransportableStateAdapter* loadState(MSTransportable* transportable, MSStageMoving* stage, std::istringstream& state) {
61  UNUSED_PARAMETER(transportable);
62  UNUSED_PARAMETER(stage);
63  UNUSED_PARAMETER(state);
64  return nullptr;
65  }
66 
68  virtual void clearState() = 0;
69 
71  virtual void remove(MSTransportableStateAdapter* state) = 0;
72 
81  virtual bool blockedAtDist(const MSLane* lane, double vehSide, double vehWidth,
82  double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
83  UNUSED_PARAMETER(lane);
84  UNUSED_PARAMETER(vehSide);
85  UNUSED_PARAMETER(vehWidth);
86  UNUSED_PARAMETER(oncomingGap);
87  UNUSED_PARAMETER(collectBlockers);
88  return false;
89  }
90 
92  virtual bool hasPedestrians(const MSLane* lane) {
93  UNUSED_PARAMETER(lane);
94  return false;
95  }
96 
98  virtual PersonDist nextBlocking(const MSLane* lane, double minPos, double minRight, double maxLeft, double stopTime = 0) {
99  UNUSED_PARAMETER(lane);
100  UNUSED_PARAMETER(minPos);
101  UNUSED_PARAMETER(minRight);
102  UNUSED_PARAMETER(maxLeft);
103  UNUSED_PARAMETER(stopTime);
104  return PersonDist(nullptr, -1);
105  }
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 
118  /* @brief return the arrival direction if the route may be traversed with the given starting direction.
119  * returns UNDEFINED_DIRECTION if the route cannot be traversed
120  */
121  static int canTraverse(int dir, const ConstMSEdgeVector& route);
122 
124  virtual bool usingInternalLanes() = 0;
125 
127  virtual int getActiveNumber() = 0;
128 
129 };
130 
131 
134 public:
136 
138  virtual double getEdgePos(const MSStageMoving& stage, SUMOTime now) const = 0;
139 
141  virtual int getDirection(const MSStageMoving& stage, SUMOTime now) const = 0;
142 
144  virtual Position getPosition(const MSStageMoving& stage, SUMOTime now) const = 0;
145 
147  virtual double getAngle(const MSStageMoving& stage, SUMOTime now) const = 0;
148 
150  virtual SUMOTime getWaitingTime(const MSStageMoving& stage, SUMOTime now) const = 0;
151 
153  virtual double getSpeed(const MSStageMoving& stage) const = 0;
154 
156  virtual const MSEdge* getNextEdge(const MSStageMoving& stage) const = 0;
157 
159  virtual void moveToXY(MSPerson* p, Position pos, MSLane* lane, double lanePos,
160  double lanePosLat, double angle, int routeOffset,
161  const ConstMSEdgeVector& edges, SUMOTime t) {
162  UNUSED_PARAMETER(p);
163  UNUSED_PARAMETER(pos);
164  UNUSED_PARAMETER(lane);
165  UNUSED_PARAMETER(lanePos);
166  UNUSED_PARAMETER(lanePosLat);
167  UNUSED_PARAMETER(angle);
168  UNUSED_PARAMETER(routeOffset);
169  UNUSED_PARAMETER(edges);
170  UNUSED_PARAMETER(t);
171  WRITE_WARNING("moveToXY is ignored by the current movement model");
172  }
173 
175  virtual bool isJammed() const {
176  return false;
177  }
178 
180  virtual const MSLane* getLane() const {
181  return nullptr;
182  }
183 
186  virtual void saveState(std::ostringstream& out) {
187  UNUSED_PARAMETER(out);
188  }
189 
190 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::pair< const MSPerson *, double > PersonDist
Definition: MSPModel.h:39
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
long long int SUMOTime
Definition: SUMOTime.h:32
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
A road/street connecting two junctions.
Definition: MSEdge.h:77
The base class for an intersection.
Definition: MSJunction.h:58
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
The simulated network and simulation perfomer.
Definition: MSNet.h:88
The pedestrian (and also sometimes container) movement model.
Definition: MSPModel.h:51
static const int BACKWARD
Definition: MSPModel.h:109
virtual int getActiveNumber()=0
return the number of active objects
virtual void clearState()=0
Resets pedestrians when quick-loading state.
static int canTraverse(int dir, const ConstMSEdgeVector &route)
Definition: MSPModel.cpp:52
static const int FORWARD
Definition: MSPModel.h:108
virtual MSTransportableStateAdapter * loadState(MSTransportable *transportable, MSStageMoving *stage, std::istringstream &state)
load the state of the given transportable
Definition: MSPModel.h:60
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
virtual void remove(MSTransportableStateAdapter *state)=0
remove the specified person from the pedestrian simulation
virtual ~MSPModel()
Definition: MSPModel.h:54
virtual MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)=0
register the given person as a pedestrian
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:81
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
Definition: MSPModel.h:92
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:98
static const double SAFETY_GAP
Definition: MSPModel.h:113
abstract base class for managing callbacks to retrieve various state information from the model
Definition: MSPModel.h:133
virtual double getSpeed(const MSStageMoving &stage) const =0
return the current speed of the transportable
virtual int getDirection(const MSStageMoving &stage, SUMOTime now) const =0
return the walking direction (FORWARD, BACKWARD)
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 transportable to the given position
Definition: MSPModel.h:159
virtual Position getPosition(const MSStageMoving &stage, SUMOTime now) const =0
return the network coordinate of the transportable
virtual const MSEdge * getNextEdge(const MSStageMoving &stage) const =0
return the list of internal edges if the transportable is on an intersection
virtual bool isJammed() const
whether the transportable is jammed
Definition: MSPModel.h:175
virtual ~MSTransportableStateAdapter()
Definition: MSPModel.h:135
virtual SUMOTime getWaitingTime(const MSStageMoving &stage, SUMOTime now) const =0
return the time the transportable spent standing
virtual double getEdgePos(const MSStageMoving &stage, SUMOTime now) const =0
return the offset from the start of the current edge measured in its natural direction
virtual const MSLane * getLane() const
whether the transportable is jammed
Definition: MSPModel.h:180
virtual double getAngle(const MSStageMoving &stage, SUMOTime now) const =0
return the direction in which the transportable faces in degrees
virtual void saveState(std::ostringstream &out)
Saves the current state into the given stream.
Definition: MSPModel.h:186
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37