Eclipse SUMO - Simulation of Urban MObility
MSPerson.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2023 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/****************************************************************************/
21// The class for modelling person-movements
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <string>
27#include <vector>
28#include <set>
31#include <utils/geom/Position.h>
35
36
37// ===========================================================================
38// class declarations
39// ===========================================================================
40class MSNet;
41class MSEdge;
42class MSLane;
43class OutputDevice;
45class MSStoppingPlace;
46class SUMOVehicle;
47class MSVehicleType;
48class MSPModel;
49class MSMoveReminder;
50
51typedef std::vector<const MSEdge*> ConstMSEdgeVector;
52
53// ===========================================================================
54// class definitions
55// ===========================================================================
61class MSPerson : public MSTransportable {
62public:
69 public:
71 MSPersonStage_Walking(const std::string& personID, const ConstMSEdgeVector& route, MSStoppingPlace* toStop, SUMOTime walkingTime,
72 double speed, double departPos, double arrivalPos, double departPosLat, int departLane = -1, const std::string& routeID = "");
73
76
77 MSStage* clone() const;
78
80 virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSStage* previous);
81
84
86 void setSpeed(double speed);
87
89 double getDistance() const {
90 return walkDistance();
91 }
92
94 int getRoutePosition() const;
95
96 std::string getStageDescription(const bool isPerson) const {
98 return "walking";
99 }
100
101 std::string getStageSummary(const bool isPerson) const;
102
105 void saveState(std::ostringstream& out);
106
109 void loadState(MSTransportable* transportable, std::istringstream& state);
110
115 virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
116
122 virtual void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
123
125 bool moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr);
126
128
129 void activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived);
130
132
133 double getMaxSpeed(const MSTransportable* const person) const;
134
135 inline double getArrivalPos() const {
136 return myArrivalPos;
137 }
138
139 inline const MSEdge* getNextRouteEdge() const {
140 return myRouteStep == myRoute.end() - 1 ? nullptr : *(myRouteStep + 1);
141 }
143
144 private:
146 double walkDistance(bool partial = false) const;
147
148 /* @brief compute average speed if the total walking duration is given
149 * @note Must be called when the previous stage changes myDepartPos from the default*/
150 double computeAverageSpeed() const;
151
152 private:
155
158
160 std::vector<MSMoveReminder*> myMoveReminders;
161
163 std::vector<SUMOTime>* myExitTimes;
164
167
168 private:
171
174
175 };
176
182 public:
184 MSPersonStage_Access(const MSEdge* destination, MSStoppingPlace* toStop,
185 const double arrivalPos, const double dist, const bool isExit);
186
189
190 MSStage* clone() const;
191
193 virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSStage* previous);
194
196 std::string getStageDescription(const bool isPerson) const;
197 std::string getStageSummary(const bool isPerson) const;
198
199 Position getPosition(SUMOTime now) const;
200
201 double getAngle(SUMOTime now) const;
202
204 double getDistance() const {
205 return myDist;
206 }
207
209 double getSpeed() const;
210
217 void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
218
220 void routeOutput(const bool, OutputDevice&, const bool, const MSStage* const) const {};
221
222 private:
223 class ProceedCmd : public Command {
224 public:
225 ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
227 SUMOTime execute(SUMOTime currentTime);
228 private:
231 private:
234 };
235
236 private:
237 const double myDist;
238 const bool myAmExit;
241 };
242
243public:
245 MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
246
248 virtual ~MSPerson();
249
250 /* @brief check whether an access stage must be added and return whether a
251 * stage was added */
252 bool checkAccess(const MSStage* const prior, const bool waitAtStop = true);
253
255 const std::string& getNextEdge() const;
256
258 const MSEdge* getNextEdgePtr() const;
259
261 virtual bool isSelected() const {
262 return false;
263 }
264
265 inline double getChosenSpeedFactor() const {
266 return myChosenSpeedFactor;
267 }
268
269 inline void setChosenSpeedFactor(const double factor) {
270 myChosenSpeedFactor = factor;
271 }
272
274 bool isJammed() const;
275
277 void reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex);
278
279
286 public:
288 Influencer();
289
290
292 ~Influencer();
293
294
295 void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
296
298 return myLastRemoteAccess;
299 }
300
302
303 bool isRemoteControlled() const;
304
305 bool isRemoteAffected(SUMOTime t) const;
306
307 private:
316 };
317
318
325
326 const Influencer* getInfluencer() const;
327
328 bool hasInfluencer() const {
329 return myInfluencer != 0;
330 }
331
334
335private:
338
340
341private:
344
347
348};
long long int SUMOTime
Definition: GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:51
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
Base (microsim) event class.
Definition: Command.h:50
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Something on a lane to be noticed about vehicle movement.
The simulated network and simulation perfomer.
Definition: MSNet.h:88
The pedestrian (and also sometimes container) movement model.
Definition: MSPModel.h:51
Changes the wished person speed and position.
Definition: MSPerson.h:285
SUMOTime myLastRemoteAccess
Definition: MSPerson.h:315
void postProcessRemoteControl(MSPerson *p)
Definition: MSPerson.cpp:667
Influencer()
Constructor.
Definition: MSPerson.cpp:635
SUMOTime getLastAccessTimeStep() const
Definition: MSPerson.h:297
ConstMSEdgeVector myRemoteRoute
Definition: MSPerson.h:314
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:642
~Influencer()
Destructor.
Definition: MSPerson.cpp:638
Position myRemoteXYPos
Definition: MSPerson.h:308
MSLane * myRemoteLane
Definition: MSPerson.h:309
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:661
bool isRemoteControlled() const
Definition: MSPerson.cpp:655
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:509
ProceedCmd(MSTransportable *person, MSEdge *edge)
Definition: MSPerson.h:225
ProceedCmd & operator=(const ProceedCmd &)
Invalidated assignment operator.
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:480
double getDistance() const
get travel distance in this stage
Definition: MSPerson.h:204
double getSpeed() const
the speed of the person in this stage
Definition: MSPerson.cpp:492
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
Definition: MSPerson.cpp:438
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:497
void routeOutput(const bool, OutputDevice &, const bool, const MSStage *const) const
Called on writing vehroute output. Currently does nothing.
Definition: MSPerson.h:220
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:458
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:486
std::string getStageDescription(const bool isPerson) const
returns the stage description as a string
Definition: MSPerson.cpp:468
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:474
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
Definition: MSPerson.h:96
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
Definition: MSPerson.cpp:281
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:256
std::vector< MSMoveReminder * > myMoveReminders
the MoveReminders encountered while walking
Definition: MSPerson.h:160
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:151
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:154
double myInternalDistance
distance walked on non-normal edges (i.e. walkingareas)
Definition: MSPerson.h:166
double getArrivalPos() const
Definition: MSPerson.h:135
double computeAverageSpeed() const
Definition: MSPerson.cpp:157
double getDistance() const
get travel distance in this stage
Definition: MSPerson.h:89
double walkDistance(bool partial=false) const
compute total walking distance
Definition: MSPerson.cpp:172
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:320
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:399
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
Definition: MSPerson.cpp:421
SUMOTime myLastEdgeEntryTime
the time the person entered the edge
Definition: MSPerson.h:157
MSPersonStage_Walking(const MSPersonStage_Walking &)
Invalidated copy constructor.
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:404
std::vector< SUMOTime > * myExitTimes
optional exit time tracking for vehroute output
Definition: MSPerson.h:163
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:107
void activateEntryReminders(MSTransportable *person)
Definition: MSPerson.cpp:379
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
Definition: MSPerson.cpp:369
int getRoutePosition() const
return index of current edge within route
Definition: MSPerson.cpp:393
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat, int departLane=-1, const std::string &routeID="")
constructor
Definition: MSPerson.cpp:56
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:145
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:139
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
Definition: MSPerson.cpp:414
bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
Definition: MSPerson.cpp:535
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:337
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:580
void setChosenSpeedFactor(const double factor)
Definition: MSPerson.h:269
double getChosenSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:265
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex,...
Definition: MSPerson.cpp:592
double myChosenSpeedFactor
Definition: MSPerson.h:339
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:261
MSPerson(const MSPerson &)
Invalidated copy constructor.
bool isJammed() const
whether the person is jammed as defined by the current pedestrian model
Definition: MSPerson.cpp:163
MSPerson & operator=(const MSPerson &)
Invalidated assignment operator.
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSPerson.h:328
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:529
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:617
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:561
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:522
void setRemoteState(Position xyPos)
sets position outside the road network
double myArrivalPos
the position at which we want to arrive
Definition: MSStage.h:241
std::vector< constMSEdge * >::iterator myRouteStep
current step
std::vector< const MSEdge * > myRoute
The route of the container.
A lane area vehicles can halt at.
bool isPerson() const
Whether it is a person.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
The car-following model and parameter.
Definition: MSVehicleType.h:63
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Representation of a vehicle.
Definition: SUMOVehicle.h:62
Structure representing possible vehicle parameter.