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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Structure representing possible vehicle parameter
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <algorithm>
34 #include <utils/common/ToString.h>
41 
42 #define EMPREFIX std::string("HBEFA3/")
43 
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
49  : id(vtid), length(5./*4.3*/), minGap(2.5), maxSpeed(200. / 3.6),
50  actionStepLength(0), defaultProbability(DEFAULT_VEH_PROB),
51  speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
52  emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)), color(RGBColor::DEFAULT_COLOR),
53  vehicleClass(vclass), impatience(0.0), personCapacity(4), containerCapacity(0), boardingDuration(500),
54  loadingDuration(90000), width(1.8), height(1.5), shape(SVS_UNKNOWN), osgFile("car-normal-citrus.obj"),
55  cfModel(SUMO_TAG_CF_KRAUSS), lcModel(LCM_DEFAULT),
56  maxSpeedLat(1.0), latAlignment(LATALIGN_CENTER), minGapLat(0.6),
57  parametersSet(0), saved(false), onlyReferenced(false) {
58  switch (vclass) {
59  case SVC_PEDESTRIAN:
60  length = 0.215;
61  minGap = 0.25;
63  width = 0.478;
64  height = 1.719;
67  break;
68  case SVC_BICYCLE:
69  length = 1.6;
70  minGap = 0.5;
71  maxSpeed = 20. / 3.6;
72  width = 0.65;
73  height = 1.7;
75  personCapacity = 1;
77  break;
78  case SVC_MOPED:
79  length = 2.1;
80  maxSpeed = 60. / 3.6;
81  width = 0.8;
82  height = 1.7;
83  shape = SVS_MOPED;
84  personCapacity = 1;
86  break;
87  case SVC_MOTORCYCLE:
88  length = 2.2;
89  width = 0.9;
90  height = 1.5;
92  personCapacity = 1;
94  break;
95  case SVC_TRUCK:
96  length = 7.1;
97  maxSpeed = 130. / 3.6;
98  width = 2.4;
99  height = 2.4;
100  shape = SVS_TRUCK;
101  osgFile = "car-microcargo-citrus.obj";
102  personCapacity = 2;
103  containerCapacity = 1;
105  break;
106  case SVC_TRAILER:
107  length = 16.5;
108  maxSpeed = 130. / 3.6;
109  width = 2.55;
110  height = 4.;
112  osgFile = "car-microcargo-citrus.obj";
113  personCapacity = 2;
114  containerCapacity = 2;
116  break;
117  case SVC_BUS:
118  length = 12.;
119  maxSpeed = 100. / 3.6;
120  width = 2.5;
121  height = 3.4;
122  shape = SVS_BUS;
123  osgFile = "car-minibus-citrus.obj";
124  personCapacity = 85;
126  break;
127  case SVC_COACH:
128  length = 14.;
129  maxSpeed = 100. / 3.6;
130  width = 2.6;
131  height = 4.;
133  osgFile = "car-minibus-citrus.obj";
134  personCapacity = 70;
136  break;
137  case SVC_TRAM:
138  length = 22.;
139  maxSpeed = 80. / 3.6;
140  width = 2.4;
141  height = 3.2;
143  personCapacity = 120;
145  break;
146  case SVC_RAIL_URBAN:
147  length = 36.5 * 3;
148  maxSpeed = 100. / 3.6;
149  width = 3.0;
150  height = 3.6;
152  personCapacity = 300;
154  break;
155  case SVC_RAIL:
156  length = 67.5 * 2;
157  maxSpeed = 1600. / 3.6;
158  width = 2.84;
159  height = 3.75;
160  shape = SVS_RAIL;
161  personCapacity = 434;
162  // slight understatement (-:
164  break;
165  case SVC_RAIL_ELECTRIC:
166  length = 25. * 8;
167  maxSpeed = 330. / 3.6;
168  width = 2.95;
169  height = 3.89;
170  shape = SVS_RAIL;
171  personCapacity = 425;
173  break;
174  case SVC_DELIVERY:
175  length = 6.5;
176  width = 2.16;
177  height = 2.86;
179  personCapacity = 2;
181  break;
182  case SVC_EMERGENCY:
183  length = 6.5;
184  width = 2.16;
185  height = 2.86;
187  personCapacity = 2;
189  break;
190  case SVC_PASSENGER:
192  break;
193  case SVC_E_VEHICLE:
196  break;
197  case SVC_SHIP:
198  length = 17;
199  width = 4;
200  maxSpeed = 8 / 1.94; // 8 knots
201  height = 4;
202  shape = SVS_SHIP;
203  // slight understatement (-:
205  break;
206  default:
207  break;
208  }
209 }
210 
211 
212 void
214  if (onlyReferenced) {
215  return;
216  }
217  dev.openTag(SUMO_TAG_VTYPE);
218  dev.writeAttr(SUMO_ATTR_ID, id);
221  }
224  }
227  }
230  }
233  }
235  // Note: action step length is only exposed in seconds to the user
237  }
240  }
243  }
245  if (impatience == -std::numeric_limits<double>::max()) {
246  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
247  } else {
249  }
250  }
253  }
256  }
259  }
262  }
265  }
268  }
271  }
274  }
277  }
280  }
283  }
286  }
289  }
292  }
293  for (SubParams::const_iterator i = lcParameter.begin(); i != lcParameter.end(); ++i) {
294  dev.writeAttr(i->first, i->second);
295  }
296  for (SubParams::const_iterator i = jmParameter.begin(); i != jmParameter.end(); ++i) {
297  dev.writeAttr(i->first, i->second);
298  }
301  }
302  for (SubParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
303  dev.writeAttr(i->first, i->second);
304  }
305  writeParams(dev);
306  dev.closeTag();
307 }
308 
309 
310 double
311 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
312  if (cfParameter.count(attr)) {
313  return TplConvert::_str2double(cfParameter.find(attr)->second);
314  } else {
315  return defaultValue;
316  }
317 }
318 
319 
320 std::string
321 SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
322  if (cfParameter.count(attr)) {
323  return cfParameter.find(attr)->second;
324  } else {
325  return defaultValue;
326  }
327 }
328 
329 double
330 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
331  if (lcParameter.count(attr)) {
332  return TplConvert::_str2double(lcParameter.find(attr)->second);
333  } else {
334  return defaultValue;
335  }
336 }
337 
338 
339 double
340 SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
341  if (jmParameter.count(attr)) {
342  return TplConvert::_str2double(jmParameter.find(attr)->second);
343  } else {
344  return defaultValue;
345  }
346 }
347 
348 double
350  switch (vc) {
351  case SVC_PEDESTRIAN:
352  return 1.5;
353  case SVC_BICYCLE:
354  return 1.2;
355  case SVC_MOTORCYCLE:
356  return 6.;
357  case SVC_MOPED:
358  return 1.1;
359  case SVC_TRUCK:
360  return 1.3;
361  case SVC_TRAILER:
362  return 1.1;
363  case SVC_BUS:
364  return 1.2;
365  case SVC_COACH:
366  return 2.;
367  case SVC_TRAM:
368  return 1.;
369  case SVC_RAIL_URBAN:
370  return 1.;
371  case SVC_RAIL:
372  return 0.25;
373  case SVC_RAIL_ELECTRIC:
374  return 0.5;
375  case SVC_SHIP:
376  return 0.1;
377  default:
378  return 2.6;//2.9;
379  }
380 }
381 
382 
383 double
385  switch (vc) {
386  case SVC_PEDESTRIAN:
387  return 2.;
388  case SVC_BICYCLE:
389  return 3.;
390  case SVC_MOPED:
391  return 7.;
392  case SVC_MOTORCYCLE:
393  return 10.;
394  case SVC_TRUCK:
395  return 4.;
396  case SVC_TRAILER:
397  return 4.;
398  case SVC_BUS:
399  return 4.;
400  case SVC_COACH:
401  return 4.;
402  case SVC_TRAM:
403  return 3.;
404  case SVC_RAIL_URBAN:
405  return 3.;
406  case SVC_RAIL:
407  return 1.3;
408  case SVC_RAIL_ELECTRIC:
409  return 1.3;
410  case SVC_SHIP:
411  return 0.15;
412  default:
413  return 4.5;//7.5;
414  }
415 }
416 
417 
418 double
420  switch (vc) {
421  case SVC_PEDESTRIAN:
422  return 3.;
423  case SVC_BICYCLE:
424  return 5.;
425  case SVC_MOPED:
426  return 8.;
427  case SVC_MOTORCYCLE:
428  return 10.;
429  case SVC_TRUCK:
430  return 7.;
431  case SVC_TRAILER:
432  return 7.;
433  case SVC_BUS:
434  return 7.;
435  case SVC_COACH:
436  return 7.;
437  case SVC_TRAM:
438  return 5.;
439  case SVC_RAIL_URBAN:
440  return 5.;
441  case SVC_RAIL:
442  return 4;
443  case SVC_RAIL_ELECTRIC:
444  return 4;
445  case SVC_SHIP:
446  return 1;
447  default:
448  return 9;//7.5;
449  }
450 }
451 
452 
453 
454 double
456  switch (vc) {
457  case SVC_TRAM:
458  case SVC_RAIL_URBAN:
459  case SVC_RAIL:
460  case SVC_RAIL_ELECTRIC:
461  case SVC_SHIP:
462  return 0.;
463  default:
464  return 0.5;
465  }
466 }
467 
468 
469 const SUMOVTypeParameter&
471  static SUMOVTypeParameter defaultParams("");
472  return defaultParams;
473 }
474 
475 
476 /****************************************************************************/
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:260
vehicle is a motorcycle
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
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:363
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
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:55
const int VTYPEPARS_ACTIONSTEPLENGTH_SET
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.
#define STEPS2TIME(x)
Definition: SUMOTime.h:64
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.
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.
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 storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
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