Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMOVehicle.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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>
28#include <utils/common/Named.h>
33
34
35// ===========================================================================
36// class declarations
37// ===========================================================================
38class MSRoute;
39class MSEdge;
40class MSLane;
41class MSPerson;
42class MSStop;
43class MSTransportable;
44class MSParkingArea;
46class MSStoppingPlace;
47class MSVehicleDevice;
49class EnergyParams;
50class PositionVector;
51
52typedef std::vector<const MSEdge*> ConstMSEdgeVector;
53
54
55// ===========================================================================
56// class definitions
57// ===========================================================================
63public:
64
66 SUMOVehicle(const std::string& id) : SUMOTrafficObject(id) {}
67
69 virtual ~SUMOVehicle() {}
70
75 virtual double getLateralPositionOnLane() const = 0;
76
80 virtual double getAngle() const = 0;
81
83 virtual const MSRoute& getRoute() const = 0;
84
86 virtual ConstMSRoutePtr getRoutePtr() const = 0;
87
95 virtual const MSEdge* succEdge(int nSuccs) const = 0;
96
102 virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const = 0;
103
116 virtual bool replaceRouteEdges(ConstMSEdgeVector& edges, double cost, double savings, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true, std::string* msgReturn = nullptr) = 0;
117
128 virtual bool reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit = false, const bool withTaz = false, const bool silent = false, const MSEdge* sink = nullptr) = 0;
129
135 virtual bool hasValidRoute(std::string& msg, ConstMSRoutePtr route = 0) const = 0;
137 virtual bool hasValidRouteStart(std::string& msg) = 0;
138
140 virtual int getRouteValidity(bool update = true, bool silent = false, std::string* msgReturn = nullptr) = 0;
141
145 virtual const ConstMSEdgeVector::const_iterator& getCurrentRouteEdge() const = 0;
146
152
155 virtual void replaceParameter(const SUMOVehicleParameter* newParameter) = 0;
156
162 virtual void onDepart() = 0;
163
167 virtual bool isOnRoad() const = 0;
168
172 virtual bool isIdling() const = 0;
173
177 virtual bool isFrontOnLane(const MSLane*) const = 0;
178
182 virtual bool isParking() const = 0;
183
188 virtual bool isRemoteControlled() const = 0;
189
194 virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const = 0;
195
199 virtual SUMOTime getDeparture() const = 0;
200
204 virtual double getDepartPos() const = 0;
205
210 virtual double getArrivalPos() const = 0;
211
214 virtual void setArrivalPos(double arrivalPos) = 0;
215
218 virtual bool hasDeparted() const = 0;
219
223 virtual double getOdometer() const = 0;
224
228 virtual int getNumberReroutes() const = 0;
229
231 virtual bool allowsBoarding(const MSTransportable* t) const = 0;
232
237 virtual void addTransportable(MSTransportable* transportable) = 0;
238
242 virtual int getPersonNumber() const = 0;
243
247 virtual std::vector<std::string> getPersonIDList() const = 0;
248
252 virtual int getContainerNumber() const = 0;
253
256
258 virtual const std::vector<MSTransportable*>& getPersons() const = 0;
259
261 virtual const std::vector<MSTransportable*>& getContainers() const = 0;
262
269 virtual bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0,
270 ConstMSEdgeVector::const_iterator* searchStart = 0) = 0;
271
273 virtual std::vector<std::pair<int, double> > getStopIndices() const = 0;
274
276 virtual bool isLineStop(double position) const = 0;
277
279 virtual bool abortNextStop(int nextStopIndex = 0) = 0;
280
281
287
294 virtual bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg) = 0;
295
297 virtual SUMOTime remainingStopDuration() const = 0;
298
301 virtual bool isStopped() const = 0;
304 virtual bool isStoppedTriggered() const = 0;
305
308 virtual bool isStoppedParking() const = 0;
309
311 virtual bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture = false) const = 0;
312
314 virtual bool stopsAt(MSStoppingPlace* stop) const = 0;
315
317 virtual bool stopsAtEdge(const MSEdge* edge) const = 0;
318
322 virtual bool hasStops() const = 0;
323
328 virtual const std::list<MSStop>& getStops() const = 0;
329
334 virtual MSStop& getNextStop() = 0;
335
337 virtual void unregisterWaiting() = 0;
338
341
348 virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string& errorMsg) = 0;
349
350 virtual void setChosenSpeedFactor(const double factor) = 0;
351
352 virtual SUMOTime getDepartDelay() const = 0;
353
354 virtual SUMOTime getTimeLoss() const = 0;
355
357 virtual double getBrakeGap(bool delayed = false) const = 0;
358
360 virtual double getImpatience() const = 0;
361
365 virtual const std::vector<MSVehicleDevice*>& getDevices() const = 0;
366
368 virtual double getLength() const = 0;
369
370 virtual SUMOTime getLastActionTime() const = 0;
371
373 virtual PositionVector getBoundingBox(double offset = 0) const = 0;
374
376
377 virtual void rememberBlockedParkingArea(const MSStoppingPlace* pa, bool local) = 0;
378 virtual SUMOTime sawBlockedParkingArea(const MSStoppingPlace* pa, bool local) const = 0;
379 virtual void rememberParkingAreaScore(const MSStoppingPlace* pa, const std::string& score) = 0;
380 virtual void resetParkingAreaScores() = 0;
381 virtual int getNumberParkingReroutes() const = 0;
382 virtual void setNumberParkingReroutes(int value) = 0;
383
384 virtual void rememberBlockedChargingStation(const MSStoppingPlace* cs, bool local) = 0;
385 virtual SUMOTime sawBlockedChargingStation(const MSStoppingPlace* cs, bool local) const = 0;
386 virtual void rememberChargingStationScore(const MSStoppingPlace* cs, const std::string& score) = 0;
387 virtual void resetChargingStationScores() = 0;
389
391
392
394 virtual void saveState(OutputDevice& out) = 0;
395
398 virtual void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) = 0;
400};
long long int SUMOTime
Definition GUI.h:36
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
std::vector< const MSEdge * > ConstMSEdgeVector
Definition SUMOVehicle.h:52
An upper class for objects with additional parameters.
A road/street connecting two junctions.
Definition MSEdge.h:77
Representation of a lane in the micro simulation.
Definition MSLane.h:84
A lane area vehicles can halt at.
A lane area vehicles can halt at.
Abstract in-vehicle device.
Static storage of an output device and its base (abstract) implementation.
A list of positions.
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:62
virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const =0
Returns the starting point for reroutes (usually the current edge)
virtual bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)=0
Performs a rerouting using the given router.
virtual SUMOTime sawBlockedParkingArea(const MSStoppingPlace *pa, bool local) const =0
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given edges.
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual const std::vector< MSTransportable * > & getContainers() const =0
retrieve riding containers
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue.
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
virtual bool stopsAtEdge(const MSEdge *edge) const =0
Returns whether the vehicle stops at the given edge.
virtual int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)=0
computes validity attributes for the current route
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 hasStops() const =0
Returns whether the vehicle has to stop somewhere.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, ConstMSEdgeVector::const_iterator *searchStart=0)=0
Adds a stop.
virtual MSParkingArea * getNextParkingArea()=0
virtual SUMOTime remainingStopDuration() const =0
Returns the remaining stop duration for a stopped vehicle or 0.
virtual SUMOTime getTimeLoss() const =0
virtual const std::list< MSStop > & getStops() const =0
SUMOVehicle(const std::string &id)
Constructor.
Definition SUMOVehicle.h:66
virtual SUMOTime sawBlockedChargingStation(const MSStoppingPlace *cs, bool local) const =0
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 void onDepart()=0
Called when the vehicle is inserted into the network.
virtual ~SUMOVehicle()
Destructor.
Definition SUMOVehicle.h:69
virtual void rememberParkingAreaScore(const MSStoppingPlace *pa, const std::string &score)=0
virtual bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture=false) const =0
Returns whether the vehicle is stopped in the range of the given position.
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
virtual int getPersonNumber() const =0
Returns the number of persons.
virtual void rememberBlockedParkingArea(const MSStoppingPlace *pa, bool local)=0
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 void unregisterWaiting()=0
mark vehicle as active
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 int getNumberParkingReroutes() const =0
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 std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
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 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 double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual ConstMSRoutePtr getRoutePtr() const =0
Returns the current route.
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle's parameter.
virtual bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const =0
Validates the current or given route.
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 void rememberBlockedChargingStation(const MSStoppingPlace *cs, bool local)=0
virtual PositionVector getBoundingBox(double offset=0) const =0
get bounding rectangle
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual void resetParkingAreaScores()=0
virtual double getImpatience() const =0
Returns this vehicles impatience.
virtual SUMOTime getLastActionTime() const =0
virtual double getBrakeGap(bool delayed=false) const =0
get distance for coming to a stop (used for rerouting checks)
virtual bool isLineStop(double position) const =0
returns whether the vehicle serves a public transport line that serves the given stop
virtual std::vector< std::pair< int, double > > getStopIndices() const =0
return list of route indices and stop positions for the remaining stops
virtual void resetChargingStationScores()=0
virtual bool isStoppedParking() const =0
Returns whether the vehicle is at a stop and parking.
virtual bool allowsBoarding(const MSTransportable *t) const =0
whether the given transportable is allowed to board this vehicle
virtual EnergyParams * getEmissionParameters() const =0
Returns the vehicle's emission model parameter.
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
virtual void rememberChargingStationScore(const MSStoppingPlace *cs, const std::string &score)=0
virtual double getAngle() const =0
Get the vehicle's angle.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual MSStop & getNextStop()=0
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)=0
virtual const SUMOVehicleParameter::Stop * getNextStopParameter() const =0
Returns parameters of the next stop or nullptr.
virtual void setNumberParkingReroutes(int value)=0
virtual std::vector< std::string > getPersonIDList() const =0
Returns the list of persons.
virtual const MSRoute & getRoute() const =0
Returns the current route.
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.