Eclipse SUMO - Simulation of Urban MObility
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-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 // A base class for vehicle implementations
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <iostream>
26 #include <vector>
27 #include <set>
28 #include <utils/common/StdDefs.h>
32 #include "MSRoute.h"
33 #include "MSMoveReminder.h"
34 #include "MSVehicleType.h"
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSLane;
41 class MSStop;
43 class MSDevice_Emissions;
44 class MSVehicleDevice;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
55 class MSBaseVehicle : public SUMOVehicle {
56 public:
57  // XXX: This definition was introduced to make the MSVehicle's previousSpeed
58  // available in the context of MSMoveReminder::notifyMove(). Another solution
59  // would be to modify notifyMove()'s interface to work with MSVehicle instead
60  // of SUMOVehicle (it is only called with MSVehicles!). Refs. #2579
64  double getPreviousSpeed() const;
65 
66  friend class GUIBaseVehicle;
67 
72  ROUTE_UNCHECKED = 1 << 0,
74  ROUTE_INVALID = 1 << 1,
75  // starting edge permissions invalid (could change)
77  // insertion lane does not exist
79  };
80 
89  MSVehicleType* type, const double speedFactor);
90 
91 
93  virtual ~MSBaseVehicle();
94 
95  virtual void initDevices();
96 
97  bool isVehicle() const {
98  return true;
99  }
100 
102  void setID(const std::string& newID);
103 
108  const SUMOVehicleParameter& getParameter() const;
109 
111  std::string getPrefixedParameter(const std::string& key, std::string& error) const;
112 
114  void replaceParameter(const SUMOVehicleParameter* newParameter);
115 
117  bool hasDevice(const std::string& deviceName) const;
118 
120  void createDevice(const std::string& deviceName);
121 
123  std::string getDeviceParameter(const std::string& deviceName, const std::string& key) const;
124 
126  void setDeviceParameter(const std::string& deviceName, const std::string& key, const std::string& value);
127 
129  void setJunctionModelParameter(const std::string& key, const std::string& value);
130 
132  void setCarFollowModelParameter(const std::string& key, const std::string& value);
133 
137  inline const MSRoute& getRoute() const {
138  return *myRoute;
139  }
140 
144  inline ConstMSRoutePtr getRoutePtr() const {
145  return myRoute;
146  }
147 
151  inline const MSVehicleType& getVehicleType() const {
152  return *myType;
153  }
154 
158  inline SUMOVehicleClass getVClass() const {
159  return myType->getParameter().vehicleClass;
160  }
161 
165  bool ignoreTransientPermissions() const;
166 
170  double getMaxSpeed() const;
171 
179  const MSEdge* succEdge(int nSuccs) const;
180 
185  const MSEdge* getEdge() const;
186 
190  virtual const MSEdge* getCurrentEdge() const {
191  return getEdge();
192  }
193 
195  const std::set<SUMOTrafficObject::NumericalID> getUpcomingEdgeIDs() const;
196 
198  bool stopsAt(MSStoppingPlace* stop) const;
199 
201  bool stopsAtEdge(const MSEdge* edge) const;
202 
204  virtual const MSEdge* getNextEdgePtr() const {
205  return nullptr;
206  }
207 
211  virtual bool isOnRoad() const {
212  return true;
213  }
214 
219  virtual bool isRemoteControlled() const {
220  return false;
221  }
222 
223  virtual bool wasRemoteControlled(SUMOTime lookBack = DELTA_T) const {
224  UNUSED_PARAMETER(lookBack);
225  return false;
226  }
227 
231  virtual bool isFrontOnLane(const MSLane*) const {
232  return true;
233  }
234 
239  virtual double getLateralPositionOnLane() const {
240  return 0;
241  }
242 
248  virtual double getRightSideOnEdge(const MSLane* lane = 0) const {
249  UNUSED_PARAMETER(lane);
250  return 0;
251  }
252 
258  virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const {
259  return myCurrEdge;
260  }
261 
266  virtual const MSEdge* getRerouteDestination() const {
267  return myRoute->getLastEdge();
268  }
269 
272  virtual double getTimeLossSeconds() const {
273  // better timeLoss for meso?
274  return 0;
275  }
276 
283  double getWaitingSeconds() const {
284  return STEPS2TIME(getWaitingTime());
285  }
286 
287 
288 
293  return myCurrEdge;
294  }
295 
296 
307  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);
308 
309 
322  bool replaceRouteEdges(ConstMSEdgeVector& edges, double cost, double savings, const std::string& info, bool onInit = false, bool check = false, bool removeStops = true,
323  std::string* msgReturn = nullptr);
324 
335  virtual bool replaceRoute(ConstMSRoutePtr route, const std::string& info, bool onInit = false, int offset = 0, bool addStops = true, bool removeStops = true,
336  std::string* msgReturn = nullptr);
337 
343  virtual double getAcceleration() const;
344 
350  void onDepart();
351 
355  inline SUMOTime getDeparture() const {
356  return myDeparture;
357  }
358 
360  SUMOTime getDepartDelay() const;
361 
364  virtual double getStopDelay() const {
366  return -1;
367  }
368 
371  virtual double getStopArrivalDelay() const {
373  return INVALID_DOUBLE;
374  }
375 
379  inline double getDepartPos() const {
380  return myDepartPos;
381  }
382 
387  virtual double getArrivalPos() const {
388  return myArrivalPos;
389  }
390 
391  virtual int getArrivalLane() const {
392  return myArrivalLane;
393  }
394 
397  virtual void setArrivalPos(double arrivalPos) {
398  myArrivalPos = arrivalPos;
399  }
400 
408  virtual void onRemovalFromNet(const MSMoveReminder::Notification /*reason*/) {}
409 
412  inline bool hasDeparted() const {
413  return myDeparture != NOT_YET_DEPARTED;
414  }
415 
419  virtual bool hasArrived() const;
420 
422  int getRoutePosition() const;
423 
425  void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure);
426 
430  double getOdometer() const;
431 
433  void addToOdometer(double value) {
434  myOdometer += value;
435  }
436 
440  inline int getNumberReroutes() const {
441  return myNumberReroutes;
442  }
443 
445  double getImpatience() const;
446 
450  int getPersonNumber() const;
451 
455  int getLeavingPersonNumber() const;
456 
460  std::vector<std::string> getPersonIDList() const;
461 
465  int getContainerNumber() const;
466 
467 
471  inline const std::vector<MSVehicleDevice*>& getDevices() const {
472  return myDevices;
473  }
474 
476  bool allowsBoarding(const MSTransportable* t) const;
477 
482  virtual void addTransportable(MSTransportable* transportable);
483 
486 
488  const std::vector<MSTransportable*>& getPersons() const;
489 
491  const std::vector<MSTransportable*>& getContainers() const;
492 
494  bool isLineStop(double position) const;
495 
497  bool hasJump(const MSRouteIterator& it) const;
498 
504  bool hasValidRoute(std::string& msg, ConstMSRoutePtr route = 0) const;
505 
507  virtual bool hasValidRouteStart(std::string& msg);
508 
510  int getRouteValidity(bool update = true, bool silent = false, std::string* msgReturn = nullptr);
511 
517  void addReminder(MSMoveReminder* rem);
518 
524  void removeReminder(MSMoveReminder* rem);
525 
537  virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
538 
539 
543  inline double getLength() const {
544  return myType->getLength();
545  }
546 
547 
551  inline double getWidth() const {
552  return myType->getWidth();
553  }
554 
555 
559  inline double getChosenSpeedFactor() const {
560  return myChosenSpeedFactor;
561  }
562 
566  inline void setChosenSpeedFactor(const double factor) {
567  myChosenSpeedFactor = factor;
568  }
569 
571  MSDevice* getDevice(const std::type_info& type) const;
572 
573 
582  virtual void replaceVehicleType(MSVehicleType* type);
583 
584 
593 
595 
596 
598  virtual void saveState(OutputDevice& out);
599 
601 
602  virtual bool handleCollisionStop(MSStop& stop, const double distToStop);
603 
607  bool isStopped() const;
608 
612  bool isParking() const;
613 
617  bool isJumping() const;
618 
622  inline bool isReversed() const {
623  return myAmReversed;
624  }
625 
629  bool isStoppedTriggered() const;
630 
634  bool isStoppedParking() const;
635 
638  bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture = false) const;
639 
643  bool hasStops() const {
644  return !myStops.empty();
645  }
646 
649  bool replaceParkingArea(MSParkingArea* parkingArea, std::string& errorMsg);
650 
654 
657 
659  const std::vector<std::string>& getParkingBadges() const;
660 
662  double basePos(const MSEdge* edge) const;
663 
670  bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0,
671  MSRouteIterator* searchStart = nullptr);
672 
680  void addStops(const bool ignoreStopErrors, MSRouteIterator* searchStart = nullptr, bool addRouteStops = true);
681 
683  bool haveValidStopEdges(bool silent = false) const;
684 
688  const ConstMSEdgeVector getStopEdges(double& firstPos, double& lastPos, std::set<int>& jumps) const;
689 
691  std::vector<std::pair<int, double> > getStopIndices() const;
692 
697  inline const std::list<MSStop>& getStops() const {
698  return myStops;
699  }
700 
701  inline const std::vector<SUMOVehicleParameter::Stop>& getPastStops() const {
702  return myPastStops;
703  }
704 
709  MSStop& getNextStop();
710 
712  SUMOTime getStopDuration() const;
713 
718  MSStop& getStop(int nextStopIndex);
719 
722 
729  virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string& errorMsg);
730 
735  virtual bool resumeFromStopping() = 0;
736 
738  bool abortNextStop(int nextStopIndex = 0);
739 
751  bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string& info, bool teleport, std::string& errorMsg);
752 
760  bool rerouteBetweenStops(int nextStopIndex, const std::string& info, bool teleport, std::string& errorMsg);
761 
772  bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string& info, bool teleport, std::string& errorMsg);
773 
774 
776  virtual bool isSelected() const {
777  return false;
778  }
779 
781  int getRNGIndex() const;
782 
784  SumoRNG* getRNG() const;
785 
786  inline NumericalID getNumericalID() const {
787  return myNumericalID;
788  }
789 
791  return myPersonDevice;
792  }
793 
795  return myContainerDevice;
796  }
797 
800  if (myEnergyParams == nullptr) {
802  }
803  return myEnergyParams;
804  }
805 
807 
808 
813  template<PollutantsInterface::EmissionType ET>
814  double getEmissions() const {
815  if (isOnRoad() || isIdling()) {
817  }
818  return 0.;
819  }
820 
825  double getStateOfCharge() const;
826 
830  double getRelativeStateOfCharge() const;
831 
835  double getChargedEnergy() const;
836 
842  double getElecHybridCurrent() const;
843 
847  double getHarmonoise_NoiseEmissions() const;
849 
863  public:
865  BaseInfluencer();
866 
868  virtual ~BaseInfluencer() {}
869 
871  static void init();
873  static void cleanup();
874 
875 
877  double getExtraImpatience() const {
878  return myExtraImpatience;
879  }
880 
884  void setExtraImpatience(double value) {
885  myExtraImpatience = value;
886  }
887 
888  protected:
890  double myExtraImpatience = 0;
891 
892  };
893 
894 
895 
902 
903  virtual const BaseInfluencer* getBaseInfluencer() const = 0;
904 
905  virtual bool hasInfluencer() const = 0;
906 
908  int getRoutingMode() const {
909  return myRoutingMode;
910  }
911 
915  void setRoutingMode(int value) {
916  myRoutingMode = value;
917  }
918 
919 
921 
929 
937  virtual std::pair<const MSVehicle* const, double> getLeader(double dist = 0) const {
938  UNUSED_PARAMETER(dist);
939  WRITE_WARNING(TL("getLeader not yet implemented for meso"));
940  return std::make_pair(nullptr, -1);
941  }
942 
951  virtual std::pair<const MSVehicle* const, double> getFollower(double dist = 0) const {
952  UNUSED_PARAMETER(dist);
953  WRITE_WARNING(TL("getFollower not yet implemented for meso"));
954  return std::make_pair(nullptr, -1);
955  }
956 
959  void calculateArrivalParams(bool onInit);
960 
963 
966 
968 
969  void rememberBlockedParkingArea(const MSParkingArea* pa, bool local);
970  SUMOTime sawBlockedParkingArea(const MSParkingArea* pa, bool local) const;
971 
973  void rememberParkingAreaScore(const MSParkingArea* pa, const std::string& score);
974  void resetParkingAreaScores();
975 
977  struct PaMemory {
979 
982  std::string score;
983  };
984 
987  }
988  void setNumberParkingReroutes(int value) {
989  myNumberParkingReroutes = value;
990  }
991 
992  typedef std::map<const MSParkingArea*, PaMemory, ComparatorIdLess> ParkingMemory;
994  return myParkingMemory;
995  }
997 
998 protected:
1001 
1004 
1007 
1010 
1013 
1015  std::list<MSStop> myStops;
1016 
1018  std::vector<SUMOVehicleParameter::Stop> myPastStops;
1019 
1020 
1023 
1025  // The double value holds the relative position offset, i.e.,
1026  // offset + vehicle-position - moveReminder-position = distance,
1027  // i.e. the offset is counted up when the vehicle continues to a
1028  // succeeding lane.
1029  typedef std::vector< std::pair<MSMoveReminder*, double> > MoveReminderCont;
1030 
1034 
1036  std::vector<MSVehicleDevice*> myDevices;
1037 
1040 
1043 
1046 
1049 
1051  double myDepartPos;
1052 
1055 
1058 
1061 
1064 
1066  double myOdometer;
1067 
1070 
1074 
1077 
1078  /* @brief magic value for undeparted vehicles
1079  * @note: in previous versions this was -1
1080  */
1082 
1083  static std::vector<MSTransportable*> myEmptyTransportableVector;
1084 
1085  /* @brief The logical 'reversed' state of the vehicle - intended to be used by drawing functions
1086  * @note: only set by vClass rail reversing at the moment
1087  */
1088  bool myAmReversed = false;
1089 
1092 
1093 private:
1095 
1096  /* @brief The vehicle's knowledge about edge efforts/travel times; @see MSEdgeWeightsStorage
1097  * @note member is initialized on first access */
1099 
1101 
1103 
1105  void initTransientModelParams();
1106 
1108  std::string getFlowID() const;
1109 
1111  void checkRouteRemoval();
1112 
1114  bool insertJump(int nextStopIndex, MSRouteIterator itStart, std::string& errorMsg);
1115 
1116 private:
1119 
1120 #ifdef _DEBUG
1121 public:
1122  static void initMoveReminderOutput(const OptionsCont& oc);
1123 
1124 protected:
1126  void traceMoveReminder(const std::string& type, MSMoveReminder* rem, double pos, bool keep) const;
1127 
1129  const bool myTraceMoveReminders;
1130 private:
1132  static std::set<std::string> myShallTraceMoveReminders;
1133 #endif
1134 
1135 
1136 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:56
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:31
SUMOTime DELTA_T
Definition: SUMOTime.cpp:38
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
DepartLaneDefinition
Possible ways to choose a lane on depart.
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
An upper class for objects with additional parameters.
Definition: EnergyParams.h:43
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.
Definition: MSBaseVehicle.h:55
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
virtual const MSEdge * getNextEdgePtr() const
returns the next edge (possibly an internal edge)
ParkingMemory * myParkingMemory
memory for parking search
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
void rememberBlockedParkingArea(const MSParkingArea *pa, bool local)
const MSDevice_Transportable * getPersonDevice() const
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.
double getImpatience() const
Returns this vehicles impatience.
virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
virtual void initDevices()
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
std::map< const MSParkingArea *, PaMemory, ComparatorIdLess > ParkingMemory
virtual double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
virtual BaseInfluencer & getBaseInfluencer()=0
Returns the velocity/lane influencer.
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...
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.
MSBaseVehicle(SUMOVehicleParameter *pars, ConstMSRoutePtr route, MSVehicleType *type, const double speedFactor)
Constructor.
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()
MSVehicleType * myType
This vehicle's type.
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.
double myDepartPos
The real depart position.
const std::list< MSStop > & getStops() const
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
virtual std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
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.
double getPreviousSpeed() const
Returns the vehicle's previous speed.
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.
const SUMOVehicleParameter::Stop * getNextStopParameter() const
return parameters for the next stop (SUMOVehicle Interface)
std::vector< std::pair< MSMoveReminder *, double > > MoveReminderCont
Definition of a move reminder container.
virtual double getTimeLossSeconds() const
Returns the time loss in seconds.
double getOdometer() const
Returns the distance that was already driven by this vehicle.
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
virtual const MSEdge * getCurrentEdge() const
Returns the edge the vehicle is currently at (possibly an internal edge)
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
SUMOTime sawBlockedParkingArea(const MSParkingArea *pa, bool local) const
virtual void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
bool isStoppedParking() const
Returns whether the vehicle is on a parking stop.
void setNumberParkingReroutes(int value)
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.
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.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
virtual int getArrivalLane() const
int getPersonNumber() const
Returns the number of persons.
virtual std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
double getRelativeStateOfCharge() const
Returns actual relative state of charge of battery (-)
const MSDevice_Transportable * getContainerDevice() const
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)
virtual const MSEdge * getRerouteDestination() const
Returns the end point for reroutes (usually the last edge of the route)
MSRouteIterator myCurrEdge
Iterator to current route-edge.
static MSLane * interpretOppositeStop(SUMOVehicleParameter::Stop &stop)
interpret stop lane on opposite side of the road
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.
MSStop & getNextStop()
bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
ConstMSRoutePtr myRoute
This vehicle's route.
const ConstMSEdgeVector 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 getWidth() const
Returns the vehicle's width.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
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.
Definition: MSBaseVehicle.h:97
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given name
SumoRNG * getRNG() const
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
EnergyParams * getEmissionParameters() const
retrieve parameters for the energy consumption model
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
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.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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
const ParkingMemory * getParkingMemory() const
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.
@ ROUTE_INVALID
route was checked and is valid
Definition: MSBaseVehicle.h:74
@ ROUTE_START_INVALID_LANE
Definition: MSBaseVehicle.h:78
@ ROUTE_START_INVALID_PERMISSIONS
Definition: MSBaseVehicle.h:76
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
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
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 ~MSBaseVehicle()
Destructor.
bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
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.
virtual bool resumeFromStopping()=0
const std::vector< MSVehicleDevice * > & getDevices() const
Returns this vehicle's devices.
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
bool stopsAtEdge(const MSEdge *edge) const
Returns whether the vehicle stops at the given edge.
void rememberParkingAreaScore(const MSParkingArea *pa, const std::string &score)
score only needed when running with gui
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
std::vector< SUMOVehicleParameter::Stop > myPastStops
The list of stops that the vehicle has already reached.
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)
virtual const BaseInfluencer * getBaseInfluencer() const =0
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
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
int myNumberParkingReroutes
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 replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const std::vector< SUMOVehicleParameter::Stop > & getPastStops() const
const std::vector< MSTransportable * > & getContainers() const
retrieve riding containers
const MSRoute & getRoute() const
Returns the current route.
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
MSBaseVehicle & operator=(const MSBaseVehicle &s)=delete
invalidated assignment operator
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.
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.
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.
Definition: MSParkingArea.h:60
Definition: MSStop.h:44
A lane area vehicles can halt at.
Abstract in-vehicle device.
The car-following model and parameter.
Definition: MSVehicleType.h:63
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
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.
Definition: OutputDevice.h:61
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
SUMOVehicleClass vehicleClass
The vehicle's class.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
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.
store information for a single parking area