Eclipse SUMO - Simulation of Urban MObility
MSPModel_Interacting.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2014-2024 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 /****************************************************************************/
19 // The abstract superclass for pedestrian models which actually interact with vehicles
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include "MSPModel.h"
25 
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
42 public:
44 
46  virtual void clearState();
47 
49  virtual void remove(MSTransportableStateAdapter* state);
50 
60  bool blockedAtDist(const SUMOTrafficObject* ego, const MSLane* lane, double vehSide, double vehWidth,
61  double oncomingGap, std::vector<const MSPerson*>* collectBlockers);
62 
72  PersonDist nextBlocking(const MSLane* lane, double minPos, double minRight, double maxLeft, double stopTime = 0, bool bidi = false);
73 
75  bool hasPedestrians(const MSLane* lane);
76 
79  bool usingInternalLanes();
80 
81  static bool usingInternalLanesStatic();
82 
86  }
87 
89  void registerActive() {
91  }
92 
94  static void unregisterCrossingApproach(const MSPModel_InteractingState& ped, const MSLane* crossing);
95 
96 protected:
97  typedef std::vector<MSPModel_InteractingState*> Pedestrians;
98  typedef std::map<const MSLane*, Pedestrians, ComparatorNumericalIdLess> ActiveLanes;
99 
101  Pedestrians& getPedestrians(const MSLane* lane);
102 
105 
108 
110  bool myAmActive = false;
111 
113  std::set<MSLink*> myApproachedCrossings;
114 
117 
118 };
119 
120 
127 public:
129  MSPModel_InteractingState(MSPerson* person, MSStageMoving* stage, const MSLane* lane) :
130  myPerson(person),
131  myStage(stage),
132  myLane(lane),
133  myEdgePos(stage != nullptr ? stage->getDepartPos() : 0.),
134  myPosLat(stage != nullptr ? stage->getDepartPosLat() : 0.),
135  myDir(MSPModel::UNDEFINED_DIRECTION),
136  myWaitingToEnter(person != nullptr) {}
137 
139 
143  inline double getEdgePos(SUMOTime /* now */) const {
144  return myEdgePos;
145  }
146 
148  inline int getDirection() const {
149  return myDir;
150  }
151 
153  inline SUMOTime getWaitingTime() const {
154  return myWaitingTime;
155  }
156 
158  inline double getSpeed(const MSStageMoving& /* stage */) const {
159  return mySpeed;
160  }
161 
163  inline bool isJammed() const {
164  return myAmJammed;
165  }
166 
168  inline const MSLane* getLane() const {
169  return myLane;
170  }
172 
174  virtual const MSLane* getNextCrossing() const {
175  return nullptr;
176  }
177 
179  virtual double getLatOffset() const {
180  return myPosLat;
181  }
182 
184  inline MSPerson* getPerson() const {
185  return myPerson;
186  }
187 
189  inline MSStageMoving* getStage() const {
190  return myStage;
191  }
192 
194  inline bool isWaitingToEnter() const {
195  return myWaitingToEnter;
196  }
197 
199  inline const Position& getRemotePosition() const {
200  return myRemoteXYPos;
201  }
202 
204  virtual const std::string& getID() const {
205  return myPerson->getID();
206  }
207 
209  virtual double getAngle(const MSStageMoving&, SUMOTime) const {
210  return myAngle;
211  }
212 
213 protected:
215  MSPerson* myPerson = nullptr;
217  MSStageMoving* myStage = nullptr;
219  const MSLane* myLane = nullptr;
221  double myEdgePos = 0.;
223  double myPosLat = 0.;
227  double mySpeed = 0.;
229  double mySpeedLat = 0.;
231  bool myWaitingToEnter = false;
235  bool myAmJammed = false;
239  mutable double myAngle = std::numeric_limits<double>::max();
240 
241 private:
244 };
long long int SUMOTime
Definition: GUI.h:35
std::pair< const MSPerson *, double > PersonDist
Definition: MSPModel.h:39
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
The abstract superclass for pedestrian models which actually interact with vehicles.
std::set< MSLink * > myApproachedCrossings
all crossings being approached by pedestrians
std::map< const MSLane *, Pedestrians, ComparatorNumericalIdLess > ActiveLanes
std::vector< MSPModel_InteractingState * > Pedestrians
bool usingInternalLanes()
whether movements on intersections are modelled /
Pedestrians & getPedestrians(const MSLane *lane)
retrieves the pedestrian vector for the given lane (may be empty)
PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0, bool bidi=false)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or nullptr
bool blockedAtDist(const SUMOTrafficObject *ego, 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
ActiveLanes myActiveLanes
store of all lanes which have pedestrians on them
int getActiveNumber()
return the number of active pedestrians
bool myAmActive
whether an event for pedestrian processing was added
static Pedestrians noPedestrians
empty pedestrian vector
static bool usingInternalLanesStatic()
int myNumActivePedestrians
the total number of active pedestrians
void registerActive()
increase the number of active pedestrians
virtual void remove(MSTransportableStateAdapter *state)
remove the specified person from the pedestrian simulation
bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
virtual void clearState()
Resets pedestrians when quick-loading state.
static void unregisterCrossingApproach(const MSPModel_InteractingState &ped, const MSLane *crossing)
unregister pedestrian approach with the junction model
Container for pedestrian state and individual position update function.
SUMOTime myWaitingTime
the consecutive time spent at speed 0
MSPerson * myPerson
the person who is being represented
int myDir
the walking direction on the current lane (1 forward, -1 backward)
virtual const MSLane * getNextCrossing() const
placeholder function for the accessing the next crossing
double myEdgePos
the advancement along the current lane
virtual double getAngle(const MSStageMoving &, SUMOTime) const
return the current orientation in degrees
double getEdgePos(SUMOTime) const
abstract methods inherited from MSTransportableStateAdapter
MSPerson * getPerson() const
return the represented person
virtual double getLatOffset() const
return the lateral offset to the lane center
MSPModel_InteractingState & operator=(const MSPModel_InteractingState &)=delete
Invalidated assignment operator.
virtual const std::string & getID() const
return ID of the person (or sometimes vehicle) being represented
const MSLane * myLane
the current lane of this pedestrian
double mySpeed
the current walking speed
MSStageMoving * myStage
the current stage of this pedestrian
const Position & getRemotePosition() const
return the remote position if being controlled by TraCI or JuPedSim
MSStageMoving * getStage() const
return the current stage
double myPosLat
the orthogonal shift on the current lane
double mySpeedLat
the current lateral walking speed
bool isWaitingToEnter() const
whether the person still waits to entere the network
Position myRemoteXYPos
remote-controlled position
MSPModel_InteractingState(MSPerson *person, MSStageMoving *stage, const MSLane *lane)
constructor
const MSLane * getLane() const
the current lane of the transportable
bool myWaitingToEnter
whether the pedestrian is waiting to start its walk
int getDirection() const
return the walking direction (FORWARD, BACKWARD, UNDEFINED_DIRECTION)
SUMOTime getWaitingTime() const
return the time the transportable spent standing
bool myAmJammed
whether the person is jammed
double getSpeed(const MSStageMoving &) const
return the current speed of the transportable
bool isJammed() const
whether the transportable is jammed
The pedestrian (and also sometimes container) movement model.
Definition: MSPModel.h:51
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:56
abstract base class for managing callbacks to retrieve various state information from the model
Definition: MSPModel.h:154
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
Representation of a vehicle, person, or container.