SUMO - Simulation of Urban MObility
MSPerson.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The class for modelling person-movements
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSPerson_h
24 #define MSPerson_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <set>
39 #include <utils/common/SUMOTime.h>
40 #include <utils/common/Command.h>
41 #include <utils/geom/Position.h>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class MSNet;
50 class MSEdge;
51 class MSLane;
52 class OutputDevice;
54 class MSStoppingPlace;
55 class SUMOVehicle;
56 class MSVehicleType;
57 class MSPModel;
59 
60 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
70 class MSPerson : public MSTransportable {
71 public:
78  friend class MSPModel;
79  friend class GUIPerson; // debugging
80 
81  public:
83  MSPersonStage_Walking(const ConstMSEdgeVector& route, MSStoppingPlace* toStop, SUMOTime walkingTime,
84  double speed, double departPos, double arrivalPos, double departPosLat);
85 
88 
90  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
91 
93  void abort(MSTransportable*);
94 
96  void setSpeed(double speed);
97 
99  const MSEdge* getEdge() const;
100  const MSEdge* getFromEdge() const;
101  double getEdgePos(SUMOTime now) const;
102 
104  Position getPosition(SUMOTime now) const;
105 
106  double getAngle(SUMOTime now) const;
107 
108  SUMOTime getWaitingTime(SUMOTime now) const;
109 
110  double getSpeed() const;
111 
113  ConstMSEdgeVector getEdges() const;
114 
115  std::string getStageDescription() const {
116  return "walking";
117  }
118 
123  virtual void tripInfoOutput(OutputDevice& os) const;
124 
129  virtual void routeOutput(OutputDevice& os) const;
130 
135  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
136 
141  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
142 
144  bool moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal = 0);
145 
146 
148 
149  inline double getMaxSpeed() const {
150  return mySpeed;
151  }
152  inline double getDepartPos() const {
153  return myDepartPos;
154  }
155 
156  inline double getDepartPosLat() const {
157  return myDepartPosLat;
158  }
159 
160  inline double getArrivalPos() const {
161  return myArrivalPos;
162  }
163 
164  inline const MSEdge* getRouteEdge() const {
165  return *myRouteStep;
166  }
167  inline const MSEdge* getNextRouteEdge() const {
168  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
169  }
170  inline const ConstMSEdgeVector& getRoute() const {
171  return myRoute;
172  }
173 
175  return myPedestrianState;
176  }
178 
179 
180  private:
181 
183  double walkDistance() const;
184 
185  /* @brief compute average speed if the total walking duration is given
186  * @note Must be called when the previous stage changes myDepartPos from the default*/
187  double computeAverageSpeed() const;
188 
189 
190  private:
193 
196 
197 
198  ConstMSEdgeVector::iterator myRouteStep;
199 
202 
203  double myDepartPos;
205  double mySpeed;
206 
209 
211  public:
213  explicit arrival_finder(SUMOTime time) : myTime(time) {}
214 
216  bool operator()(double t) const {
217  return myTime > t;
218  }
219 
220  private:
223  };
224 
225  private:
228 
231 
232  };
233 
239  public:
241  MSPersonStage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
242  const double arrivalPos, const std::vector<std::string>& lines);
243 
246 
248  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
249 
251  std::string getStageDescription() const;
252 
258  virtual void tripInfoOutput(OutputDevice& os) const;
259 
265  virtual void routeOutput(OutputDevice& os) const;
266  };
267 
268 public:
271 
273  virtual ~MSPerson();
274 
275  /* @brief proceeds to the next step of the route,
276  * @return Whether the persons plan continues */
277  bool proceed(MSNet* net, SUMOTime time);
278 
280  const std::string& getNextEdge() const;
281 
283  const MSEdge* getNextEdgePtr() const;
284 
290  virtual void tripInfoOutput(OutputDevice& os) const;
291 
297  virtual void routeOutput(OutputDevice& os) const;
298 
300  virtual bool isSelected() const {
301  return false;
302  }
303 
304  double getSpeedFactor() const;
305 
306 
307 private:
309  MSPerson(const MSPerson&);
310 
312  MSPerson& operator=(const MSPerson&);
313 
314 };
315 
316 
317 #endif
318 
319 /****************************************************************************/
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:99
double getDepartPos() const
Definition: MSPerson.h:152
MSPersonStage_Walking(const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat)
constructor
Definition: MSPerson.cpp:59
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:346
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:167
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:213
double getArrivalPos() const
Definition: MSPerson.h:160
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:201
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan)
constructor
Definition: MSPerson.cpp:341
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:105
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:398
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:218
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:230
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:58
The simulated network and simulation perfomer.
Definition: MSNet.h:89
The car-following model and parameter.
Definition: MSVehicleType.h:73
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:111
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:129
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:83
The pedestrian following model.
Definition: MSPModel.h:56
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:134
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:195
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
bool operator()(double t) const
comparison operator
Definition: MSPerson.h:216
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:159
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
Definition: MSPerson.cpp:244
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:174
Representation of a vehicle.
Definition: SUMOVehicle.h:67
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:170
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:198
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:164
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:165
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:117
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:115
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:129
double getMaxSpeed() const
accessors to be used by MSPModel
Definition: MSPerson.h:149
double computeAverageSpeed() const
Definition: MSPerson.cpp:171
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:237
Structure representing possible vehicle parameter.
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:222
double getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:123
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:192
double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.cpp:434
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:78
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:379
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:208
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:300
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:93
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
long long int SUMOTime
Definition: TraCIDefs.h:52
double getDepartPosLat() const
Definition: MSPerson.h:156
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
double walkDistance() const
compute total walking distance
Definition: MSPerson.cpp:177
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:207
double myArrivalPos
the position at which we want to arrive