Eclipse SUMO - Simulation of Urban MObility
MSPModel_Remote.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-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 /****************************************************************************/
15 // The pedestrian following model for remote controlled pedestrian movement
16 /****************************************************************************/
17 
18 #ifndef SUMO_MSPMODEL_REMOTE_H
19 #define SUMO_MSPMODEL_REMOTE_H
20 
21 
23 #include <microsim/MSNet.h>
24 #include <microsim/pedestrians/hybridsim.grpc.pb.h>
25 #include <utils/geom/Boundary.h>
26 #include "MSPModel.h"
27 class MSPModel_Remote : public MSPModel {
28 
29 
30 public:
31  MSPModel_Remote(const OptionsCont& oc, MSNet* net);
32 
35  void remove(PedestrianState* state) override;
36  void cleanupHelper() override;
37  bool usingInternalLanes();
38 
40  class Event : public Command {
41  public:
42  explicit Event(MSPModel_Remote* remoteModel)
43  : myRemoteModel(remoteModel) { }
44  SUMOTime execute(SUMOTime currentTime) override {
45  return myRemoteModel->execute(currentTime);
46  }
47  private:
49  };
50 
51 private:
56  class PState : public PedestrianState {
57  public:
59  ~PState() override;
60  double getEdgePos(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
61  Position getPosition(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
62  double getAngle(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
63  SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
64  double getSpeed(const MSPerson::MSPersonStage_Walking& stage) const override;
65  const MSEdge* getNextEdge(const MSPerson::MSPersonStage_Walking& stage) const override;
68 
69  void setPosition(double x, double y);
70  void setPhi(double phi);
71  private:
73  double myPhi;
76  };
77 
78 
80  std::unique_ptr<hybridsim::HybridSimulation::Stub> myHybridsimStub;
82  void initialize();
83  void handleWalkingArea(MSEdge* msEdge, hybridsim::Scenario& scenario);
84  void handlePedestrianLane(MSLane* pLane, hybridsim::Scenario& scenario);
85  void makeStartOrEndTransition(Position position, Position scnd, double width, hybridsim::Scenario& scenario,
86  hybridsim::Edge_Type type, int i);
87  void handleShape(const PositionVector& shape, hybridsim::Scenario& scenario);
88 
89  std::map<int, PState*> remoteIdPStateMapping;
90  std::map<const MSEdge*, std::tuple<int, int>> edgesTransitionsMapping;
91  std::map<int, const MSEdge*> transitionsEdgesMapping;
92  int myLastId = 0;
94 
95 
96  MSLane* getFirstPedestrianLane(const MSEdge* const& edge);
97 };
98 
99 
100 #endif //SUMO_MSPMODEL_REMOTE_H
Boundary.h
MSPModel_Remote::makeStartOrEndTransition
void makeStartOrEndTransition(Position position, Position scnd, double width, hybridsim::Scenario &scenario, hybridsim::Edge_Type type, int i)
Definition: MSPModel_Remote.cpp:338
MSPModel_Remote::PState::getPosition
Position getPosition(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const override
return the network coordinate of the person
Definition: MSPModel_Remote.cpp:393
MSPModel
The pedestrian following model.
Definition: MSPModel.h:50
MSPModel_Remote::myLastTransitionId
int myLastTransitionId
Definition: MSPModel_Remote.h:93
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSPModel_Remote::handlePedestrianLane
void handlePedestrianLane(MSLane *pLane, hybridsim::Scenario &scenario)
Definition: MSPModel_Remote.cpp:300
MSPModel_Remote::PState::setPhi
void setPhi(double phi)
Definition: MSPModel_Remote.cpp:411
OptionsCont.h
MSPModel_Remote::transitionsEdgesMapping
std::map< int, const MSEdge * > transitionsEdgesMapping
Definition: MSPModel_Remote.h:91
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
MSPerson
Definition: MSPerson.h:64
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSPModel_Remote::myNet
MSNet * myNet
Definition: MSPModel_Remote.h:79
MSPModel_Remote::PState::getWaitingTime
SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const override
return the time the person spent standing
Definition: MSPModel_Remote.cpp:399
MSPModel_Remote::PState::getSpeed
double getSpeed(const MSPerson::MSPersonStage_Walking &stage) const override
return the current speed of the person
Definition: MSPModel_Remote.cpp:402
MSPModel_Remote::MSPModel_Remote
MSPModel_Remote(const OptionsCont &oc, MSNet *net)
Definition: MSPModel_Remote.cpp:33
MSPModel_Remote::Event
Definition: MSPModel_Remote.h:40
MSPModel_Remote::Event::myRemoteModel
MSPModel_Remote * myRemoteModel
Definition: MSPModel_Remote.h:48
PositionVector
A list of positions.
Definition: PositionVector.h:46
MSPModel_Remote::add
PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now) override
register the given person as a pedestrian
Definition: MSPModel_Remote.cpp:44
PedestrianState
abstract base class for managing callbacks to retrieve various state information from the model
Definition: MSPModel.h:128
MSPModel_Remote
Definition: MSPModel_Remote.h:27
MSPModel_Remote::cleanupHelper
void cleanupHelper() override
Definition: MSPModel_Remote.cpp:216
MSPModel_Remote::PState::getEdgePos
double getEdgePos(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const override
return the offset from the start of the current edge measured in its natural direction
Definition: MSPModel_Remote.cpp:390
MSPModel_Remote::myLastId
int myLastId
Definition: MSPModel_Remote.h:92
MSPModel_Remote::~MSPModel_Remote
~MSPModel_Remote()
Definition: MSPModel_Remote.cpp:119
MSPModel_Remote::Event::Event
Event(MSPModel_Remote *remoteModel)
Definition: MSPModel_Remote.h:42
MSPModel_Remote::PState::myPhi
double myPhi
Definition: MSPModel_Remote.h:73
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
MSPModel_Remote::PState::setPosition
void setPosition(double x, double y)
Definition: MSPModel_Remote.cpp:408
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
MSPModel_Remote::PState::getNextEdge
const MSEdge * getNextEdge(const MSPerson::MSPersonStage_Walking &stage) const override
return the list of internal edges if the pedestrian is on an intersection
Definition: MSPModel_Remote.cpp:405
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSPModel_Remote::handleWalkingArea
void handleWalkingArea(MSEdge *msEdge, hybridsim::Scenario &scenario)
Definition: MSPModel_Remote.cpp:277
MSPModel_Remote::execute
SUMOTime execute(SUMOTime time)
Definition: MSPModel_Remote.cpp:132
MSPModel_Remote::PState::getPerson
MSPerson * getPerson()
Definition: MSPModel_Remote.cpp:417
MSPModel_Remote::PState::getAngle
double getAngle(const MSPerson::MSPersonStage_Walking &stage, SUMOTime now) const override
return the direction in which the person faces in degrees
Definition: MSPModel_Remote.cpp:396
MSPModel_Remote::PState::myPerson
MSPerson * myPerson
Definition: MSPModel_Remote.h:75
MSPModel_Remote::myHybridsimStub
std::unique_ptr< hybridsim::HybridSimulation::Stub > myHybridsimStub
Definition: MSPModel_Remote.h:80
MSPModel_Remote::PState
Container for pedestrian state and individual position update function.
Definition: MSPModel_Remote.h:56
MSPModel_Remote::myBoundary
Boundary myBoundary
Definition: MSPModel_Remote.h:81
MSPModel_Remote::PState::myStage
MSPerson::MSPersonStage_Walking * myStage
Definition: MSPModel_Remote.h:74
MSPModel_Remote::handleShape
void handleShape(const PositionVector &shape, hybridsim::Scenario &scenario)
Definition: MSPModel_Remote.cpp:359
MSPModel_Remote::remove
void remove(PedestrianState *state) override
remove the specified person from the pedestrian simulation
Definition: MSPModel_Remote.cpp:212
MSPModel_Remote::PState::myPosition
Position myPosition
Definition: MSPModel_Remote.h:72
Command
Base (microsim) event class.
Definition: Command.h:53
MSPModel_Remote::PState::getStage
MSPerson::MSPersonStage_Walking * getStage()
Definition: MSPModel_Remote.cpp:414
MSPerson::MSPersonStage_Walking
Definition: MSPerson.h:71
MSPModel_Remote::getFirstPedestrianLane
MSLane * getFirstPedestrianLane(const MSEdge *const &edge)
Definition: MSPModel_Remote.cpp:203
MSPModel.h
MSPModel_Remote::PState::~PState
~PState() override
Definition: MSPModel_Remote.cpp:387
MSPModel_Remote::remoteIdPStateMapping
std::map< int, PState * > remoteIdPStateMapping
Definition: MSPModel_Remote.h:89
MSPModel_Remote::usingInternalLanes
bool usingInternalLanes()
whether movements on intersections are modelled
Definition: MSPModel_Remote.cpp:422
MSPModel_Remote::Event::execute
SUMOTime execute(SUMOTime currentTime) override
Executes the command.
Definition: MSPModel_Remote.h:44
MSPModel_Remote::PState::PState
PState(MSPerson *person, MSPerson::MSPersonStage_Walking *stage)
Definition: MSPModel_Remote.cpp:382
MSPModel_Remote::initialize
void initialize()
Definition: MSPModel_Remote.cpp:220
MSPModel_Remote::edgesTransitionsMapping
std::map< const MSEdge *, std::tuple< int, int > > edgesTransitionsMapping
Definition: MSPModel_Remote.h:90