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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // The class for modelling person-movements
19 /****************************************************************************/
20 #ifndef MSPerson_h
21 #define MSPerson_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <vector>
31 #include <set>
32 #include <utils/common/SUMOTime.h>
33 #include <utils/common/Command.h>
34 #include <utils/geom/Position.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class MSNet;
43 class MSEdge;
44 class MSLane;
45 class OutputDevice;
47 class MSStoppingPlace;
48 class SUMOVehicle;
49 class MSVehicleType;
50 class MSPModel;
51 class PedestrianState;
52 class DummyState;
53 
54 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
64 class MSPerson : public MSTransportable {
65 public:
72  public:
74  MSPersonStage_Walking(const std::string& personID, const ConstMSEdgeVector& route, MSStoppingPlace* toStop, SUMOTime walkingTime,
75  double speed, double departPos, double arrivalPos, double departPosLat);
76 
79 
81  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
82 
84  void abort(MSTransportable*);
85 
87  void setSpeed(double speed);
88 
90  const MSEdge* getEdge() const;
91  const MSEdge* getFromEdge() const;
92  double getEdgePos(SUMOTime now) const;
93 
95  Position getPosition(SUMOTime now) const;
96 
97  double getAngle(SUMOTime now) const;
98 
99  SUMOTime getWaitingTime(SUMOTime now) const;
100 
101  double getSpeed() const;
102 
104  ConstMSEdgeVector getEdges() const;
105 
106  std::string getStageDescription() const {
107  return "walking";
108  }
109  std::string getStageSummary() const;
110 
115  virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
116 
122  virtual void routeOutput(OutputDevice& os, const bool withRouteLength) const;
123 
128  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
129 
134  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
135 
137  bool moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal = nullptr);
138 
140  void setRouteIndex(MSPerson* person, int routeOffset);
141 
143 
144  double getMaxSpeed(const MSTransportable* const 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  const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
242 
245 
247  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
248 
250  std::string getStageDescription() const;
251  std::string getStageSummary() const;
252 
259  virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
260 
267  virtual void routeOutput(OutputDevice& os, const bool withRouteLength) const;
268  };
269 
275  public:
277  MSPersonStage_Access(const MSEdge* destination, MSStoppingPlace* toStop,
278  const double arrivalPos, const double dist, const bool isExit);
279 
282 
284  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
285 
287  std::string getStageDescription() const;
288  std::string getStageSummary() const;
289 
290  Position getPosition(SUMOTime now) const;
291 
292  double getAngle(SUMOTime now) const;
293 
300  void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
301 
303  void routeOutput(OutputDevice&, const bool) const {};
304 
307 
310 
311  private:
312  class ProceedCmd : public Command {
313  public:
314  ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
316  SUMOTime execute(SUMOTime currentTime);
317  private:
320  private:
323  };
324 
325  private:
326  const double myDist;
327  const bool myAmExit;
330  };
331 
332 public:
334  MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
335 
337  virtual ~MSPerson();
338 
339  /* @brief proceeds to the next step of the route,
340  * @return Whether the persons plan continues */
341  bool proceed(MSNet* net, SUMOTime time);
342 
344  const std::string& getNextEdge() const;
345 
347  const MSEdge* getNextEdgePtr() const;
348 
354  virtual void tripInfoOutput(OutputDevice& os) const;
355 
361  virtual void routeOutput(OutputDevice& os, const bool withRouteLength) const;
362 
364  virtual bool isSelected() const {
365  return false;
366  }
367 
368  inline double getSpeedFactor() const {
369  return myChosenSpeedFactor;
370  }
371 
373  void reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex);
374 
375 
381  class Influencer {
382  public:
384  Influencer();
385 
386 
388  ~Influencer();
389 
390 
391  void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
392 
394  return myLastRemoteAccess;
395  }
396 
397  void postProcessRemoteControl(MSPerson* p);
398 
399  bool isRemoteControlled() const;
400 
401  bool isRemoteAffected(SUMOTime t) const;
402 
403  private:
406  double myRemotePos;
412  };
413 
414 
421 
422  const Influencer* getInfluencer() const;
423 
424  bool hasInfluencer() const {
425  return myInfluencer != 0;
426  }
427 
429  void setRemoteState(Position xyPos);
430 
431 private:
434 
435  const double myChosenSpeedFactor;
436 
438 
439 private:
441  MSPerson(const MSPerson&);
442 
444  MSPerson& operator=(const MSPerson&);
445 
446 };
447 
448 
449 #endif
450 
451 /****************************************************************************/
ProceedCmd(MSTransportable *person, MSEdge *edge)
Definition: MSPerson.h:314
long long int SUMOTime
Definition: SUMOTime.h:36
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:308
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:553
void endEventOutput(const MSTransportable &, SUMOTime, OutputDevice &) const
Called on writing events output (end of an action). Currently does nothing.
Definition: MSPerson.h:309
void setRemoteState(Position xyPos)
sets position outside the road network
SUMOTime getLastAccessTimeStep() const
Definition: MSPerson.h:393
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:424
void beginEventOutput(const MSTransportable &, SUMOTime, OutputDevice &) const
Called on writing events output (begin of an action). Currently does nothing.
Definition: MSPerson.h:306
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:88
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:110
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:605
MSLane * myRemoteLane
Definition: MSPerson.h:405
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
SUMOTime myLastRemoteAccess
Definition: MSPerson.h:411
Base (microsim) event class.
Definition: Command.h:54
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:52
The simulated network and simulation perfomer.
Definition: MSNet.h:84
The car-following model and parameter.
Definition: MSVehicleType.h:66
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:172
The pedestrian following model.
Definition: MSPModel.h:50
std::string getStageSummary() const
return string summary of the current stage
Definition: MSPerson.cpp:354
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:301
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:140
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:193
A road/street connecting two junctions.
Definition: MSEdge.h:75
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:165
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:690
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:364
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSPerson.cpp:134
A list of positions.
void routeOutput(OutputDevice &, const bool) const
Called on writing vehroute output. Currently does nothing.
Definition: MSPerson.h:303
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:116
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSPerson.cpp:279
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:349
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:196
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:171
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:547
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:128
const std::vector< const MSEdge * >::iterator getRouteStep() const
Definition: MSPerson.h:158
Changes the wished person speed and position.
Definition: MSPerson.h:381
double computeAverageSpeed() const
Definition: MSPerson.cpp:177
double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:368
Structure representing possible vehicle parameter.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:122
ConstMSEdgeVector myRemoteRoute
Definition: MSPerson.h:410
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex, nextIndex[
Definition: MSPerson.cpp:665
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:220
const double myChosenSpeedFactor
Definition: MSPerson.h:435
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:190
double getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:128
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:315
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:80
std::string getStageDescription() const
return (brief) string representation of the current stage
Definition: MSPerson.h:106
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:56
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:206
static DummyState myDummyState
Definition: MSPerson.h:437
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:624
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool operator()(double t) const
comparison operator
Definition: MSPerson.h:214
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:162
Position myRemoteXYPos
Definition: MSPerson.h:404
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:165
double walkDistance() const
compute total walking distance
Definition: MSPerson.cpp:183
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:433
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:98
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:104
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:259
double myArrivalPos
the position at which we want to arrive
double getDepartPosLat() const
Definition: MSPerson.h:150
void setRouteIndex(MSPerson *person, int routeOffset)
place person on a previously passed edge
Definition: MSPerson.cpp:340