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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The car-following model and parameter
18 /****************************************************************************/
19 #ifndef MSVehicleType_h
20 #define MSVehicleType_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <cassert>
29 #include <map>
30 #include <string>
32 #include <utils/common/SUMOTime.h>
33 #include <utils/common/StdDefs.h>
37 #include <utils/common/RGBColor.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSLane;
44 class BinaryInputDevice;
45 class MSCFModel;
46 class SUMOVTypeParameter;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
66 public:
71  MSVehicleType(const SUMOVTypeParameter& parameter);
72 
73 
75  virtual ~MSVehicleType();
76 
77 
82  bool wasSet(int what) const {
83  return (myParameter.parametersSet & what) != 0;
84  }
85 
86 
89 
93  const std::string& getID() const {
94  return myParameter.id;
95  }
96 
97 
101  int getNumericalID() const {
102  return myIndex;
103  }
104 
105 
109  double getLength() const {
110  return myParameter.length;
111  }
112 
113 
117  double getLengthWithGap() const {
119  }
120 
121 
125  double getMinGap() const {
126  return myParameter.minGap;
127  }
128 
132  double getMinGapLat() const {
133  return myParameter.minGapLat;
134  }
135 
136 
140  inline const MSCFModel& getCarFollowModel() const {
141  return *myCarFollowModel;
142  }
143 
144 
149  return *myCarFollowModel;
150  }
151 
152 
154  return myParameter.lcModel;
155  }
156 
157 
161  double getMaxSpeed() const {
162  return myParameter.maxSpeed;
163  }
164 
165 
169  double computeChosenSpeedDeviation(std::mt19937* rng, const double minDev = -1.) const;
170 
171 
175  double getDefaultProbability() const {
177  }
178 
179 
185  return myParameter.vehicleClass;
186  }
187 
188 
194  return myParameter.emissionClass;
195  }
196 
197 
201  const RGBColor& getColor() const {
202  return myParameter.color;
203  }
204 
205 
210  return myParameter.speedFactor;
211  }
212 
213 
219  }
220 
221 
225  double getActionStepLengthSecs() const {
227  }
228 
229 
233  double getImpatience() const {
234  return myParameter.impatience;
235  }
237 
238 
239 
242 
246  double getWidth() const {
247  return myParameter.width;
248  }
249 
253  double getHeight() const {
254  return myParameter.height;
255  }
256 
262  return myParameter.shape;
263  }
264 
268  std::string getOSGFile() const {
269  return myParameter.osgFile;
270  }
271 
272 
276  std::string getImgFile() const {
277  return myParameter.imgFile;
278  }
279 
280 
284  int getPersonCapacity() const {
286  }
287 
288 
292  int getContainerCapacity() const {
294  }
295 
301  }
302 
308  }
309 
313  double getMaxSpeedLat() const {
314  return myParameter.maxSpeedLat;
315  }
316 
321  return myParameter.latAlignment;
322  }
324 
325 
328 
332  void setAccel(double accel);
333 
337  void setDecel(double decel);
338 
342  void setEmergencyDecel(double emergencyDecel);
343 
347  void setApparentDecel(double apparentDecel);
348 
352  void setImperfection(double imperfection);
353 
357  void setTau(double tau);
358 
366  void setLength(const double& length);
367 
368 
376  void setHeight(const double& height);
377 
378 
386  void setMinGap(const double& minGap);
387 
388 
396  void setMinGapLat(const double& minGapLat);
397 
405  void setMaxSpeed(const double& maxSpeed);
406 
414  void setMaxSpeedLat(const double& maxSpeedLat);
415 
419  void setVClass(SUMOVehicleClass vclass);
420 
421 
429  void setDefaultProbability(const double& prob);
430 
431 
439  void setSpeedFactor(const double& factor);
440 
441 
449  void setSpeedDeviation(const double& dev);
450 
451 
465  void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset);
466 
467 
471  void setEmissionClass(SUMOEmissionClass eclass);
472 
473 
477  void setColor(const RGBColor& color);
478 
479 
487  void setWidth(const double& width);
488 
489 
493  void setShape(SUMOVehicleShape shape);
494 
498  void setImpatience(const double impatience);
499 
504 
505 
506 
509 
515  static MSVehicleType* build(SUMOVTypeParameter& from);
516 
518  SUMOTime getEntryManoeuvreTime(const int angle) const;
520  SUMOTime getExitManoeuvreTime(const int angle) const;
521 
522 
530  MSVehicleType* buildSingularType(const std::string& id) const;
531 
532 
540  MSVehicleType* duplicateType(const std::string& id, bool persistent) const;
542 
543 
547  bool isVehicleSpecific() const {
548  return myOriginalType != nullptr;
549  }
550 
551 
555  const std::string& getOriginalID() const {
556  return myOriginalType != nullptr ? myOriginalType->getID() : getID();
557  }
558 
559 
561  return myParameter;
562  }
563 
568  void check();
569 
570 protected:
573 
574 private:
577 
580 
584 
586  const int myIndex;
587 
590 
593 
595  static int myNextIndex;
596 
597 
598 private:
600  MSVehicleType(const MSVehicleType&) = delete;
601 
603  MSVehicleType& operator=(const MSVehicleType&) = delete;
604 };
605 
606 
607 #endif
608 
609 /****************************************************************************/
610 
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:65
MSVehicleType::getBoardingDuration
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
Definition: MSVehicleType.h:299
MSVehicleType::setHeight
void setHeight(const double &height)
Set a new value for this type's height.
Definition: MSVehicleType.cpp:100
MSVehicleType::getEmissionClass
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
Definition: MSVehicleType.h:193
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
Distribution_Parameterized
Definition: Distribution_Parameterized.h:42
MSVehicleType::buildSingularType
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
Definition: MSVehicleType.cpp:363
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:93
MSVehicleType::getActionStepLength
SUMOTime getActionStepLength() const
Returns this type's default action step length.
Definition: MSVehicleType.h:217
MSVehicleType::setPreferredLateralAlignment
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle's preferred lateral alignment.
Definition: MSVehicleType.cpp:161
SUMOVTypeParameter::length
double length
The physical vehicle length.
Definition: SUMOVTypeParameter.h:215
MSVehicleType::setMinGapLat
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
Definition: MSVehicleType.cpp:122
MSVehicleType::getPreferredLateralAlignment
LateralAlignment getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment.
Definition: MSVehicleType.h:320
MSVehicleType::getNumericalID
int getNumericalID() const
Returns the running index of the vehicle type.
Definition: MSVehicleType.h:101
MSVehicleType::setAccel
void setAccel(double accel)
Set a new value for this type's acceleration.
Definition: MSVehicleType.cpp:398
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSVehicleType::isVehicleSpecific
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
Definition: MSVehicleType.h:547
MSVehicleType::myWarnedActionStepLengthTauOnce
bool myWarnedActionStepLengthTauOnce
Indicator whether the user was already warned once about an action step length larger than the desire...
Definition: MSVehicleType.h:583
SUMOVTypeParameter::actionStepLength
SUMOTime actionStepLength
The vehicle type's default actionStepLength [ms], i.e. the interval between two control actions....
Definition: SUMOVTypeParameter.h:225
MSVehicleType::getGuiShape
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
Definition: MSVehicleType.h:261
LateralAlignment
LateralAlignment
Numbers representing special SUMO-XML-attribute values Information how vehicles align themselves with...
Definition: SUMOXMLDefinitions.h:1328
LaneChangeModel
LaneChangeModel
Definition: SUMOXMLDefinitions.h:1303
MSVehicleType::setVClass
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
Definition: MSVehicleType.cpp:155
SUMOVTypeParameter::impatience
double impatience
The vehicle's impatience (willingness to obstruct others)
Definition: SUMOVTypeParameter.h:243
MSVehicleType::getMaxSpeedLat
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
Definition: MSVehicleType.h:313
SUMOVTypeParameter::osgFile
std::string osgFile
3D model file for this class
Definition: SUMOVTypeParameter.h:270
MSVehicleType::setEmergencyDecel
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
Definition: MSVehicleType.cpp:416
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSVehicleType::getImpatience
double getImpatience() const
Returns this type's impatience.
Definition: MSVehicleType.h:233
MSVehicleType::~MSVehicleType
virtual ~MSVehicleType()
Destructor.
Definition: MSVehicleType.cpp:76
MSVehicleType::operator=
MSVehicleType & operator=(const MSVehicleType &)=delete
Invalidated assignment operator.
SUMOEmissionClass
int SUMOEmissionClass
Definition: SUMOVehicleClass.h:231
MSVehicleType::getCarFollowModel
MSCFModel & getCarFollowModel()
Returns the vehicle type's car following model definition (non-const version)
Definition: MSVehicleType.h:148
MSVehicleType::duplicateType
MSVehicleType * duplicateType(const std::string &id, bool persistent) const
Duplicates the microsim vehicle type giving the newly created type the given id.
Definition: MSVehicleType.cpp:369
SUMOVTypeParameter::shape
SUMOVehicleShape shape
This class' shape.
Definition: SUMOVTypeParameter.h:267
MSVehicleType::setMinGap
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
Definition: MSVehicleType.cpp:111
MSVehicleType::setWidth
void setWidth(const double &width)
Set a new value for this type's width.
Definition: MSVehicleType.cpp:251
MSVehicleType::getPersonCapacity
int getPersonCapacity() const
Get this vehicle type's person capacity.
Definition: MSVehicleType.h:284
MSVehicleType::getMinGapLat
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
Definition: MSVehicleType.h:132
SUMOVTypeParameter::containerCapacity
int containerCapacity
The container capacity of the vehicle.
Definition: SUMOVTypeParameter.h:249
RGBColor.h
MSVehicleType::initRailVisualizationParameters
void initRailVisualizationParameters()
init Rail Visualization Parameters
Definition: MSVehicleType.cpp:453
MSVehicleType::getHeight
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
Definition: MSVehicleType.h:253
MSVehicleType::setColor
void setColor(const RGBColor &color)
Set a new value for this type's color.
Definition: MSVehicleType.cpp:244
SUMOVTypeParameter::parametersSet
int parametersSet
Information for the router which parameter were set.
Definition: SUMOVTypeParameter.h:307
MSVehicleType::MSVehicleType
MSVehicleType(const SUMOVTypeParameter &parameter)
Constructor.
Definition: MSVehicleType.cpp:63
MSVehicleType::getOriginalID
const std::string & getOriginalID() const
Returns the id of the original vehicle type if this is a vehicle specific type, the id otherwise.
Definition: MSVehicleType.h:555
RGBColor
Definition: RGBColor.h:39
MSVehicleType::check
void check()
Checks whether vehicle type parameters may be problematic (Currently, only the value for the action s...
Definition: MSVehicleType.cpp:384
MSVehicleType::computeChosenSpeedDeviation
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Definition: MSVehicleType.cpp:82
SUMOVTypeParameter::imgFile
std::string imgFile
Image file for this class.
Definition: SUMOVTypeParameter.h:273
MSVehicleType::myOriginalType
const MSVehicleType * myOriginalType
The original type.
Definition: MSVehicleType.h:592
MSVehicleType::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
Definition: MSVehicleType.h:140
SUMOVTypeParameter::height
double height
This class' height.
Definition: SUMOVTypeParameter.h:264
MSVehicleType::getWidth
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
Definition: MSVehicleType.h:246
MSVehicleType::getLengthWithGap
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
Definition: MSVehicleType.h:117
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
SUMOVehicleShape
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
Definition: SUMOVehicleClass.h:50
SUMOVTypeParameter::defaultProbability
double defaultProbability
The probability when being added to a distribution without an explicit probability.
Definition: SUMOVTypeParameter.h:228
SUMOVehicleClass.h
MSVehicleType::getColor
const RGBColor & getColor() const
Returns this type's color.
Definition: MSVehicleType.h:201
MSVehicleType::setActionStepLength
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
Definition: MSVehicleType.cpp:201
MSVehicleType::myParameter
SUMOVTypeParameter myParameter
the parameter container
Definition: MSVehicleType.h:576
SUMOVTypeParameter::boardingDuration
SUMOTime boardingDuration
The time a person needs to board the vehicle.
Definition: SUMOVTypeParameter.h:252
SUMOVTypeParameter::minGap
double minGap
This class' free space in front of the vehicle itself.
Definition: SUMOVTypeParameter.h:218
MSVehicleType::setLength
void setLength(const double &length)
Set a new value for this type's length.
Definition: MSVehicleType.cpp:89
SUMOVTypeParameter::width
double width
This class' width.
Definition: SUMOVTypeParameter.h:261
MSVehicleType::getMinGap
double getMinGap() const
Get the free space in front of vehicles of this class.
Definition: MSVehicleType.h:125
SUMOVTypeParameter::maxSpeedLat
double maxSpeedLat
The vehicle type's maximum lateral speed [m/s].
Definition: SUMOVTypeParameter.h:293
MSVehicleType::getLaneChangeModel
LaneChangeModel getLaneChangeModel() const
Definition: MSVehicleType.h:153
SUMOVTypeParameter::maxSpeed
double maxSpeed
The vehicle type's maximum speed [m/s].
Definition: SUMOVTypeParameter.h:221
MSVehicleType::setDecel
void setDecel(double decel)
Set a new value for this type's deceleration.
Definition: MSVehicleType.cpp:407
SUMOVTypeParameter::personCapacity
int personCapacity
The person capacity of the vehicle.
Definition: SUMOVTypeParameter.h:246
MSVehicleType::setDefaultProbability
void setDefaultProbability(const double &prob)
Set a new value for this type's default probability.
Definition: MSVehicleType.cpp:168
MSVehicleType::getEntryManoeuvreTime
SUMOTime getEntryManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning entry time for a specific manoeuver angle.
Definition: MSVehicleType.cpp:353
MSVehicleType::getSpeedFactor
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
Definition: MSVehicleType.h:209
MSVehicleType::setShape
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
Definition: MSVehicleType.cpp:272
SUMOVTypeParameter::speedFactor
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
Definition: SUMOVTypeParameter.h:231
MSVehicleType::myCachedActionStepLengthSecs
double myCachedActionStepLengthSecs
the vtypes actionsStepLength in seconds (cached because needed very often)
Definition: MSVehicleType.h:579
MSVehicleType::setMaxSpeedLat
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
Definition: MSVehicleType.cpp:144
MSVehicleType::getExitManoeuvreTime
SUMOTime getExitManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning exit time for a specific manoeuver angle.
Definition: MSVehicleType.cpp:358
MSVehicleType::setSpeedDeviation
void setSpeedDeviation(const double &dev)
Set a new value for this type's speed deviation.
Definition: MSVehicleType.cpp:190
SUMOVTypeParameter::latAlignment
LateralAlignment latAlignment
The vehicles desired lateral alignment.
Definition: SUMOVTypeParameter.h:296
MSVehicleType::getActionStepLengthSecs
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
Definition: MSVehicleType.h:225
SUMOVTypeParameter::id
std::string id
The vehicle type's id.
Definition: SUMOVTypeParameter.h:212
MSVehicleType::build
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
Definition: MSVehicleType.cpp:281
MSVehicleType::getLength
double getLength() const
Get vehicle's length [m].
Definition: MSVehicleType.h:109
MSVehicleType::getOSGFile
std::string getOSGFile() const
Get this vehicle type's 3D model file name.
Definition: MSVehicleType.h:268
MSVehicleType::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:82
MSCFModel.h
MSVehicleType::setApparentDecel
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
Definition: MSVehicleType.cpp:425
MSVehicleType::getImgFile
std::string getImgFile() const
Get this vehicle type's raster model file name.
Definition: MSVehicleType.h:276
MSVehicleType::myNextIndex
static int myNextIndex
next value for the running index
Definition: MSVehicleType.h:595
MSVehicleType::getParameter
const SUMOVTypeParameter & getParameter() const
Definition: MSVehicleType.h:560
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:161
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:56
SUMOVTypeParameter::lcModel
LaneChangeModel lcModel
The lane-change model to use.
Definition: SUMOVTypeParameter.h:290
config.h
MSVehicleType::setMaxSpeed
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
Definition: MSVehicleType.cpp:133
MSVehicleType::myCarFollowModel
MSCFModel * myCarFollowModel
instance of the car following model.
Definition: MSVehicleType.h:589
MSVehicleType::myIndex
const int myIndex
the running index
Definition: MSVehicleType.h:586
MSVehicleType::getContainerCapacity
int getContainerCapacity() const
Get this vehicle type's container capacity.
Definition: MSVehicleType.h:292
RandHelper.h
SUMOVTypeParameter::loadingDuration
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
Definition: SUMOVTypeParameter.h:255
StdDefs.h
SUMOVTypeParameter::color
RGBColor color
The color.
Definition: SUMOVTypeParameter.h:237
SUMOVTypeParameter::emissionClass
SUMOEmissionClass emissionClass
The emission class of this vehicle.
Definition: SUMOVTypeParameter.h:234
MSVehicleType::setSpeedFactor
void setSpeedFactor(const double &factor)
Set a new value for this type's speed factor.
Definition: MSVehicleType.cpp:179
MSVehicleType::getVehicleClass
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
Definition: MSVehicleType.h:184
MSVehicleType::getDefaultProbability
double getDefaultProbability() const
Get the default probability of this vehicle type.
Definition: MSVehicleType.h:175
SUMOVTypeParameter.h
SUMOVTypeParameter::vehicleClass
SUMOVehicleClass vehicleClass
The vehicle's class.
Definition: SUMOVTypeParameter.h:240
MSVehicleType::setImpatience
void setImpatience(const double impatience)
Set a new value for this type's impatience.
Definition: MSVehicleType.cpp:261
MSVehicleType::setTau
void setTau(double tau)
Set a new value for this type's headway.
Definition: MSVehicleType.cpp:443
MSVehicleType::setEmissionClass
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
Definition: MSVehicleType.cpp:237
MSVehicleType::setImperfection
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
Definition: MSVehicleType.cpp:434
BinaryInputDevice
Encapsulates binary reading operations on a file.
Definition: BinaryInputDevice.h:57
MSVehicleType::getLoadingDuration
SUMOTime getLoadingDuration() const
Get this vehicle type's loading duration.
Definition: MSVehicleType.h:306
SUMOVTypeParameter::minGapLat
double minGapLat
The vehicle type's minimum lateral gap [m].
Definition: SUMOVTypeParameter.h:299