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.dev/sumo
3 // Copyright (C) 2014-2024 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 
62  void clearState();
63 
66 
69  return false;
70  }
71 
75  }
76 
77  void registerArrived() {
79  }
80 
81 private:
82  class MoveToNextEdge : public Command {
83  public:
85  myParent(walk), myTransportable(transportable), myModel(model) {}
86  SUMOTime execute(SUMOTime currentTime);
87  void abortWalk() {
88  myTransportable = nullptr;
89  }
91  return myTransportable;
92  }
93 
94  private:
98 
99  private:
102  };
103 
104 
107  public:
108  PState(MoveToNextEdge* cmd, std::istringstream* in = nullptr);
109 
113  double getEdgePos(SUMOTime now) const;
114  int getDirection() const;
115  virtual Position getPosition(const MSStageMoving& stage, SUMOTime now) const;
116  virtual double getAngle(const MSStageMoving& stage, SUMOTime now) const;
118  return 0;
119  }
120  double getSpeed(const MSStageMoving& stage) const;
121  const MSEdge* getNextEdge(const MSStageMoving& stage) const;
123 
125  virtual SUMOTime computeDuration(const MSEdge* prev, const MSStageMoving& stage, SUMOTime currentTime);
127  return myCommand;
128  }
129 
132  }
133 
136  void saveState(std::ostringstream& out);
137 
138  protected:
144  };
145 
146 
147  class CState : public PState {
148  public:
149  CState(MoveToNextEdge* cmd, std::istringstream* in = nullptr);
150 
152  static const double LATERAL_OFFSET;
153 
155  Position getPosition(const MSStageMoving& stage, SUMOTime now) const;
157  double getAngle(const MSStageMoving& stage, SUMOTime now) const;
159  SUMOTime computeDuration(const MSEdge* prev, const MSStageMoving& stage, SUMOTime currentTime);
160 
161  private:
162  Position myCurrentBeginPosition; //the position the container is moving from during its tranship stage
163  Position myCurrentEndPosition; //the position the container is moving to during its tranship stage
164  };
165 
166 private:
169 
172 
173 };
long long int SUMOTime
Definition: GUI.h:35
Base (microsim) event class.
Definition: Command.h:50
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:84
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
int getDirection() const
return the walking direction (FORWARD, BACKWARD, UNDEFINED_DIRECTION)
double getEdgePos(SUMOTime now) const
abstract methods inherited from PedestrianState
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
PState(MoveToNextEdge *cmd, std::istringstream *in=nullptr)
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
SUMOTime getWaitingTime() const
return the time the transportable spent standing
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
void clearState()
Resets pedestrians when quick-loading state.
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:154
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:37