SUMO - Simulation of Urban MObility
SUMOVTypeParameter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 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 // Structure representing possible vehicle parameter
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <algorithm>
28 #include <utils/common/ToString.h>
35 
36 #define EMPREFIX std::string("HBEFA3/")
37 
38 
39 // ===========================================================================
40 // member method definitions
41 // ===========================================================================
42 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass) :
43  id(vtid), length(5./*4.3*/), minGap(2.5), maxSpeed(200. / 3.6),
44  actionStepLength(0), defaultProbability(DEFAULT_VEH_PROB),
45  speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
46  emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)), color(RGBColor::DEFAULT_COLOR),
47  vehicleClass(vclass), impatience(0.0), personCapacity(4), containerCapacity(0), boardingDuration(500),
48  loadingDuration(90000), width(1.8), height(1.5), shape(SVS_UNKNOWN), osgFile("car-normal-citrus.obj"),
49  cfModel(SUMO_TAG_CF_KRAUSS),
50  hasDriverState(false), lcModel(LCM_DEFAULT),
51  maxSpeedLat(1.0), latAlignment(LATALIGN_CENTER), minGapLat(0.6),
52  parametersSet(0), saved(false), onlyReferenced(false) {
54  if (oc.exists("carfollow.model")) {
55  // check for valid value has been performed in MSFrame
57  }
58  switch (vclass) {
59  case SVC_PEDESTRIAN:
60  length = 0.215;
61  minGap = 0.25;
63  width = 0.478;
64  height = 1.719;
67  speedFactor.getParameter()[1] = 0.1;
68  break;
69  case SVC_BICYCLE:
70  length = 1.6;
71  minGap = 0.5;
72  maxSpeed = 20. / 3.6;
73  width = 0.65;
74  height = 1.7;
76  personCapacity = 1;
78  speedFactor.getParameter()[1] = 0.1;
79  break;
80  case SVC_MOPED:
81  length = 2.1;
82  maxSpeed = 60. / 3.6;
83  width = 0.8;
84  height = 1.7;
85  shape = SVS_MOPED;
86  personCapacity = 1;
88  speedFactor.getParameter()[1] = 0.1;
89  break;
90  case SVC_MOTORCYCLE:
91  length = 2.2;
92  width = 0.9;
93  height = 1.5;
95  personCapacity = 1;
97  speedFactor.getParameter()[1] = 0.1;
98  break;
99  case SVC_TRUCK:
100  length = 7.1;
101  maxSpeed = 130. / 3.6;
102  width = 2.4;
103  height = 2.4;
104  shape = SVS_TRUCK;
105  osgFile = "car-microcargo-citrus.obj";
106  personCapacity = 2;
107  containerCapacity = 1;
109  speedFactor.getParameter()[1] = 0.05;
110  break;
111  case SVC_TRAILER:
112  length = 16.5;
113  maxSpeed = 130. / 3.6;
114  width = 2.55;
115  height = 4.;
117  osgFile = "car-microcargo-citrus.obj";
118  personCapacity = 2;
119  containerCapacity = 2;
121  speedFactor.getParameter()[1] = 0.05;
122  break;
123  case SVC_BUS:
124  length = 12.;
125  maxSpeed = 100. / 3.6;
126  width = 2.5;
127  height = 3.4;
128  shape = SVS_BUS;
129  osgFile = "car-minibus-citrus.obj";
130  personCapacity = 85;
132  break;
133  case SVC_COACH:
134  length = 14.;
135  maxSpeed = 100. / 3.6;
136  width = 2.6;
137  height = 4.;
139  osgFile = "car-minibus-citrus.obj";
140  personCapacity = 70;
142  speedFactor.getParameter()[1] = 0.05;
143  break;
144  case SVC_TRAM:
145  length = 22.;
146  maxSpeed = 80. / 3.6;
147  width = 2.4;
148  height = 3.2;
150  personCapacity = 120;
152  break;
153  case SVC_RAIL_URBAN:
154  length = 36.5 * 3;
155  maxSpeed = 100. / 3.6;
156  width = 3.0;
157  height = 3.6;
159  personCapacity = 300;
161  break;
162  case SVC_RAIL:
163  length = 67.5 * 2;
164  maxSpeed = 160. / 3.6;
165  width = 2.84;
166  height = 3.75;
167  shape = SVS_RAIL;
168  personCapacity = 434;
169  // slight understatement (-:
171  break;
172  case SVC_RAIL_ELECTRIC:
173  length = 25. * 8;
174  maxSpeed = 330. / 3.6;
175  width = 2.95;
176  height = 3.89;
177  shape = SVS_RAIL;
178  personCapacity = 425;
180  break;
181  case SVC_DELIVERY:
182  length = 6.5;
183  width = 2.16;
184  height = 2.86;
186  personCapacity = 2;
188  speedFactor.getParameter()[1] = 0.05;
189  break;
190  case SVC_EMERGENCY:
191  length = 6.5;
192  width = 2.16;
193  height = 2.86;
195  personCapacity = 2;
197  break;
198  case SVC_PASSENGER:
200  speedFactor.getParameter()[1] = 0.1;
201  break;
202  case SVC_E_VEHICLE:
205  speedFactor.getParameter()[1] = 0.1;
206  break;
207  case SVC_SHIP:
208  length = 17;
209  width = 4;
210  maxSpeed = 8 / 1.94; // 8 knots
211  height = 4;
212  shape = SVS_SHIP;
213  // slight understatement (-:
215  speedFactor.getParameter()[1] = 0.1;
216  break;
217  default:
218  break;
219  }
220  if (oc.exists("default.speeddev")) {
221  const double defaultSpeedDev = oc.getFloat("default.speeddev");
222  if (defaultSpeedDev >= 0) {
223  speedFactor.getParameter()[1] = defaultSpeedDev;
224  }
225  } else {
226  speedFactor.getParameter()[1] = 0;
227  }
228 }
229 
230 
231 void
233  if (onlyReferenced) {
234  return;
235  }
236  dev.openTag(SUMO_TAG_VTYPE);
237  dev.writeAttr(SUMO_ATTR_ID, id);
240  }
243  }
246  }
249  }
252  }
254  // Note: action step length is only exposed in seconds to the user
256  }
258  // Note: action step length is only exposed in seconds to the user
260  }
263  }
266  }
268  if (impatience == -std::numeric_limits<double>::max()) {
269  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
270  } else {
272  }
273  }
276  }
279  }
282  }
285  }
288  }
291  }
294  }
297  }
300  }
303  }
306  }
309  }
312  }
315  }
316  for (SubParams::const_iterator i = lcParameter.begin(); i != lcParameter.end(); ++i) {
317  dev.writeAttr(i->first, i->second);
318  }
319  for (SubParams::const_iterator i = jmParameter.begin(); i != jmParameter.end(); ++i) {
320  dev.writeAttr(i->first, i->second);
321  }
324  }
325  for (SubParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
326  dev.writeAttr(i->first, i->second);
327  }
328  writeParams(dev);
329  dev.closeTag();
330 }
331 
332 
333 double
334 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
335  if (cfParameter.count(attr)) {
336  return TplConvert::_str2double(cfParameter.find(attr)->second);
337  } else {
338  return defaultValue;
339  }
340 }
341 
342 
343 std::string
344 SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
345  if (cfParameter.count(attr)) {
346  return cfParameter.find(attr)->second;
347  } else {
348  return defaultValue;
349  }
350 }
351 
352 double
353 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
354  if (lcParameter.count(attr)) {
355  return TplConvert::_str2double(lcParameter.find(attr)->second);
356  } else {
357  return defaultValue;
358  }
359 }
360 
363  return lcParameter;
364 }
365 
366 
367 double
368 SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
369  if (jmParameter.count(attr)) {
370  return TplConvert::_str2double(jmParameter.find(attr)->second);
371  } else {
372  return defaultValue;
373  }
374 }
375 
376 double
378  switch (vc) {
379  case SVC_PEDESTRIAN:
380  return 1.5;
381  case SVC_BICYCLE:
382  return 1.2;
383  case SVC_MOTORCYCLE:
384  return 6.;
385  case SVC_MOPED:
386  return 1.1;
387  case SVC_TRUCK:
388  return 1.3;
389  case SVC_TRAILER:
390  return 1.1;
391  case SVC_BUS:
392  return 1.2;
393  case SVC_COACH:
394  return 2.;
395  case SVC_TRAM:
396  return 1.;
397  case SVC_RAIL_URBAN:
398  return 1.;
399  case SVC_RAIL:
400  return 0.25;
401  case SVC_RAIL_ELECTRIC:
402  return 0.5;
403  case SVC_SHIP:
404  return 0.1;
405  default:
406  return 2.6;//2.9;
407  }
408 }
409 
410 
411 double
413  switch (vc) {
414  case SVC_PEDESTRIAN:
415  return 2.;
416  case SVC_BICYCLE:
417  return 3.;
418  case SVC_MOPED:
419  return 7.;
420  case SVC_MOTORCYCLE:
421  return 10.;
422  case SVC_TRUCK:
423  return 4.;
424  case SVC_TRAILER:
425  return 4.;
426  case SVC_BUS:
427  return 4.;
428  case SVC_COACH:
429  return 4.;
430  case SVC_TRAM:
431  return 3.;
432  case SVC_RAIL_URBAN:
433  return 3.;
434  case SVC_RAIL:
435  return 1.3;
436  case SVC_RAIL_ELECTRIC:
437  return 1.3;
438  case SVC_SHIP:
439  return 0.15;
440  default:
441  return 4.5;//7.5;
442  }
443 }
444 
445 
446 double
448  const std::string defaultEmergencyDecelOption = OptionsCont::getOptions().getString("default.emergencydecel");
449  if (defaultEmergencyDecelOption == "default") {
450  double vcDecel;
451  switch (vc) {
452  case SVC_PEDESTRIAN:
453  vcDecel = 5.;
454  case SVC_BICYCLE:
455  vcDecel = 7.;
456  case SVC_MOPED:
457  vcDecel = 10.;
458  case SVC_MOTORCYCLE:
459  vcDecel = 10.;
460  case SVC_TRUCK:
461  vcDecel = 7.;
462  case SVC_TRAILER:
463  vcDecel = 7.;
464  case SVC_BUS:
465  vcDecel = 7.;
466  case SVC_COACH:
467  vcDecel = 7.;
468  case SVC_TRAM:
469  vcDecel = 7.;
470  case SVC_RAIL_URBAN:
471  vcDecel = 7.;
472  case SVC_RAIL:
473  vcDecel = 5;
474  case SVC_RAIL_ELECTRIC:
475  vcDecel = 5;
476  case SVC_SHIP:
477  vcDecel = 1;
478  default:
479  vcDecel = 9;
480  }
481  return MAX2(decel, vcDecel);
482  } else if (defaultEmergencyDecelOption == "decel") {
483  return decel;
484  } else {
485  // value already checked in MSFrame::checkOptions
486  return MAX2(decel, TplConvert::_2double(defaultEmergencyDecelOption.c_str()));
487  }
488 }
489 
490 
491 
492 double
494  switch (vc) {
495  case SVC_TRAM:
496  case SVC_RAIL_URBAN:
497  case SVC_RAIL:
498  case SVC_RAIL_ELECTRIC:
499  case SVC_SHIP:
500  return 0.;
501  default:
502  return 0.5;
503  }
504 }
505 
506 
507 const SUMOVTypeParameter&
509  static SUMOVTypeParameter defaultParams("");
510  return defaultParams;
511 }
512 
513 
514 /****************************************************************************/
const int VTYPEPARS_MAXSPEED_SET
const int VTYPEPARS_MINGAP_SET
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
vehicle is a motorcycle
const SubParams & getLCParams() const
Returns the LC parameter.
vehicle is a coach
static StringBijection< SumoXMLTag > CarFollowModels
car following models
render as a rail
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
const int VTYPEPARS_LATALIGNMENT_SET
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
description of a vehicle type
double impatience
The vehicle&#39;s impatience (willingness to obstruct others)
is a pedestrian
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
render as a motorcycle
vehicle is a not electrified rail
SUMOVehicleShape shape
This class&#39; shape.
Structure representing possible vehicle parameter.
const int VTYPEPARS_MINGAP_LAT_SET
SUMOVTypeParameter(const std::string &vtid, const SUMOVehicleClass vc=SVC_IGNORING)
Constructor.
render as a transport vehicle
double defaultProbability
The probability when being added to a distribution without an explicit probability.
std::vector< double > & getParameter()
Returns the parameters of this distribution.
vehicle is a bicycle
vehicle is a small delivery vehicle
int containerCapacity
The container capacity of the vehicle.
const int VTYPEPARS_BOARDING_DURATION
vehicle is a light rail
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
T MAX2(T a, T b)
Definition: StdDefs.h:68
render as a delivery vehicle
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const double DEFAULT_VEH_PROB
const int VTYPEPARS_CAR_FOLLOW_MODEL
const int VTYPEPARS_OSGFILE_SET
const int VTYPEPARS_MAXSPEED_LAT_SET
const int VTYPEPARS_PROBABILITY_SET
vehicle is a (possibly fast moving) electric rail
static double getDefaultAccel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default acceleration for the given vehicle class This needs to be a function because the ...
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
double height
This class&#39; height.
static double _str2double(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
Definition: TplConvert.h:357
vehicle is a city rail
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
const int VTYPEPARS_LANE_CHANGE_MODEL_SET
vehicle is a large transport vehicle
static double getDefaultImperfection(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default driver&#39;s imperfection (sigma or epsilon in Krauss&#39; model) for the given vehicle c...
double getLCParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
#define EMPREFIX
bool wasSet(int what) const
Returns whether the given parameter was set.
double maxSpeed
The vehicle type&#39;s maximum speed [m/s].
double width
This class&#39; width.
SUMOTime boardingDuration
The time a person needs to board the vehicle.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
const int VTYPEPARS_ACTIONSTEPLENGTH_SET
render as a bus
std::string osgFile
3D model file for this class
not defined
render as a bicycle
T get(const std::string &str) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
std::string imgFile
Image file for this class.
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
bool exists(const std::string &name) const
Returns the information whether the named option is known.
render as a (city) rail without locomotive
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
render as a passenger vehicle
const int VTYPEPARS_LOADING_DURATION
const int VTYPEPARS_CONTAINER_CAPACITY
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
const int VTYPEPARS_SPEEDFACTOR_SET
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
is an arbitrary ship
double maxSpeedLat
The vehicle type&#39;s maximum lateral speed [m/s].
vehicle is a moped
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
drive in the middle
int personCapacity
The person capacity of the vehicle.
vehicle is a bus
bool hasDriverState
Whether vehicles of this type are equipped with a driver (i.e. MSDriverState))
render as a pedestrian
render as a moped
double minGapLat
The vehicle type&#39;s minimum lateral gap [m].
void write(OutputDevice &dev) const
Writes the vtype.
std::string getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
const double DEFAULT_PEDESTRIAN_SPEED
render as a arbitrary ship
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
SubParams jmParameter
Junction-model parameter.
const int VTYPEPARS_IMGFILE_SET
SubParams cfParameter
Car-following parameter.
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
RGBColor color
The color.
A storage for options typed value containers)
Definition: OptionsCont.h:92
static double _2double(const E *const data)
converts a char-type array into the double value described by it
Definition: TplConvert.h:305
vehicle is a large transport vehicle
const int VTYPEPARS_PERSON_CAPACITY
LateralAlignment latAlignment
The vehicles desired lateral alignment.
SUMOTime actionStepLength
The vehicle type&#39;s default actionStepLength [ms], i.e. the interval between two control actions...
double minGap
This class&#39; free space in front of the vehicle itself.
render as a (futuristic) e-vehicle
const int VTYPEPARS_HEIGHT_SET
static double getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel)
Returns the default emergency deceleration for the given vehicle class This needs to be a function be...
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
const int VTYPEPARS_WIDTH_SET
LaneChangeModel lcModel
The lane-change model to use.
static const SUMOVTypeParameter & getDefault()
return the default parameters, this is a function due to the http://www.parashift.com/c++-faq/static-init-order.html
public emergency vehicles
const int VTYPEPARS_LENGTH_SET
const int VTYPEPARS_VEHICLECLASS_SET
render as a coach
A color information.
const int VTYPEPARS_EMISSIONCLASS_SET
const int VTYPEPARS_COLOR_SET
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
render as a semi-trailer transport vehicle ("Sattelschlepper")
const int VTYPEPARS_SHAPE_SET
double length
The physical vehicle length.
SubParams lcParameter
Lane-changing parameter.
SUMOEmissionClass emissionClass
The emission class of this vehicle.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
const int VTYPEPARS_IMPATIENCE_SET
Helper methods for PHEMlight-based emission computation.
is an electric vehicle