Eclipse SUMO - Simulation of Urban MObility
MSTransportable.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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 common superclass for modelling transportable objects like persons and containers
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <set>
24#include <cassert>
28#include <utils/geom/Position.h>
30#include <utils/geom/Boundary.h>
33#include "MSStage.h"
34
35
36// ===========================================================================
37// class declarations
38// ===========================================================================
39class MSEdge;
40class MSLane;
41class MSNet;
42class MSStoppingPlace;
43class MSVehicleType;
44class OutputDevice;
46class SUMOVehicle;
48
49typedef std::vector<const MSEdge*> ConstMSEdgeVector;
50
51// ===========================================================================
52// class definitions
53// ===========================================================================
60public:
63 bool isPerson() const {
64 return myAmPerson;
65 }
66
67 bool isContainer() const {
68 return !myAmPerson;
69 }
70
71 std::string getObjectType() {
72 return myAmPerson ? "Person" : "Container";
73 }
74
75 inline NumericalID getNumericalID() const {
76 return myNumericalID;
77 }
78
79 bool isStopped() const {
81 }
82
83 double getSlope() const;
84
86
90 double getMaxSpeed() const;
91
93
94 double getPreviousSpeed() const {
95 return getSpeed();
96 }
97
98 double getAcceleration() const {
99 return 0.0;
100 }
101
102 double getPositionOnLane() const {
103 return getEdgePos();
104 }
105
106 double getBackPositionOnLane(const MSLane* lane) const;
107
108 Position getPosition(const double /*offset*/) const {
109 return getPosition();
110 }
112
114 typedef std::vector<MSStage*> MSTransportablePlan;
115
117 MSTransportable(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportablePlan* plan, const bool isPerson);
118
120 virtual ~MSTransportable();
121
122 /* @brief proceeds to the next step of the route,
123 * @return Whether the transportables plan continues */
124 virtual bool proceed(MSNet* net, SUMOTime time, const bool vehicleArrived = false);
125
126 virtual bool checkAccess(const MSStage* const prior, const bool waitAtStop = true) {
127 UNUSED_PARAMETER(prior);
128 UNUSED_PARAMETER(waitAtStop);
129 return false;
130 }
131
133 void setID(const std::string& newID);
134
135 inline const SUMOVehicleParameter& getParameter() const {
136 return *myParameter;
137 }
138
139 inline const MSVehicleType& getVehicleType() const {
140 return *myVType;
141 }
142
144 SumoRNG* getRNG() const;
145
148
150 void setDeparted(SUMOTime now);
151
153 SUMOTime getDeparture() const;
154
156 const MSEdge* getDestination() const {
157 return (*myStep)->getDestination();
158 }
159
161 const MSEdge* getNextDestination() const {
162 return (*(myStep + 1))->getDestination();
163 }
164
166 const MSEdge* getEdge() const {
167 return (*myStep)->getEdge();
168 }
169
171 const MSLane* getLane() const {
172 return (*myStep)->getLane();
173 }
174
176 const MSEdge* getFromEdge() const {
177 return (*myStep)->getFromEdge();
178 }
179
181 virtual double getEdgePos() const;
182
184 virtual int getDirection() const;
185
187 virtual Position getPosition() const;
188
190 virtual double getAngle() const;
191
193 virtual double getWaitingSeconds() const;
194
196 virtual double getSpeed() const;
197
199 virtual double getChosenSpeedFactor() const {
200 return 1;
201 }
202
205 return (*myStep)->getStageType();
206 }
207
209 MSStageType getStageType(int next) const {
210 assert(myStep + next < myPlan->end());
211 assert(myStep + next >= myPlan->begin());
212 return (*(myStep + next))->getStageType();
213 }
214
216 std::string getStageSummary(int stageIndex) const;
217
219 std::string getCurrentStageDescription() const {
220 return (*myStep)->getStageDescription(myAmPerson);
221 }
222
225 return *myStep;
226 }
227
229 MSStage* getNextStage(int next) const {
230 assert(myStep + next >= myPlan->begin());
231 assert(myStep + next < myPlan->end());
232 return *(myStep + next);
233 }
234
236 ConstMSEdgeVector getEdges(int next) const {
237 assert(myStep + next < myPlan->end());
238 assert(myStep + next >= myPlan->begin());
239 return (*(myStep + next))->getEdges();
240 }
241
243 int getNumRemainingStages() const;
244
246 int getNumStages() const;
247
249 int getRoutePosition() const {
250 return (*myStep)->getRoutePosition();
251 }
252
254 virtual const MSEdge* getNextEdgePtr() const {
255 return nullptr;
256 }
257
263 void tripInfoOutput(OutputDevice& os) const;
264
270 void routeOutput(OutputDevice& os, const bool withRouteLength) const;
271
273 bool isWaitingFor(const SUMOVehicle* vehicle) const {
274 return (*myStep)->isWaitingFor(vehicle);
275 }
276
278 bool isWaiting4Vehicle() const {
279 return (*myStep)->isWaiting4Vehicle();
280 }
281
282 void setAbortWaiting(const SUMOTime timeout);
283
286
289 return (*myStep)->getVehicle();
290 }
291
293 void appendStage(MSStage* stage, int next = -1);
294
296 void removeStage(int next, bool stayInSim = true);
297
299 void setSpeed(double speed);
300
302 double getArrivalPos() const {
303 return myPlan->back()->getArrivalPos();
304 }
305
307 const MSEdge* getArrivalEdge() const {
308 return myPlan->back()->getEdges().back();
309 }
310
320
321
330
331
334
336 bool hasArrived() const;
337
339 bool hasDeparted() const;
340
342 void rerouteParkingArea(MSStoppingPlace* orig, MSStoppingPlace* replacement);
343
345 MSTransportableDevice* getDevice(const std::type_info& type) const;
346
348 void setJunctionModelParameter(const std::string& key, const std::string& value);
349
353 inline const std::vector<MSTransportableDevice*>& getDevices() const {
354 return myDevices;
355 }
356
357 virtual bool hasInfluencer() const {
358 return false;
359 }
360
362 virtual bool isSelected() const {
363 return false;
364 }
365
368 void saveState(OutputDevice& out);
369
372 void loadState(const std::string& state);
373
374protected:
377
381
384
387
389 MSTransportablePlan::iterator myStep;
390
392 std::vector<MSTransportableDevice*> myDevices;
393
394private:
395 const bool myAmPerson;
396
398
400
402
403private:
406
409
410};
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
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
The simulated network and simulation perfomer.
Definition: MSNet.h:88
A lane area vehicles can halt at.
Abstract in-person device.
const MSEdge * getFromEdge() const
Returns the departure edge.
virtual double getChosenSpeedFactor() const
the current speed factor of the transportable (where applicable)
virtual double getEdgePos() const
Return the position on the edge.
bool hasDeparted() const
return whether the transportable has started it's plan
SUMOVehicleClass getVClass() const
Returns the object's access class.
static NumericalID myCurrentNumericalIndex
SUMOTime getWaitingTime() const
const std::vector< MSTransportableDevice * > & getDevices() const
Returns this vehicle's devices.
double getAcceleration() const
Returns the object's acceleration.
SUMOTime getDeparture() const
logs depart time of the current stage
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
const MSLane * getLane() const
Returns the current lane (may be nullptr)
double getBackPositionOnLane(const MSLane *lane) const
Get the object's back position along the given lane.
const MSEdge * getDestination() const
Returns the current destination.
virtual double getAngle() const
return the current angle of the transportable
const MSEdge * getArrivalEdge() const
returns the final arrival edge
void setAbortWaiting(const SUMOTime timeout)
MSStageType getStageType(int next) const
the stage type for the nth next stage
bool myWriteEvents
Whether events shall be written.
void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
virtual double getSpeed() const
the current speed of the transportable
PositionVector getBoundingBox() const
return the bounding box of the person
const bool myAmPerson
virtual bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
SUMOTime abortStage(SUMOTime step)
Abort current stage (used for aborting waiting for a vehicle)
std::string getStageSummary(int stageIndex) const
return textual summary for the given stage
MSTransportable & operator=(const MSTransportable &)
Invalidated assignment operator.
MSTransportableDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
MSStage * getCurrentStage() const
Return the current stage.
void setDeparted(SUMOTime now)
logs depart time of the current stage
void setSpeed(double speed)
set the speed for all present and future (walking) stages and modify the vType so that stages added l...
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
virtual bool isSelected() const
whether this transportable is selected in the GUI
MSTransportablePlan::iterator myStep
the iterator over the route
MSTransportablePlan * myPlan
the plan of the transportable
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
const MSEdge * getNextDestination() const
Returns the destination after the current destination.
bool isStopped() const
Returns whether the object is at a stop.
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
MSVehicleType * myVType
This transportable's type. (mainly used for drawing related information Note sure if it is really nec...
int getRoutePosition() const
return index of edge within route
bool isPerson() const
Whether it is a person.
virtual Position getPosition() const
Return the Network coordinate of the transportable.
const SUMOVehicleParameter * myParameter
the plan of the transportable
double getPreviousSpeed() const
Returns the object's previous speed.
ConstMSEdgeVector getEdges(int next) const
Return the edges of the nth next stage.
Position getPosition(const double) const
Return current position (x/y, cartesian)
double getArrivalPos() const
returns the final arrival pos
double getPositionOnLane() const
Get the object's position along the lane.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
bool isContainer() const
Whether it is a container.
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
virtual ~MSTransportable()
destructor
int getNumStages() const
Return the total number stages in this persons plan.
MSStageType getCurrentStageType() const
the current stage type of the transportable
NumericalID getNumericalID() const
return the numerical ID which is only for internal usage
void rerouteParkingArea(MSStoppingPlace *orig, MSStoppingPlace *replacement)
adapt plan when the vehicle reroutes and now stops at replacement instead of orig
std::string getObjectType()
void loadState(const std::string &state)
Reconstructs the current state.
std::vector< MSTransportableDevice * > myDevices
The devices this transportable has.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
MSTransportable(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportablePlan *plan, const bool isPerson)
constructor
MSStage * getNextStage(int next) const
Return the current stage.
bool hasArrived() const
return whether the person has reached the end of its plan
double getSlope() const
Returns the slope of the road at object's position in degrees.
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
const NumericalID myNumericalID
virtual bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
SumoRNG * getRNG() const
returns the associated RNG
MSTransportable(const MSTransportable &)
Invalidated copy constructor.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSEdge * getEdge() const
Returns the current edge.
virtual const MSEdge * getNextEdgePtr() const
returns the next edge ptr (used by walking persons)
virtual int getDirection() const
Return the movement directon on the edge.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
void setID(const std::string &newID)
set the id (inherited from Named but forbidden for transportables)
WrappingCommand< MSTransportable > * myAbortCommand
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle in the current step.
SUMOTime getDesiredDepart() const
Returns the desired departure time.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical maximum speed)
The car-following model and parameter.
Definition: MSVehicleType.h:63
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Representation of a vehicle, person, or container.
long long int NumericalID
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Structure representing possible vehicle parameter.