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_PRIVATE:
199  case SVC_VIP:
200  case SVC_PASSENGER:
201  case SVC_HOV:
202  case SVC_CUSTOM1:
203  case SVC_CUSTOM2:
205  speedFactor.getParameter()[1] = 0.1;
206  break;
207  case SVC_TAXI:
209  speedFactor.getParameter()[1] = 0.05;
210  break;
211  case SVC_E_VEHICLE:
214  speedFactor.getParameter()[1] = 0.1;
215  break;
216  case SVC_SHIP:
217  length = 17;
218  width = 4;
219  maxSpeed = 8 / 1.94; // 8 knots
220  height = 4;
221  shape = SVS_SHIP;
222  // slight understatement (-:
224  speedFactor.getParameter()[1] = 0.1;
225  break;
226  default:
227  break;
228  }
229  if (oc.exists("default.speeddev")) {
230  const double defaultSpeedDev = oc.getFloat("default.speeddev");
231  if (defaultSpeedDev >= 0) {
232  speedFactor.getParameter()[1] = defaultSpeedDev;
233  }
234  } else {
235  speedFactor.getParameter()[1] = 0;
236  }
237 }
238 
239 
240 void
242  if (onlyReferenced) {
243  return;
244  }
245  dev.openTag(SUMO_TAG_VTYPE);
246  dev.writeAttr(SUMO_ATTR_ID, id);
249  }
252  }
255  }
258  }
261  }
263  // Note: action step length is only exposed in seconds to the user
265  }
267  // Note: action step length is only exposed in seconds to the user
269  }
272  }
275  }
277  if (impatience == -std::numeric_limits<double>::max()) {
278  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
279  } else {
281  }
282  }
285  }
288  }
291  }
294  }
297  }
300  }
303  }
306  }
309  }
312  }
315  }
318  }
321  }
324  }
325  for (SubParams::const_iterator i = lcParameter.begin(); i != lcParameter.end(); ++i) {
326  dev.writeAttr(i->first, i->second);
327  }
328  for (SubParams::const_iterator i = jmParameter.begin(); i != jmParameter.end(); ++i) {
329  dev.writeAttr(i->first, i->second);
330  }
333  }
334  for (SubParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
335  dev.writeAttr(i->first, i->second);
336  }
337  writeParams(dev);
338  dev.closeTag();
339 }
340 
341 
342 double
343 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
344  if (cfParameter.count(attr)) {
345  return StringUtils::toDouble(cfParameter.find(attr)->second);
346  } else {
347  return defaultValue;
348  }
349 }
350 
351 
352 std::string
353 SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
354  if (cfParameter.count(attr)) {
355  return cfParameter.find(attr)->second;
356  } else {
357  return defaultValue;
358  }
359 }
360 
361 double
362 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
363  if (lcParameter.count(attr)) {
364  return StringUtils::toDouble(lcParameter.find(attr)->second);
365  } else {
366  return defaultValue;
367  }
368 }
369 
372  return lcParameter;
373 }
374 
375 
376 double
377 SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
378  if (jmParameter.count(attr)) {
379  return StringUtils::toDouble(jmParameter.find(attr)->second);
380  } else {
381  return defaultValue;
382  }
383 }
384 
385 double
387  switch (vc) {
388  case SVC_PEDESTRIAN:
389  return 1.5;
390  case SVC_BICYCLE:
391  return 1.2;
392  case SVC_MOTORCYCLE:
393  return 6.;
394  case SVC_MOPED:
395  return 1.1;
396  case SVC_TRUCK:
397  return 1.3;
398  case SVC_TRAILER:
399  return 1.1;
400  case SVC_BUS:
401  return 1.2;
402  case SVC_COACH:
403  return 2.;
404  case SVC_TRAM:
405  return 1.;
406  case SVC_RAIL_URBAN:
407  return 1.;
408  case SVC_RAIL:
409  return 0.25;
410  case SVC_RAIL_ELECTRIC:
411  return 0.5;
412  case SVC_SHIP:
413  return 0.1;
414  default:
415  return 2.6;//2.9;
416  }
417 }
418 
419 
420 double
422  switch (vc) {
423  case SVC_PEDESTRIAN:
424  return 2.;
425  case SVC_BICYCLE:
426  return 3.;
427  case SVC_MOPED:
428  return 7.;
429  case SVC_MOTORCYCLE:
430  return 10.;
431  case SVC_TRUCK:
432  case SVC_TRAILER:
433  case SVC_BUS:
434  case SVC_COACH:
435  return 4.;
436  case SVC_TRAM:
437  case SVC_RAIL_URBAN:
438  return 3.;
439  case SVC_RAIL:
440  case SVC_RAIL_ELECTRIC:
441  return 1.3;
442  case SVC_SHIP:
443  return 0.15;
444  default:
445  return 4.5;//7.5;
446  }
447 }
448 
449 
450 double
451 SUMOVTypeParameter::getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption) {
452  if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT) {
453  double vcDecel;
454  switch (vc) {
455  case SVC_PEDESTRIAN:
456  vcDecel = 5.;
457  break;
458  case SVC_BICYCLE:
459  vcDecel = 7.;
460  break;
461  case SVC_MOPED:
462  case SVC_MOTORCYCLE:
463  vcDecel = 10.;
464  break;
465  case SVC_TRUCK:
466  case SVC_TRAILER:
467  case SVC_BUS:
468  case SVC_COACH:
469  case SVC_TRAM:
470  case SVC_RAIL_URBAN:
471  vcDecel = 7.;
472  break;
473  case SVC_RAIL:
474  case SVC_RAIL_ELECTRIC:
475  vcDecel = 5.;
476  break;
477  case SVC_SHIP:
478  vcDecel = 1.;
479  break;
480  default:
481  vcDecel = 9.;
482  }
483  return MAX2(decel, vcDecel);
484  } else if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL) {
485  return decel;
486  } else {
487  // value already checked in MSFrame::checkOptions
488  return MAX2(decel, defaultOption);
489  }
490 }
491 
492 
493 
494 double
496  switch (vc) {
497  case SVC_TRAM:
498  case SVC_RAIL_URBAN:
499  case SVC_RAIL:
500  case SVC_RAIL_ELECTRIC:
501  case SVC_SHIP:
502  return 0.;
503  default:
504  return 0.5;
505  }
506 }
507 
508 
509 const SUMOVTypeParameter&
511  static SUMOVTypeParameter defaultParams("");
512  return defaultParams;
513 }
514 
515 
516 /****************************************************************************/
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
const int VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL
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:76
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
vehicle is a HOV
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.
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
is a user-defined type
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
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
private vehicles
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
vehicle is a taxi
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.
vip vehicles
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
vehicle is a large transport vehicle
const int VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT
const int VTYPEPARS_PERSON_CAPACITY
static double getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption)
Returns the default emergency deceleration for the given vehicle class This needs to be a function be...
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 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
is a user-defined type
Helper methods for PHEMlight-based emission computation.
is an electric vehicle