Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSVehicleType.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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>
37
38
39// ===========================================================================
40// class declarations
41// ===========================================================================
42class MSLane;
43class MSCFModel;
45
46
47// ===========================================================================
48// class definitions
49// ===========================================================================
64public:
69 MSVehicleType(const SUMOVTypeParameter& parameter);
70
71
73 virtual ~MSVehicleType();
74
75
80 bool wasSet(long long int what) const {
81 return (myParameter.parametersSet & what) != 0;
82 }
83
84
87
91 const std::string& getID() const {
92 return myParameter.id;
93 }
94
95
99 int getNumericalID() const {
100 return myIndex;
101 }
102
103
107 double getLength() const {
108 return myParameter.length;
109 }
110
111
115 double getLengthWithGap() const {
116 return myParameter.length + myParameter.minGap;
117 }
118
119
123 double getMinGap() const {
124 return myParameter.minGap;
125 }
126
130 double getMinGapLat() const {
131 return myParameter.minGapLat;
132 }
133
134
138 inline const MSCFModel& getCarFollowModel() const {
139 return *myCarFollowModel;
140 }
141
142
147 return *myCarFollowModel;
148 }
149
150
152 return myParameter.lcModel;
153 }
154
155
159 double getMaxSpeed() const {
160 return myParameter.maxSpeed;
161 }
162
166 double getDesiredMaxSpeed() const {
167 return myParameter.desiredMaxSpeed;
168 }
169
170
174 double computeChosenSpeedDeviation(SumoRNG* rng, const double minDev = -1.) const;
175
176
180 double getDefaultProbability() const {
181 return myParameter.defaultProbability;
182 }
183
184
190 return myParameter.vehicleClass;
191 }
192
193
199 return myParameter.emissionClass;
200 }
201
202
206 inline double getMass() const {
207 return myEnergyParams.getDouble(SUMO_ATTR_MASS);
208 }
209
210
214 const RGBColor& getColor() const {
215 return myParameter.color;
216 }
217
218
222 const std::vector<std::string>& getParkingBadges() const {
223 return myParameter.parkingBadges;
224 }
225
226
231 return myParameter.speedFactor;
232 }
233
234
239 return myParameter.actionStepLength;
240 }
241
242
246 double getActionStepLengthSecs() const {
248 }
249
250
254 double getImpatience() const {
255 return myParameter.impatience;
256 }
257
258
259
260
263
267 double getWidth() const {
268 return myParameter.width;
269 }
270
274 double getSeatingWidth() const {
275 return myParameter.seatingWidth >= 0 ? myParameter.seatingWidth : myParameter.width;
276 }
277
281 double getHeight() const {
282 return myParameter.height;
283 }
284
290 return myParameter.shape;
291 }
292
296 std::string getOSGFile() const {
297 return myParameter.osgFile;
298 }
299
300
304 std::string getImgFile() const {
305 return myParameter.imgFile;
306 }
307
308
312 int getPersonCapacity() const {
313 return myParameter.personCapacity;
314 }
315
316
321 return myParameter.containerCapacity;
322 }
323
327 SUMOTime getLoadingDuration(const bool isPerson) const {
328 return isPerson ? myParameter.boardingDuration : myParameter.loadingDuration;
329 }
330
334 SUMOTime getBoardingDuration(const bool isPerson) const {
335 return isPerson ? myParameter.boardingDuration : myParameter.loadingDuration;
336 }
337
341 double getBoardingFactor() const {
342 return myParameter.boardingFactor;
343 }
344
345
349 double getMaxSpeedLat() const {
350 return myParameter.maxSpeedLat;
351 }
352
357 return myParameter.latAlignmentProcedure;
358 }
359
364 return myParameter.latAlignmentOffset;
365 }
366
368 double getFrontSeatPos() const {
369 return myParameter.frontSeatPos;
370 }
371
372
373
376
380 void setAccel(double accel);
381
385 void setDecel(double decel);
386
390 void setEmergencyDecel(double emergencyDecel);
391
395 void setApparentDecel(double apparentDecel);
396
400 void setMaxAccelProfile(std::vector<std::pair<double, double> > accelProfile);
401
405 void setDesAccelProfile(std::vector<std::pair<double, double> > accelProfile);
406
410 void setImperfection(double imperfection);
411
415 void setTau(double tau);
416
424 void setLength(const double& length);
425
426
434 void setHeight(const double& height);
435
436
444 void setMinGap(const double& minGap);
445
446
454 void setMinGapLat(const double& minGapLat);
455
463 void setMaxSpeed(const double& maxSpeed);
464
472 void setMaxSpeedLat(const double& maxSpeedLat);
473
477 void setVClass(SUMOVehicleClass vclass);
478
482 void setGUIShape(SUMOVehicleShape shape);
483
484
492 void setDefaultProbability(const double& prob);
493
494
502 void setSpeedFactor(const double& factor);
503
504
512 void setSpeedDeviation(const double& dev);
513
514
528 void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset);
529
530
535
536
540 void setMass(double mass);
541
542
546 void setColor(const RGBColor& color);
547
548
552 void setParkingBadges(const std::vector<std::string>& badges);
553
554
562 void setWidth(const double& width);
563
564
568 void setShape(SUMOVehicleShape shape);
569
574 void setBoardingDuration(SUMOTime duration, bool isPerson = true);
575
579 void setImpatience(const double impatience);
580
583 void setPreferredLateralAlignment(const LatAlignmentDefinition& latAlignment, double latAlignmentOffset = 0.0);
584
587 void setScale(double value);
588
591 void setLcContRight(const std::string& value);
593
594
595
598
604 static MSVehicleType* build(SUMOVTypeParameter& from, const std::string& fileName = "");
605
607 SUMOTime getEntryManoeuvreTime(const int angle) const;
609 SUMOTime getExitManoeuvreTime(const int angle) const;
610
611
619 MSVehicleType* buildSingularType(const std::string& id) const;
620
621
629 MSVehicleType* duplicateType(const std::string& id, bool persistent) const;
631
632
636 bool isVehicleSpecific() const {
637 return myOriginalType != nullptr;
638 }
639
640
644 const std::string& getOriginalID() const {
645 return myOriginalType != nullptr ? myOriginalType->getID() : getID();
646 }
647
648
650 return myParameter;
651 }
652
657 void check();
658
660 inline const EnergyParams* getEmissionParameters() const {
661 return &myEnergyParams;
662 }
663
664private:
667
669
672
678
680 const int myIndex;
681
684
687
689 static int myNextIndex;
690
691
692private:
694 MSVehicleType(const MSVehicleType&) = delete;
695
698};
long long int SUMOTime
Definition GUI.h:36
const std::string invalid_return< std::string >::value
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
int SUMOEmissionClass
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SUMO_ATTR_MASS
An upper class for objects with additional parameters.
The car-following model abstraction.
Definition MSCFModel.h:57
Representation of a lane in the micro simulation.
Definition MSLane.h:84
The car-following model and parameter.
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.
const EnergyParams * getEmissionParameters() const
retrieve parameters for the energy consumption model
SUMOTime getBoardingDuration(const bool isPerson) const
Get this vehicle type's boarding duration.
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.
MSCFModel & getCarFollowModel()
Returns the vehicle type's car following model definition (non-const version).
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.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
const int myIndex
the running index
MSVehicleType(const MSVehicleType &)=delete
Invalidated copy constructor.
void setGUIShape(SUMOVehicleShape shape)
Set a new value for this type's gui shape.
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.
double getDesiredMaxSpeed() const
Returns the vehicles's desired maximum speed.
const LatAlignmentDefinition & getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment procedure.
int getPersonCapacity() const
Get this vehicle type's person capacity.
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
double getSeatingWidth() const
Get the width of the passenger compartment when being drawn.
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...
const std::string & getID() const
Returns the name of the vehicle type.
void setParkingBadges(const std::vector< std::string > &badges)
Set a new value for parking access rights of this type.
MSCFModel * myCarFollowModel
instance of the car following model.
void setDesAccelProfile(std::vector< std::pair< double, double > > accelProfile)
Set a new value for this type's desired acceleration profile.
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
bool wasSet(long long int what) const
Returns whether the given parameter was set.
bool myWarnedStepLengthTauOnce
LaneChangeModel getLaneChangeModel() const
SUMOTime getLoadingDuration(const bool isPerson) const
Get this vehicle type's loading duration.
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
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 Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
void setBoardingDuration(SUMOTime duration, bool isPerson=true)
Set a new value for this type's boardingDuration.
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.
void setAccel(double accel)
Set a new value for this type's acceleration.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version).
void setWidth(const double &width)
Set a new value for this type's width.
void setLcContRight(const std::string &value)
Set lcContRight (which is the only lc-attribute not used within the laneChange model).
void setColor(const RGBColor &color)
Set a new value for this type's color.
double getFrontSeatPos() const
Get offset of first seat from vehicle front.
MSVehicleType & operator=(const MSVehicleType &)=delete
Invalidated assignment operator.
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.
static MSVehicleType * build(SUMOVTypeParameter &from, const std::string &fileName="")
Builds the microsim vehicle type described by the given parameter.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
static int myNextIndex
next value for the running index
void setTau(double tau)
Set a new value for this type's headway.
void setMaxAccelProfile(std::vector< std::pair< double, double > > accelProfile)
Set a new value for this type's maximum acceleration profile.
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.
void setMass(double mass)
Set a new value for this type's mass.
double getMass() const
Get this vehicle type's mass.
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
const std::string & getOriginalID() const
Returns the id of the original vehicle type if this is a vehicle specific type, the id otherwise.
std::string getImgFile() const
Get this vehicle type's raster model file name.
double getBoardingFactor() const
Get this person type's factor for loading/boarding duration.
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.
int getNumericalID() const
Returns the running index of the vehicle type.
const SUMOVTypeParameter & getParameter() const
double computeChosenSpeedDeviation(SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
SUMOTime getActionStepLength() const
Returns this type's default action step length.
virtual ~MSVehicleType()
Destructor.
double getPreferredLateralAlignmentOffset() const
Get vehicle's preferred lateral alignment offset (in m from center line).
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
const EnergyParams myEnergyParams
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...
const RGBColor & getColor() const
Returns this type's color.
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...
const std::vector< std::string > & getParkingBadges() const
Returns the parking access rights of this type.
void setScale(double value)
Set traffic scaling factor.
Structure representing possible vehicle parameter.