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 
182  /* @brief compute average speed if the total walking duration is given
183  * @note Must be called when the previous stage changes myDepartPos from the default*/
184  double computeAverageSpeed() const;
185 
186 
187  private:
190 
193 
194 
195  ConstMSEdgeVector::iterator myRouteStep;
196 
199 
200  double myDepartPos;
202  double mySpeed;
203 
206 
208  public:
210  explicit arrival_finder(SUMOTime time) : myTime(time) {}
211 
213  bool operator()(double t) const {
214  return myTime > t;
215  }
216 
217  private:
220  };
221 
222  private:
225 
228 
229  };
230 
236  public:
238  MSPersonStage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
239  const double arrivalPos, const std::vector<std::string>& lines);
240 
243 
245  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
246 
248  std::string getStageDescription() const;
249 
255  virtual void tripInfoOutput(OutputDevice& os) const;
256 
262  virtual void routeOutput(OutputDevice& os) const;
263  };
264 
265 public:
268 
270  virtual ~MSPerson();
271 
272  /* @brief proceeds to the next step of the route,
273  * @return Whether the persons plan continues */
274  bool proceed(MSNet* net, SUMOTime time);
275 
277  const std::string& getNextEdge() const;
278 
280  const MSEdge* getNextEdgePtr() const;
281 
287  virtual void tripInfoOutput(OutputDevice& os) const;
288 
294  virtual void routeOutput(OutputDevice& os) const;
295 
296 private:
298  MSPerson(const MSPerson&);
299 
301  MSPerson& operator=(const MSPerson&);
302 
303 };
304 
305 
306 #endif
307 
308 /****************************************************************************/
MSPersonStage_Walking(const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat)
constructor
Definition: MSPerson.cpp:56
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:200
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:299
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:210
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:198
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:80
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:102
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:329
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:58
The simulated network and simulation perfomer.
Definition: MSNet.h:94
The car-following model and parameter.
Definition: MSVehicleType.h:74
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:174
The pedestrian following model.
Definition: MSPModel.h:54
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:193
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:131
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:192
A road/street connecting two junctions.
Definition: MSEdge.h:80
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:151
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
Definition: MSPerson.cpp:207
Representation of a vehicle.
Definition: SUMOVehicle.h:67
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:181
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:126
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:175
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:108
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:195
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:157
double getArrivalPos() const
Definition: MSPerson.h:160
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:170
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:96
double computeAverageSpeed() const
Definition: MSPerson.cpp:163
Structure representing possible vehicle parameter.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:114
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:219
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:189
double getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:120
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:75
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:115
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:205
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:348
MSPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan)
constructor
Definition: MSPerson.cpp:294
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool operator()(double t) const
comparison operator
Definition: MSPerson.h:213
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:164
long long int SUMOTime
Definition: TraCIDefs.h:52
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:167
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:90
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:96
double getMaxSpeed() const
accessors to be used by MSPModel
Definition: MSPerson.h:149
double myArrivalPos
the position at which we want to arrive
double getDepartPosLat() const
Definition: MSPerson.h:156