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 /****************************************************************************/
14 // The pedestrian following model for remote controlled pedestrian movement
15 /****************************************************************************/
16 
17 #ifndef SUMO_MSPMODEL_REMOTE_H
18 #define SUMO_MSPMODEL_REMOTE_H
19 
20 
22 #include <microsim/MSNet.h>
23 #include <microsim/pedestrians/hybridsim.grpc.pb.h>
24 #include <utils/geom/Boundary.h>
25 #include "MSPModel.h"
26 class MSPModel_Remote : public MSPModel {
27 
28 
29 public:
30  MSPModel_Remote(const OptionsCont& oc, MSNet* net);
31 
34  void remove(PedestrianState* state) override;
35  void cleanupHelper() override;
36  bool usingInternalLanes();
37 
39  class Event : public Command {
40  public:
41  explicit Event(MSPModel_Remote* remoteModel)
42  : myRemoteModel(remoteModel) { }
43  SUMOTime execute(SUMOTime currentTime) override {
44  return myRemoteModel->execute(currentTime);
45  }
46  private:
48  };
49 
50 private:
55  class PState : public PedestrianState {
56  public:
58  ~PState() override;
59  double getEdgePos(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
60  Position getPosition(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
61  double getAngle(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
62  SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
63  double getSpeed(const MSPerson::MSPersonStage_Walking& stage) const override;
64  const MSEdge* getNextEdge(const MSPerson::MSPersonStage_Walking& stage) const override;
67 
68  void setPosition(double x, double y);
69  void setPhi(double phi);
70  private:
72  double myPhi;
75  };
76 
77 
79  std::unique_ptr<hybridsim::HybridSimulation::Stub> myHybridsimStub;
81  void initialize();
82  void handleWalkingArea(MSEdge* msEdge, hybridsim::Scenario& scenario);
83  void handlePedestrianLane(MSLane* pLane, hybridsim::Scenario& scenario);
84  void makeStartOrEndTransition(Position position, Position scnd, double width, hybridsim::Scenario& scenario,
85  hybridsim::Edge_Type type, int i);
86  void handleShape(const PositionVector& shape, hybridsim::Scenario& scenario);
87 
88  std::map<int, PState*> remoteIdPStateMapping;
89  std::map<const MSEdge*, std::tuple<int, int>> edgesTransitionsMapping;
90  std::map<int, const MSEdge*> transitionsEdgesMapping;
91  int myLastId = 0;
93 
94 
95  MSLane* getFirstPedestrianLane(const MSEdge* const& edge);
96 };
97 
98 
99 #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:337
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:392
MSPModel
The pedestrian following model.
Definition: MSPModel.h:52
MSPModel_Remote::myLastTransitionId
int myLastTransitionId
Definition: MSPModel_Remote.h:92
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSPModel_Remote::handlePedestrianLane
void handlePedestrianLane(MSLane *pLane, hybridsim::Scenario &scenario)
Definition: MSPModel_Remote.cpp:299
MSPModel_Remote::PState::setPhi
void setPhi(double phi)
Definition: MSPModel_Remote.cpp:410
OptionsCont.h
MSPModel_Remote::transitionsEdgesMapping
std::map< int, const MSEdge * > transitionsEdgesMapping
Definition: MSPModel_Remote.h:90
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
MSPerson
Definition: MSPerson.h:63
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSPModel_Remote::myNet
MSNet * myNet
Definition: MSPModel_Remote.h:78
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:398
MSPModel_Remote::PState::getSpeed
double getSpeed(const MSPerson::MSPersonStage_Walking &stage) const override
return the current speed of the person
Definition: MSPModel_Remote.cpp:401
MSPModel_Remote::MSPModel_Remote
MSPModel_Remote(const OptionsCont &oc, MSNet *net)
Definition: MSPModel_Remote.cpp:32
MSPModel_Remote::Event
Definition: MSPModel_Remote.h:39
MSPModel_Remote::Event::myRemoteModel
MSPModel_Remote * myRemoteModel
Definition: MSPModel_Remote.h:47
PositionVector
A list of positions.
Definition: PositionVector.h:45
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:43
PedestrianState
abstract base class for managing callbacks to retrieve various state information from the model
Definition: MSPModel.h:137
MSPModel_Remote
Definition: MSPModel_Remote.h:26
MSPModel_Remote::cleanupHelper
void cleanupHelper() override
Definition: MSPModel_Remote.cpp:215
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:389
MSPModel_Remote::myLastId
int myLastId
Definition: MSPModel_Remote.h:91
MSPModel_Remote::~MSPModel_Remote
~MSPModel_Remote()
Definition: MSPModel_Remote.cpp:118
MSPModel_Remote::Event::Event
Event(MSPModel_Remote *remoteModel)
Definition: MSPModel_Remote.h:41
MSPModel_Remote::PState::myPhi
double myPhi
Definition: MSPModel_Remote.h:72
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
MSPModel_Remote::PState::setPosition
void setPosition(double x, double y)
Definition: MSPModel_Remote.cpp:407
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
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:404
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSPModel_Remote::handleWalkingArea
void handleWalkingArea(MSEdge *msEdge, hybridsim::Scenario &scenario)
Definition: MSPModel_Remote.cpp:276
MSPModel_Remote::execute
SUMOTime execute(SUMOTime time)
Definition: MSPModel_Remote.cpp:131
MSPModel_Remote::PState::getPerson
MSPerson * getPerson()
Definition: MSPModel_Remote.cpp:416
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:395
MSPModel_Remote::PState::myPerson
MSPerson * myPerson
Definition: MSPModel_Remote.h:74
MSPModel_Remote::myHybridsimStub
std::unique_ptr< hybridsim::HybridSimulation::Stub > myHybridsimStub
Definition: MSPModel_Remote.h:79
MSPModel_Remote::PState
Container for pedestrian state and individual position update function.
Definition: MSPModel_Remote.h:55
MSPModel_Remote::myBoundary
Boundary myBoundary
Definition: MSPModel_Remote.h:80
MSPModel_Remote::PState::myStage
MSPerson::MSPersonStage_Walking * myStage
Definition: MSPModel_Remote.h:73
MSPModel_Remote::handleShape
void handleShape(const PositionVector &shape, hybridsim::Scenario &scenario)
Definition: MSPModel_Remote.cpp:358
MSPModel_Remote::remove
void remove(PedestrianState *state) override
remove the specified person from the pedestrian simulation
Definition: MSPModel_Remote.cpp:211
MSPModel_Remote::PState::myPosition
Position myPosition
Definition: MSPModel_Remote.h:71
Command
Base (microsim) event class.
Definition: Command.h:52
MSPModel_Remote::PState::getStage
MSPerson::MSPersonStage_Walking * getStage()
Definition: MSPModel_Remote.cpp:413
MSPerson::MSPersonStage_Walking
Definition: MSPerson.h:70
MSPModel_Remote::getFirstPedestrianLane
MSLane * getFirstPedestrianLane(const MSEdge *const &edge)
Definition: MSPModel_Remote.cpp:202
MSPModel.h
MSPModel_Remote::PState::~PState
~PState() override
Definition: MSPModel_Remote.cpp:386
MSPModel_Remote::remoteIdPStateMapping
std::map< int, PState * > remoteIdPStateMapping
Definition: MSPModel_Remote.h:88
MSPModel_Remote::usingInternalLanes
bool usingInternalLanes()
whether movements on intersections are modelled
Definition: MSPModel_Remote.cpp:421
MSPModel_Remote::Event::execute
SUMOTime execute(SUMOTime currentTime) override
Executes the command.
Definition: MSPModel_Remote.h:43
MSPModel_Remote::PState::PState
PState(MSPerson *person, MSPerson::MSPersonStage_Walking *stage)
Definition: MSPModel_Remote.cpp:381
MSPModel_Remote::initialize
void initialize()
Definition: MSPModel_Remote.cpp:219
MSPModel_Remote::edgesTransitionsMapping
std::map< const MSEdge *, std::tuple< int, int > > edgesTransitionsMapping
Definition: MSPModel_Remote.h:89