Eclipse 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-2019 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 
80  Stage* clone() const;
81 
83  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
84 
86  void abort(MSTransportable*);
87 
89  void setSpeed(double speed);
90 
92  const MSEdge* getEdge() const;
93  const MSEdge* getFromEdge() const;
94  double getEdgePos(SUMOTime now) const;
95 
97  Position getPosition(SUMOTime now) const;
98 
99  double getAngle(SUMOTime now) const;
100 
102  double getDistance() const {
103  return walkDistance();
104  }
105 
106  SUMOTime getWaitingTime(SUMOTime now) const;
107 
108  double getSpeed() const;
109 
111  ConstMSEdgeVector getEdges() const;
112 
113  std::string getStageDescription() const {
114  return "walking";
115  }
116  std::string getStageSummary() const;
117 
122  virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
123 
129  virtual void routeOutput(OutputDevice& os, const bool withRouteLength) 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 = nullptr);
145 
147  void setRouteIndex(MSPerson* person, int routeOffset);
148 
150 
151  double getMaxSpeed(const MSTransportable* const person) const;
152 
153  inline double getDepartPos() const {
154  return myDepartPos;
155  }
156 
157  inline double getDepartPosLat() const {
158  return myDepartPosLat;
159  }
160 
161  inline double getArrivalPos() const {
162  return myArrivalPos;
163  }
164 
165  inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
166  return myRouteStep;
167  }
168 
169  inline const MSEdge* getRouteEdge() const {
170  return *myRouteStep;
171  }
172  inline const MSEdge* getNextRouteEdge() const {
173  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
174  }
175  inline const ConstMSEdgeVector& getRoute() const {
176  return myRoute;
177  }
178 
180  return myPedestrianState;
181  }
183 
184 
185  private:
186 
188  double walkDistance() const;
189 
190  /* @brief compute average speed if the total walking duration is given
191  * @note Must be called when the previous stage changes myDepartPos from the default*/
192  double computeAverageSpeed() const;
193 
194 
195  private:
198 
201 
204 
205 
206  ConstMSEdgeVector::iterator myRouteStep;
207 
210 
211  double myDepartPos;
213  double mySpeed;
214 
217 
219  public:
221  explicit arrival_finder(SUMOTime time) : myTime(time) {}
222 
224  bool operator()(double t) const {
225  return myTime > t;
226  }
227 
228  private:
231  };
232 
233  private:
236 
239 
240  };
241 
247  public:
249  MSPersonStage_Driving(const MSEdge* destination, MSStoppingPlace* toStop,
250  const double arrivalPos, const std::vector<std::string>& lines,
251  const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
252 
255 
256  Stage* clone() const;
257 
259  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
260 
262  std::string getStageDescription() const;
263  std::string getStageSummary() const;
264 
271  virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
272 
279  virtual void routeOutput(OutputDevice& os, const bool withRouteLength) const;
280  };
281 
287  public:
289  MSPersonStage_Access(const MSEdge* destination, MSStoppingPlace* toStop,
290  const double arrivalPos, const double dist, const bool isExit);
291 
294 
295  Stage* clone() const;
296 
298  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
299 
301  std::string getStageDescription() const;
302  std::string getStageSummary() const;
303 
304  Position getPosition(SUMOTime now) const;
305 
306  double getAngle(SUMOTime now) const;
307 
309  double getDistance() const {
310  return myDist;
311  }
312 
319  void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
320 
322  void routeOutput(OutputDevice&, const bool) const {};
323 
326 
329 
330  private:
331  class ProceedCmd : public Command {
332  public:
333  ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
335  SUMOTime execute(SUMOTime currentTime);
336  private:
339  private:
342  };
343 
344  private:
345  const double myDist;
346  const bool myAmExit;
349  };
350 
351 public:
353  MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
354 
356  virtual ~MSPerson();
357 
358  /* @brief proceeds to the next step of the route,
359  * @return Whether the persons plan continues */
360  bool proceed(MSNet* net, SUMOTime time);
361 
363  const std::string& getNextEdge() const;
364 
366  const MSEdge* getNextEdgePtr() const;
367 
373  virtual void tripInfoOutput(OutputDevice& os) const;
374 
380  virtual void routeOutput(OutputDevice& os, const bool withRouteLength) const;
381 
383  virtual bool isSelected() const {
384  return false;
385  }
386 
387  inline double getSpeedFactor() const {
388  return myChosenSpeedFactor;
389  }
390 
392  void reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex);
393 
394 
400  class Influencer {
401  public:
403  Influencer();
404 
405 
407  ~Influencer();
408 
409 
410  void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
411 
413  return myLastRemoteAccess;
414  }
415 
416  void postProcessRemoteControl(MSPerson* p);
417 
418  bool isRemoteControlled() const;
419 
420  bool isRemoteAffected(SUMOTime t) const;
421 
422  private:
425  double myRemotePos;
431  };
432 
433 
440 
441  const Influencer* getInfluencer() const;
442 
443  bool hasInfluencer() const {
444  return myInfluencer != 0;
445  }
446 
448  void setRemoteState(Position xyPos);
449 
450 private:
453 
454  const double myChosenSpeedFactor;
455 
457 
458 private:
460  MSPerson(const MSPerson&);
461 
463  MSPerson& operator=(const MSPerson&);
464 
465 };
466 
467 
468 #endif
469 
470 /****************************************************************************/
ProceedCmd(MSTransportable *person, MSEdge *edge)
Definition: MSPerson.h:333
long long int SUMOTime
Definition: SUMOTime.h:35
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:321
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:598
void endEventOutput(const MSTransportable &, SUMOTime, OutputDevice &) const
Called on writing events output (end of an action). Currently does nothing.
Definition: MSPerson.h:328
void setRemoteState(Position xyPos)
sets position outside the road network
SUMOTime getLastAccessTimeStep() const
Definition: MSPerson.h:412
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:221
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:209
bool hasInfluencer() const
Definition: MSPerson.h:443
void beginEventOutput(const MSTransportable &, SUMOTime, OutputDevice &) const
Called on writing events output (begin of an action). Currently does nothing.
Definition: MSPerson.h:325
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:92
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:114
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:655
double getDistance() const
get travel distance in this stage
Definition: MSPerson.h:102
MSLane * myRemoteLane
Definition: MSPerson.h:424
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
SUMOTime myLastRemoteAccess
Definition: MSPerson.h:430
Base (microsim) event class.
Definition: Command.h:53
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSPerson.h:52
The simulated network and simulation perfomer.
Definition: MSNet.h:92
The car-following model and parameter.
Definition: MSVehicleType.h:66
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:179
The pedestrian following model.
Definition: MSPModel.h:50
std::string getStageSummary() const
return string summary of the current stage
Definition: MSPerson.cpp:384
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:314
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSPerson.cpp:144
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:203
A road/street connecting two junctions.
Definition: MSEdge.h:76
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:177
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:740
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:383
Representation of a vehicle.
Definition: SUMOVehicle.h:61
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:138
A list of positions.
void routeOutput(OutputDevice &, const bool) const
Called on writing vehroute output. Currently does nothing.
Definition: MSPerson.h:322
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:120
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
Definition: MSPerson.cpp:292
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:379
double getDistance() const
get travel distance in this stage
Definition: MSPerson.h:309
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:206
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:183
double getArrivalPos() const
Definition: MSPerson.h:161
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:175
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:592
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:165
Changes the wished person speed and position.
Definition: MSPerson.h:400
double computeAverageSpeed() const
Definition: MSPerson.cpp:189
double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:387
Structure representing possible vehicle parameter.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:126
ConstMSEdgeVector myRemoteRoute
Definition: MSPerson.h:429
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:715
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:230
const double myChosenSpeedFactor
Definition: MSPerson.h:454
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:197
double getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:132
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
Definition: MSPerson.cpp:328
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:80
std::string getStageDescription() const
return (brief) string representation of the current stage
Definition: MSPerson.h:113
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:216
static DummyState myDummyState
Definition: MSPerson.h:456
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:674
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:224
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:169
SUMOTime myLastEdgeEntryTime
the time the person entered the edge
Definition: MSPerson.h:200
Position myRemoteXYPos
Definition: MSPerson.h:423
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:172
double walkDistance() const
compute total walking distance
Definition: MSPerson.cpp:195
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
Definition: MSPerson.h:452
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:102
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:108
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:271
double myArrivalPos
the position at which we want to arrive
double getDepartPosLat() const
Definition: MSPerson.h:157
void setRouteIndex(MSPerson *person, int routeOffset)
place person on a previously passed edge
Definition: MSPerson.cpp:370