Eclipse SUMO - Simulation of Urban MObility
MSStageWalking.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
21 // A stage performing walking on a sequence of edges.
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
27 #include <vector>
28 #include <set>
29 #include <utils/common/SUMOTime.h>
30 #include <utils/common/Command.h>
31 #include <utils/geom/Position.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSNet;
41 class MSEdge;
42 class MSLane;
43 class OutputDevice;
45 class MSStoppingPlace;
46 class SUMOVehicle;
47 class MSVehicleType;
48 class MSPModel;
49 class MSMoveReminder;
50 
51 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
59 class MSStageWalking : public MSStageMoving {
60 public:
62  MSStageWalking(const std::string& personID, const ConstMSEdgeVector& route, MSStoppingPlace* toStop, SUMOTime walkingTime,
63  double speed, double departPos, double arrivalPos, double departPosLat, int departLane = -1, const std::string& routeID = "");
64 
67 
68  MSStage* clone() const;
69 
71  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSStage* previous);
72 
74  void abort(MSTransportable*);
75 
77  void setSpeed(double speed);
78 
80  double getDistance() const {
81  return walkDistance();
82  }
83 
85  int getRoutePosition() const;
86 
87  std::string getStageDescription(const bool isPerson) const {
88  UNUSED_PARAMETER(isPerson);
89  return "walking";
90  }
91 
92  std::string getStageSummary(const bool isPerson) const;
93 
96  void saveState(std::ostringstream& out);
97 
100  void loadState(MSTransportable* transportable, std::istringstream& state);
101 
106  virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
107 
113  virtual void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
114 
116  bool moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr);
117 
118  void activateEntryReminders(MSTransportable* person, const bool isDepart = false);
119 
120  void activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived);
121 
123 
124  double getMaxSpeed(const MSTransportable* const person) const;
125 
126  inline double getArrivalPos() const {
127  return myArrivalPos;
128  }
129 
130  inline const MSEdge* getNextRouteEdge() const {
131  return myRouteStep == myRoute.end() - 1 ? nullptr : *(myRouteStep + 1);
132  }
134 
136  bool isWalk() const {
137  return true;
138  }
139 
140  SUMOTime getTimeLoss(const MSTransportable* transportable) const;
141 
142 private:
144  double walkDistance(bool partial = false) const;
145 
146  /* @brief compute average speed if the total walking duration is given
147  * @note Must be called when the previous stage changes myDepartPos from the default*/
148  double computeAverageSpeed() const;
149 
150 private:
153 
156 
158  std::vector<MSMoveReminder*> myMoveReminders;
159 
161  std::vector<SUMOTime>* myExitTimes;
162 
165 
167 
168 private:
171 
174 
175 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
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:89
The pedestrian (and also sometimes container) movement model.
Definition: MSPModel.h:51
double myArrivalPos
the longitudinal position at which we want to arrive
Definition: MSStage.h:275
std::vector< const MSEdge * > myRoute
The route of the container.
std::vector< const MSEdge * >::iterator myRouteStep
current step
double myInternalDistance
distance walked on non-normal edges (i.e. walkingareas)
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
int getRoutePosition() const
return index of current edge within route
double walkDistance(bool partial=false) const
compute total walking distance
std::vector< MSMoveReminder * > myMoveReminders
the MoveReminders encountered while walking
void abort(MSTransportable *)
abort this stage (TraCI)
bool isWalk() const
Whether the transportable is walking.
const MSEdge * getNextRouteEdge() const
SUMOTime myLastEdgeEntryTime
the time the person entered the edge
MSStageWalking(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
double getArrivalPos() const
SUMOTime myWalkingTime
the time the person is walking
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
MSStage * clone() const
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
double getDistance() const
get travel distance in this stage
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
static bool myWarnedInvalidTripinfo
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
~MSStageWalking()
destructor
double computeAverageSpeed() const
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
void activateEntryReminders(MSTransportable *person, const bool isDepart=false)
add the move reminders for the current lane on entry
SUMOTime getTimeLoss(const MSTransportable *transportable) const
MSStageWalking(const MSStageWalking &)
Invalidated copy constructor.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
std::vector< SUMOTime > * myExitTimes
optional exit time tracking for vehroute output
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
MSStageWalking & operator=(const MSStageWalking &)
Invalidated assignment operator.
A lane area vehicles can halt at.
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
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Structure representing possible vehicle parameter.