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 /****************************************************************************/
18 // The car-following model and parameter
19 /****************************************************************************/
20 #ifndef MSVehicleType_h
21 #define MSVehicleType_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <cassert>
30 #include <map>
31 #include <string>
33 #include <utils/common/SUMOTime.h>
34 #include <utils/common/StdDefs.h>
38 #include <utils/common/RGBColor.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class MSLane;
45 class BinaryInputDevice;
46 class MSCFModel;
47 class SUMOVTypeParameter;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
67 public:
72  MSVehicleType(const SUMOVTypeParameter& parameter);
73 
74 
76  virtual ~MSVehicleType();
77 
78 
83  bool wasSet(int what) const {
84  return (myParameter.parametersSet & what) != 0;
85  }
86 
87 
90 
94  const std::string& getID() const {
95  return myParameter.id;
96  }
97 
98 
102  int getNumericalID() const {
103  return myIndex;
104  }
105 
106 
110  double getLength() const {
111  return myParameter.length;
112  }
113 
114 
118  double getLengthWithGap() const {
120  }
121 
122 
126  double getMinGap() const {
127  return myParameter.minGap;
128  }
129 
133  double getMinGapLat() const {
134  return myParameter.minGapLat;
135  }
136 
137 
141  inline const MSCFModel& getCarFollowModel() const {
142  return *myCarFollowModel;
143  }
144 
145 
150  return *myCarFollowModel;
151  }
152 
153 
155  return myParameter.lcModel;
156  }
157 
158 
162  double getMaxSpeed() const {
163  return myParameter.maxSpeed;
164  }
165 
166 
170  double computeChosenSpeedDeviation(std::mt19937* rng, const double minDev = -1.) const;
171 
172 
176  double getDefaultProbability() const {
178  }
179 
180 
186  return myParameter.vehicleClass;
187  }
188 
189 
195  return myParameter.emissionClass;
196  }
197 
198 
202  const RGBColor& getColor() const {
203  return myParameter.color;
204  }
205 
206 
211  return myParameter.speedFactor;
212  }
213 
214 
220  }
221 
222 
226  double getActionStepLengthSecs() const {
228  }
229 
230 
234  double getImpatience() const {
235  return myParameter.impatience;
236  }
238 
239 
240 
243 
247  double getWidth() const {
248  return myParameter.width;
249  }
250 
254  double getHeight() const {
255  return myParameter.height;
256  }
257 
263  return myParameter.shape;
264  }
265 
269  std::string getOSGFile() const {
270  return myParameter.osgFile;
271  }
272 
273 
277  std::string getImgFile() const {
278  return myParameter.imgFile;
279  }
280 
281 
285  int getPersonCapacity() const {
287  }
288 
289 
293  int getContainerCapacity() const {
295  }
296 
302  }
303 
309  }
310 
314  double getMaxSpeedLat() const {
315  return myParameter.maxSpeedLat;
316  }
317 
322  return myParameter.latAlignment;
323  }
325 
326 
329 
333  void setAccel(double accel);
334 
338  void setDecel(double decel);
339 
343  void setEmergencyDecel(double emergencyDecel);
344 
348  void setApparentDecel(double apparentDecel);
349 
353  void setImperfection(double imperfection);
354 
358  void setTau(double tau);
359 
367  void setLength(const double& length);
368 
369 
377  void setHeight(const double& height);
378 
379 
387  void setMinGap(const double& minGap);
388 
389 
397  void setMinGapLat(const double& minGapLat);
398 
406  void setMaxSpeed(const double& maxSpeed);
407 
415  void setMaxSpeedLat(const double& maxSpeedLat);
416 
420  void setVClass(SUMOVehicleClass vclass);
421 
422 
430  void setDefaultProbability(const double& prob);
431 
432 
440  void setSpeedFactor(const double& factor);
441 
442 
450  void setSpeedDeviation(const double& dev);
451 
452 
466  void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset);
467 
468 
472  void setEmissionClass(SUMOEmissionClass eclass);
473 
474 
478  void setColor(const RGBColor& color);
479 
480 
488  void setWidth(const double& width);
489 
490 
494  void setShape(SUMOVehicleShape shape);
495 
499  void setImpatience(const double impatience);
500 
505 
506 
507 
510 
516  static MSVehicleType* build(SUMOVTypeParameter& from);
517 
518 
526  MSVehicleType* buildSingularType(const std::string& id) const;
527 
528 
536  MSVehicleType* duplicateType(const std::string& id, bool persistent) const;
538 
539 
543  bool isVehicleSpecific() const {
544  return myOriginalType != nullptr;
545  }
546 
547 
551  const std::string& getOriginalID() const {
552  return myOriginalType != nullptr ? myOriginalType->getID() : getID();
553  }
554 
555 
557  return myParameter;
558  }
559 
564  void check();
565 
566 protected:
569 
570 private:
573 
576 
580 
582  const int myIndex;
583 
586 
589 
591  static int myNextIndex;
592 
593 
594 private:
596  MSVehicleType(const MSVehicleType&) = delete;
597 
599  MSVehicleType& operator=(const MSVehicleType&) = delete;
600 };
601 
602 
603 #endif
604 
605 /****************************************************************************/
606 
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSVehicleType::getBoardingDuration
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
Definition: MSVehicleType.h:300
MSVehicleType::setHeight
void setHeight(const double &height)
Set a new value for this type's height.
Definition: MSVehicleType.cpp:101
MSVehicleType::getEmissionClass
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
Definition: MSVehicleType.h:194
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
Distribution_Parameterized
Definition: Distribution_Parameterized.h:43
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:355
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
MSVehicleType::getActionStepLength
SUMOTime getActionStepLength() const
Returns this type's default action step length.
Definition: MSVehicleType.h:218
MSVehicleType::setPreferredLateralAlignment
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle's preferred lateral alignment.
Definition: MSVehicleType.cpp:162
SUMOVTypeParameter::length
double length
The physical vehicle length.
Definition: SUMOVTypeParameter.h:213
MSVehicleType::setMinGapLat
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
Definition: MSVehicleType.cpp:123
MSVehicleType::getPreferredLateralAlignment
LateralAlignment getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment.
Definition: MSVehicleType.h:321
MSVehicleType::getNumericalID
int getNumericalID() const
Returns the running index of the vehicle type.
Definition: MSVehicleType.h:102
MSVehicleType::setAccel
void setAccel(double accel)
Set a new value for this type's acceleration.
Definition: MSVehicleType.cpp:390
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSVehicleType::isVehicleSpecific
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
Definition: MSVehicleType.h:543
MSVehicleType::myWarnedActionStepLengthTauOnce
bool myWarnedActionStepLengthTauOnce
Indicator whether the user was already warned once about an action step length larger than the desire...
Definition: MSVehicleType.h:579
SUMOVTypeParameter::actionStepLength
SUMOTime actionStepLength
The vehicle type's default actionStepLength [ms], i.e. the interval between two control actions....
Definition: SUMOVTypeParameter.h:223
MSVehicleType::getGuiShape
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
Definition: MSVehicleType.h:262
LateralAlignment
LateralAlignment
Numbers representing special SUMO-XML-attribute values Information how vehicles align themselves with...
Definition: SUMOXMLDefinitions.h:1323
LaneChangeModel
LaneChangeModel
Definition: SUMOXMLDefinitions.h:1298
MSVehicleType::setVClass
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
Definition: MSVehicleType.cpp:156
SUMOVTypeParameter::impatience
double impatience
The vehicle's impatience (willingness to obstruct others)
Definition: SUMOVTypeParameter.h:241
MSVehicleType::getMaxSpeedLat
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
Definition: MSVehicleType.h:314
SUMOVTypeParameter::osgFile
std::string osgFile
3D model file for this class
Definition: SUMOVTypeParameter.h:268
MSVehicleType::setEmergencyDecel
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
Definition: MSVehicleType.cpp:408
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSVehicleType::getImpatience
double getImpatience() const
Returns this type's impatience.
Definition: MSVehicleType.h:234
MSVehicleType::~MSVehicleType
virtual ~MSVehicleType()
Destructor.
Definition: MSVehicleType.cpp:77
MSVehicleType::operator=
MSVehicleType & operator=(const MSVehicleType &)=delete
Invalidated assignment operator.
SUMOEmissionClass
int SUMOEmissionClass
Definition: SUMOVehicleClass.h:232
MSVehicleType::getCarFollowModel
MSCFModel & getCarFollowModel()
Returns the vehicle type's car following model definition (non-const version)
Definition: MSVehicleType.h:149
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:361
SUMOVTypeParameter::shape
SUMOVehicleShape shape
This class' shape.
Definition: SUMOVTypeParameter.h:265
MSVehicleType::setMinGap
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
Definition: MSVehicleType.cpp:112
MSVehicleType::setWidth
void setWidth(const double &width)
Set a new value for this type's width.
Definition: MSVehicleType.cpp:252
MSVehicleType::getPersonCapacity
int getPersonCapacity() const
Get this vehicle type's person capacity.
Definition: MSVehicleType.h:285
MSVehicleType::getMinGapLat
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
Definition: MSVehicleType.h:133
SUMOVTypeParameter::containerCapacity
int containerCapacity
The container capacity of the vehicle.
Definition: SUMOVTypeParameter.h:247
RGBColor.h
MSVehicleType::initRailVisualizationParameters
void initRailVisualizationParameters()
init Rail Visualization Parameters
Definition: MSVehicleType.cpp:445
MSVehicleType::getHeight
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
Definition: MSVehicleType.h:254
MSVehicleType::setColor
void setColor(const RGBColor &color)
Set a new value for this type's color.
Definition: MSVehicleType.cpp:245
SUMOVTypeParameter::parametersSet
int parametersSet
Information for the router which parameter were set.
Definition: SUMOVTypeParameter.h:308
MSVehicleType::MSVehicleType
MSVehicleType(const SUMOVTypeParameter &parameter)
Constructor.
Definition: MSVehicleType.cpp:64
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:551
RGBColor
Definition: RGBColor.h:40
MSVehicleType::check
void check()
Checks whether vehicle type parameters may be problematic (Currently, only the value for the action s...
Definition: MSVehicleType.cpp:376
MSVehicleType::computeChosenSpeedDeviation
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Definition: MSVehicleType.cpp:83
SUMOVTypeParameter::imgFile
std::string imgFile
Image file for this class.
Definition: SUMOVTypeParameter.h:271
MSVehicleType::myOriginalType
const MSVehicleType * myOriginalType
The original type.
Definition: MSVehicleType.h:588
MSVehicleType::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
Definition: MSVehicleType.h:141
SUMOVTypeParameter::height
double height
This class' height.
Definition: SUMOVTypeParameter.h:262
MSVehicleType::getWidth
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
Definition: MSVehicleType.h:247
MSVehicleType::getLengthWithGap
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
Definition: MSVehicleType.h:118
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
SUMOVehicleShape
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
Definition: SUMOVehicleClass.h:51
SUMOVTypeParameter::defaultProbability
double defaultProbability
The probability when being added to a distribution without an explicit probability.
Definition: SUMOVTypeParameter.h:226
SUMOVehicleClass.h
MSVehicleType::getColor
const RGBColor & getColor() const
Returns this type's color.
Definition: MSVehicleType.h:202
MSVehicleType::setActionStepLength
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
Definition: MSVehicleType.cpp:202
MSVehicleType::myParameter
SUMOVTypeParameter myParameter
the parameter container
Definition: MSVehicleType.h:572
SUMOVTypeParameter::boardingDuration
SUMOTime boardingDuration
The time a person needs to board the vehicle.
Definition: SUMOVTypeParameter.h:250
SUMOVTypeParameter::minGap
double minGap
This class' free space in front of the vehicle itself.
Definition: SUMOVTypeParameter.h:216
MSVehicleType::setLength
void setLength(const double &length)
Set a new value for this type's length.
Definition: MSVehicleType.cpp:90
SUMOVTypeParameter::width
double width
This class' width.
Definition: SUMOVTypeParameter.h:259
MSVehicleType::getMinGap
double getMinGap() const
Get the free space in front of vehicles of this class.
Definition: MSVehicleType.h:126
SUMOVTypeParameter::maxSpeedLat
double maxSpeedLat
The vehicle type's maximum lateral speed [m/s].
Definition: SUMOVTypeParameter.h:294
MSVehicleType::getLaneChangeModel
LaneChangeModel getLaneChangeModel() const
Definition: MSVehicleType.h:154
SUMOVTypeParameter::maxSpeed
double maxSpeed
The vehicle type's maximum speed [m/s].
Definition: SUMOVTypeParameter.h:219
MSVehicleType::setDecel
void setDecel(double decel)
Set a new value for this type's deceleration.
Definition: MSVehicleType.cpp:399
SUMOVTypeParameter::personCapacity
int personCapacity
The person capacity of the vehicle.
Definition: SUMOVTypeParameter.h:244
MSVehicleType::setDefaultProbability
void setDefaultProbability(const double &prob)
Set a new value for this type's default probability.
Definition: MSVehicleType.cpp:169
MSVehicleType::getSpeedFactor
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
Definition: MSVehicleType.h:210
MSVehicleType::setShape
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
Definition: MSVehicleType.cpp:273
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:229
MSVehicleType::myCachedActionStepLengthSecs
double myCachedActionStepLengthSecs
the vtypes actionsStepLength in seconds (cached because needed very often)
Definition: MSVehicleType.h:575
MSVehicleType::setMaxSpeedLat
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
Definition: MSVehicleType.cpp:145
MSVehicleType::setSpeedDeviation
void setSpeedDeviation(const double &dev)
Set a new value for this type's speed deviation.
Definition: MSVehicleType.cpp:191
SUMOVTypeParameter::latAlignment
LateralAlignment latAlignment
The vehicles desired lateral alignment.
Definition: SUMOVTypeParameter.h:297
MSVehicleType::getActionStepLengthSecs
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
Definition: MSVehicleType.h:226
SUMOVTypeParameter::id
std::string id
The vehicle type's id.
Definition: SUMOVTypeParameter.h:210
MSVehicleType::build
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
Definition: MSVehicleType.cpp:282
MSVehicleType::getLength
double getLength() const
Get vehicle's length [m].
Definition: MSVehicleType.h:110
MSVehicleType::getOSGFile
std::string getOSGFile() const
Get this vehicle type's 3D model file name.
Definition: MSVehicleType.h:269
MSVehicleType::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:83
MSCFModel.h
MSVehicleType::setApparentDecel
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
Definition: MSVehicleType.cpp:417
MSVehicleType::getImgFile
std::string getImgFile() const
Get this vehicle type's raster model file name.
Definition: MSVehicleType.h:277
MSVehicleType::myNextIndex
static int myNextIndex
next value for the running index
Definition: MSVehicleType.h:591
MSVehicleType::getParameter
const SUMOVTypeParameter & getParameter() const
Definition: MSVehicleType.h:556
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:162
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:57
SUMOVTypeParameter::lcModel
LaneChangeModel lcModel
The lane-change model to use.
Definition: SUMOVTypeParameter.h:291
config.h
MSVehicleType::setMaxSpeed
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
Definition: MSVehicleType.cpp:134
MSVehicleType::myCarFollowModel
MSCFModel * myCarFollowModel
instance of the car following model.
Definition: MSVehicleType.h:585
MSVehicleType::myIndex
const int myIndex
the running index
Definition: MSVehicleType.h:582
MSVehicleType::getContainerCapacity
int getContainerCapacity() const
Get this vehicle type's container capacity.
Definition: MSVehicleType.h:293
RandHelper.h
SUMOVTypeParameter::loadingDuration
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
Definition: SUMOVTypeParameter.h:253
StdDefs.h
SUMOVTypeParameter::color
RGBColor color
The color.
Definition: SUMOVTypeParameter.h:235
SUMOVTypeParameter::emissionClass
SUMOEmissionClass emissionClass
The emission class of this vehicle.
Definition: SUMOVTypeParameter.h:232
MSVehicleType::setSpeedFactor
void setSpeedFactor(const double &factor)
Set a new value for this type's speed factor.
Definition: MSVehicleType.cpp:180
MSVehicleType::getVehicleClass
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
Definition: MSVehicleType.h:185
MSVehicleType::getDefaultProbability
double getDefaultProbability() const
Get the default probability of this vehicle type.
Definition: MSVehicleType.h:176
SUMOVTypeParameter.h
SUMOVTypeParameter::vehicleClass
SUMOVehicleClass vehicleClass
The vehicle's class.
Definition: SUMOVTypeParameter.h:238
MSVehicleType::setImpatience
void setImpatience(const double impatience)
Set a new value for this type's impatience.
Definition: MSVehicleType.cpp:262
MSVehicleType::setTau
void setTau(double tau)
Set a new value for this type's headway.
Definition: MSVehicleType.cpp:435
MSVehicleType::setEmissionClass
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
Definition: MSVehicleType.cpp:238
MSVehicleType::setImperfection
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
Definition: MSVehicleType.cpp:426
BinaryInputDevice
Encapsulates binary reading operations on a file.
Definition: BinaryInputDevice.h:58
MSVehicleType::getLoadingDuration
SUMOTime getLoadingDuration() const
Get this vehicle type's loading duration.
Definition: MSVehicleType.h:307
SUMOVTypeParameter::minGapLat
double minGapLat
The vehicle type's minimum lateral gap [m].
Definition: SUMOVTypeParameter.h:300