Eclipse SUMO - Simulation of Urban MObility
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>
27 #include <utils/common/SUMOTime.h>
28 #include <utils/common/Named.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class MSVehicleType;
37 class SUMOVTypeParameter;
38 class MSEdge;
39 class MSLane;
40 class Position;
41 class MSDevice;
42 class MSRoute;
43 
44 typedef std::shared_ptr<const MSRoute> ConstMSRoutePtr;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
54 class SUMOTrafficObject : public Named {
55 public:
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 
149  virtual int getRoutePosition() const = 0;
150 
155  virtual const MSEdge* getRerouteDestination() const = 0;
156 
158  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;
159 
163  virtual double getSlope() const = 0;
164 
165  virtual double getChosenSpeedFactor() const = 0;
166 
170  virtual SUMOVehicleClass getVClass() const = 0;
171 
175  virtual bool ignoreTransientPermissions() const {
176  return false;
177  };
178 
179  virtual int getRoutingMode() const = 0;
180 
184  virtual double getMaxSpeed() const = 0;
185 
186  virtual SUMOTime getWaitingTime(const bool accumulated = false) const = 0;
187 
191  virtual double getSpeed() const = 0;
192 
193  // This definition was introduced to make the MSVehicle's previousSpeed Refs. #2579
197  virtual double getPreviousSpeed() const = 0;
198 
199 
203  virtual double getAcceleration() const = 0;
204 
208  virtual double getPositionOnLane() const = 0;
209 
213  virtual double getBackPositionOnLane(const MSLane* lane) const = 0;
214 
215 
223  virtual Position getPosition(const double offset = 0) const = 0;
224 
227  virtual double getAngle() const = 0;
228 
231  virtual bool hasArrived() const = 0;
232 
234  virtual bool hasInfluencer() const = 0;
235 
237  virtual bool isSelected() const = 0;
238 
240  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
241 
244 
250  std::string getStringParam(const std::string& paramName, const bool required = false, const std::string& deflt = "") const;
251 
258  double getFloatParam(const std::string& paramName, const bool required = false, const double deflt = INVALID_DOUBLE) const;
259 
266  bool getBoolParam(const std::string& paramName, const bool required = false, const bool deflt = false) const;
267 
274  SUMOTime getTimeParam(const std::string& paramName, const bool required = false, const SUMOTime deflt = SUMOTime_MIN) const;
276 };
long long int SUMOTime
Definition: GUI.h:35
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:31
#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.
Definition: MSVehicleType.h:63
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 const MSEdge * getNextEdgePtr() const =0
returns the next edge (possibly an internal edge)
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual const std::set< NumericalID > getUpcomingEdgeIDs() const =0
returns the numerical IDs of edges to be used (possibly of future stages)
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 MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
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 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 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 SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual bool isPerson() const
Whether it is a person.
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 const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
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 const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual ~SUMOTrafficObject()
Destructor.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSEdge * getRerouteDestination() const =0
Returns the end point for reroutes (usually the last edge of the route)
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 SUMOVTypeParameter & getVTypeParameter() const =0
Returns the object's "vehicle" type parameter.
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 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 const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Structure representing possible vehicle parameter.
Structure representing possible vehicle parameter.