Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSStage.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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/****************************************************************************/
20// The common superclass for modelling transportable objects like persons and containers
21/****************************************************************************/
22#include <config.h>
23
25#include <microsim/MSEdge.h>
26#include <microsim/MSLane.h>
27#include <microsim/MSNet.h>
33
34
35/* -------------------------------------------------------------------------
36* static member definitions
37* ----------------------------------------------------------------------- */
38const double MSStage::ARRIVALPOS_UNSPECIFIED(std::numeric_limits<double>::infinity());
39const double MSStage::ROADSIDE_OFFSET(3);
40
41// ===========================================================================
42// method definitions
43// ===========================================================================
44/* -------------------------------------------------------------------------
45 * MSStage - methods
46 * ----------------------------------------------------------------------- */
47MSStage::MSStage(MSStageType type, const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos,
48 const double arrivalPosLat, const std::string& group) :
49 myDestination(destination),
50 myDestinationStop(toStop),
51 myArrivalPos(arrivalPos),
52 myArrivalPosLat(arrivalPosLat),
53 myDeparted(-1),
54 myArrived(-1),
55 myType(type),
56 myGroup(group),
57 myCosts(-1),
59{}
60
62
63
64const MSEdge*
66 return myDestination;
67}
68
69
70const MSEdge*
72 return myDestination;
73}
74
75
76const MSEdge*
78 return myDestination;
79}
80
81
82double
83MSStage::getEdgePos(SUMOTime /* now */) const {
84 return myArrivalPos;
85}
86
87
88double
90 return myArrivalPosLat;
91}
92
93
94int
98
99
100double
102 return 0.;
103}
104
105
108 ConstMSEdgeVector result;
109 result.push_back(getDestination());
110 return result;
111}
112
113
114void
116 if (myDeparted < 0) {
117 myDeparted = now;
118 }
119}
120
123 return myDeparted;
124}
125
128 return myArrived;
129}
130
131
134 return myArrived >= 0 ? myArrived - myDeparted : SUMOTime_MAX;
135}
136
137
140 return getDuration();
141}
142
145 return 0;
146}
147
150 return getWaitingTime();
151}
152
154MSStage::getTimeLoss(const MSTransportable* /*transportable*/) const {
155 return 0;
156}
157
158
159const std::string
160MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) {
161 myArrived = now;
162 return "";
163}
164
165bool
166MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const {
167 return false;
168}
169
171MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const {
172 return getLanePosition(e->getLanes()[0], at, offset);
173}
174
176MSStage::getLanePosition(const MSLane* lane, double at, double offset) const {
177 return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
178}
179
180
181double
182MSStage::getEdgeAngle(const MSEdge* e, double at) const {
183 return e->getLanes()[0]->getShape().rotationAtOffset(at);
184}
185
186
187void
188MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
189 myDestination = newDestination;
190 myDestinationStop = newDestStop;
191 if (newDestStop != nullptr) {
192 myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
193 }
194}
195
196bool
200
201
202
203/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
MSStageType
Definition MSStage.h:55
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSStage.h:50
#define SUMOTime_MAX
Definition SUMOTime.h:34
A road/street connecting two junctions.
Definition MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:554
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
The simulated network and simulation perfomer.
Definition MSNet.h:89
static const int UNDEFINED_DIRECTION
Definition MSPModel.h:56
virtual SUMOTime getTotalWaitingTime() const
Definition MSStage.cpp:149
virtual ~MSStage()
destructor
Definition MSStage.cpp:61
const MSEdge * getDestination() const
returns the destination edge
Definition MSStage.cpp:65
double myArrivalPosLat
the lateral position at which we want to arrive
Definition MSStage.h:311
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition MSStage.cpp:107
virtual double getEdgePos(SUMOTime now) const
Definition MSStage.cpp:83
virtual int getDirection() const
Return the movement directon on the edge.
Definition MSStage.cpp:95
virtual const MSEdge * getFromEdge() const
Definition MSStage.cpp:77
virtual double getEdgePosLat(SUMOTime now) const
Definition MSStage.cpp:89
static const double ARRIVALPOS_UNSPECIFIED
sentinel value
Definition MSStage.h:72
int myParametersSet
Information on which parameter were set (mainly for vehroute output).
Definition MSStage.h:329
virtual SUMOTime getTimeLoss(const MSTransportable *transportable) const
Definition MSStage.cpp:154
virtual SUMOTime getTravelTime() const
Definition MSStage.cpp:139
SUMOTime getDeparted() const
get departure time of stage
Definition MSStage.cpp:122
void setDeparted(SUMOTime now)
logs end of the step
Definition MSStage.cpp:115
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition MSStage.cpp:166
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:305
const std::string myGroup
The id of the group of transportables traveling together.
Definition MSStage.h:323
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:160
SUMOTime getArrived() const
get arrival time of stage
Definition MSStage.cpp:127
bool unspecifiedArrivalPos() const
Definition MSStage.cpp:197
MSStage(const MSStageType type, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double arrivalPosLat=0.0, const std::string &group="")
constructor
Definition MSStage.cpp:47
virtual double getSpeed() const
the speed of the transportable
Definition MSStage.cpp:101
double myCosts
The assigned or calculated costs.
Definition MSStage.h:326
virtual SUMOTime getWaitingTime() const
Definition MSStage.cpp:144
virtual SUMOTime getDuration() const
Definition MSStage.cpp:133
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:317
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition MSStage.cpp:188
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition MSStage.cpp:176
MSStageType myType
The type of this stage.
Definition MSStage.h:320
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:182
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition MSStage.cpp:71
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:334
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:308
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition MSStage.cpp:171
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:302
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:314
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a vehicle.
Definition SUMOVehicle.h:62