SUMO - Simulation of Urban MObility
SUMOVTypeParameter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Structure representing possible vehicle parameter
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <algorithm>
35 #include <utils/common/ToString.h>
42 
43 #define EMPREFIX std::string("HBEFA3/")
44 
45 
46 // ===========================================================================
47 // member method definitions
48 // ===========================================================================
49 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
50  : id(vtid), length(5./*4.3*/), minGap(2.5), maxSpeed(200. / 3.6),
51  defaultProbability(DEFAULT_VEH_PROB),
52  speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
53  emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)), color(RGBColor::DEFAULT_COLOR),
54  vehicleClass(vclass), impatience(0.0), personCapacity(4), containerCapacity(0), boardingDuration(500),
55  loadingDuration(90000), width(1.8), height(1.5), shape(SVS_UNKNOWN), osgFile("car-normal-citrus.obj"),
56  cfModel(SUMO_TAG_CF_KRAUSS), lcModel(LCM_DEFAULT),
57  maxSpeedLat(1.0), latAlignment(LATALIGN_CENTER), minGapLat(1.00),
58  setParameter(0), saved(false), onlyReferenced(false) {
59  switch (vclass) {
60  case SVC_PEDESTRIAN:
61  length = 0.215;
62  minGap = 0.25;
64  width = 0.478;
65  height = 1.719;
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  break;
79  case SVC_MOPED:
80  length = 2.1;
81  maxSpeed = 60. / 3.6;
82  width = 0.8;
83  height = 1.7;
84  shape = SVS_MOPED;
85  personCapacity = 1;
87  break;
88  case SVC_MOTORCYCLE:
89  length = 2.2;
90  width = 0.9;
91  height = 1.5;
93  personCapacity = 1;
95  break;
96  case SVC_TRUCK:
97  length = 7.1;
98  maxSpeed = 130. / 3.6;
99  width = 2.4;
100  height = 2.4;
101  shape = SVS_TRUCK;
102  osgFile = "car-microcargo-citrus.obj";
103  personCapacity = 2;
104  containerCapacity = 1;
106  break;
107  case SVC_TRAILER:
108  length = 16.5;
109  maxSpeed = 130. / 3.6;
110  width = 2.55;
111  height = 4.;
113  osgFile = "car-microcargo-citrus.obj";
114  personCapacity = 2;
115  containerCapacity = 2;
117  break;
118  case SVC_BUS:
119  length = 12.;
120  maxSpeed = 100. / 3.6;
121  width = 2.5;
122  height = 3.4;
123  shape = SVS_BUS;
124  osgFile = "car-minibus-citrus.obj";
125  personCapacity = 85;
127  break;
128  case SVC_COACH:
129  length = 14.;
130  maxSpeed = 100. / 3.6;
131  width = 2.6;
132  height = 4.;
134  osgFile = "car-minibus-citrus.obj";
135  personCapacity = 70;
137  break;
138  case SVC_TRAM:
139  length = 22.;
140  maxSpeed = 80. / 3.6;
141  width = 2.4;
142  height = 3.2;
144  personCapacity = 120;
146  break;
147  case SVC_RAIL_URBAN:
148  length = 36.5 * 3;
149  maxSpeed = 100. / 3.6;
150  width = 3.0;
151  height = 3.6;
153  personCapacity = 300;
155  break;
156  case SVC_RAIL:
157  length = 67.5 * 2;
158  maxSpeed = 1600. / 3.6;
159  width = 2.84;
160  height = 3.75;
161  shape = SVS_RAIL;
162  personCapacity = 434;
163  // slight understatement (-:
165  break;
166  case SVC_RAIL_ELECTRIC:
167  length = 25. * 8;
168  maxSpeed = 330. / 3.6;
169  width = 2.95;
170  height = 3.89;
171  shape = SVS_RAIL;
172  personCapacity = 425;
174  break;
175  case SVC_DELIVERY:
176  length = 6.5;
177  width = 2.16;
178  height = 2.86;
180  personCapacity = 2;
182  break;
183  case SVC_EMERGENCY:
184  length = 6.5;
185  width = 2.16;
186  height = 2.86;
188  personCapacity = 2;
190  break;
191  case SVC_PASSENGER:
193  break;
194  case SVC_E_VEHICLE:
197  break;
198  case SVC_SHIP:
199  length = 17;
200  width = 4;
201  maxSpeed = 8 / 1.94; // 8 knots
202  height = 4;
203  shape = SVS_SHIP;
204  // slight understatement (-:
206  break;
207  default:
208  break;
209  }
210 }
211 
212 
213 void
215  if (onlyReferenced) {
216  return;
217  }
218  dev.openTag(SUMO_TAG_VTYPE);
219  dev.writeAttr(SUMO_ATTR_ID, id);
222  }
225  }
228  }
231  }
234  }
237  }
240  }
243  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
244  } else {
246  }
247  }
250  }
253  }
256  }
259  }
262  }
265  }
268  }
271  }
274  }
277  }
280  }
283  }
286  }
287  if (wasSet(VTYPEPARS_LANE_CHANGE_MODEL_SET) || lcParameter.size() != 0) {
289  std::vector<SumoXMLAttr> attrs;
290  for (SubParams::const_iterator i = lcParameter.begin(); i != lcParameter.end(); ++i) {
291  attrs.push_back(i->first);
292  }
293  std::sort(attrs.begin(), attrs.end());
294  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
295  dev.writeAttr(*i, lcParameter.find(*i)->second);
296  }
297  }
298  if (wasSet(VTYPEPARS_CAR_FOLLOW_MODEL) || cfParameter.size() != 0) {
299  dev.openTag(cfModel);
300  std::vector<SumoXMLAttr> attrs;
301  for (SubParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
302  attrs.push_back(i->first);
303  }
304  std::sort(attrs.begin(), attrs.end());
305  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
306  dev.writeAttr(*i, cfParameter.find(*i)->second);
307  }
308  dev.closeTag();
309  }
310  writeParams(dev);
311  dev.closeTag();
312 }
313 
314 
315 double
316 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
317  if (cfParameter.count(attr)) {
318  return TplConvert::_str2double(cfParameter.find(attr)->second);
319  } else {
320  return defaultValue;
321  }
322 }
323 
324 
325 std::string
326 SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
327  if (cfParameter.count(attr)) {
328  return cfParameter.find(attr)->second;
329  } else {
330  return defaultValue;
331  }
332 }
333 
334 double
335 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
336  if (lcParameter.count(attr)) {
337  return TplConvert::_str2double(lcParameter.find(attr)->second);
338  } else {
339  return defaultValue;
340  }
341 }
342 
343 
344 
345 double
347  switch (vc) {
348  case SVC_PEDESTRIAN:
349  return 1.5;
350  case SVC_BICYCLE:
351  return 1.2;
352  case SVC_MOTORCYCLE:
353  return 6.;
354  case SVC_MOPED:
355  return 1.1;
356  case SVC_TRUCK:
357  return 1.3;
358  case SVC_TRAILER:
359  return 1.1;
360  case SVC_BUS:
361  return 1.2;
362  case SVC_COACH:
363  return 2.;
364  case SVC_TRAM:
365  return 1.;
366  case SVC_RAIL_URBAN:
367  return 1.;
368  case SVC_RAIL:
369  return 0.25;
370  case SVC_RAIL_ELECTRIC:
371  return 0.5;
372  case SVC_SHIP:
373  return 0.1;
374  default:
375  return 2.6;//2.9;
376  }
377 }
378 
379 
380 double
382  switch (vc) {
383  case SVC_PEDESTRIAN:
384  return 2.;
385  case SVC_BICYCLE:
386  return 3.;
387  case SVC_MOPED:
388  return 7.;
389  case SVC_MOTORCYCLE:
390  return 10.;
391  case SVC_TRUCK:
392  return 4.;
393  case SVC_TRAILER:
394  return 4.;
395  case SVC_BUS:
396  return 4.;
397  case SVC_COACH:
398  return 4.;
399  case SVC_TRAM:
400  return 3.;
401  case SVC_RAIL_URBAN:
402  return 3.;
403  case SVC_RAIL:
404  return 1.3;
405  case SVC_RAIL_ELECTRIC:
406  return 1.3;
407  case SVC_SHIP:
408  return 0.15;
409  default:
410  return 4.5;//7.5;
411  }
412 }
413 
414 
415 double
417  switch (vc) {
418  case SVC_PEDESTRIAN:
419  return 3.;
420  case SVC_BICYCLE:
421  return 5.;
422  case SVC_MOPED:
423  return 8.;
424  case SVC_MOTORCYCLE:
425  return 10.;
426  case SVC_TRUCK:
427  return 7.;
428  case SVC_TRAILER:
429  return 7.;
430  case SVC_BUS:
431  return 7.;
432  case SVC_COACH:
433  return 7.;
434  case SVC_TRAM:
435  return 5.;
436  case SVC_RAIL_URBAN:
437  return 5.;
438  case SVC_RAIL:
439  return 4;
440  case SVC_RAIL_ELECTRIC:
441  return 4;
442  case SVC_SHIP:
443  return 1;
444  default:
445  return 9;//7.5;
446  }
447 }
448 
449 
450 
451 double
453  switch (vc) {
454  case SVC_TRAM:
455  case SVC_RAIL_URBAN:
456  case SVC_RAIL:
457  case SVC_RAIL_ELECTRIC:
458  case SVC_SHIP:
459  return 0.;
460  default:
461  return 0.5;
462  }
463 }
464 
465 
466 const SUMOVTypeParameter&
468  static SUMOVTypeParameter defaultParams("");
469  return defaultParams;
470 }
471 
472 
473 /****************************************************************************/
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
vehicle is a coach
render as a rail
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
const int VTYPEPARS_LATALIGNMENT_SET
description of a vehicle type
double impatience
The vehicle&#39;s impatience (willingness to obstruct others)
is a pedestrian
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.
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.
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 ...
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:348
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
void writeParams(OutputDevice &out) const
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
#define max(a, b)
Definition: polyfonts.c:65
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:56
render as a bus
std::string osgFile
3D model file for this class
not defined
render as a bicycle
std::string imgFile
Image file for this class.
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
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) ...
static double getDefaultEmergencyDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default emergency deceleration for the given vehicle class This needs to be a function be...
const int VTYPEPARS_SPEEDFACTOR_SET
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
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.
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.
vehicle is a large transport vehicle
const int VTYPEPARS_PERSON_CAPACITY
LateralAlignment latAlignment
The vehicles desired lateral alignment.
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:71
bool closeTag()
Closes the most recently opened tag.
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