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  const MSEdge* getEdge() const;
233  const MSEdge* getFromEdge() const;
234  SUMOReal getEdgePos(SUMOTime now) const;
235 
237  Position getPosition(SUMOTime now) const;
238 
239  SUMOReal getAngle(SUMOTime now) const;
240 
241  std::string getStageDescription() const;
242 
244  bool isWaitingFor(const std::string& line) const;
245 
247  bool isWaiting4Vehicle() const;
248 
251  return myVehicle;
252  }
253 
255  SUMOTime getWaitingTime(SUMOTime now) const;
256 
257  SUMOReal getSpeed() const;
258 
260  myVehicle = v;
261  }
262 
268  virtual void tripInfoOutput(OutputDevice& os) const;
269 
275  virtual void routeOutput(OutputDevice& os) const;
276 
281  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
282 
287  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
288 
289  private:
291  const std::set<std::string> myLines;
292 
295 
301 
302  private:
305 
308 
309  };
310 
315  public:
317  MSPersonStage_Waiting(const MSEdge& destination,
318  SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string& actType);
319 
322 
324  const MSEdge* getEdge() const;
325  const MSEdge* getFromEdge() const;
326  SUMOReal getEdgePos(SUMOTime now) const;
327  SUMOTime getUntil() const;
328 
330  Position getPosition(SUMOTime now) const;
331 
332  SUMOReal getAngle(SUMOTime now) const;
333 
334  SUMOTime getWaitingTime(SUMOTime now) const;
335 
336  SUMOReal getSpeed() const;
337 
338  std::string getStageDescription() const {
339  return "waiting (" + myActType + ")";
340  }
341 
343  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
344 
350  virtual void tripInfoOutput(OutputDevice& os) const;
351 
357  virtual void routeOutput(OutputDevice& os) const;
358 
363  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
364 
369  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
370 
371  private:
374 
377 
380 
382  std::string myActType;
383 
384  private:
387 
390 
391  };
392 
393 public:
396 
398  virtual ~MSPerson();
399 
400  /* @brief proceeds to the next step of the route,
401  * @return Whether the persons plan continues */
402  bool proceed(MSNet* net, SUMOTime time);
403 
409  void routeOutput(OutputDevice& os) const;
410 
412  const std::string& getNextEdge() const;
413 
415  const MSEdge* getNextEdgePtr() const;
416 
417 private:
419  MSPerson(const MSPerson&);
420 
422  MSPerson& operator=(const MSPerson&);
423 
424 };
425 
426 
427 #endif
428 
429 /****************************************************************************/
SUMOVehicle * getVehicle() const
The vehicle the person is riding or 0.
Definition: MSPerson.h:250
const MSEdge * myWaitingEdge
Definition: MSPerson.h:299
long long int SUMOTime
Definition: SUMOTime.h:43
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:485
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:152
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
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
Definition: MSPerson.h:298
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:105
const std::set< std::string > myLines
the lines to choose from
Definition: MSPerson.h:291
SUMOTime myWaitingUntil
the time until the person is waiting
Definition: MSPerson.h:376
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:544
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:169
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
virtual bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:181
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:58
The simulated network and simulation perfomer.
Definition: MSNet.h:94
SUMOReal getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:99
The car-following model and parameter.
Definition: MSVehicleType.h:74
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:83
The pedestrian following model.
Definition: MSPModel.h:54
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
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
Definition: MSPerson.cpp:195
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:159
Representation of a vehicle.
Definition: SUMOVehicle.h:65
virtual bool isWaitingFor(const std::string &line) const
Whether the transportable waits for a vehicle of the line specified.
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:155
SUMOReal computeAverageSpeed() const
Definition: MSPerson.cpp:151
SUMOTime myWaitingDuration
the time the person is waiting
Definition: MSPerson.h:373
SUMOReal myArrivalPos
the position at which we want to arrive
std::string myActType
The type of activity.
Definition: MSPerson.h:382
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:180
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:149
bool operator()(SUMOReal t) const
comparison operator
Definition: MSPerson.h:197
void setVehicle(SUMOVehicle *v)
Definition: MSPerson.h:259
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:105
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:93
SUMOReal getArrivalPos() const
Definition: MSPerson.h:145
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:111
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:188
Structure representing possible vehicle parameter.
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:203
SUMOTime myWaitingStart
the time the person is waiting
Definition: MSPerson.h:379
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:174
SUMOReal getDepartPos() const
Definition: MSPerson.h:142
~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:526
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:189
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:93
MSPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan)
constructor
Definition: MSPerson.cpp:480
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
MSPersonStage_Walking(const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos)
constructor
Definition: MSPerson.cpp:60
SUMOVehicle * myVehicle
The taken vehicle.
Definition: MSPerson.h:294
SUMOReal getMaxSpeed() const
accessors to be used by MSPModel
Definition: MSPerson.h:139
SUMOReal getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:123
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:338
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:163