SUMO - Simulation of Urban MObility
MSPerson.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // The class for modelling person-movements
21 /****************************************************************************/
22 #ifndef MSPerson_h
23 #define MSPerson_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <set>
38 #include <utils/common/SUMOTime.h>
39 #include <utils/common/Command.h>
40 #include <utils/geom/Position.h>
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class MSNet;
49 class MSEdge;
50 class MSLane;
51 class OutputDevice;
53 class MSStoppingPlace;
54 class SUMOVehicle;
55 class MSVehicleType;
56 class MSPModel;
58 
59 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
60 
61 // ===========================================================================
62 // class definitions
63 // ===========================================================================
69 class MSPerson : public MSTransportable {
70 public:
77  public:
79  MSPersonStage_Walking(const std::string& personID, const ConstMSEdgeVector& route, MSStoppingPlace* toStop, SUMOTime walkingTime,
80  double speed, double departPos, double arrivalPos, double departPosLat);
81 
84 
86  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
87 
89  void abort(MSTransportable*);
90 
92  void setSpeed(double speed);
93 
95  const MSEdge* getEdge() const;
96  const MSEdge* getFromEdge() const;
97  double getEdgePos(SUMOTime now) const;
98 
100  Position getPosition(SUMOTime now) const;
101 
102  double getAngle(SUMOTime now) const;
103 
104  SUMOTime getWaitingTime(SUMOTime now) const;
105 
106  double getSpeed() const;
107 
109  ConstMSEdgeVector getEdges() const;
110 
111  std::string getStageDescription() const {
112  return "walking";
113  }
114 
119  virtual void tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const;
120 
125  virtual void routeOutput(OutputDevice& os) const;
126 
131  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
132 
137  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
138 
140  bool moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal = 0);
141 
143 
144  double getMaxSpeed(const MSPerson* person) const;
145 
146  inline double getDepartPos() const {
147  return myDepartPos;
148  }
149 
150  inline double getDepartPosLat() const {
151  return myDepartPosLat;
152  }
153 
154  inline double getArrivalPos() const {
155  return myArrivalPos;
156  }
157 
158  inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
159  return myRouteStep;
160  }
161 
162  inline const MSEdge* getRouteEdge() const {
163  return *myRouteStep;
164  }
165  inline const MSEdge* getNextRouteEdge() const {
166  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
167  }
168  inline const ConstMSEdgeVector& getRoute() const {
169  return myRoute;
170  }
171 
173  return myPedestrianState;
174  }
176 
177 
178  private:
179 
181  double walkDistance() const;
182 
183  /* @brief compute average speed if the total walking duration is given
184  * @note Must be called when the previous stage changes myDepartPos from the default*/
185  double computeAverageSpeed() const;
186 
187 
188  private:
191 
194 
195 
196  ConstMSEdgeVector::iterator myRouteStep;
197 
200 
201  double myDepartPos;
203  double mySpeed;
204 
207 
209  public:
211  explicit arrival_finder(SUMOTime time) : myTime(time) {}
212 
214  bool operator()(double t) const {
215  return myTime > t;
216  }
217 
218  private:
221  };
222 
223  private:
226 
229 
230  };
231 
237  public:
239  MSPersonStage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
240  const double arrivalPos, const std::vector<std::string>& lines);
241 
244 
246  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
247 
249  std::string getStageDescription() const;
250 
256  virtual void tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const;
257 
263  virtual void routeOutput(OutputDevice& os) const;
264  };
265 
266 public:
268  MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
269 
271  virtual ~MSPerson();
272 
273  /* @brief proceeds to the next step of the route,
274  * @return Whether the persons plan continues */
275  bool proceed(MSNet* net, SUMOTime time);
276 
278  const std::string& getNextEdge() const;
279 
281  const MSEdge* getNextEdgePtr() const;
282 
288  virtual void tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const;
289 
295  virtual void routeOutput(OutputDevice& os) const;
296 
298  virtual bool isSelected() const {
299  return false;
300  }
301 
302  inline double getSpeedFactor() const {
303  return myChosenSpeedFactor;
304  }
305 
307  void reroute(ConstMSEdgeVector& newEdges);
308 
309 #ifndef NO_TRACI
310 
316  class Influencer {
317  public:
319  Influencer();
320 
321 
323  ~Influencer();
324 
325 
326  void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
327 
329  return myLastRemoteAccess;
330  }
331 
332  void postProcessRemoteControl(MSPerson* p);
333 
334  bool isRemoteControlled() const;
335 
336  bool isRemoteAffected(SUMOTime t) const;
337 
338  private:
341  double myRemotePos;
347  };
348 
349 
356 
357  const Influencer* getInfluencer() const;
358 
359  bool hasInfluencer() const {
360  return myInfluencer != 0;
361  }
362 
364  void setRemoteState(Position xyPos);
365 
366 private:
369 #endif
370 
371 private:
372  const double myChosenSpeedFactor;
373 
374 private:
376  MSPerson(const MSPerson&);
377 
379  MSPerson& operator=(const MSPerson&);
380 
381 };
382 
383 
384 #endif
385 
386 /****************************************************************************/
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:280
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:403
void setRemoteState(Position xyPos)
sets position outside the road network
SUMOTime getLastAccessTimeStep() const
Definition: MSPerson.h:328
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:211
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:199
bool hasInfluencer() const
Definition: MSPerson.h:359
double getMaxSpeed(const MSPerson *person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:313
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:87
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:109
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:437
MSLane * myRemoteLane
Definition: MSPerson.h:340
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
SUMOTime myLastRemoteAccess
Definition: MSPerson.h:346
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:57
void reroute(ConstMSEdgeVector &newEdges)
set new walk
Definition: MSPerson.cpp:494
The simulated network and simulation perfomer.
Definition: MSNet.h:90
The car-following model and parameter.
Definition: MSVehicleType.h:72
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:172
The pedestrian following model.
Definition: MSPModel.h:55
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:273
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:138
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:193
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:162
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
Definition: MSPerson.cpp:287
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:513
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:298
Representation of a vehicle.
Definition: SUMOVehicle.h:66
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:258
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:133
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:115
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:196
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:168
double getArrivalPos() const
Definition: MSPerson.h:154
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:168
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:397
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:131
const std::vector< const MSEdge * >::iterator getRouteStep() const
Definition: MSPerson.h:158
Changes the wished person speed and position.
Definition: MSPerson.h:316
double computeAverageSpeed() const
Definition: MSPerson.cpp:174
double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:302
Structure representing possible vehicle parameter.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:121
ConstMSEdgeVector myRemoteRoute
Definition: MSPerson.h:345
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:220
const double myChosenSpeedFactor
Definition: MSPerson.h:372
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:190
double getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:127
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:82
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:111
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat)
constructor
Definition: MSPerson.cpp:58
virtual void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:238
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:206
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:456
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool operator()(double t) const
comparison operator
Definition: MSPerson.h:214
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:162
long long int SUMOTime
Definition: TraCIDefs.h:51
Position myRemoteXYPos
Definition: MSPerson.h:339
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:165
double walkDistance() const
compute total walking distance
Definition: MSPerson.cpp:180
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:368
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:97
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:103
double myArrivalPos
the position at which we want to arrive
double getDepartPosLat() const
Definition: MSPerson.h:150