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-2016 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, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos);
84 
87 
89  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
90 
92  const MSEdge* getEdge() const;
93  const MSEdge* getFromEdge() const;
94  SUMOReal getEdgePos(SUMOTime now) const;
95 
97  Position getPosition(SUMOTime now) const;
98 
99  SUMOReal getAngle(SUMOTime now) const;
100 
101  SUMOTime getWaitingTime(SUMOTime now) const;
102 
103  SUMOReal getSpeed() const;
104 
105  std::string getStageDescription() const {
106  return "walking";
107  }
108 
113  virtual void tripInfoOutput(OutputDevice& os) const;
114 
119  virtual void routeOutput(OutputDevice& os) const;
120 
125  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
126 
131  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
132 
134  bool moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal = 0);
135 
136 
138 
139  inline SUMOReal getMaxSpeed() const {
140  return mySpeed;
141  }
142  inline SUMOReal getDepartPos() const {
143  return myDepartPos;
144  }
145  inline SUMOReal getArrivalPos() const {
146  return myArrivalPos;
147  }
148 
149  inline const MSEdge* getRouteEdge() const {
150  return *myRouteStep;
151  }
152  inline const MSEdge* getNextRouteEdge() const {
153  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
154  }
155  inline const ConstMSEdgeVector& getRoute() const {
156  return myRoute;
157  }
158 
160  return myPedestrianState;
161  }
163 
164 
165  private:
166 
167  /* @brief compute average speed if the total walking duration is given
168  * @note Must be callled when the previous stage changes myDepartPos from the default*/
170 
171 
172  private:
175 
178 
179 
180  ConstMSEdgeVector::iterator myRouteStep;
181 
184 
187 
190 
192  public:
194  explicit arrival_finder(SUMOTime time) : myTime(time) {}
195 
197  bool operator()(SUMOReal t) const {
198  return myTime > t;
199  }
200 
201  private:
204  };
205 
206  private:
209 
212 
213  };
214 
220  public:
222  MSPersonStage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
223  const SUMOReal arrivalPos, const std::vector<std::string>& lines);
224 
227 
229  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
230 
232  std::string getStageDescription() const;
233 
239  virtual void tripInfoOutput(OutputDevice& os) const;
240 
246  virtual void routeOutput(OutputDevice& os) const;
247  };
248 
249 public:
252 
254  virtual ~MSPerson();
255 
256  /* @brief proceeds to the next step of the route,
257  * @return Whether the persons plan continues */
258  bool proceed(MSNet* net, SUMOTime time);
259 
261  const std::string& getNextEdge() const;
262 
264  const MSEdge* getNextEdgePtr() const;
265 
271  virtual void tripInfoOutput(OutputDevice& os) const;
272 
278  virtual void routeOutput(OutputDevice& os) const;
279 
280 private:
282  MSPerson(const MSPerson&);
283 
285  MSPerson& operator=(const MSPerson&);
286 
287 };
288 
289 
290 #endif
291 
292 /****************************************************************************/
SUMOReal getDepartPos() const
Definition: MSPerson.h:142
long long int SUMOTime
Definition: SUMOTime.h:43
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:187
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:286
SUMOReal getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:99
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:194
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:183
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:83
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:105
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:316
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:58
bool operator()(SUMOReal t) const
comparison operator
Definition: MSPerson.h:197
The simulated network and simulation perfomer.
Definition: MSNet.h:93
The car-following model and parameter.
Definition: MSVehicleType.h:74
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:159
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:180
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:129
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:177
A road/street connecting two junctions.
Definition: MSEdge.h:80
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
SUMOReal getMaxSpeed() const
accessors to be used by MSPModel
Definition: MSPerson.h:139
SUMOReal computeAverageSpeed() const
Definition: MSPerson.cpp:150
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
Definition: MSPerson.cpp:194
Representation of a vehicle.
Definition: SUMOVehicle.h:66
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:168
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:111
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:162
SUMOReal myArrivalPos
the position at which we want to arrive
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:180
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:155
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:93
SUMOReal getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:123
Structure representing possible vehicle parameter.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:117
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:203
SUMOReal getArrivalPos() const
Definition: MSPerson.h:145
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:174
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:78
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:105
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:189
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:335
MSPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan)
constructor
Definition: MSPerson.cpp:281
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:149
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:152
MSPersonStage_Walking(const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos)
constructor
Definition: MSPerson.cpp:60
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:93