SUMO - Simulation of Urban MObility
MSPModel_Remote.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The pedestrian following model for remote controlled pedestrian movement
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2014-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 #ifndef SUMO_MSPMODEL_REMOTE_H
22 #define SUMO_MSPMODEL_REMOTE_H
23 
24 
26 #include <microsim/MSNet.h>
27 #include <microsim/pedestrians/hybridsim.grpc.pb.h>
28 #include <utils/geom/Boundary.h>
29 #include "MSPModel.h"
30 class MSPModel_Remote : public MSPModel {
31 
32 
33 public:
34  MSPModel_Remote(const OptionsCont& oc, MSNet* net);
35 
38  void remove(PedestrianState* state) override;
39  void cleanupHelper() override;
40 
42  class Event : public Command {
43  public:
44  explicit Event(MSPModel_Remote* remoteModel)
45  : myRemoteModel(remoteModel) { }
46  SUMOTime execute(SUMOTime currentTime) override {
47  return myRemoteModel->execute(currentTime);
48  }
49  private:
51  };
52 
53 private:
58  class PState : public PedestrianState {
59  public:
61  ~PState() override;
62  double getEdgePos(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
63  Position getPosition(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
64  double getAngle(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
65  SUMOTime getWaitingTime(const MSPerson::MSPersonStage_Walking& stage, SUMOTime now) const override;
66  double getSpeed(const MSPerson::MSPersonStage_Walking& stage) const override;
67  const MSEdge* getNextEdge(const MSPerson::MSPersonStage_Walking& stage) const override;
69  MSPerson* getPerson();
70 
71  void setPosition(double x, double y);
72  void setPhi(double phi);
73  private:
75  double myPhi;
78  };
79 
80 
82  std::unique_ptr<hybridsim::HybridSimulation::Stub> myHybridsimStub;
84  void initialize();
85  void handleWalkingArea(MSEdge* msEdge, hybridsim::Scenario& scenario);
86  void handlePedestrianLane(MSLane* pLane, hybridsim::Scenario& scenario);
87  void makeStartOrEndTransition(Position position, Position scnd, double width, hybridsim::Scenario& scenario,
88  hybridsim::Edge_Type type, int i);
89  void handleShape(const PositionVector& shape, hybridsim::Scenario& scenario);
90 
91  std::map<int, PState*> remoteIdPStateMapping;
92  std::map<const MSEdge*, std::tuple<int, int>> edgesTransitionsMapping;
93  std::map<int, const MSEdge*> transitionsEdgesMapping;
94  int myLastId = 0;
96 
97 
98  MSLane* getFirstPedestrianLane(const MSEdge* const& edge);
99 };
100 
101 
102 #endif //SUMO_MSPMODEL_REMOTE_H
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:61
SUMOTime execute(SUMOTime time)
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The simulated network and simulation perfomer.
Definition: MSNet.h:89
The pedestrian following model.
Definition: MSPModel.h:56
A road/street connecting two junctions.
Definition: MSEdge.h:81
MSPModel_Remote * myRemoteModel
std::map< int, PState * > remoteIdPStateMapping
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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:129
Container for pedestrian state and individual position update function.
A storage for options typed value containers)
Definition: OptionsCont.h:99
std::unique_ptr< hybridsim::HybridSimulation::Stub > myHybridsimStub
std::map< const MSEdge *, std::tuple< int, int > > edgesTransitionsMapping
Event(MSPModel_Remote *remoteModel)
MSPerson::MSPersonStage_Walking * myStage
long long int SUMOTime
Definition: TraCIDefs.h:52
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
void cleanupHelper() override
void handleWalkingArea(MSEdge *msEdge, hybridsim::Scenario &scenario)