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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Abstract base class for vehicle representations
18 /****************************************************************************/
19 #ifndef SUMOVehicle_h
20 #define SUMOVehicle_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <vector>
29 #include <typeinfo>
30 #include <utils/common/SUMOTime.h>
31 #include <utils/common/Named.h>
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class MSRoute;
42 class MSEdge;
43 class MSLane;
44 class MSPerson;
45 class MSTransportable;
46 class MSParkingArea;
47 class MSStoppingPlace;
48 class MSVehicleDevice;
50 
51 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
62 public:
63  typedef long long int NumericalID;
64 
66  virtual ~SUMOVehicle() {}
67 
72  virtual double getLateralPositionOnLane() const = 0;
73 
77  virtual double getAngle() const = 0;
78 
82  virtual MSLane* getLane() const = 0;
83 
84 
86  virtual const MSRoute& getRoute() const = 0;
87 
95  virtual const MSEdge* succEdge(int nSuccs) const = 0;
96 
109  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, double cost, double savings, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true) = 0;
110 
112  virtual bool replaceRoute(const MSRoute* route, const std::string& info, bool onInit = false, int offset = 0, bool addStops = true, bool removeStops = true) = 0;
113 
123  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;
124 
130  virtual bool hasValidRoute(std::string& msg, const MSRoute* route = 0) const = 0;
131 
132 
136  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
137 
142  virtual const SUMOVehicleParameter& getParameter() const = 0;
143 
146  virtual void replaceParameter(const SUMOVehicleParameter* newParameter) = 0;
147 
153  virtual void onDepart() = 0;
154 
158  virtual bool isOnRoad() const = 0;
159 
163  virtual bool isFrontOnLane(const MSLane*) const = 0;
164 
168  virtual bool isParking() const = 0;
169 
174  virtual bool isRemoteControlled() const = 0;
175 
180  virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const = 0;
181 
185  virtual SUMOTime getDeparture() const = 0;
186 
190  virtual double getDepartPos() const = 0;
191 
196  virtual double getArrivalPos() const = 0;
197 
200  virtual void setArrivalPos(double arrivalPos) = 0;
201 
204  virtual bool hasDeparted() const = 0;
205 
209  virtual int getNumberReroutes() const = 0;
210 
217  virtual void addPerson(MSTransportable* person) = 0;
218 
225  virtual void addContainer(MSTransportable* container) = 0;
226 
230  virtual int getPersonNumber() const = 0;
231 
235  virtual std::vector<std::string> getPersonIDList() const = 0;
236 
240  virtual int getContainerNumber() const = 0;
241 
243  virtual void removeTransportable(MSTransportable* t) = 0;
244 
246  virtual const std::vector<MSTransportable*>& getPersons() const = 0;
247 
249  virtual const std::vector<MSTransportable*>& getContainers() const = 0;
250 
257  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0, bool collision = false,
258  ConstMSEdgeVector::const_iterator* searchStart = 0) = 0;
259 
261  virtual std::vector<std::pair<int, double> > getStopIndices() const = 0;
262 
263 
268  virtual MSParkingArea* getNextParkingArea() = 0;
269 
276  virtual bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg) = 0;
277 
279  virtual SUMOTime remainingStopDuration() const = 0;
280 
283  virtual bool isStoppedTriggered() const = 0;
284 
286  virtual bool isStoppedInRange(const double pos, const double tolerance) const = 0;
287 
289  virtual bool stopsAt(MSStoppingPlace* stop) const = 0;
290 
291  virtual void setChosenSpeedFactor(const double factor) = 0;
292 
293  virtual SUMOTime getAccumulatedWaitingTime() const = 0;
294 
295  virtual SUMOTime getDepartDelay() const = 0;
296 
298  virtual double getBrakeGap() const = 0;
299 
301  virtual double getImpatience() const = 0;
302 
306  virtual const std::vector<MSVehicleDevice*>& getDevices() const = 0;
307 
309  virtual MSVehicleDevice* getDevice(const std::type_info& type) const = 0;
310 
312  virtual bool isSelected() const = 0;
313 
317  virtual std::mt19937* getRNG() const = 0;
318 
320  // (especially fast comparison in maps which need vehicles as keys)
321  virtual NumericalID getNumericalID() const = 0;
322 
324 
325 
327  virtual void saveState(OutputDevice& out) = 0;
328 
331  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
333 };
334 
335 
336 #endif
337 
338 /****************************************************************************/
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.
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
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.
long long int SUMOTime
Definition: SUMOTime.h:35
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual double getArrivalPos() const =0
Returns this vehicle&#39;s desired arrivalPos for its current route (may change on reroute) ...
virtual MSParkingArea * getNextParkingArea()=0
virtual SUMOTime remainingStopDuration() const =0
Returns the remaining stop duration for a stopped vehicle or 0.
virtual const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual const MSRoute & getRoute() const =0
Returns the current route.
A lane area vehicles can halt at.
virtual bool isStoppedTriggered() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue...
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
virtual double getBrakeGap() const =0
get distance for coming to a stop (used for rerouting checks)
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 std::vector< std::string > getPersonIDList() const =0
Returns the list of persons.
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
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 bool isSelected() const =0
whether this vehicle is selected in the GUI
virtual std::vector< std::pair< int, double > > getStopIndices() const =0
return list of route indices and stop positions for the remaining stops
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: SUMOVehicle.h:49
virtual void addContainer(MSTransportable *container)=0
Adds a container to this vehicle.
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
A road/street connecting two junctions.
Definition: MSEdge.h:76
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle&#39;s parameter.
virtual std::mt19937 * getRNG() const =0
Returns the associated RNG for this vehicle.
virtual void setChosenSpeedFactor(const double factor)=0
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 void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
Encapsulated SAX-Attributes.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual bool hasValidRoute(std::string &msg, const MSRoute *route=0) const =0
Validates the current or given route.
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle&#39;s devices.
virtual SUMOTime getAccumulatedWaitingTime() const =0
virtual bool isFrontOnLane(const MSLane *) const =0
Returns the information whether the front of the vehhicle is on the given lane.
virtual int getPersonNumber() const =0
Returns the number of persons.
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
Definition of vehicle stop (position and duration)
virtual double getDepartPos() const =0
Returns this vehicle&#39;s real departure position.
virtual const std::vector< MSTransportable * > & getContainers() const =0
retrieve riding containers
virtual SUMOTime getDepartDelay() const =0
Structure representing possible vehicle parameter.
virtual double getAngle() const =0
Get the vehicle&#39;s angle.
Representation of a vehicle or person.
virtual SUMOTime getDeparture() const =0
Returns this vehicle&#39;s real departure time.
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
virtual double getLateralPositionOnLane() const =0
Get the vehicle&#39;s lateral position on the lane.
Abstract in-vehicle device.
virtual void addPerson(MSTransportable *person)=0
Adds a person to this vehicle.
virtual int getContainerNumber() const =0
Returns the number of containers.
virtual double getImpatience() const =0
Returns this vehicles impatience.
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle&#39;s desired arrivalPos for its current route.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
long long int NumericalID
Definition: SUMOVehicle.h:63
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:66
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.