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.org/sumo
3 // Copyright (C) 2001-2020 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 <utils/common/SUMOTime.h>
26 #include <utils/common/Named.h>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class MSVehicleType;
35 class MSEdge;
36 class MSLane;
37 class Position;
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
46 class SUMOTrafficObject : public Named {
47 public:
48 
50  SUMOTrafficObject(const std::string& id) : Named(id) {}
51 
53  virtual ~SUMOTrafficObject() {}
54 
58  virtual bool isVehicle() const {
59  return false;
60  }
61 
65  virtual bool isPerson() const {
66  return false;
67  }
68 
72  virtual bool isContainer() const {
73  return false;
74  }
75 
79  virtual const MSVehicleType& getVehicleType() const = 0;
80 
89  virtual void replaceVehicleType(MSVehicleType* type) = 0;
90 
91 
96  virtual const SUMOVehicleParameter& getParameter() const = 0;
97 
101  virtual std::mt19937* getRNG() const = 0;
102 
106  virtual bool isStopped() const = 0;
107 
112  virtual const MSEdge* getEdge() const = 0;
113 
118  virtual const MSLane* getLane() const = 0;
119 
123  virtual double getSlope() const = 0;
124 
125  virtual double getChosenSpeedFactor() const = 0;
126 
130  virtual SUMOVehicleClass getVClass() const = 0;
131 
135  virtual double getMaxSpeed() const = 0;
136 
137  virtual SUMOTime getWaitingTime() const = 0;
138 
142  virtual double getSpeed() const = 0;
143 
144  // This definition was introduced to make the MSVehicle's previousSpeed Refs. #2579
148  virtual double getPreviousSpeed() const = 0;
149 
150 
154  virtual double getAcceleration() const = 0;
155 
159  virtual double getPositionOnLane() const = 0;
160 
164  virtual double getBackPositionOnLane(const MSLane* lane) const = 0;
165 
166 
174  virtual Position getPosition(const double offset = 0) const = 0;
175 
178  virtual double getAngle() const = 0;
179 
182  virtual bool hasArrived() const = 0;
183 
184 };
long long int SUMOTime
Definition: SUMOTime.h:31
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
The car-following model and parameter.
Definition: MSVehicleType.h:62
Base class for objects which have an id.
Definition: Named.h:53
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Representation of a vehicle, person, or container.
virtual SUMOTime getWaitingTime() const =0
virtual bool isContainer() const
Whether it is a container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual double getAcceleration() const =0
Returns the object's acceleration.
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual std::mt19937 * getRNG() const =0
Returns the associated RNG for this object.
virtual double getPreviousSpeed() const =0
Returns the object's previous speed.
virtual double getChosenSpeedFactor() const =0
virtual double getSpeed() const =0
Returns the object's current speed.
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.
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 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.
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.