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 and person representations
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <vector>
24 #include <typeinfo>
25 #include <memory>
26 #include <utils/common/SUMOTime.h>
27 #include <utils/common/Named.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class MSVehicleType;
36 class MSEdge;
37 class MSLane;
38 class Position;
39 class MSDevice;
40 class MSRoute;
41 
42 typedef std::shared_ptr<const MSRoute> ConstMSRoutePtr;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
52 class SUMOTrafficObject : public Named {
53 public:
54  typedef long long int NumericalID;
55 
57  SUMOTrafficObject(const std::string& id) : Named(id) {}
58 
60  virtual ~SUMOTrafficObject() {}
61 
65  virtual bool isVehicle() const {
66  return false;
67  }
68 
72  virtual bool isPerson() const {
73  return false;
74  }
75 
79  virtual bool isContainer() const {
80  return false;
81  }
82 
84  // (especially fast comparison in maps which need vehicles as keys)
85  virtual NumericalID getNumericalID() const = 0;
86 
87 
91  virtual const MSVehicleType& getVehicleType() const = 0;
92 
101  virtual void replaceVehicleType(MSVehicleType* type) = 0;
102 
103 
108  virtual const SUMOVehicleParameter& getParameter() const = 0;
109 
113  virtual SumoRNG* getRNG() const = 0;
114 
116  virtual int getRNGIndex() const = 0;
117 
121  virtual bool isStopped() const = 0;
122 
127  virtual const MSEdge* getEdge() const = 0;
128 
130  virtual const MSEdge* getNextEdgePtr() const = 0;
131 
133  virtual const std::set<NumericalID> getUpcomingEdgeIDs() const = 0;
134 
139  virtual const MSLane* getLane() const = 0;
140 
142  virtual int getRoutePosition() const = 0;
143 
148  virtual const MSEdge* getRerouteDestination() const = 0;
149 
151  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;
152 
156  virtual double getSlope() const = 0;
157 
158  virtual double getChosenSpeedFactor() const = 0;
159 
163  virtual SUMOVehicleClass getVClass() const = 0;
164 
168  virtual bool ignoreTransientPermissions() const {
169  return false;
170  };
171 
172  virtual int getRoutingMode() const = 0;
173 
177  virtual double getMaxSpeed() const = 0;
178 
179  virtual SUMOTime getWaitingTime(const bool accumulated = false) const = 0;
180 
184  virtual double getSpeed() const = 0;
185 
186  // This definition was introduced to make the MSVehicle's previousSpeed Refs. #2579
190  virtual double getPreviousSpeed() const = 0;
191 
192 
196  virtual double getAcceleration() const = 0;
197 
201  virtual double getPositionOnLane() const = 0;
202 
206  virtual double getBackPositionOnLane(const MSLane* lane) const = 0;
207 
208 
216  virtual Position getPosition(const double offset = 0) const = 0;
217 
220  virtual double getAngle() const = 0;
221 
224  virtual bool hasArrived() const = 0;
225 
227  virtual bool hasInfluencer() const = 0;
228 
230  virtual bool isSelected() const = 0;
231 
233  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
234 
235 
236 };
long long int SUMOTime
Definition: GUI.h:35
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:31
std::shared_ptr< const MSRoute > ConstMSRoutePtr
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
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.
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.
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual int getRNGIndex() const =0
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.
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 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.