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, MSTransportable* transportable) const;
116 
121  virtual void routeOutput(OutputDevice& os) const;
122 
127  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
128 
133  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
134 
136  bool moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal = nullptr);
137 
139  void setRouteIndex(MSPerson* person, int routeOffset);
140 
142 
143  double getMaxSpeed(const MSPerson* person) const;
144 
145  inline double getDepartPos() const {
146  return myDepartPos;
147  }
148 
149  inline double getDepartPosLat() const {
150  return myDepartPosLat;
151  }
152 
153  inline double getArrivalPos() const {
154  return myArrivalPos;
155  }
156 
157  inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
158  return myRouteStep;
159  }
160 
161  inline const MSEdge* getRouteEdge() const {
162  return *myRouteStep;
163  }
164  inline const MSEdge* getNextRouteEdge() const {
165  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
166  }
167  inline const ConstMSEdgeVector& getRoute() const {
168  return myRoute;
169  }
170 
172  return myPedestrianState;
173  }
175 
176 
177  private:
178 
180  double walkDistance() const;
181 
182  /* @brief compute average speed if the total walking duration is given
183  * @note Must be called when the previous stage changes myDepartPos from the default*/
184  double computeAverageSpeed() const;
185 
186 
187  private:
190 
193 
194 
195  ConstMSEdgeVector::iterator myRouteStep;
196 
199 
200  double myDepartPos;
202  double mySpeed;
203 
206 
208  public:
210  explicit arrival_finder(SUMOTime time) : myTime(time) {}
211 
213  bool operator()(double t) const {
214  return myTime > t;
215  }
216 
217  private:
220  };
221 
222  private:
225 
228 
229  };
230 
236  public:
238  MSPersonStage_Driving(const MSEdge* destination, MSStoppingPlace* toStop,
239  const double arrivalPos, const std::vector<std::string>& lines,
240  const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
241 
244 
246  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
247 
249  std::string getStageDescription() const;
250  std::string getStageSummary() const;
251 
258  virtual void tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const;
259 
265  virtual void routeOutput(OutputDevice& os) const;
266  };
267 
273  public:
275  MSPersonStage_Access(const MSEdge* destination, MSStoppingPlace* toStop,
276  const double arrivalPos, const double dist, const bool isExit);
277 
280 
282  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous);
283 
285  std::string getStageDescription() const;
286  std::string getStageSummary() const;
287 
288  Position getPosition(SUMOTime now) const;
289 
290  double getAngle(SUMOTime now) const;
291 
298  void tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const;
299 
301  void routeOutput(OutputDevice&) const {};
302 
305 
308 
309  private:
310  class ProceedCmd : public Command {
311  public:
312  ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
314  SUMOTime execute(SUMOTime currentTime);
315  private:
318  private:
321  };
322 
323  private:
324  const double myDist;
325  const bool myAmExit;
328  };
329 
330 public:
332  MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
333 
335  virtual ~MSPerson();
336 
337  /* @brief proceeds to the next step of the route,
338  * @return Whether the persons plan continues */
339  bool proceed(MSNet* net, SUMOTime time);
340 
342  const std::string& getNextEdge() const;
343 
345  const MSEdge* getNextEdgePtr() const;
346 
352  virtual void tripInfoOutput(OutputDevice& os, MSTransportable* transportable) const;
353 
359  virtual void routeOutput(OutputDevice& os) const;
360 
362  virtual bool isSelected() const {
363  return false;
364  }
365 
366  inline double getSpeedFactor() const {
367  return myChosenSpeedFactor;
368  }
369 
371  void reroute(ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex);
372 
373 
379  class Influencer {
380  public:
382  Influencer();
383 
384 
386  ~Influencer();
387 
388 
389  void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
390 
392  return myLastRemoteAccess;
393  }
394 
395  void postProcessRemoteControl(MSPerson* p);
396 
397  bool isRemoteControlled() const;
398 
399  bool isRemoteAffected(SUMOTime t) const;
400 
401  private:
404  double myRemotePos;
410  };
411 
412 
419 
420  const Influencer* getInfluencer() const;
421 
422  bool hasInfluencer() const {
423  return myInfluencer != 0;
424  }
425 
427  void setRemoteState(Position xyPos);
428 
429 private:
432 
433  const double myChosenSpeedFactor;
434 
436 
437 private:
439  MSPerson(const MSPerson&);
440 
442  MSPerson& operator=(const MSPerson&);
443 
444 };
445 
446 
447 #endif
448 
449 /****************************************************************************/
ProceedCmd(MSTransportable *person, MSEdge *edge)
Definition: MSPerson.h:312
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:305
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:547
void endEventOutput(const MSTransportable &, SUMOTime, OutputDevice &) const
Called on writing events output (end of an action). Currently does nothing.
Definition: MSPerson.h:307
void setRemoteState(Position xyPos)
sets position outside the road network
SUMOTime getLastAccessTimeStep() const
Definition: MSPerson.h:391
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:210
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:198
bool hasInfluencer() const
Definition: MSPerson.h:422
void beginEventOutput(const MSTransportable &, SUMOTime, OutputDevice &) const
Called on writing events output (begin of an action). Currently does nothing.
Definition: MSPerson.h:304
double getMaxSpeed(const MSPerson *person) const
accessors to be used by MSPModel
Definition: MSPerson.cpp:346
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:599
MSLane * myRemoteLane
Definition: MSPerson.h:403
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
SUMOTime myLastRemoteAccess
Definition: MSPerson.h:409
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:85
The car-following model and parameter.
Definition: MSVehicleType.h:66
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:171
The pedestrian following model.
Definition: MSPModel.h:50
std::string getStageSummary() const
return string summary of the current stage
Definition: MSPerson.cpp:351
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:298
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:192
A road/street connecting two junctions.
Definition: MSEdge.h:75
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
void routeOutput(OutputDevice &) const
Called on writing vehroute output. Currently does nothing.
Definition: MSPerson.h:301
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSPerson.cpp:165
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSPerson.cpp:681
virtual bool isSelected() const
whether this person is selected in the GUI
Definition: MSPerson.h:362
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:279
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.
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:116
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:195
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
Definition: MSPerson.cpp:171
double getArrivalPos() const
Definition: MSPerson.h:153
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:167
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
Definition: MSPerson.cpp:541
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:157
Changes the wished person speed and position.
Definition: MSPerson.h:379
double computeAverageSpeed() const
Definition: MSPerson.cpp:177
double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
Definition: MSPerson.h:366
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:408
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:656
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:219
const double myChosenSpeedFactor
Definition: MSPerson.h:433
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:189
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:312
~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
virtual void tripInfoOutput(OutputDevice &os, MSTransportable *transportable) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:259
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:205
static DummyState myDummyState
Definition: MSPerson.h:435
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:618
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:213
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:161
Position myRemoteXYPos
Definition: MSPerson.h:402
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:164
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:431
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:98
double getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:104
double myArrivalPos
the position at which we want to arrive
double getDepartPosLat() const
Definition: MSPerson.h:149
void setRouteIndex(MSPerson *person, int routeOffset)
place person on a previously passed edge
Definition: MSPerson.cpp:337