Eclipse SUMO - Simulation of Urban MObility
SUMOVehicle.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 /****************************************************************************/
20 // Abstract base class for vehicle representations
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <vector>
26 #include <typeinfo>
27 #include <utils/common/SUMOTime.h>
28 #include <utils/common/Named.h>
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class MSRoute;
39 class MSEdge;
40 class MSLane;
41 class MSPerson;
42 class MSTransportable;
43 class MSParkingArea;
44 class MSStoppingPlace;
45 class MSVehicleDevice;
46 class SUMOSAXAttributes;
47 
48 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
59 public:
60  typedef long long int NumericalID;
61 
63  SUMOVehicle(const std::string& id) : SUMOTrafficObject(id) {}
64 
66  virtual ~SUMOVehicle() {}
67 
72  virtual double getLateralPositionOnLane() const = 0;
73 
77  virtual double getAngle() const = 0;
78 
80  virtual const MSRoute& getRoute() const = 0;
81 
83  virtual int getRoutePosition() const = 0;
84 
92  virtual const MSEdge* succEdge(int nSuccs) const = 0;
93 
106  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, double cost, double savings, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true) = 0;
107 
109  virtual bool replaceRoute(const MSRoute* route, const std::string& info, bool onInit = false, int offset = 0, bool addStops = true, bool removeStops = true) = 0;
110 
120  virtual void reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false, const bool silent = false) = 0;
121 
127  virtual bool hasValidRoute(std::string& msg, const MSRoute* route = 0) const = 0;
129  virtual bool hasValidRouteStart(std::string& msg) = 0;
130 
132  virtual int getRouteValidity(bool update = true, bool silent = false) = 0;
133 
137  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
138 
143  virtual const std::map<int, double>* getEmissionParameters() const = 0;
144 
147  virtual void replaceParameter(const SUMOVehicleParameter* newParameter) = 0;
148 
154  virtual void onDepart() = 0;
155 
159  virtual bool isOnRoad() const = 0;
160 
164  virtual bool isIdling() const = 0;
165 
169  virtual bool isFrontOnLane(const MSLane*) const = 0;
170 
174  virtual bool isParking() const = 0;
175 
180  virtual bool isRemoteControlled() const = 0;
181 
186  virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const = 0;
187 
191  virtual SUMOTime getDeparture() const = 0;
192 
196  virtual double getDepartPos() const = 0;
197 
202  virtual double getArrivalPos() const = 0;
203 
206  virtual void setArrivalPos(double arrivalPos) = 0;
207 
210  virtual bool hasDeparted() const = 0;
211 
215  virtual double getOdometer() const = 0;
216 
220  virtual int getNumberReroutes() const = 0;
221 
223  virtual bool allowsBoarding(MSTransportable* t) const = 0;
224 
229  virtual void addTransportable(MSTransportable* transportable) = 0;
230 
234  virtual int getPersonNumber() const = 0;
235 
239  virtual std::vector<std::string> getPersonIDList() const = 0;
240 
244  virtual int getContainerNumber() const = 0;
245 
247  virtual void removeTransportable(MSTransportable* t) = 0;
248 
250  virtual const std::vector<MSTransportable*>& getPersons() const = 0;
251 
253  virtual const std::vector<MSTransportable*>& getContainers() const = 0;
254 
261  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0, bool collision = false,
262  ConstMSEdgeVector::const_iterator* searchStart = 0) = 0;
263 
265  virtual std::vector<std::pair<int, double> > getStopIndices() const = 0;
266 
268  virtual bool isLineStop(double position) const = 0;
269 
271  virtual bool abortNextStop(int nextStopIndex = 0) = 0;
272 
273 
279 
286  virtual bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg) = 0;
287 
289  virtual SUMOTime remainingStopDuration() const = 0;
290 
293  virtual bool isStoppedTriggered() const = 0;
294 
296  virtual bool isStoppedInRange(const double pos, const double tolerance) const = 0;
297 
299  virtual bool stopsAt(MSStoppingPlace* stop) const = 0;
300 
302  virtual bool stopsAtEdge(const MSEdge* edge) const = 0;
303 
306 
307  virtual void setChosenSpeedFactor(const double factor) = 0;
308 
309  virtual SUMOTime getAccumulatedWaitingTime() const = 0;
310 
311  virtual SUMOTime getDepartDelay() const = 0;
312 
313  virtual SUMOTime getTimeLoss() const = 0;
314 
316  virtual double getBrakeGap() const = 0;
317 
319  virtual double getImpatience() const = 0;
320 
324  virtual const std::vector<MSVehicleDevice*>& getDevices() const = 0;
325 
327  virtual MSVehicleDevice* getDevice(const std::type_info& type) const = 0;
328 
330  virtual bool isSelected() const = 0;
331 
333  virtual int getRNGIndex() const = 0;
334 
336  // (especially fast comparison in maps which need vehicles as keys)
337  virtual NumericalID getNumericalID() const = 0;
338 
340  virtual double getLength() const = 0;
341 
343 
344 
346  virtual void saveState(OutputDevice& out) = 0;
347 
350  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
352 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
long long int SUMOTime
Definition: SUMOTime.h:31
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: SUMOVehicle.h:46
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
A lane area vehicles can halt at.
Definition: MSParkingArea.h:57
A lane area vehicles can halt at.
Abstract in-vehicle device.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual bool hasValidRoute(std::string &msg, const MSRoute *route=0) const =0
Validates the current or given route.
virtual const std::map< int, double > * getEmissionParameters() const =0
Returns the vehicle's emission model parameter.
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
virtual std::vector< std::pair< int, double > > getStopIndices() const =0
return list of route indices and stop positions for the remaining stops
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual MSParkingArea * getNextParkingArea()=0
virtual std::vector< std::string > getPersonIDList() const =0
Returns the list of persons.
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
virtual void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)=0
Performs a rerouting using the given router.
virtual bool stopsAtEdge(const MSEdge *edge) const =0
Returns whether the vehicle stops at the given edge.
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, ConstMSEdgeVector::const_iterator *searchStart=0)=0
Adds a stop.
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual const std::vector< MSTransportable * > & getContainers() const =0
retrieve riding containers
virtual SUMOTime remainingStopDuration() const =0
Returns the remaining stop duration for a stopped vehicle or 0.
virtual SUMOTime getTimeLoss() const =0
virtual SUMOTime getAccumulatedWaitingTime() const =0
SUMOVehicle(const std::string &id)
Constructor.
Definition: SUMOVehicle.h:63
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual void setChosenSpeedFactor(const double factor)=0
virtual bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)=0
Replaces the current route by the given one.
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:66
virtual int getRNGIndex() const =0
long long int NumericalID
Definition: SUMOVehicle.h:60
virtual int getPersonNumber() const =0
Returns the number of persons.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual double getOdometer() const =0
Returns the distance that was already driven by this vehicle.
virtual double getLength() const =0
Returns the vehicles's length.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual bool isStoppedTriggered() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue.
virtual const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
virtual void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual void addTransportable(MSTransportable *transportable)=0
Adds a person or container to this vehicle.
virtual bool isFrontOnLane(const MSLane *) const =0
Returns the information whether the front of the vehhicle is on the given lane.
virtual int getRouteValidity(bool update=true, bool silent=false)=0
computes validity attributes for the current route
virtual bool hasValidRouteStart(std::string &msg)=0
checks wether the vehicle can depart on the first edge
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle's parameter.
virtual int getContainerNumber() const =0
Returns the number of containers.
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
virtual bool isIdling() const =0
Returns whether the vehicle is idling (waiting to re-enter the net.
virtual SUMOTime getDepartDelay() const =0
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool isStoppedInRange(const double pos, const double tolerance) const =0
Returns whether the vehicle is stopped in the range of the given position.
virtual double getImpatience() const =0
Returns this vehicles impatience.
virtual bool isSelected() const =0
whether this vehicle is selected in the GUI
virtual bool isLineStop(double position) const =0
returns whether the vehicle serves a public transport line that serves the given stop
virtual int getRoutePosition() const =0
return index of edge within route
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
virtual double getBrakeGap() const =0
get distance for coming to a stop (used for rerouting checks)
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
virtual double getAngle() const =0
Get the vehicle's angle.
virtual const SUMOVehicleParameter::Stop * getNextStopParameter() const =0
Returns parameters of the next stop or nullptr.
virtual bool allowsBoarding(MSTransportable *t) const =0
whether the given transportable is allowed to board this vehicle
virtual bool abortNextStop(int nextStopIndex=0)=0
deletes the next stop at the given index if it exists
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.