Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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// ===========================================================================
42public:
44
46 virtual void clearState();
47
49 virtual void remove(MSTransportableStateAdapter* state);
50
60 bool blockedAtDist(const SUMOTrafficObject* ego, const MSLane* lane, double vehCenter, 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
92
94 static void unregisterCrossingApproach(const MSPModel_InteractingState& ped, const MSLane* crossing);
95
96protected:
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
127public:
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 return myTotalWaitingTime;
159 }
160
162 inline double getSpeed(const MSStageMoving& /* stage */) const {
163 return mySpeed;
164 }
165
167 inline bool isJammed() const {
168 return myAmJammed;
169 }
170
172 inline const MSLane* getLane() const {
173 return myLane;
174 }
176
178 virtual const MSLane* getNextCrossing() const {
179 return nullptr;
180 }
181
183 virtual double getLatOffset() const {
184 return myPosLat;
185 }
186
188 inline MSPerson* getPerson() const {
189 return myPerson;
190 }
191
193 inline MSStageMoving* getStage() const {
194 return myStage;
195 }
196
198 inline bool isWaitingToEnter() const {
199 return myWaitingToEnter;
200 }
201
203 inline const Position& getRemotePosition() const {
204 return myRemoteXYPos;
205 }
206
208 virtual const std::string& getID() const {
209 return myPerson->getID();
210 }
211
213 virtual double getAngle(const MSStageMoving&, SUMOTime) const {
214 return myAngle;
215 }
216
217protected:
219 MSPerson* myPerson = nullptr;
223 const MSLane* myLane = nullptr;
225 double myEdgePos = 0.;
227 double myPosLat = 0.;
231 double mySpeed = 0.;
233 double mySpeedLat = 0.;
235 bool myWaitingToEnter = false;
241 bool myAmJammed = false;
245 mutable double myAngle = std::numeric_limits<double>::max();
246
247private:
250};
long long int SUMOTime
Definition GUI.h:36
std::pair< const MSPerson *, double > PersonDist
Definition MSPModel.h:41
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
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
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 blockedAtDist(const SUMOTrafficObject *ego, const MSLane *lane, double vehCenter, double vehWidth, double oncomingGap, std::vector< const MSPerson * > *collectBlockers)
whether a pedestrian is blocking the crossing of lane for the given vehicle bondaries
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
MSStageMoving * getStage() const
return the current stage
virtual SUMOTime getTotalWaitingTime() const
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 const std::string & getID() const
return ID of the person (or sometimes vehicle) being represented
const Position & getRemotePosition() const
return the remote position if being controlled by TraCI or JuPedSim
virtual double getLatOffset() const
return the lateral offset to the lane center
const MSLane * myLane
the current lane of this pedestrian
double mySpeed
the current walking speed
MSStageMoving * myStage
the current stage of this pedestrian
SUMOTime myTotalWaitingTime
the total time spent at speed 0
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
bool myWaitingToEnter
whether the pedestrian is waiting to start its walk
const MSLane * getLane() const
the current lane of the transportable
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
MSPModel_InteractingState & operator=(const MSPModel_InteractingState &)=delete
Invalidated assignment operator.
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:319
Representation of a vehicle, person, or container.