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 /****************************************************************************/
16 // Abstract base class for vehicle representations
17 /****************************************************************************/
18 #ifndef SUMOVehicle_h
19 #define SUMOVehicle_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <typeinfo>
29 #include <utils/common/SUMOTime.h>
30 #include <utils/common/Named.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSRoute;
41 class MSEdge;
42 class MSLane;
43 class MSPerson;
44 class MSTransportable;
45 class MSParkingArea;
46 class MSStoppingPlace;
47 class MSVehicleDevice;
48 class SUMOSAXAttributes;
49 
50 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
61 public:
62  typedef long long int NumericalID;
63 
65  virtual ~SUMOVehicle() {}
66 
71  virtual double getLateralPositionOnLane() const = 0;
72 
76  virtual double getAngle() const = 0;
77 
81  virtual MSLane* getLane() const = 0;
82 
83 
85  virtual const MSRoute& getRoute() const = 0;
86 
94  virtual const MSEdge* succEdge(int nSuccs) const = 0;
95 
108  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, double cost, double savings, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true) = 0;
109 
111  virtual bool replaceRoute(const MSRoute* route, const std::string& info, bool onInit = false, int offset = 0, bool addStops = true, bool removeStops = true) = 0;
112 
122  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;
123 
129  virtual bool hasValidRoute(std::string& msg, const MSRoute* route = 0) const = 0;
130 
131 
135  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
136 
141  virtual const SUMOVehicleParameter& getParameter() const = 0;
142 
147  virtual const std::map<int, double>* getEmissionParameters() const = 0;
148 
151  virtual void replaceParameter(const SUMOVehicleParameter* newParameter) = 0;
152 
158  virtual void onDepart() = 0;
159 
163  virtual bool isOnRoad() const = 0;
164 
168  virtual bool isFrontOnLane(const MSLane*) const = 0;
169 
173  virtual bool isParking() const = 0;
174 
179  virtual bool isRemoteControlled() const = 0;
180 
185  virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const = 0;
186 
190  virtual SUMOTime getDeparture() const = 0;
191 
195  virtual double getDepartPos() const = 0;
196 
201  virtual double getArrivalPos() const = 0;
202 
205  virtual void setArrivalPos(double arrivalPos) = 0;
206 
209  virtual bool hasDeparted() const = 0;
210 
214  virtual int getNumberReroutes() const = 0;
215 
222  virtual void addPerson(MSTransportable* person) = 0;
223 
230  virtual void addContainer(MSTransportable* container) = 0;
231 
235  virtual int getPersonNumber() const = 0;
236 
240  virtual std::vector<std::string> getPersonIDList() const = 0;
241 
245  virtual int getContainerNumber() const = 0;
246 
248  virtual void removeTransportable(MSTransportable* t) = 0;
249 
251  virtual const std::vector<MSTransportable*>& getPersons() const = 0;
252 
254  virtual const std::vector<MSTransportable*>& getContainers() const = 0;
255 
262  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0, bool collision = false,
263  ConstMSEdgeVector::const_iterator* searchStart = 0) = 0;
264 
266  virtual std::vector<std::pair<int, double> > getStopIndices() const = 0;
267 
268 
274 
281  virtual bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg) = 0;
282 
284  virtual SUMOTime remainingStopDuration() const = 0;
285 
288  virtual bool isStoppedTriggered() const = 0;
289 
291  virtual bool isStoppedInRange(const double pos, const double tolerance) const = 0;
292 
294  virtual bool stopsAt(MSStoppingPlace* stop) const = 0;
295 
297  virtual bool stopsAtEdge(const MSEdge* edge) const = 0;
298 
299  virtual void setChosenSpeedFactor(const double factor) = 0;
300 
301  virtual SUMOTime getAccumulatedWaitingTime() const = 0;
302 
303  virtual SUMOTime getDepartDelay() const = 0;
304 
306  virtual double getBrakeGap() const = 0;
307 
309  virtual double getImpatience() const = 0;
310 
314  virtual const std::vector<MSVehicleDevice*>& getDevices() const = 0;
315 
317  virtual MSVehicleDevice* getDevice(const std::type_info& type) const = 0;
318 
320  virtual bool isSelected() const = 0;
321 
323  virtual int getRNGIndex() const = 0;
324 
328  virtual std::mt19937* getRNG() const = 0;
329 
331  // (especially fast comparison in maps which need vehicles as keys)
332  virtual NumericalID getNumericalID() const = 0;
333 
335 
336 
338  virtual void saveState(OutputDevice& out) = 0;
339 
342  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
344 };
345 
346 
347 #endif
348 
349 /****************************************************************************/
SUMOVehicle::getRNGIndex
virtual int getRNGIndex() const =0
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
SUMOVehicle::getContainers
virtual const std::vector< MSTransportable * > & getContainers() const =0
retrieve riding containers
SUMOVehicle::getDepartDelay
virtual SUMOTime getDepartDelay() const =0
MSStoppingPlace
A lane area vehicles can halt at.
Definition: MSStoppingPlace.h:59
MSParkingArea
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
SUMOVehicle::getAngle
virtual double getAngle() const =0
Get the vehicle's angle.
SUMOVehicle::addPerson
virtual void addPerson(MSTransportable *person)=0
Adds a person to this vehicle.
SUMOTime.h
SUMOVehicle::setChosenSpeedFactor
virtual void setChosenSpeedFactor(const double factor)=0
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
SUMOVehicle::replaceParameter
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle's parameter.
SUMOVehicle::getRNG
virtual std::mt19937 * getRNG() const =0
Returns the associated RNG for this vehicle.
SUMOVehicle::replaceRouteEdges
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.
SUMOVehicle::getParameter
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
SUMOVehicle::getStopIndices
virtual std::vector< std::pair< int, double > > getStopIndices() const =0
return list of route indices and stop positions for the remaining stops
SUMOVehicle::replaceParkingArea
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
SUMOVehicle::getCurrentRouteEdge
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
SUMOVehicle::getContainerNumber
virtual int getContainerNumber() const =0
Returns the number of containers.
MSPerson
Definition: MSPerson.h:63
SUMOVehicle::getImpatience
virtual double getImpatience() const =0
Returns this vehicles impatience.
SUMOVehicle::getAccumulatedWaitingTime
virtual SUMOTime getAccumulatedWaitingTime() const =0
SUMOVehicle::isRemoteControlled
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
SUMOVehicle::~SUMOVehicle
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:65
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
SUMOVehicle::isOnRoad
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
SUMOVehicle::hasValidRoute
virtual bool hasValidRoute(std::string &msg, const MSRoute *route=0) const =0
Validates the current or given route.
SUMOVehicle::stopsAt
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
SUMOVehicle::NumericalID
long long int NumericalID
Definition: SUMOVehicle.h:62
MSTransportable
Definition: MSTransportable.h:58
SUMOVehicle::getEmissionParameters
virtual const std::map< int, double > * getEmissionParameters() const =0
Returns the vehicle's emission model parameter.
MSRoute
Definition: MSRoute.h:66
SUMOVehicle::getNextParkingArea
virtual MSParkingArea * getNextParkingArea()=0
SUMOVehicleParameter.h
SUMOVehicle::getPersons
virtual const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
SUMOVehicle::getDeparture
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
SUMOVehicle::getRoute
virtual const MSRoute & getRoute() const =0
Returns the current route.
SUMOVehicle::stopsAtEdge
virtual bool stopsAtEdge(const MSEdge *edge) const =0
Returns whether the vehicle stops at the given edge.
Named.h
SUMOVehicle::setArrivalPos
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
SUMOVehicle::getDevice
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
SUMOVehicle::isStoppedTriggered
virtual bool isStoppedTriggered() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue.
SUMOVehicle::getLane
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
SUMOVehicle::getNumericalID
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
SUMOVehicle::replaceRoute
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.
OutputDevice.h
SUMOVehicle::getLateralPositionOnLane
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
SUMOVehicle::removeTransportable
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
SUMOVehicle::getBrakeGap
virtual double getBrakeGap() const =0
get distance for coming to a stop (used for rerouting checks)
SUMOAbstractRouter< MSEdge, SUMOVehicle >
SUMOVehicle::addContainer
virtual void addContainer(MSTransportable *container)=0
Adds a container to this vehicle.
SUMOVehicle::succEdge
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
SUMOVehicle::isStoppedInRange
virtual bool isStoppedInRange(const double pos, const double tolerance) const =0
Returns whether the vehicle is stopped in the range of the given position.
SUMOVehicle::reroute
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.
SUMOVehicle::loadState
virtual void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
Loads the state of this vehicle from the given description.
SUMOVehicle::hasDeparted
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
SUMOVehicle::remainingStopDuration
virtual SUMOTime remainingStopDuration() const =0
Returns the remaining stop duration for a stopped vehicle or 0.
SUMOVehicle::getNumberReroutes
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
SUMOVehicle::addStop
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.
SUMOVehicle::onDepart
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
SUMOVehicle::getPersonNumber
virtual int getPersonNumber() const =0
Returns the number of persons.
SUMOVehicle::getArrivalPos
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
SUMOVehicle::saveState
virtual void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
config.h
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: SUMOVehicle.h:48
SUMOTrafficObject.h
SUMOVehicle::getDevices
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
SUMOVehicle::isFrontOnLane
virtual bool isFrontOnLane(const MSLane *) const =0
Returns the information whether the front of the vehhicle is on the given lane.
SUMOAbstractRouter.h
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
SUMOVehicle::getDepartPos
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
SUMOVehicle::wasRemoteControlled
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
SUMOVehicle::isParking
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
SUMOVehicle::getPersonIDList
virtual std::vector< std::string > getPersonIDList() const =0
Returns the list of persons.
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:572
SUMOVehicle::isSelected
virtual bool isSelected() const =0
whether this vehicle is selected in the GUI
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54