Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMOTrafficObject.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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// Abstract base class for vehicle, person, and container representations
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <string>
24#include <vector>
25#include <typeinfo>
26#include <memory>
28#include <utils/common/Named.h>
30
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35class MSVehicleType;
38class MSEdge;
39class MSLane;
40class Position;
41class MSDevice;
42class MSRoute;
43
44typedef std::shared_ptr<const MSRoute> ConstMSRoutePtr;
45
46
47// ===========================================================================
48// class definitions
49// ===========================================================================
54class SUMOTrafficObject : public Named {
55public:
56 typedef long long int NumericalID;
57
59 SUMOTrafficObject(const std::string& id) : Named(id) {}
60
62 virtual ~SUMOTrafficObject() {}
63
67 virtual bool isVehicle() const {
68 return false;
69 }
70
74 virtual bool isPerson() const {
75 return false;
76 }
77
81 virtual bool isContainer() const {
82 return false;
83 }
84
86 // (especially fast comparison in maps which need vehicles as keys)
87 virtual NumericalID getNumericalID() const = 0;
88
89
93 virtual const MSVehicleType& getVehicleType() const = 0;
94
98 virtual const SUMOVTypeParameter& getVTypeParameter() const = 0;
99
108 virtual void replaceVehicleType(MSVehicleType* type) = 0;
109
110
115 virtual const SUMOVehicleParameter& getParameter() const = 0;
116
120 virtual SumoRNG* getRNG() const = 0;
121
123 virtual int getRNGIndex() const = 0;
124
128 virtual bool isStopped() const = 0;
129
134 virtual const MSEdge* getEdge() const = 0;
135
137 virtual const MSEdge* getNextEdgePtr() const = 0;
138
140 virtual const std::set<NumericalID> getUpcomingEdgeIDs() const = 0;
141
146 virtual const MSLane* getLane() const = 0;
147
152 virtual const MSLane* getBackLane() const = 0;
153
154
156 virtual int getRoutePosition() const = 0;
157
162 virtual const MSEdge* getRerouteDestination() const = 0;
163
165 virtual bool replaceRoute(ConstMSRoutePtr route, const std::string& info, bool onInit = false, int offset = 0, bool addStops = true, bool removeStops = true, std::string* msgReturn = nullptr) = 0;
166
170 virtual double getSlope() const = 0;
171
172 virtual double getChosenSpeedFactor() const = 0;
173
177 virtual SUMOVehicleClass getVClass() const = 0;
178
182 virtual bool ignoreTransientPermissions() const {
183 return false;
184 };
185
186 virtual int getRoutingMode() const = 0;
187
191 virtual double getMaxSpeed() const = 0;
192
193 virtual SUMOTime getWaitingTime(const bool accumulated = false) const = 0;
194
198 virtual double getSpeed() const = 0;
199
200 // This definition was introduced to make the MSVehicle's previousSpeed Refs. #2579
204 virtual double getPreviousSpeed() const = 0;
205
206
210 virtual double getAcceleration() const = 0;
211
215 virtual double getPositionOnLane() const = 0;
216
220 virtual double getBackPositionOnLane(const MSLane* lane) const = 0;
221
222
230 virtual Position getPosition(const double offset = 0) const = 0;
231
234 virtual double getAngle() const = 0;
235
238 virtual bool hasArrived() const = 0;
239
241 virtual bool hasInfluencer() const = 0;
242
244 virtual bool isSelected() const = 0;
245
247 virtual MSDevice* getDevice(const std::type_info& type) const = 0;
248
251
257 std::string getStringParam(const std::string& paramName, const bool required = false, const std::string& deflt = "") const;
258
265 double getFloatParam(const std::string& paramName, const bool required = false, const double deflt = INVALID_DOUBLE) const;
266
273 bool getBoolParam(const std::string& paramName, const bool required = false, const bool deflt = false) const;
274
281 SUMOTime getTimeParam(const std::string& paramName, const bool required = false, const SUMOTime deflt = SUMOTime_MIN) const;
283};
long long int SUMOTime
Definition GUI.h:36
#define SUMOTime_MIN
Definition SUMOTime.h:35
std::shared_ptr< const MSRoute > ConstMSRoutePtr
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
Abstract in-vehicle / in-person device.
Definition MSDevice.h:62
A road/street connecting two junctions.
Definition MSEdge.h:77
Representation of a lane in the micro simulation.
Definition MSLane.h:84
The car-following model and parameter.
Base class for objects which have an id.
Definition Named.h:54
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Representation of a vehicle, person, or container.
virtual bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual bool isContainer() const
Whether it is a container.
virtual bool isVehicle() const
Whether it is a vehicle.
bool getBoolParam(const std::string &paramName, const bool required=false, const bool deflt=false) const
Retrieve a boolean parameter for the traffic object.
virtual bool hasInfluencer() const =0
whether the vehicle is individually influenced (via TraCI or special parameters)
virtual double getAcceleration() const =0
Returns the object's acceleration.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
std::string getStringParam(const std::string &paramName, const bool required=false, const std::string &deflt="") const
Retrieve a string parameter for the traffic object.
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const SUMOVTypeParameter & getVTypeParameter() const =0
Returns the object's "vehicle" type parameter.
virtual int getRNGIndex() const =0
SUMOTime getTimeParam(const std::string &paramName, const bool required=false, const SUMOTime deflt=SUMOTime_MIN) const
Retrieve a time parameter for the traffic object.
virtual const MSLane * getBackLane() const =0
Returns the lane the where the rear of the object is currently at.
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given one.
virtual double getPreviousSpeed() const =0
Returns the object's previous speed.
virtual double getChosenSpeedFactor() const =0
long long int NumericalID
virtual double getSpeed() const =0
Returns the object's current speed.
virtual SUMOTime getWaitingTime(const bool accumulated=false) const =0
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual bool isPerson() const
Whether it is a person.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual double getAngle() const =0
Returns the object's angle in degrees.
virtual double getMaxSpeed() const =0
Returns the object's maximum speed (minimum of technical and desired maximum speed)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
double getFloatParam(const std::string &paramName, const bool required=false, const double deflt=INVALID_DOUBLE) const
Retrieve a floating point parameter for the traffic object.
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual ~SUMOTrafficObject()
Destructor.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual bool isSelected() const =0
whether this object is selected in the GUI
virtual int getRoutePosition() const =0
return index of edge within route
virtual const std::set< NumericalID > getUpcomingEdgeIDs() const =0
returns the numerical IDs of edges to be used (possibly of future stages)
virtual bool hasArrived() const =0
Returns whether this object has arrived.
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the object's back position along the given lane.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual const MSEdge * getNextEdgePtr() const =0
returns the next edge (possibly an internal edge)
virtual const MSEdge * getRerouteDestination() const =0
Returns the end point for reroutes (usually the last edge of the route)
virtual int getRoutingMode() const =0
SUMOTrafficObject(const std::string &id)
Constructor.
virtual void replaceVehicleType(MSVehicleType *type)=0
Replaces the current vehicle type by the one given.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Structure representing possible vehicle parameter.
Structure representing possible vehicle parameter.