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-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/****************************************************************************/
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
165 private:
168
171
172 };
173
179 public:
181 MSPersonStage_Access(const MSEdge* destination, MSStoppingPlace* toStop,
182 const double arrivalPos, const double dist, const bool isExit);
183
186
187 MSStage* clone() const;
188
190 virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSStage* previous);
191
193 std::string getStageDescription(const bool isPerson) const;
194 std::string getStageSummary(const bool isPerson) const;
195
196 Position getPosition(SUMOTime now) const;
197
198 double getAngle(SUMOTime now) const;
199
201 double getDistance() const {
202 return myDist;
203 }
204
206 double getSpeed() const;
207
214 void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
215
217 void routeOutput(const bool, OutputDevice&, const bool, const MSStage* const) const {};
218
219 private:
220 class ProceedCmd : public Command {
221 public:
222 ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
224 SUMOTime execute(SUMOTime currentTime);
225 private:
228 private:
231 };
232
233 private:
234 const double myDist;
235 const bool myAmExit;
238 };
239
240public:
242 MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
243
245 virtual ~MSPerson();
246
247 /* @brief check whether an access stage must be added and return whether a
248 * stage was added */
249 bool checkAccess(const MSStage* const prior, const bool waitAtStop = true);
250
252 const std::string& getNextEdge() const;
253
255 const MSEdge* getNextEdgePtr() const;
256
258 virtual bool isSelected() const {
259 return false;
260 }
261
262 inline double getChosenSpeedFactor() const {
263 return myChosenSpeedFactor;
264 }
265
266 inline void setChosenSpeedFactor(const double factor) {
267 myChosenSpeedFactor = factor;
268 }
269
271 bool isJammed() const;
272
274 void reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex);
275
276
283 public:
285 Influencer();
286
287
289 ~Influencer();
290
291
292 void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
293
295 return myLastRemoteAccess;
296 }
297
299
300 bool isRemoteControlled() const;
301
302 bool isRemoteAffected(SUMOTime t) const;
303
304 private:
313 };
314
315
322
323 const Influencer* getInfluencer() const;
324
325 bool hasInfluencer() const {
326 return myInfluencer != 0;
327 }
328
331
332private:
335
337
338private:
341
344
345};
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:282
SUMOTime myLastRemoteAccess
Definition: MSPerson.h:312
void postProcessRemoteControl(MSPerson *p)
Definition: MSPerson.cpp:656
Influencer()
Constructor.
Definition: MSPerson.cpp:624
SUMOTime getLastAccessTimeStep() const
Definition: MSPerson.h:294
ConstMSEdgeVector myRemoteRoute
Definition: MSPerson.h:311
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition: MSPerson.cpp:631
~Influencer()
Destructor.
Definition: MSPerson.cpp:627
Position myRemoteXYPos
Definition: MSPerson.h:305
MSLane * myRemoteLane
Definition: MSPerson.h:306
bool isRemoteAffected(SUMOTime t) const
Definition: MSPerson.cpp:650
bool isRemoteControlled() const
Definition: MSPerson.cpp:644
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Definition: MSPerson.cpp:499
ProceedCmd(MSTransportable *person, MSEdge *edge)
Definition: MSPerson.h:222
ProceedCmd & operator=(const ProceedCmd &)
Invalidated assignment operator.
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:470
double getDistance() const
get travel distance in this stage
Definition: MSPerson.h:201
double getSpeed() const
the speed of the person in this stage
Definition: MSPerson.cpp:482
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
Definition: MSPerson.cpp:429
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:487
void routeOutput(const bool, OutputDevice &, const bool, const MSStage *const) const
Called on writing vehroute output. Currently does nothing.
Definition: MSPerson.h:217
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSPerson.cpp:449
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:476
std::string getStageDescription(const bool isPerson) const
returns the stage description as a string
Definition: MSPerson.cpp:458
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSPerson.cpp:464
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:275
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:250
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:149
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:154
double getArrivalPos() const
Definition: MSPerson.h:135
double computeAverageSpeed() const
Definition: MSPerson.cpp:155
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:170
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:314
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:390
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
Definition: MSPerson.cpp:412
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:395
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:105
void activateEntryReminders(MSTransportable *person)
Definition: MSPerson.cpp:370
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
Definition: MSPerson.cpp:360
int getRoutePosition() const
return index of current edge within route
Definition: MSPerson.cpp:384
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:55
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:143
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:405
bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
Definition: MSPerson.cpp:524
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:334
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
Definition: MSPerson.cpp:569
void setChosenSpeedFactor(const double factor)
Definition: MSPerson.h:266
double getChosenSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:262
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:581
double myChosenSpeedFactor
Definition: MSPerson.h:336
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:258
MSPerson(const MSPerson &)
Invalidated copy constructor.
bool isJammed() const
whether the person is jammed as defined by the current pedestrian model
Definition: MSPerson.cpp:161
MSPerson & operator=(const MSPerson &)
Invalidated assignment operator.
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSPerson.h:325
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:518
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:606
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:550
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:511
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:60
Structure representing possible vehicle parameter.