Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSBaseVehicle.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2010-2026 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// A base class for vehicle implementations
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <iostream>
26#include <vector>
27#include <set>
33#include "MSRoute.h"
34#include "MSMoveReminder.h"
35#include "MSVehicleType.h"
36
37
38// ===========================================================================
39// class declarations
40// ===========================================================================
41class MSLane;
42class MSStop;
45class MSVehicleDevice;
49
50
51// ===========================================================================
52// class definitions
53// ===========================================================================
58class MSBaseVehicle : public SUMOVehicle {
59public:
60 // XXX: This definition was introduced to make the MSVehicle's previousSpeed
61 // available in the context of MSMoveReminder::notifyMove(). Another solution
62 // would be to modify notifyMove()'s interface to work with MSVehicle instead
63 // of SUMOVehicle (it is only called with MSVehicles!). Refs. #2579
67 double getPreviousSpeed() const;
68
69 friend class GUIBaseVehicle;
70
77 ROUTE_INVALID = 1 << 1,
78 // starting edge permissions invalid (could change)
80 // insertion lane does not exist
82 };
83
92 MSVehicleType* type, const double speedFactor);
93
94
96 virtual ~MSBaseVehicle();
97
98 virtual void initDevices();
99
100 bool isVehicle() const {
101 return true;
102 }
103
105 void setID(const std::string& newID);
106
111 const SUMOVehicleParameter& getParameter() const;
112
114 std::string getPrefixedParameter(const std::string& key, std::string& error) const;
115
117 void replaceParameter(const SUMOVehicleParameter* newParameter);
118
120 bool hasDevice(const std::string& deviceName) const;
121
123 void createDevice(const std::string& deviceName);
124
126 std::string getDeviceParameter(const std::string& deviceName, const std::string& key) const;
127
129 void setDeviceParameter(const std::string& deviceName, const std::string& key, const std::string& value);
130
132 void setJunctionModelParameter(const std::string& key, const std::string& value);
133
135 void setCarFollowModelParameter(const std::string& key, const std::string& value);
136
140 inline const MSRoute& getRoute() const {
141 return *myRoute;
142 }
143
148 return myRoute;
149 }
150
154 inline const MSVehicleType& getVehicleType() const {
155 return *myType;
156 }
157
161 inline const SUMOVTypeParameter& getVTypeParameter() const {
162 return myType->getParameter();
163 }
164
170 }
171
175 bool ignoreTransientPermissions() const;
176
178 virtual bool instantStopping() const {
179 return false;
180 }
181
185 double getMaxSpeed() const;
186
194 const MSEdge* succEdge(int nSuccs) const;
195
200 const MSEdge* getEdge() const;
201
205 virtual const MSEdge* getCurrentEdge() const {
206 return getEdge();
207 }
208
210 const std::set<SUMOTrafficObject::NumericalID> getUpcomingEdgeIDs() const;
211
213 bool stopsAt(MSStoppingPlace* stop) const;
214
216 bool stopsAtEdge(const MSEdge* edge) const;
217
219 virtual const MSEdge* getNextEdgePtr() const {
220 return nullptr;
221 }
222
226 virtual bool isOnRoad() const {
227 return true;
228 }
229
234 virtual bool isRemoteControlled() const {
235 return false;
236 }
237
238 virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const {
239 UNUSED_PARAMETER(lookBack);
240 return false;
241 }
242
246 virtual bool isFrontOnLane(const MSLane*) const {
247 return true;
248 }
249
254 virtual double getLateralPositionOnLane() const {
255 return 0;
256 }
257
263 virtual double getRightSideOnEdge(const MSLane* lane = 0) const {
264 UNUSED_PARAMETER(lane);
265 return 0;
266 }
267
273 virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const {
274 return myCurrEdge;
275 }
276
281 virtual const MSEdge* getRerouteDestination() const {
282 return myRoute->getLastEdge();
283 }
284
287 virtual double getTimeLossSeconds() const {
288 // better timeLoss for meso?
289 return 0;
290 }
291
298 double getWaitingSeconds() const {
299 return STEPS2TIME(getWaitingTime());
300 }
301
302
303
308 return myCurrEdge;
309 }
310
311
322 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);
323
324
337 bool replaceRouteEdges(ConstMSEdgeVector& edges, double cost, double savings, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true,
338 std::string* msgReturn = nullptr);
339
351 virtual bool replaceRoute(ConstMSRoutePtr route, const std::string& info, bool onInit = false, int offset = 0, bool addRouteStops = true, bool removeStops = true,
352 std::string* msgReturn = nullptr);
353
359 virtual double getAcceleration() const;
360
366 void onDepart();
367
371 inline SUMOTime getDeparture() const {
372 return myDeparture;
373 }
374
376 SUMOTime getDepartDelay() const;
377
380 virtual double getStopDelay() const {
382 return -1;
383 }
384
387 virtual double getStopArrivalDelay() const {
389 return INVALID_DOUBLE;
390 }
391
393 virtual std::pair<double, double> estimateTimeToNextStop() const {
394 return std::make_pair(-1, -1);
395 }
396
400 inline double getDepartPos() const {
401 return myDepartPos;
402 }
403
408 virtual double getArrivalPos() const {
409 return myArrivalPos;
410 }
411
412 virtual int getArrivalLane() const {
413 return myArrivalLane;
414 }
415
418 virtual void setArrivalPos(double arrivalPos) {
419 myArrivalPos = arrivalPos;
420 }
421
429 virtual void onRemovalFromNet(const MSMoveReminder::Notification /*reason*/) {}
430
433 inline bool hasDeparted() const {
435 }
436
440 virtual bool hasArrived() const;
441
443 int getRoutePosition() const;
444
446 int getNumRemainingEdges() const;
447
448 int getArrivalIndex() const {
449 return myParameter->arrivalEdge;
450 }
451
453 void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure);
454
458 double getOdometer() const;
459
461 void addToOdometer(double value) {
462 myOdometer += value;
463 }
464
468 inline int getNumberReroutes() const {
469 return myNumberReroutes;
470 }
471
473 double getImpatience() const;
474
478 int getPersonNumber() const;
479
483 int getLeavingPersonNumber() const;
484
488 std::vector<std::string> getPersonIDList() const;
489
493 int getContainerNumber() const;
494
495
499 inline const std::vector<MSVehicleDevice*>& getDevices() const {
500 return myDevices;
501 }
502
504 bool allowsBoarding(const MSTransportable* t) const;
505
510 virtual void addTransportable(MSTransportable* transportable);
511
514
517
520
522 const std::vector<MSTransportable*>& getPersons() const;
523
525 const std::vector<MSTransportable*>& getContainers() const;
526
528 bool isLineStop(double position) const;
529
531 bool hasJump(const MSRouteIterator& it) const;
532
538 bool hasValidRoute(std::string& msg, ConstMSRoutePtr route = 0) const;
539
540 bool hasValidRoute(std::string& msg, MSRouteIterator start, MSRouteIterator last, bool checkJumps) const;
541
543 virtual bool hasValidRouteStart(std::string& msg);
544
546 int getRouteValidity(bool update = true, bool silent = false, std::string* msgReturn = nullptr);
547
549 bool hasReminder(MSMoveReminder* rem) const;
550
556 void addReminder(MSMoveReminder* rem, double pos = 0);
557
564
576 virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
577
578
582 inline double getLength() const {
583 return myType->getLength();
584 }
585
586 /* @brief Return whether this vehicle must be treated like a railway vehicle
587 * either due to its vClass or the vClass of it's edge */
588 bool isRail() const;
589
593 inline double getWidth() const {
594 return myType->getWidth();
595 }
596
597
601 inline double getChosenSpeedFactor() const {
602 return myChosenSpeedFactor;
603 }
604
605 inline double getDesiredMaxSpeed() const {
607 }
608
612 inline void setChosenSpeedFactor(const double factor) {
613 myChosenSpeedFactor = factor;
614 }
615
617 MSDevice* getDevice(const std::type_info& type) const;
618
619
628 virtual void replaceVehicleType(const MSVehicleType* type);
629
630 virtual std::unique_ptr<MFXOptionalLock> getScopeLock() {
631 return std::unique_ptr<MFXOptionalLock>(new MFXNoOpLock());
632 }
633
642
644
645
647 virtual void saveState(OutputDevice& out);
648
650
651 virtual bool handleCollisionStop(MSStop& stop, const double distToStop);
652
656 bool isStopped() const;
657
661 bool isParking() const;
662
666 bool isJumping() const;
667
671 inline bool isReversed() const {
672 return myAmReversed;
673 }
674
678 bool isStoppedTriggered() const;
679
683 bool isStoppedParking() const;
684
687 bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture = false) const;
688
692 bool hasStops() const {
693 return !myStops.empty();
694 }
695
696
699
702 bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg);
703
707
710
712 const std::vector<std::string>& getParkingBadges() const;
713
715 double basePos(const MSEdge* edge) const;
716
723 bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0,
724 MSRouteIterator* searchStart = nullptr);
725
733 void addStops(const bool ignoreStopErrors, MSRouteIterator* searchStart = nullptr, bool addRouteStops = true);
734
736 bool haveValidStopEdges(bool silent = false) const;
737
739 std::vector<std::pair<int, double> > getStopIndices() const;
740
745 inline const std::list<MSStop>& getStops() const {
746 return myStops;
747 }
748
749 inline const StopParVector& getPastStops() const {
750 return myPastStops;
751 }
752
757 const MSStop& getNextStop() const;
758
764
767
772 MSStop& getStop(int nextStopIndex);
773
776
783 virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string& errorMsg);
784
789 virtual bool resumeFromStopping() = 0;
790
792 void unregisterWaiting();
793
795 bool abortNextStop(int nextStopIndex = 0);
796
808 bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string& info, bool teleport, std::string& errorMsg);
809
817 bool rerouteBetweenStops(int nextStopIndex, const std::string& info, bool teleport, std::string& errorMsg);
818
829 bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string& info, bool teleport, std::string& errorMsg);
830
831
833 virtual bool isSelected() const {
834 return false;
835 }
836
837 virtual void updateBestLanes(bool forceRebuild = false, const MSLane* startLane = 0) {
838 UNUSED_PARAMETER(forceRebuild);
839 UNUSED_PARAMETER(startLane);
840 }
841
843 int getRNGIndex() const;
844
846 SumoRNG* getRNG() const;
847
849 return myNumericalID;
850 }
851
853 long long int getRandomSeed() const {
854 return myRandomSeed;
855 }
856
858 return myPersonDevice;
859 }
860
864
867
869
870
875 template<PollutantsInterface::EmissionType ET>
876 double getEmissions() const {
877 if (isOnRoad() || isIdling()) {
879 }
880 return 0.;
881 }
882
887 double getStateOfCharge() const;
888
892 double getRelativeStateOfCharge() const;
893
897 double getChargedEnergy() const;
898
902 double getMaxChargeRate() const;
903
909 double getElecHybridCurrent() const;
910
914 double getHarmonoise_NoiseEmissions() const;
916
930 public:
933
935 virtual ~BaseInfluencer() {}
936
938 static void init();
940 static void cleanup();
941
942
944 double getExtraImpatience() const {
945 return myExtraImpatience;
946 }
947
951 void setExtraImpatience(double value) {
952 myExtraImpatience = value;
953 }
954
955 protected:
958
959 };
960
961
962
969
970 virtual const BaseInfluencer* getBaseInfluencer() const = 0;
971
972 virtual bool hasInfluencer() const = 0;
973
975 int getRoutingMode() const {
976 return myRoutingMode;
977 }
978
982 void setRoutingMode(int value) {
983 myRoutingMode = value;
984 }
985
986
988
996
1005 virtual std::pair<const MSVehicle* const, double> getLeader(double dist = 0, bool considerCrossingFoes = true) const {
1006 UNUSED_PARAMETER(dist);
1007 UNUSED_PARAMETER(considerCrossingFoes);
1008 WRITE_WARNING(TL("getLeader not yet implemented for meso"));
1009 return std::make_pair(nullptr, -1);
1010 }
1011
1020 virtual std::pair<const MSVehicle* const, double> getFollower(double dist = 0) const {
1021 UNUSED_PARAMETER(dist);
1022 WRITE_WARNING(TL("getFollower not yet implemented for meso"));
1023 return std::make_pair(nullptr, -1);
1024 }
1025
1028 void calculateArrivalParams(bool onInit);
1029
1032
1033 int getDepartEdge() const;
1034
1035 int getInsertionChecks() const;
1036
1039
1041
1042 void rememberBlockedParkingArea(const MSStoppingPlace* pa, bool local);
1043 SUMOTime sawBlockedParkingArea(const MSStoppingPlace* pa, bool local) const;
1044 void rememberBlockedChargingStation(const MSStoppingPlace* cs, bool local);
1045 SUMOTime sawBlockedChargingStation(const MSStoppingPlace* cs, bool local) const;
1046
1048 void rememberParkingAreaScore(const MSStoppingPlace* pa, const std::string& score);
1050 void rememberChargingStationScore(const MSStoppingPlace* cs, const std::string& score);
1052
1055 }
1058 }
1059
1061 return myParkingMemory;
1062 }
1063
1065 return myChargingMemory;
1066 }
1068
1070
1071 StopEdgeInfo(const MSEdge* _edge, double _priority, SUMOTime _arrival, double _pos, bool _isSink = false):
1072 edge(_edge), pos(_pos),
1073 priority(_priority),
1074 arrival(_arrival),
1075 isSink(_isSink) {}
1076
1077 const MSEdge* edge;
1078 double pos;
1079 double priority;
1084 int routeIndex = -1;
1085 bool skipped = false;
1086 bool backtracked = false;
1089 std::pair<std::string, SumoXMLTag> nameTag;
1091 const MSEdge* origEdge = nullptr;
1092
1093 bool operator==(const StopEdgeInfo& o) const {
1094 return edge == o.edge;
1095 }
1096 bool operator!=(const StopEdgeInfo& o) const {
1097 return !(*this == o);
1098 }
1099 };
1100
1101protected:
1103 virtual void resetApproachOnReroute() {};
1104
1108 std::vector<StopEdgeInfo> getStopEdges(double& firstPos, double& lastPos, std::set<int>& jumps) const;
1109
1110 static double addStopPriority(double p1, double p2);
1111
1113 bool replaceWithAlternative(std::list<MSStop>::iterator iter, const MSRouteIterator searchStart, const MSRouteIterator end);
1114
1115protected:
1118
1121
1124
1127
1130
1132 std::list<MSStop> myStops;
1133
1136
1139
1141 // The double value holds the relative position offset, i.e.,
1142 // offset + vehicle-position - moveReminder-position = distance,
1143 // i.e. the offset is counted up when the vehicle continues to a
1144 // succeeding lane.
1145 typedef std::vector< std::pair<MSMoveReminder*, double> > MoveReminderCont;
1146
1150
1152 std::vector<MSVehicleDevice*> myDevices;
1153
1156
1159
1162
1165
1168
1171
1174
1177
1180
1183
1186
1191
1194
1195 /* @brief magic value for undeparted vehicles
1196 * @note: in previous versions this was -1
1197 */
1199
1200 static std::vector<MSTransportable*> myEmptyTransportableVector;
1201
1202 /* @brief The logical 'reversed' state of the vehicle - intended to be used by drawing functions
1203 * @note: only set by vClass rail reversing at the moment
1204 */
1205 bool myAmReversed = false;
1206
1209
1210private:
1212
1213 const long long int myRandomSeed;
1214
1215 /* @brief The vehicle's knowledge about edge efforts/travel times; @see MSEdgeWeightsStorage
1216 * @note member is initialized on first access */
1218
1220
1222
1225
1227 std::string getFlowID() const;
1228
1230 void checkRouteRemoval();
1231
1233 bool insertJump(int nextStopIndex, MSRouteIterator itStart, std::string& errorMsg);
1234
1236 void setSkips(MSStop& stop, int prevActiveStops);
1237
1240
1241private:
1244
1245#ifdef _DEBUG
1246public:
1247 static void initMoveReminderOutput(const OptionsCont& oc);
1248
1249protected:
1251 void traceMoveReminder(const std::string& type, MSMoveReminder* rem, double pos, bool keep) const;
1252
1254 const bool myTraceMoveReminders;
1255private:
1257 static std::set<std::string> myShallTraceMoveReminders;
1258#endif
1259
1260
1261};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition MSRoute.h:57
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
#define STEPS2TIME(x)
Definition SUMOTime.h:58
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
DepartLaneDefinition
Possible ways to choose a lane on depart.
std::vector< SUMOVehicleParameter::Stop > StopParVector
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
An upper class for objects with additional parameters.
A MSVehicle extended by some values for usage within the gui.
void setExtraImpatience(double value)
Sets routing behavior.
double getExtraImpatience() const
return the current routing mode
static void cleanup()
Static cleanup.
static void init()
Static initalization.
virtual ~BaseInfluencer()
Destructor.
double myExtraImpatience
dynamic impatience offset
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
bool haveValidStopEdges(bool silent=false) const
check whether all stop.edge MSRouteIterators are valid and in order
int myRoutingMode
routing mode (see TraCIConstants.h)
bool hasJump(const MSRouteIterator &it) const
check wether the vehicle has jump at the given part of its route
double getDepartPos() const
Returns this vehicle's real departure position.
ConstMSRoutePtr getRoutePtr() const
Returns the current route.
virtual bool isSelected() const
whether this vehicle is selected in the GUI
bool hasReminder(MSMoveReminder *rem) const
Checks whether the vehilce has the given MoveReminder.
static double addStopPriority(double p1, double p2)
virtual bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
std::list< MSStop > myStops
The vehicle's list of stops.
StoppingPlaceMemory * myParkingMemory
memory for parking search
double getImpatience() const
Returns this vehicles impatience.
void setSkips(MSStop &stop, int prevActiveStops)
patch stop.pars.index to record the number of skipped candidate edges before stop....
virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
const StoppingPlaceMemory * getParkingMemory() const
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
virtual void initDevices()
void rememberParkingAreaScore(const MSStoppingPlace *pa, const std::string &score)
score only needed when running with gui
const long long int myRandomSeed
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
int getDepartEdge() const
Returns the edge on which this vehicle shall depart.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
virtual double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
StoppingPlaceMemory * myChargingMemory
const std::vector< MSVehicleDevice * > & getDevices() const
Returns this vehicle's devices.
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
int getLeavingPersonNumber() const
Returns the number of leaving persons.
void calculateArrivalParams(bool onInit)
(Re-)Calculates the arrival position and lane from the vehicle parameters
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
void setCarFollowModelParameter(const std::string &key, const std::string &value)
set individual carFollow model parameters (not type related)
void setRoutingMode(int value)
Sets routing behavior.
void resetParkingAreaScores()
static NumericalID myCurrentNumericalIndex
virtual double getStopDelay() const
Returns the estimated public transport stop (departure) delay in seconds.
bool rerouteBetweenStops(int nextStopIndex, const std::string &info, bool teleport, std::string &errorMsg)
MoveReminderCont myMoveReminders
Currently relevant move reminders.
void rememberChargingStationScore(const MSStoppingPlace *cs, const std::string &score)
int getInsertionChecks() const
double myDepartPos
The real depart position.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getMaxChargeRate() const
Returns the maximum charge rate allowed by the battery in the current time step (W)
virtual const BaseInfluencer * getBaseInfluencer() const =0
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
void rememberBlockedParkingArea(const MSStoppingPlace *pa, bool local)
int getNumberParkingReroutes() const
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
virtual const MSEdge * getCurrentEdge() const
Returns the edge the vehicle is currently at (possibly an internal edge)
double getPreviousSpeed() const
Returns the vehicle's previous speed.
void removeTransportableMass(MSTransportable *t)
removes a person or containers mass
MSStop & getNextStopMutable()
virtual void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
bool isReversed() const
Returns whether the logical state of the vehicle is reversed - for drawing.
virtual void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
virtual BaseInfluencer & getBaseInfluencer()=0
Returns the velocity/lane influencer.
const SUMOVehicleParameter::Stop * getNextStopParameter() const
return parameters for the next stop (SUMOVehicle Interface)
void rememberBlockedChargingStation(const MSStoppingPlace *cs, bool local)
std::vector< std::pair< MSMoveReminder *, double > > MoveReminderCont
Definition of a move reminder container.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual double getTimeLossSeconds() const
Returns the time loss in seconds.
SUMOTime activateRemindersOnReroute(SUMOTime currentTime)
remove outdated driveways on reroute
int getNumRemainingEdges() const
return the number of edges remaining in the route (include the current)
double getOdometer() const
Returns the distance that was already driven by this vehicle.
bool isRail() const
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
const NumericalID myNumericalID
bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture=false) const
return whether the given position is within range of the current stop
bool isJumping() const
Returns whether the vehicle is perform a jump.
void checkRouteRemoval()
remove route at the end of the simulation
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSVehicleType * myType
This vehicle's type.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
bool isStoppedParking() const
Returns whether the vehicle is on a parking stop.
void setNumberParkingReroutes(int value)
void unregisterWaiting()
mark vehicle as active
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const
Returns the information whether the vehicle is fully controlled via TraCI.
bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const
Validates the current or given route.
void cleanupParkingReservation()
unregisters from a parking reservation when changing or skipping stops
virtual void onRemovalFromNet(const MSMoveReminder::Notification)
Called when the vehicle is removed from the network.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
MSParkingArea * getCurrentParkingArea()
get the current parking area stop or nullptr
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSBaseVehicle & operator=(const MSBaseVehicle &s)=delete
invalidated assignment operator
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
virtual int getArrivalLane() const
int getPersonNumber() const
Returns the number of persons.
double getRelativeStateOfCharge() const
Returns actual relative state of charge of battery (-)
virtual std::unique_ptr< MFXOptionalLock > getScopeLock()
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
void setDepartAndArrivalEdge()
apply departEdge and arrivalEdge attributes
void setID(const std::string &newID)
set the id (inherited from Named but forbidden for vehicles)
MSRouteIterator myCurrEdge
Iterator to current route-edge.
static MSLane * interpretOppositeStop(SUMOVehicleParameter::Stop &stop)
interpret stop lane on opposite side of the road
StopParVector myPastStops
The list of stops that the vehicle has already reached.
virtual const MSEdge * getNextEdgePtr() const
returns the next edge (possibly an internal edge)
static std::vector< MSTransportable * > myEmptyTransportableVector
const std::vector< std::string > & getParkingBadges() const
get the valid parking access rights (vehicle settings override vehicle type settings)
bool hasDeparted() const
Returns whether this vehicle has already departed.
bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
virtual void resetApproachOnReroute()
reset rail signal approach information
ConstMSRoutePtr myRoute
This vehicle's route.
virtual std::pair< double, double > estimateTimeToNextStop() const
return time (s) and distance to the next stop
double getWidth() const
Returns the vehicle's width.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
const std::list< MSStop > & getStops() const
void resetChargingStationScores()
bool allowsBoarding(const MSTransportable *t) const
whether the given transportable is allowed to board this vehicle
double getStateOfCharge() const
Returns actual state of charge of battery (Wh) RICE_CHECK: This may be a misnomer,...
MSEdgeWeightsStorage & _getWeightsStorage() const
virtual bool handleCollisionStop(MSStop &stop, const double distToStop)
bool isVehicle() const
Whether it is a vehicle.
double getDesiredMaxSpeed() const
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given name
void addReminder(MSMoveReminder *rem, double pos=0)
Adds a MoveReminder dynamically.
SumoRNG * getRNG() const
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
const MSDevice_Transportable * getPersonDevice() const
SUMOTime sawBlockedChargingStation(const MSStoppingPlace *cs, bool local) const
EnergyParams * getEmissionParameters() const
retrieve parameters for the energy consumption model
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
virtual std::pair< const MSVehicle *const, double > getLeader(double dist=0, bool considerCrossingFoes=true) const
Returns the leader of the vehicle looking for a fixed distance.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
void addToOdometer(double value)
Manipulate the odometer.
std::string getFlowID() const
reconstruct flow id from vehicle id
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
bool isLineStop(double position) const
returns whether the vehicle serves a public transport line that serves the given stop
double myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit.
const MSStop & getNextStop() const
@ ROUTE_INVALID
route was checked and is valid
@ ROUTE_START_INVALID_PERMISSIONS
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
bool replaceWithAlternative(std::list< MSStop >::iterator iter, const MSRouteIterator searchStart, const MSRouteIterator end)
replace stop with a same-name alternative that is on the route and return success
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr, bool addRouteStops=true)
Adds stops to the built vehicle.
void removeTransportable(MSTransportable *t)
removes a person or container
SUMOTime sawBlockedParkingArea(const MSStoppingPlace *pa, bool local) const
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
MSParkingArea * getNextParkingArea()
get the upcoming parking area stop or nullptr
int myArrivalLane
The destination lane where the vehicle stops.
int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)
check for route validity at first insertion attempt
MSStop & getStop(int nextStopIndex)
virtual std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
virtual ~MSBaseVehicle()
Destructor.
bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
virtual bool instantStopping() const
whether instant stopping is permitted
SUMOTime myDeparture
The real departure time.
virtual void setArrivalPos(double arrivalPos)
Sets this vehicle's desired arrivalPos for its current route.
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
const SUMOVTypeParameter & getVTypeParameter() const
Returns the vehicle's type parameter.
virtual bool resumeFromStopping()=0
virtual bool hasInfluencer() const =0
whether the vehicle is individually influenced (via TraCI or special parameters)
const std::set< SUMOTrafficObject::NumericalID > getUpcomingEdgeIDs() const
returns the numerical ids of edges to travel
void initTransportableDevice(bool isPerson)
init device during state loading
bool stopsAtEdge(const MSEdge *edge) const
Returns whether the vehicle stops at the given edge.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, MSRouteIterator *searchStart=nullptr)
Adds a stop.
double getChargedEnergy() const
Returns the energy charged to the battery in the current time step (Wh)
NumericalID getNumericalID() const
return the numerical ID which is only for internal usage
void onDepart()
Called when the vehicle is inserted into the network.
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
SUMOTime getStopDuration() const
get remaining stop duration or 0 if the vehicle isn't stopped
virtual double getAcceleration() const
Returns the vehicle's acceleration.
virtual double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
const MSRoute & getRoute() const
Returns the current route.
int getRoutingMode() const
return routing mode (configures router choice but also handling of transient permission changes)
int getRoutePosition() const
return index of edge within route
virtual const MSEdge * getRerouteDestination() const
Returns the end point for reroutes (usually the last edge of the route)
const MSDevice_Transportable * getContainerDevice() const
bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
static const SUMOTime NOT_YET_DEPARTED
const StopParVector & getPastStops() const
SUMOTime getDepartDelay() const
Returns the depart delay.
double getEmissions() const
Returns emissions of the current state The value is always per 1s, so multiply by step length if nece...
double getElecHybridCurrent() const
Returns actual current (A) of ElecHybrid device RICE_CHECK: Is this the current consumed from the ove...
bool myAmRegisteredAsWaiting
Whether this vehicle is registered as waiting for a person or container (for deadlock-recognition)
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
EnergyParams * myEnergyParams
The emission parameters this vehicle may have.
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
virtual bool hasValidRouteStart(std::string &msg)
checks wether the vehicle can depart on the first edge
int myRouteValidity
status of the current vehicle route
std::vector< std::pair< int, double > > getStopIndices() const
return list of route indices for the remaining stops
virtual bool isFrontOnLane(const MSLane *) const
Returns the information whether the front of the vehhicle is on the given lane.
SUMOTime myStopUntilOffset
The offset when adding route stops with 'until' on route replacement.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
long long int getRandomSeed() const
return vehicle-specific random number
const std::vector< MSTransportable * > & getContainers() const
retrieve riding containers
const StoppingPlaceMemory * getChargingMemory() const
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)
Performs a rerouting using the given router.
bool stopsAt(MSStoppingPlace *stop) const
Returns whether the vehicle stops at the given stopping place.
int getRNGIndex() const
MSEdgeWeightsStorage * myEdgeWeights
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void createDevice(const std::string &deviceName)
create device of the given type
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
int getArrivalIndex() const
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
bool insertJump(int nextStopIndex, MSRouteIterator itStart, std::string &errorMsg)
helper function
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
virtual void replaceVehicleType(const MSVehicleType *type)
Replaces the current vehicle type by the one given.
std::vector< StopEdgeInfo > getStopEdges(double &firstPos, double &lastPos, std::set< int > &jumps) const
Returns the list of still pending stop edges also returns the first and last stop position.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
void initTransientModelParams()
init model parameters from generic params
int getContainerNumber() const
Returns the number of containers.
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)
Replaces the current route by the given edges.
A device which collects vehicular emissions.
Abstract in-vehicle / in-person device.
Definition MSDevice.h:62
A road/street connecting two junctions.
Definition MSEdge.h:77
A storage for edge travel times and efforts.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
A lane area vehicles can halt at.
A lane area vehicles can halt at.
Abstract in-vehicle device.
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getDesiredMaxSpeed() const
Returns the vehicles's desired maximum speed.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
double getLength() const
Get vehicle's length [m].
const SUMOVTypeParameter & getParameter() const
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const EnergyParams *param)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
long long int NumericalID
virtual double getSpeed() const =0
Returns the object's current speed.
virtual SUMOTime getWaitingTime(const bool accumulated=false) const =0
virtual bool isPerson() const
Whether it is a person.
Structure representing possible vehicle parameter.
SUMOVehicleClass vehicleClass
The vehicle's class.
Representation of a vehicle.
Definition SUMOVehicle.h:63
virtual bool isIdling() const =0
Returns whether the vehicle is idling (waiting to re-enter the net.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
int arrivalEdge
(optional) The final edge within the route of the vehicle
#define UNUSED_PARAMETER(x)
std::pair< std::string, SumoXMLTag > nameTag
optional info about stopping place
bool operator==(const StopEdgeInfo &o) const
bool operator!=(const StopEdgeInfo &o) const
const SUMOVehicleParameter::Stop * stopPar
const MSEdge * origEdge
set when replacing stop with an alternative
StopEdgeInfo(const MSEdge *_edge, double _priority, SUMOTime _arrival, double _pos, bool _isSink=false)
int routeIndex
values set during routing and used during optimization