Eclipse SUMO - Simulation of Urban MObility
MSVehicleType.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 // The car-following model and parameter
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <cassert>
27 #include <map>
28 #include <string>
30 #include <utils/common/SUMOTime.h>
31 #include <utils/common/StdDefs.h>
35 #include <utils/common/RGBColor.h>
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class MSLane;
42 class MSCFModel;
43 class SUMOVTypeParameter;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
63 public:
68  MSVehicleType(const SUMOVTypeParameter& parameter);
69 
70 
72  virtual ~MSVehicleType();
73 
74 
79  bool wasSet(int what) const {
80  return (myParameter.parametersSet & what) != 0;
81  }
82 
83 
86 
90  const std::string& getID() const {
91  return myParameter.id;
92  }
93 
94 
98  int getNumericalID() const {
99  return myIndex;
100  }
101 
102 
106  double getLength() const {
107  return myParameter.length;
108  }
109 
110 
114  double getLengthWithGap() const {
116  }
117 
118 
122  double getMinGap() const {
123  return myParameter.minGap;
124  }
125 
129  double getMinGapLat() const {
130  return myParameter.minGapLat;
131  }
132 
133 
137  inline const MSCFModel& getCarFollowModel() const {
138  return *myCarFollowModel;
139  }
140 
141 
146  return *myCarFollowModel;
147  }
148 
149 
151  return myParameter.lcModel;
152  }
153 
154 
158  double getMaxSpeed() const {
159  return myParameter.maxSpeed;
160  }
161 
162 
166  double computeChosenSpeedDeviation(std::mt19937* rng, const double minDev = -1.) const;
167 
168 
172  double getDefaultProbability() const {
174  }
175 
176 
182  return myParameter.vehicleClass;
183  }
184 
185 
191  return myParameter.emissionClass;
192  }
193 
194 
198  const RGBColor& getColor() const {
199  return myParameter.color;
200  }
201 
202 
207  return myParameter.speedFactor;
208  }
209 
210 
216  }
217 
218 
222  double getActionStepLengthSecs() const {
224  }
225 
226 
230  double getImpatience() const {
231  return myParameter.impatience;
232  }
234 
235 
236 
239 
243  double getWidth() const {
244  return myParameter.width;
245  }
246 
250  double getHeight() const {
251  return myParameter.height;
252  }
253 
259  return myParameter.shape;
260  }
261 
265  std::string getOSGFile() const {
266  return myParameter.osgFile;
267  }
268 
269 
273  std::string getImgFile() const {
274  return myParameter.imgFile;
275  }
276 
277 
281  int getPersonCapacity() const {
283  }
284 
285 
289  int getContainerCapacity() const {
291  }
292 
298  }
299 
305  }
306 
310  double getMaxSpeedLat() const {
311  return myParameter.maxSpeedLat;
312  }
313 
318  return myParameter.latAlignment;
319  }
321 
322 
325 
329  void setAccel(double accel);
330 
334  void setDecel(double decel);
335 
339  void setEmergencyDecel(double emergencyDecel);
340 
344  void setApparentDecel(double apparentDecel);
345 
349  void setImperfection(double imperfection);
350 
354  void setTau(double tau);
355 
363  void setLength(const double& length);
364 
365 
373  void setHeight(const double& height);
374 
375 
383  void setMinGap(const double& minGap);
384 
385 
393  void setMinGapLat(const double& minGapLat);
394 
402  void setMaxSpeed(const double& maxSpeed);
403 
411  void setMaxSpeedLat(const double& maxSpeedLat);
412 
416  void setVClass(SUMOVehicleClass vclass);
417 
418 
426  void setDefaultProbability(const double& prob);
427 
428 
436  void setSpeedFactor(const double& factor);
437 
438 
446  void setSpeedDeviation(const double& dev);
447 
448 
462  void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset);
463 
464 
468  void setEmissionClass(SUMOEmissionClass eclass);
469 
470 
474  void setColor(const RGBColor& color);
475 
476 
484  void setWidth(const double& width);
485 
486 
490  void setShape(SUMOVehicleShape shape);
491 
495  void setImpatience(const double impatience);
496 
501 
502 
503 
506 
512  static MSVehicleType* build(SUMOVTypeParameter& from);
513 
515  SUMOTime getEntryManoeuvreTime(const int angle) const;
517  SUMOTime getExitManoeuvreTime(const int angle) const;
518 
519 
527  MSVehicleType* buildSingularType(const std::string& id) const;
528 
529 
537  MSVehicleType* duplicateType(const std::string& id, bool persistent) const;
539 
540 
544  bool isVehicleSpecific() const {
545  return myOriginalType != nullptr;
546  }
547 
548 
552  const std::string& getOriginalID() const {
553  return myOriginalType != nullptr ? myOriginalType->getID() : getID();
554  }
555 
556 
558  return myParameter;
559  }
560 
565  void check();
566 
567 protected:
570 
571 private:
574 
577 
582 
584  const int myIndex;
585 
588 
591 
593  static int myNextIndex;
594 
595 
596 private:
598  MSVehicleType(const MSVehicleType&) = delete;
599 
602 };
long long int SUMOTime
Definition: SUMOTime.h:31
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SUMOEmissionClass
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
LateralAlignment
Numbers representing special SUMO-XML-attribute values Information how vehicles align themselves with...
LaneChangeModel
The car-following model abstraction.
Definition: MSCFModel.h:55
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
The car-following model and parameter.
Definition: MSVehicleType.h:62
void setHeight(const double &height)
Set a new value for this type's height.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getDefaultProbability() const
Get the default probability of this vehicle type.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double myCachedActionStepLengthSecs
the vtypes actionsStepLength in seconds (cached because needed very often)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setSpeedFactor(const double &factor)
Set a new value for this type's speed factor.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const int myIndex
the running index
MSVehicleType(const MSVehicleType &)=delete
Invalidated copy constructor.
std::string getOSGFile() const
Get this vehicle type's 3D model file name.
MSVehicleType(const SUMOVTypeParameter &parameter)
Constructor.
void setDefaultProbability(const double &prob)
Set a new value for this type's default probability.
int getPersonCapacity() const
Get this vehicle type's person capacity.
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
void setSpeedDeviation(const double &dev)
Set a new value for this type's speed deviation.
bool myWarnedActionStepLengthTauOnce
Indicator whether the user was already warned once about an action step length larger than the desire...
MSCFModel * myCarFollowModel
instance of the car following model.
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
double getMinGap() const
Get the free space in front of vehicles of this class.
MSVehicleType * duplicateType(const std::string &id, bool persistent) const
Duplicates the microsim vehicle type giving the newly created type the given id.
SUMOVTypeParameter myParameter
the parameter container
LaneChangeModel getLaneChangeModel() const
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
void initRailVisualizationParameters()
init Rail Visualization Parameters
MSVehicleType & operator=(const MSVehicleType &)=delete
Invalidated assignment operator.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
const MSVehicleType * myOriginalType
The original type.
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
void setLength(const double &length)
Set a new value for this type's length.
void setDecel(double decel)
Set a new value for this type's deceleration.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
SUMOTime getExitManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning exit time for a specific manoeuver angle.
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
MSCFModel & getCarFollowModel()
Returns the vehicle type's car following model definition (non-const version)
void setAccel(double accel)
Set a new value for this type's acceleration.
const RGBColor & getColor() const
Returns this type's color.
void setWidth(const double &width)
Set a new value for this type's width.
SUMOTime getLoadingDuration() const
Get this vehicle type's loading duration.
void setColor(const RGBColor &color)
Set a new value for this type's color.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
void setImpatience(const double impatience)
Set a new value for this type's impatience.
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
const std::string & getOriginalID() const
Returns the id of the original vehicle type if this is a vehicle specific type, the id otherwise.
static int myNextIndex
next value for the running index
void setTau(double tau)
Set a new value for this type's headway.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle's preferred lateral alignment.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:79
LateralAlignment getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
std::string getImgFile() const
Get this vehicle type's raster model file name.
SUMOTime getEntryManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning entry time for a specific manoeuver angle.
double getImpatience() const
Returns this type's impatience.
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
const SUMOVTypeParameter & getParameter() const
int getNumericalID() const
Returns the running index of the vehicle type.
Definition: MSVehicleType.h:98
SUMOTime getActionStepLength() const
Returns this type's default action step length.
virtual ~MSVehicleType()
Destructor.
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
int getContainerCapacity() const
Get this vehicle type's container capacity.
void check()
Checks whether vehicle type parameters may be problematic (Currently, only the value for the action s...
bool myWarnedActionStepLengthBallisticOnce
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
Structure representing possible vehicle parameter.
double width
This class' width.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
SUMOTime actionStepLength
The vehicle type's default actionStepLength [ms], i.e. the interval between two control actions....
double height
This class' height.
SUMOEmissionClass emissionClass
The emission class of this vehicle.
double length
The physical vehicle length.
double maxSpeedLat
The vehicle type's maximum lateral speed [m/s].
LateralAlignment latAlignment
The vehicles desired lateral alignment.
RGBColor color
The color.
double minGap
This class' free space in front of the vehicle itself.
std::string imgFile
Image file for this class.
SUMOVehicleShape shape
This class' shape.
int personCapacity
The person capacity of the vehicle.
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
std::string osgFile
3D model file for this class
double maxSpeed
The vehicle type's maximum speed [m/s].
int parametersSet
Information for the router which parameter were set.
int containerCapacity
The container capacity of the vehicle.
SUMOTime boardingDuration
The time a person needs to board the vehicle.
double minGapLat
The vehicle type's minimum lateral gap [m].
SUMOVehicleClass vehicleClass
The vehicle's class.
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
std::string id
The vehicle type's id.
double impatience
The vehicle's impatience (willingness to obstruct others)
LaneChangeModel lcModel
The lane-change model to use.