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-2023 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::ROADSIDE_OFFSET(3);
39
40
41// ===========================================================================
42// method definitions
43// ===========================================================================
44/* -------------------------------------------------------------------------
45 * MSStage - methods
46 * ----------------------------------------------------------------------- */
47MSStage::MSStage(const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, MSStageType type, const std::string& group) :
48 myDestination(destination),
49 myDestinationStop(toStop),
50 myArrivalPos(arrivalPos),
51 myDeparted(-1),
52 myArrived(-1),
53 myType(type),
54 myGroup(group),
55 myParametersSet(0)
56{}
57
59
60const MSEdge*
62 return myDestination;
63}
64
65
66const MSEdge*
68 return myDestination;
69}
70
71
72const MSEdge*
74 return myDestination;
75}
76
77
78double
79MSStage::getEdgePos(SUMOTime /* now */) const {
80 return myArrivalPos;
81}
82
83int
87
88
91 return 0;
92}
93
94
95double
97 return 0.;
98}
99
100
103 ConstMSEdgeVector result;
104 result.push_back(getDestination());
105 return result;
106}
107
108
109void
111 if (myDeparted < 0) {
112 myDeparted = now;
113 }
114}
115
118 return myDeparted;
119}
120
123 return myArrived;
124}
125
126const std::string
127MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) {
128 myArrived = now;
129 return "";
130}
131
132bool
133MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const {
134 return false;
135}
136
138MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const {
139 return getLanePosition(e->getLanes()[0], at, offset);
140}
141
143MSStage::getLanePosition(const MSLane* lane, double at, double offset) const {
144 return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
145}
146
147
148double
149MSStage::getEdgeAngle(const MSEdge* e, double at) const {
150 return e->getLanes()[0]->getShape().rotationAtOffset(at);
151}
152
153
154void
155MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
156 myDestination = newDestination;
157 myDestinationStop = newDestStop;
158 if (newDestStop != nullptr) {
159 myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
160 }
161}
162
163
164/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
MSStageType
Definition MSStage.h:54
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSStage.h:49
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:545
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:293
The simulated network and simulation perfomer.
Definition MSNet.h:88
static const int UNDEFINED_DIRECTION
Definition MSPModel.h:121
virtual ~MSStage()
destructor
Definition MSStage.cpp:58
const MSEdge * getDestination() const
returns the destination edge
Definition MSStage.cpp:61
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition MSStage.cpp:102
virtual double getEdgePos(SUMOTime now) const
Definition MSStage.cpp:79
virtual int getDirection() const
Return the movement directon on the edge.
Definition MSStage.cpp:84
virtual const MSEdge * getFromEdge() const
Definition MSStage.cpp:73
MSStage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, MSStageType type, const std::string &group="")
constructor
Definition MSStage.cpp:47
SUMOTime getDeparted() const
get departure time of stage
Definition MSStage.cpp:117
void setDeparted(SUMOTime now)
logs end of the step
Definition MSStage.cpp:110
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition MSStage.cpp:133
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:238
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:127
SUMOTime getArrived() const
get arrival time of stage
Definition MSStage.cpp:122
virtual double getSpeed() const
the speed of the transportable
Definition MSStage.cpp:96
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:247
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition MSStage.cpp:155
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition MSStage.cpp:143
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:149
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition MSStage.cpp:67
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:259
double myArrivalPos
the position at which we want to arrive
Definition MSStage.h:241
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition MSStage.cpp:138
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:235
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition MSStage.cpp:90
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:244
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