Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-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/****************************************************************************/
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>
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// ===========================================================================
60public:
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
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, const bool isReplay = false);
117
118 void activateEntryReminders(MSTransportable* person, const bool isDepart = false);
119
120 void activateMoveReminders(MSTransportable* person, double oldPos, double newPos, double newSpeed);
121
122 void activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived);
123
125
126 double getMaxSpeed(const MSTransportable* const person) const;
127
128 inline double getArrivalPos() const {
129 return myArrivalPos;
130 }
131
132 inline const MSEdge* getNextRouteEdge() const {
133 return myRouteStep == myRoute.end() - 1 ? nullptr : *(myRouteStep + 1);
134 }
135
136
138 bool isWalk() const {
139 return true;
140 }
141
142 SUMOTime getTimeLoss(const MSTransportable* transportable) const;
143
144 bool equals(const MSStage& s) const {
145 if (!MSStageMoving::equals(s)) {
146 return false;
147 }
148 // this is safe because MSStage already checked that the type fits
149 const MSStageWalking& sw = static_cast<const MSStageWalking&>(s);
150 return myWalkingTime == sw.myWalkingTime;
151 }
152
153private:
155 double walkDistance(bool partial = false) const;
156
157 /* @brief compute average speed if the total walking duration is given
158 * @note Must be called when the previous stage changes myDepartPos from the default*/
159 double computeAverageSpeed() const;
160
161private:
164
167
169 std::vector<MSMoveReminder*> myMoveReminders;
170
172 std::vector<SUMOTime>* myExitTimes;
173
176
178
179private:
182
185
186};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
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
MSStage(const MSStageType type, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double arrivalPosLat=0.0, const std::string &group="")
constructor
Definition MSStage.cpp:47
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:308
bool equals(const MSStage &s) const
std::vector< constMSEdge * >::iterator myRouteStep
current step
MSStageMoving(const MSStageType type, const std::vector< const MSEdge * > &route, const std::string &routeID, MSStoppingPlace *toStop, const double speed, const double departPos, const double arrivalPos, const double departPosLat, const int departLane)
constructor
std::vector< const MSEdge * > myRoute
The route of the container.
double myInternalDistance
distance walked on non-normal edges (i.e. walkingareas)
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)
move forward and return whether the person arrived
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.
void activateMoveReminders(MSTransportable *person, double oldPos, double newPos, double newSpeed)
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
MSStageWalking & operator=(const MSStageWalking &)
Invalidated assignment operator.
MSStage * clone() const
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
bool equals(const MSStage &s) const
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
const MSEdge * getNextRouteEdge() const
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.
A lane area vehicles can halt at.
The car-following model and parameter.
Static storage of an output device and its base (abstract) implementation.
Representation of a vehicle.
Definition SUMOVehicle.h:62
Structure representing possible vehicle parameter.
#define UNUSED_PARAMETER(x)