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-2018 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>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSVehicleType;
41 class MSRoute;
42 class MSEdge;
43 class MSLane;
44 class MSDevice;
45 class MSPerson;
46 class MSTransportable;
47 class MSParkingArea;
49 
50 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
60 class SUMOVehicle {
61 public:
62 
63  // XXX: This definition was introduced to make the MSVehicle's previousSpeed
64  // available in the context of MSMoveReminder::notifyMove(). Another solution
65  // would be to modify notifyMove()'s interface to work with MSVehicle instead
66  // of SUMOVehicle (it is only called with MSVehicles!). Refs. #2579
70  virtual double getPreviousSpeed() const = 0;
71 
73  virtual ~SUMOVehicle() {}
74 
78  virtual const std::string& getID() const = 0;
79 
83  virtual double getPositionOnLane() const = 0;
84 
88  virtual double getBackPositionOnLane(const MSLane* lane) const = 0;
89 
94  virtual double getLateralPositionOnLane() const = 0;
95 
99  virtual double getAngle() const = 0;
100 
108  virtual Position getPosition(const double offset = 0) const = 0;
109 
113  virtual double getMaxSpeed() const = 0;
114 
118  virtual double getSpeed() const = 0;
119 
123  virtual MSLane* getLane() const = 0;
124 
128  virtual const MSVehicleType& getVehicleType() const = 0;
129 
133  virtual SUMOVehicleClass getVClass() const = 0;
134 
136  virtual const MSRoute& getRoute() const = 0;
137 
145  virtual const MSEdge* succEdge(int nSuccs) const = 0;
146 
159  virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true) = 0;
160 
162  virtual bool replaceRoute(const MSRoute* route, const std::string& info, bool onInit = false, int offset = 0, bool addStops = true, bool removeStops = true) = 0;
163 
173  virtual void reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false) = 0;
174 
180  virtual bool hasValidRoute(std::string& msg, const MSRoute* route = 0) const = 0;
181 
182 
186  virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
187 
191  virtual double getAcceleration() const = 0;
192 
196  virtual double getSlope() const = 0;
197 
202  virtual const MSEdge* getEdge() const = 0;
203 
208  virtual const SUMOVehicleParameter& getParameter() const = 0;
209 
212  virtual void replaceParameter(const SUMOVehicleParameter* newParameter) = 0;
213 
219  virtual void onDepart() = 0;
220 
224  virtual bool isOnRoad() const = 0;
225 
229  virtual bool isFrontOnLane(const MSLane*) const = 0;
230 
234  virtual bool isParking() const = 0;
235 
240  virtual bool isRemoteControlled() const = 0;
241 
246  virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const = 0;
247 
251  virtual SUMOTime getDeparture() const = 0;
252 
256  virtual double getDepartPos() const = 0;
257 
262  virtual double getArrivalPos() const = 0;
263 
266  virtual void setArrivalPos(double arrivalPos) = 0;
267 
270  virtual bool hasDeparted() const = 0;
271 
274  virtual bool hasArrived() const = 0;
275 
279  virtual int getNumberReroutes() const = 0;
280 
284  virtual const std::vector<MSDevice*>& getDevices() const = 0;
285 
292  virtual void addPerson(MSTransportable* person) = 0;
293 
300  virtual void addContainer(MSTransportable* container) = 0;
301 
305  virtual int getPersonNumber() const = 0;
306 
310  virtual std::vector<std::string> getPersonIDList() const = 0;
311 
315  virtual int getContainerNumber() const = 0;
316 
318  virtual void removeTransportable(MSTransportable* t) = 0;
319 
321  virtual const std::vector<MSTransportable*>& getPersons() const = 0;
322 
324  virtual const std::vector<MSTransportable*>& getContainers() const = 0;
325 
332  virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0, bool collision = false,
333  ConstMSEdgeVector::const_iterator* searchStart = 0) = 0;
334 
335 
340  virtual MSParkingArea* getNextParkingArea() = 0;
341 
348  virtual bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg) = 0;
349 
353  virtual bool isStopped() const = 0;
354 
356  virtual SUMOTime remainingStopDuration() const = 0;
357 
360  virtual bool isStoppedTriggered() const = 0;
361 
363  virtual bool isStoppedInRange(double pos) const = 0;
364 
366  virtual MSDevice* getDevice(const std::type_info& type) const = 0;
367 
368 
369  virtual double getChosenSpeedFactor() const = 0;
370 
371  virtual void setChosenSpeedFactor(const double factor) = 0;
372 
373  virtual SUMOTime getWaitingTime() const = 0;
374 
375  virtual SUMOTime getAccumulatedWaitingTime() const = 0;
376 
377  virtual SUMOTime getDepartDelay() const = 0;
378 
380  virtual double getImpatience() const = 0;
381 
383  virtual bool isSelected() const = 0;
384 
386 
387 
389  virtual void saveState(OutputDevice& out) = 0;
390 
393  virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
395 };
396 
397 
398 #endif
399 
400 /****************************************************************************/
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
long long int SUMOTime
Definition: SUMOTime.h:36
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
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
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.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
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
virtual double getSlope() const =0
Returns the slope of the road at vehicle&#39;s position.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
The car-following model and parameter.
Definition: MSVehicleType.h:66
virtual bool isSelected() const =0
whether this vehicle is selected in the GUI
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: SUMOVehicle.h:48
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:75
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 replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle&#39;s parameter.
virtual void setChosenSpeedFactor(const double factor)=0
virtual void saveState(OutputDevice &out)=0
Saves the states of a vehicle.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
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:39
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.
virtual bool isStoppedInRange(double pos) const =0
Returns whether the vehicle is stoped in range of the given position.
virtual double getChosenSpeedFactor() const =0
virtual double getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
Abstract in-vehicle device.
Definition: MSDevice.h:65
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle&#39;s back position along the given lane.
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
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
Structure representing possible vehicle parameter.
virtual double getAngle() const =0
Get the vehicle&#39;s angle.
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 double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
Definition of vehicle stop (position and duration)
virtual double getLateralPositionOnLane() const =0
Get the vehicle&#39;s lateral position on the lane.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual SUMOTime getWaitingTime() const =0
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.
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:64
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
virtual void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)=0
Performs a rerouting using the given router.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual double getSpeed() const =0
Returns the vehicle&#39;s current speed.
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
virtual double getPreviousSpeed() const =0
Returns the vehicle&#39;s previous speed.
virtual ~SUMOVehicle()
Destructor.
Definition: SUMOVehicle.h:73
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 double getAcceleration() const =0
Returns the vehicle&#39;s acceleration.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.