Eclipse SUMO - Simulation of Urban MObility
MSPModel_NonInteracting.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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The pedestrian following model (prototype)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <string>
24 #include <limits>
25 #include <utils/common/SUMOTime.h>
26 #include <utils/common/Command.h>
27 #include "MSPerson.h"
28 #include "MSPModel.h"
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class MSNet;
34 class MSLink;
35 class MSLane;
36 class MSJunction;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
48 public:
49 
51  MSPModel_NonInteracting(const OptionsCont& oc, MSNet* net);
52 
54 
57 
59  MSTransportableStateAdapter* loadState(MSTransportable* transportable, MSStageMoving* stage, std::istringstream& in);
60 
63 
66  return false;
67  }
68 
72  }
73 
74  void registerArrived() {
76  }
77 
78 private:
79  class MoveToNextEdge : public Command {
80  public:
82  myParent(walk), myTransportable(transportable), myModel(model) {}
83  virtual ~MoveToNextEdge();
84  SUMOTime execute(SUMOTime currentTime);
85  void abortWalk() {
86  myTransportable = nullptr;
87  }
89  return myTransportable;
90  }
91 
92  private:
96 
97  private:
100  };
101 
102 
105  public:
106  PState(MoveToNextEdge* cmd, std::istringstream* in = nullptr);
107 
111  double getEdgePos(const MSStageMoving& stage, SUMOTime now) const;
112  virtual Position getPosition(const MSStageMoving& stage, SUMOTime now) const;
113  virtual double getAngle(const MSStageMoving& stage, SUMOTime now) const;
114  SUMOTime getWaitingTime(const MSStageMoving& stage, SUMOTime now) const;
115  double getSpeed(const MSStageMoving& stage) const;
116  const MSEdge* getNextEdge(const MSStageMoving& stage) const;
118 
120  virtual SUMOTime computeDuration(const MSEdge* prev, const MSStageMoving& stage, SUMOTime currentTime);
122  return myCommand;
123  }
124 
127  }
128 
131  void saveState(std::ostringstream& out);
132 
133  protected:
139  };
140 
141 
142  class CState : public PState {
143  public:
144  CState(MoveToNextEdge* cmd, std::istringstream* in = nullptr);
145 
147  static const double LATERAL_OFFSET;
148 
150  Position getPosition(const MSStageMoving& stage, SUMOTime now) const;
152  double getAngle(const MSStageMoving& stage, SUMOTime now) const;
154  SUMOTime computeDuration(const MSEdge* prev, const MSStageMoving& stage, SUMOTime currentTime);
155 
156  private:
157  Position myCurrentBeginPosition; //the position the container is moving from during its tranship stage
158  Position myCurrentEndPosition; //the position the container is moving to during its tranship stage
159  };
160 
161 private:
164 
167 
168 };
169 
170 
171 
long long int SUMOTime
Definition: SUMOTime.h:31
Base (microsim) event class.
Definition: Command.h:49
A road/street connecting two junctions.
Definition: MSEdge.h:77
The base class for an intersection.
Definition: MSJunction.h:58
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
The simulated network and simulation perfomer.
Definition: MSNet.h:89
Position getPosition(const MSStageMoving &stage, SUMOTime now) const
return the network coordinate of the container
double getAngle(const MSStageMoving &stage, SUMOTime now) const
return the direction in which the container heading to
SUMOTime computeDuration(const MSEdge *prev, const MSStageMoving &stage, SUMOTime currentTime)
compute tranship time on edge and update state members
static const double LATERAL_OFFSET
the offset for computing container positions when being transhiped
CState(MoveToNextEdge *cmd, std::istringstream *in=nullptr)
MoveToNextEdge(MSTransportable *transportable, MSStageMoving &walk, MSPModel_NonInteracting *model)
MoveToNextEdge & operator=(const MoveToNextEdge &)
Invalidated assignment operator.
const MSTransportable * getTransportable() const
SUMOTime execute(SUMOTime currentTime)
Executes the command.
implementation of callbacks to retrieve various state information from the model
const MSEdge * getNextEdge(const MSStageMoving &stage) const
return the list of internal edges if the transportable is on an intersection
SUMOTime getWaitingTime(const MSStageMoving &stage, SUMOTime now) const
return the time the transportable spent standing
virtual double getAngle(const MSStageMoving &stage, SUMOTime now) const
return the direction in which the transportable faces in degrees
double getSpeed(const MSStageMoving &stage) const
return the current speed of the transportable
virtual Position getPosition(const MSStageMoving &stage, SUMOTime now) const
return the network coordinate of the transportable
virtual SUMOTime computeDuration(const MSEdge *prev, const MSStageMoving &stage, SUMOTime currentTime)
compute walking time on edge and update state members
double getEdgePos(const MSStageMoving &stage, SUMOTime now) const
abstract methods inherited from PedestrianState
PState(MoveToNextEdge *cmd, std::istringstream *in=nullptr)
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
The pedestrian following model.
MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)
register the given transportable
MSPModel_NonInteracting(const OptionsCont &oc, MSNet *net)
Constructor (it should not be necessary to construct more than one instance)
void remove(MSTransportableStateAdapter *state)
remove the specified person from the pedestrian simulation
MSTransportableStateAdapter * loadState(MSTransportable *transportable, MSStageMoving *stage, std::istringstream &in)
load the state of the given transportable
int myNumActivePedestrians
the total number of active pedestrians
bool usingInternalLanes()
whether movements on intersections are modelled
int getActiveNumber()
return the number of active objects
MSNet * myNet
the net to which to issue moveToNextEdge commands
The pedestrian (and also sometimes container) movement model.
Definition: MSPModel.h:51
abstract base class for managing callbacks to retrieve various state information from the model
Definition: MSPModel.h:130
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36