SUMO - Simulation of Urban MObility
SUMOVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Abstract base class for vehicle representations
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef SUMOVehicle_h
23 #define SUMOVehicle_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <typeinfo>
37 #include <utils/common/SUMOTime.h>
38 #include <utils/common/Named.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSVehicleType;
48 class MSRoute;
49 class MSEdge;
50 class MSLane;
51 class MSDevice;
52 class MSPerson;
53 class MSTransportable;
55 
56 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
57 
58 
59 // ===========================================================================
60 // class definitions
61 // ===========================================================================
66 class SUMOVehicle {
67 public:
69 
71  virtual ~SUMOVehicle() {}
72 
76  virtual const std::string& getID() const = 0;
77 
81  virtual SUMOReal getPositionOnLane() const = 0;
82 
86  virtual SUMOReal getBackPositionOnLane(const MSLane* lane) const = 0;
87 
92  virtual SUMOReal getLateralPositionOnLane() const = 0;
93 
97  virtual SUMOReal getAngle() const = 0;
98 
106  virtual Position getPosition(const SUMOReal offset = 0) const = 0;
107 
111  virtual SUMOReal getMaxSpeed() const = 0;
112 
116  virtual SUMOReal getSpeed() const = 0;
117 
121  virtual MSLane* getLane() const = 0;
122 
126  virtual const MSVehicleType& getVehicleType() const = 0;
127 
131  virtual SUMOVehicleClass getVClass() const = 0;
132 
134  virtual const MSRoute& getRoute() const = 0;
135 
143  virtual const MSEdge* succEdge(int nSuccs) const = 0;
144 
156  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit = false, bool check = false) = 0;
157 
159  virtual bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0) = 0;
160 
170  virtual void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false) = 0;
171 
177  virtual bool hasValidRoute(std::string& msg, const MSRoute* route = 0) const = 0;
178 
179 
183  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
184 
188  virtual SUMOReal getAcceleration() const = 0;
189 
193  virtual SUMOReal getSlope() const = 0;
194 
199  virtual const MSEdge* getEdge() const = 0;
200 
205  virtual const SUMOVehicleParameter& getParameter() const = 0;
206 
212  virtual void onDepart() = 0;
213 
217  virtual bool isOnRoad() const = 0;
218 
222  virtual bool isFrontOnLane(const MSLane*) const = 0;
223 
227  virtual bool isParking() const = 0;
228 
233  virtual bool isRemoteControlled() const = 0;
234 
238  virtual SUMOTime getDeparture() const = 0;
239 
243  virtual SUMOReal getDepartPos() const = 0;
244 
249  virtual SUMOReal getArrivalPos() const = 0;
250 
253  virtual void setArrivalPos(SUMOReal arrivalPos) = 0;
254 
257  virtual bool hasDeparted() const = 0;
258 
261  virtual bool hasArrived() const = 0;
262 
266  virtual int getNumberReroutes() const = 0;
267 
271  virtual const std::vector<MSDevice*>& getDevices() const = 0;
272 
279  virtual void addPerson(MSTransportable* person) = 0;
280 
287  virtual void addContainer(MSTransportable* container) = 0;
288 
295  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0) = 0;
296 
300  virtual bool isStopped() const = 0;
301 
302 
305  virtual bool isStoppedTriggered() const = 0;
306 
308  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
309 
310 
311  virtual SUMOReal getChosenSpeedFactor() const = 0;
312 
313  virtual void setChosenSpeedFactor(const SUMOReal factor) = 0;
314 
315  virtual SUMOTime getWaitingTime() const = 0;
316 
317  virtual SUMOTime getDepartDelay() const = 0;
318 
320  virtual SUMOReal getImpatience() const = 0;
321 
323 
324 
326  virtual void saveState(OutputDevice& out) = 0;
327 
330  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
332 };
333 
334 
335 #endif
336 
337 /****************************************************************************/
long long int SUMOTime
Definition: SUMOTime.h:43
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
Function-object for stable sorting of objects acting like Named without being derived (SUMOVehicle) ...
Definition: Named.h:90
virtual const MSRoute & getRoute() const =0
Returns the current route.
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.
Named::NamedLikeComparatorIdLess< SUMOVehicle > ComparatorIdLess
Definition: SUMOVehicle.h:68
virtual SUMOReal getDepartPos() const =0
Returns this vehicle&#39;s real departure position.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual SUMOReal getAngle() const =0
Get the vehicle&#39;s angle.
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
The car-following model and parameter.
Definition: MSVehicleType.h:74
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0)=0
Adds a stop.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: SUMOVehicle.h:54
virtual void addContainer(MSTransportable *container)=0
Adds a container to this vehicle.
virtual SUMOReal getChosenSpeedFactor() const =0
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:80
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
virtual const std::vector< MSDevice * > & getDevices() const =0
Returns this vehicle&#39;s devices.
virtual void setChosenSpeedFactor(const SUMOReal factor)=0
virtual void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual SUMOReal getImpatience() const =0
Returns this vehicles impatience.
virtual void setArrivalPos(SUMOReal arrivalPos)=0
Sets this vehicle&#39;s desired arrivalPos for its current route.
virtual void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)=0
Performs a rerouting using the given router.
virtual bool isFrontOnLane(const MSLane *) const =0
Returns the information whether the front of the vehhicle is on the given lane.
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 SUMOReal getLateralPositionOnLane() const =0
Get the vehicle&#39;s lateral position on the lane.
Abstract in-vehicle device.
Definition: MSDevice.h:69
virtual SUMOTime getDepartDelay() const =0
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false)=0
Replaces the current route by the given edges.
virtual SUMOReal getSpeed() const =0
Returns the vehicle&#39;s current speed.
Structure representing possible vehicle parameter.
virtual SUMOTime getDeparture() const =0
Returns this vehicle&#39;s real departure time.
virtual bool hasArrived() const =0
Returns whether this vehicle has arrived.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
Definition of vehicle stop (position and duration)
virtual SUMOReal getAcceleration() const =0
Returns the vehicle&#39;s acceleration.
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0)=0
Replaces the current route by the given one.
virtual Position getPosition(const SUMOReal offset=0) const =0
Return current position (x/y, cartesian)
virtual SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle&#39;s back position along the given lane.
virtual SUMOTime getWaitingTime() const =0
virtual void addPerson(MSTransportable *person)=0
Adds a person to this vehicle.
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual SUMOReal getSlope() const =0
Returns the slope of the road at vehicle&#39;s position.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual SUMOReal getArrivalPos() const =0
Returns this vehicle&#39;s desired arrivalPos for its current route (may change on reroute) ...
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:71
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.