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-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 /****************************************************************************/
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;
67  MSPerson* getPerson();
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
long long int SUMOTime
Definition: SUMOTime.h:36
MSLane * getFirstPedestrianLane(const MSEdge *const &edge)
void makeStartOrEndTransition(Position position, Position scnd, double width, hybridsim::Scenario &scenario, hybridsim::Edge_Type type, int i)
MSPModel_Remote(const OptionsCont &oc, MSNet *net)
SUMOTime execute(SUMOTime currentTime) override
Executes the command.
std::map< int, const MSEdge * > transitionsEdgesMapping
void handlePedestrianLane(MSLane *pLane, hybridsim::Scenario &scenario)
Base (microsim) event class.
Definition: Command.h:54
SUMOTime execute(SUMOTime time)
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
The simulated network and simulation perfomer.
Definition: MSNet.h:84
The pedestrian following model.
Definition: MSPModel.h:50
A road/street connecting two junctions.
Definition: MSEdge.h:75
MSPModel_Remote * myRemoteModel
std::map< int, PState * > remoteIdPStateMapping
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
void handleShape(const PositionVector &shape, hybridsim::Scenario &scenario)
PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now) override
register the given person as a pedestrian
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:128
Container for pedestrian state and individual position update function.
bool usingInternalLanes()
whether movements on intersections are modelled
A storage for options typed value containers)
Definition: OptionsCont.h:92
std::unique_ptr< hybridsim::HybridSimulation::Stub > myHybridsimStub
std::map< const MSEdge *, std::tuple< int, int > > edgesTransitionsMapping
Event(MSPModel_Remote *remoteModel)
MSPerson::MSPersonStage_Walking * myStage
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
void cleanupHelper() override
void handleWalkingArea(MSEdge *msEdge, hybridsim::Scenario &scenario)