Eclipse SUMO - Simulation of Urban MObility
SUMOVehicleParameter.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 /****************************************************************************/
21 // Structure representing possible vehicle parameter
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
28 #include <utils/common/RGBColor.h>
29 #include <utils/common/SUMOTime.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class OutputDevice;
37 class OptionsCont;
38 
39 
40 // ===========================================================================
41 // value definitions
42 // ===========================================================================
43 const int VEHPARS_COLOR_SET = 1;
44 const int VEHPARS_VTYPE_SET = 2;
45 const int VEHPARS_DEPARTLANE_SET = 2 << 1;
46 const int VEHPARS_DEPARTPOS_SET = 2 << 2;
47 const int VEHPARS_DEPARTSPEED_SET = 2 << 3;
48 const int VEHPARS_END_SET = 2 << 4;
49 const int VEHPARS_NUMBER_SET = 2 << 5;
50 const int VEHPARS_PERIOD_SET = 2 << 6;
51 const int VEHPARS_VPH_SET = 2 << 7;
52 const int VEHPARS_PROB_SET = 2 << 8;
53 const int VEHPARS_ROUTE_SET = 2 << 9;
54 const int VEHPARS_ARRIVALLANE_SET = 2 << 10;
55 const int VEHPARS_ARRIVALPOS_SET = 2 << 11;
56 const int VEHPARS_ARRIVALSPEED_SET = 2 << 12;
57 const int VEHPARS_LINE_SET = 2 << 13;
58 const int VEHPARS_FROM_TAZ_SET = 2 << 14;
59 const int VEHPARS_TO_TAZ_SET = 2 << 15;
60 const int VEHPARS_FORCE_REROUTE = 2 << 16;
61 const int VEHPARS_PERSON_CAPACITY_SET = 2 << 17;
62 const int VEHPARS_PERSON_NUMBER_SET = 2 << 18;
63 const int VEHPARS_CONTAINER_NUMBER_SET = 2 << 19;
64 const int VEHPARS_DEPARTPOSLAT_SET = 2 << 20;
65 const int VEHPARS_ARRIVALPOSLAT_SET = 2 << 21;
66 const int VEHPARS_VIA_SET = 2 << 22;
67 const int VEHPARS_SPEEDFACTOR_SET = 2 << 23;
68 const int VEHPARS_DEPARTEDGE_SET = 2 << 24;
69 
70 const int STOP_INDEX_END = -1;
71 const int STOP_INDEX_FIT = -2;
72 
73 const int STOP_START_SET = 1;
74 const int STOP_END_SET = 2;
75 const int STOP_DURATION_SET = 2 << 1;
76 const int STOP_UNTIL_SET = 2 << 2;
77 const int STOP_EXTENSION_SET = 2 << 3;
78 const int STOP_TRIGGER_SET = 2 << 4;
79 const int STOP_PARKING_SET = 2 << 5;
80 const int STOP_EXPECTED_SET = 2 << 6;
81 const int STOP_CONTAINER_TRIGGER_SET = 2 << 7;
82 const int STOP_EXPECTED_CONTAINERS_SET = 2 << 8;
83 const int STOP_TRIP_ID_SET = 2 << 9;
84 const int STOP_LINE_SET = 2 << 10;
85 const int STOP_SPEED_SET = 2 << 11;
86 const int STOP_SPLIT_SET = 2 << 12;
87 const int STOP_JOIN_SET = 2 << 13;
88 const int STOP_ARRIVAL_SET = 2 << 14;
89 
90 const double MIN_STOP_LENGTH = 2 * POSITION_EPS;
91 
92 
93 // ===========================================================================
94 // enum definitions
95 // ===========================================================================
113 };
114 
115 
122  DEFAULT,
124  GIVEN,
126  RANDOM,
128  FREE,
130  ALLOWED_FREE,
132  BEST_FREE,
135 };
136 
137 
144  DEFAULT,
146  GIVEN,
148  RANDOM,
150  FREE,
152  BASE,
154  LAST,
156  RANDOM_FREE,
158  STOP
159 };
160 
161 
168  DEFAULT,
170  GIVEN,
172  RIGHT,
174  CENTER,
176  LEFT,
178  RANDOM,
180  FREE,
183 };
184 
185 
192  DEFAULT,
194  GIVEN,
196  RANDOM,
198  MAX,
200  DESIRED,
202  LIMIT
203 };
204 
205 
212  DEFAULT,
214  GIVEN,
216  RANDOM,
217 };
218 
219 
226  DEFAULT,
228  GIVEN,
230  CURRENT
231 };
232 
233 
240  DEFAULT,
242  GIVEN,
244  RANDOM,
246  CENTER,
248  MAX
249 };
250 
251 
258  DEFAULT,
260  GIVEN,
262  RIGHT,
264  CENTER,
266  LEFT
267 };
268 
269 
276  DEFAULT,
278  GIVEN,
280  CURRENT
281 };
282 
283 
284 // ===========================================================================
285 // struct definitions
286 // ===========================================================================
300 public:
306 
308  virtual ~SUMOVehicleParameter();
309 
313  class Stop : public Parameterised {
314  public:
316  virtual ~Stop() {}
317 
323  void write(OutputDevice& dev, bool close = true) const;
324 
326  void writeTriggers(OutputDevice& dev) const;
327 
329  std::string edge;
330 
332  std::string lane;
333 
335  std::string busstop;
336 
338  std::string containerstop;
339 
341  std::string parkingarea;
342 
344  std::string chargingStation;
345 
347  std::string overheadWireSegment;
348 
350  double startPos = 0.;
351 
353  double endPos = 0.;
354 
357 
360 
363 
366 
368  bool triggered = false;
369 
371  bool containerTriggered = false;
372 
374  bool joinTriggered = false;
375 
377  bool parking = false;
378 
380  std::set<std::string> awaitedPersons;
381 
383  std::set<std::string> awaitedContainers;
384 
386  bool friendlyPos = false;
387 
389  std::string actType;
390 
392  std::string tripId;
393 
395  std::string line;
396 
398  std::string split;
399 
401  std::string join;
402 
404  double speed = 0.;
405 
407  mutable SUMOTime actualArrival = -1;
408 
411 
413  std::vector<std::tuple<std::string, double, double> > accessPos;
414 
416  int index = 0;
417 
419  int parametersSet = 0;
420 
421  };
422 
423 
428  bool wasSet(int what) const {
429  return (parametersSet & what) != 0;
430  }
431 
440  void write(OutputDevice& dev, const OptionsCont& oc, const SumoXMLTag tag = SUMO_TAG_VEHICLE, const std::string& typeID = "") const;
441 
447  bool defaultOptionOverrides(const OptionsCont& oc, const std::string& optionName) const;
448 
451 
460  static bool parseDepart(const std::string& val, const std::string& element, const std::string& id,
461  SUMOTime& depart, DepartDefinition& dd, std::string& error);
462 
472  static bool parseDepartLane(const std::string& val, const std::string& element, const std::string& id,
473  int& lane, DepartLaneDefinition& dld, std::string& error);
474 
484  static bool parseDepartPos(const std::string& val, const std::string& element, const std::string& id,
485  double& pos, DepartPosDefinition& dpd, std::string& error);
486 
496  static bool parseDepartPosLat(const std::string& val, const std::string& element, const std::string& id,
497  double& pos, DepartPosLatDefinition& dpd, std::string& error);
498 
508  static bool parseDepartSpeed(const std::string& val, const std::string& element, const std::string& id,
509  double& speed, DepartSpeedDefinition& dsd, std::string& error);
510 
520  static bool parseDepartEdge(const std::string& val, const std::string& element, const std::string& id,
521  int& edgeIndex, DepartEdgeDefinition& ded, std::string& error);
522 
532  static bool parseArrivalLane(const std::string& val, const std::string& element, const std::string& id,
533  int& lane, ArrivalLaneDefinition& ald, std::string& error);
534 
544  static bool parseArrivalPos(const std::string& val, const std::string& element, const std::string& id,
545  double& pos, ArrivalPosDefinition& apd, std::string& error);
546 
556  static bool parseArrivalPosLat(const std::string& val, const std::string& element, const std::string& id,
557  double& pos, ArrivalPosLatDefinition& apd, std::string& error);
558 
559 
569  static bool parseArrivalSpeed(const std::string& val, const std::string& element, const std::string& id,
570  double& speed, ArrivalSpeedDefinition& asd, std::string& error);
572 
580  static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string& id, bool silent = false);
581 
590  static bool parsePersonModes(const std::string& modes, const std::string& element, const std::string& id, SVCPermissions& modeSet, std::string& error);
591 
593  static void parseStopTriggers(const std::vector<std::string>& triggers, bool expectTrigger, Stop& stop);
594 
597 
599  std::string id;
600 
602  std::string routeid;
603 
605  std::string vtypeid;
606 
608  mutable RGBColor color;
609 
614 
617 
620 
623 
625  double departPos;
626 
629 
631  double departPosLat;
632 
635 
637  double departSpeed;
638 
641 
644 
647 
649 
654 
657 
659  double arrivalPos;
660 
663 
666 
669 
671  double arrivalSpeed;
672 
675 
677 
682 
685 
688 
691 
694 
696 
698  mutable std::string line;
699 
701  std::string fromTaz;
702 
704  std::string toTaz;
705 
707  mutable std::vector<Stop> stops;
708 
710  mutable std::vector<std::string> via;
711 
714 
717 
719  double speedFactor;
720 
722  mutable int parametersSet;
723 
724 protected:
726  std::string getDepart() const;
727 
729  std::string getDepartLane() const;
730 
732  std::string getDepartPos() const;
733 
735  std::string getDepartPosLat() const;
736 
738  std::string getDepartSpeed() const;
739 
741  std::string getDepartEdge() const;
742 
744  std::string getArrivalLane() const;
745 
747  std::string getArrivalPos() const;
748 
750  std::string getArrivalPosLat() const;
751 
753  std::string getArrivalSpeed() const;
754 };
long long int SUMOTime
Definition: SUMOTime.h:31
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const int VEHPARS_DEPARTEDGE_SET
const int VEHPARS_PROB_SET
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_INDEX_END
const int VEHPARS_VPH_SET
const int VEHPARS_END_SET
const int VEHPARS_ROUTE_SET
const int VEHPARS_COLOR_SET
const int STOP_EXPECTED_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ RANDOM
The lane is chosen randomly.
@ BEST_FREE
The least occupied lane from best lanes.
@ GIVEN
The lane is given.
@ ALLOWED_FREE
The least occupied lane from lanes which allow the continuation.
@ DEFAULT
No information given; use default.
@ FIRST_ALLOWED
The rightmost lane the vehicle may use.
@ FREE
The least occupied lane is used.
const int VEHPARS_TO_TAZ_SET
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
@ DEFAULT
No information given; use default.
DepartPosLatDefinition
@ RIGHT
At the rightmost side of the lane.
@ DEFAULT
No information given; use default.
@ LEFT
At the leftmost side of the lane.
@ CENTER
At the center of the lane.
DepartPosDefinition
Possible ways to choose the departure position.
@ DEFAULT
No information given; use default.
@ STOP
depart position is endPos of first stop
@ BASE
Back-at-zero position.
@ LAST
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
@ RANDOM_FREE
If a fixed number of random choices fails, a free position is chosen.
const int STOP_SPEED_SET
const int STOP_UNTIL_SET
const int VEHPARS_SPEEDFACTOR_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ DEFAULT
No information given; use default.
@ CURRENT
The current lane shall be used.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int VEHPARS_ARRIVALLANE_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ MAX
The maximum safe speed is used.
@ LIMIT
The maximum lane speed is used (speedLimit)
@ DEFAULT
No information given; use default.
@ DESIRED
The maximum lane speed is used (speedLimit * speedFactor)
const int VEHPARS_DEPARTLANE_SET
const int STOP_SPLIT_SET
const int VEHPARS_ARRIVALPOSLAT_SET
DepartEdgeDefinition
Possible ways to choose the departure edge.
@ DEFAULT
No information given; use default.
const int STOP_START_SET
const int VEHPARS_FROM_TAZ_SET
const int VEHPARS_NUMBER_SET
const int STOP_JOIN_SET
const int VEHPARS_ARRIVALSPEED_SET
const int STOP_CONTAINER_TRIGGER_SET
const int STOP_EXTENSION_SET
const int VEHPARS_FORCE_REROUTE
const int STOP_INDEX_FIT
const int STOP_TRIGGER_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ DEFAULT
No information given; use default.
const int STOP_END_SET
const int VEHPARS_LINE_SET
const double MIN_STOP_LENGTH
const int VEHPARS_PERSON_NUMBER_SET
const int STOP_EXPECTED_CONTAINERS_SET
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_PERIOD_SET
ArrivalPosLatDefinition
Possible ways to choose the departure position.
@ DEFAULT
No information given; use default.
const int VEHPARS_VTYPE_SET
const int VEHPARS_PERSON_CAPACITY_SET
const int VEHPARS_ARRIVALPOS_SET
DepartDefinition
Possible ways to depart.
@ DEPART_SPLIT
The departure is triggered by a train split.
@ DEPART_GIVEN
The time is given.
@ DEPART_DEF_MAX
Tag for the last element in the enum for safe int casting.
@ DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
@ DEPART_TRIGGERED
The departure is person triggered.
@ DEPART_NOW
The vehicle is discarded if emission fails (not fully implemented yet)
const int VEHPARS_VIA_SET
const int VEHPARS_DEPARTPOSLAT_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VEHICLE
description of a vehicle
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
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:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
Definition of vehicle stop (position and duration)
std::string edge
The edge to stop at (used only in NETEDIT)
std::string lane
The lane to stop at.
void write(OutputDevice &dev, bool close=true) const
Writes the stop as XML.
SUMOTime extension
The maximum time extension for boarding / loading.
bool friendlyPos
enable or disable friendly position (used by NETEDIT)
SUMOTime depart
the time at which this stop was ended
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
int parametersSet
Information for the output which parameter were set.
int index
at which position in the stops list
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
void writeTriggers(OutputDevice &dev) const
write trigger attribute
SUMOTime actualArrival
the time at which this stop was reached
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by NETEDIT)
bool triggered
whether an arriving person lets the vehicle continue
double endPos
The stopping position end.
std::vector< std::tuple< std::string, double, double > > accessPos
lanes and positions connected to this stop (only used by duarouter where Stop is used to store stoppi...
bool parking
whether the vehicle is removed from the net while stopping
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
bool joinTriggered
whether an joined vehicle lets this vehicle continue
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
virtual ~SUMOVehicleParameter()
Destructor.
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
double repetitionProbability
The probability for emitting a vehicle per second.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
double speedFactor
individual speedFactor (overriding distribution from vType)
SUMOVehicleParameter()
Constructor.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
int repetitionsDone
The number of times the vehicle was already inserted.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
std::string getDepart() const
obtain depart parameter in string format
double departPos
(optional) The position the vehicle shall depart from
std::string getDepartEdge() const
obtain depart edge parameter in string format
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
DepartEdgeDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
bool defaultOptionOverrides(const OptionsCont &oc, const std::string &optionName) const
Returns whether the defaults shall be used.
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
static bool parseDepartEdge(const std::string &val, const std::string &element, const std::string &id, int &edgeIndex, DepartEdgeDefinition &ded, std::string &error)
Validates a given departEdge value.
int containerNumber
The static number of containers in the vehicle when it departs.
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
Definition of vehicle stop (position and duration)
Definition: MSStop.h:35