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 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 #define EMPREFIX std::string("HBEFA3/")
48 
49 
50 // ===========================================================================
51 // member method definitions
52 // ===========================================================================
53 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
54  : id(vtid), length(5./*4.3*/), minGap(2.5), maxSpeed(200. / 3.6),
55  defaultProbability(DEFAULT_VEH_PROB),
56  speedFactor(1.0), speedDev(0.0),
57  emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)), color(RGBColor::DEFAULT_COLOR),
58  vehicleClass(vclass), impatience(0.0), personCapacity(4), containerCapacity(0), boardingDuration(500),
59  loadingDuration(90000), width(1.8), height(1.5), shape(SVS_UNKNOWN), osgFile("car-normal-citrus.obj"),
60  cfModel(SUMO_TAG_CF_KRAUSS), lcModel(LCM_DEFAULT),
61  maxSpeedLat(1.0), latAlignment(LATALIGN_CENTER), minGapLat(0.12),
62  setParameter(0), saved(false), onlyReferenced(false) {
63  switch (vclass) {
64  case SVC_PEDESTRIAN:
65  length = 0.215;
66  minGap = 0.25;
68  width = 0.478;
69  height = 1.719;
72  break;
73  case SVC_BICYCLE:
74  length = 1.6;
75  minGap = 0.5;
76  maxSpeed = 20. / 3.6;
77  width = 0.65;
78  height = 1.7;
80  personCapacity = 1;
82  break;
83  case SVC_MOPED:
84  length = 2.1;
85  maxSpeed = 60. / 3.6;
86  width = 0.8;
87  height = 1.7;
88  shape = SVS_MOPED;
89  personCapacity = 1;
91  break;
92  case SVC_MOTORCYCLE:
93  length = 2.2;
94  width = 0.9;
95  height = 1.5;
97  personCapacity = 1;
99  break;
100  case SVC_TRUCK:
101  length = 7.1;
102  maxSpeed = 130. / 3.6;
103  width = 2.4;
104  height = 2.4;
105  shape = SVS_TRUCK;
106  osgFile = "car-microcargo-citrus.obj";
107  personCapacity = 2;
108  containerCapacity = 1;
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  break;
122  case SVC_BUS:
123  length = 12.;
124  maxSpeed = 100. / 3.6;
125  width = 2.5;
126  height = 3.4;
127  shape = SVS_BUS;
128  osgFile = "car-minibus-citrus.obj";
129  personCapacity = 85;
131  break;
132  case SVC_COACH:
133  length = 14.;
134  maxSpeed = 100. / 3.6;
135  width = 2.6;
136  height = 4.;
138  osgFile = "car-minibus-citrus.obj";
139  personCapacity = 70;
141  break;
142  case SVC_TRAM:
143  length = 22.;
144  maxSpeed = 80. / 3.6;
145  width = 2.4;
146  height = 3.2;
148  personCapacity = 120;
150  break;
151  case SVC_RAIL_URBAN:
152  length = 36.5 * 3;
153  maxSpeed = 100. / 3.6;
154  width = 3.0;
155  height = 3.6;
157  personCapacity = 300;
159  break;
160  case SVC_RAIL:
161  length = 67.5 * 2;
162  maxSpeed = 160. / 3.6;
163  width = 2.84;
164  height = 3.75;
165  shape = SVS_RAIL;
166  personCapacity = 434;
167  // slight understatement (-:
169  break;
170  case SVC_RAIL_ELECTRIC:
171  length = 25. * 8;
172  maxSpeed = 330. / 3.6;
173  width = 2.95;
174  height = 3.89;
175  shape = SVS_RAIL;
176  personCapacity = 425;
178  break;
179  case SVC_DELIVERY:
180  length = 6.5;
181  width = 2.16;
182  height = 2.86;
184  personCapacity = 2;
186  break;
187  case SVC_EMERGENCY:
188  length = 6.5;
189  width = 2.16;
190  height = 2.86;
192  personCapacity = 2;
194  break;
195  case SVC_PASSENGER:
197  break;
198  case SVC_E_VEHICLE:
201  break;
202  case SVC_SHIP:
203  length = 17;
204  width = 4;
205  maxSpeed = 8 / 1.94; // 8 knots
206  height = 4;
207  shape = SVS_SHIP;
208  // slight understatement (-:
210  break;
211  default:
212  break;
213  }
214 }
215 
216 
217 void
219  if (onlyReferenced) {
220  return;
221  }
222  dev.openTag(SUMO_TAG_VTYPE);
223  dev.writeAttr(SUMO_ATTR_ID, id);
226  }
229  }
232  }
235  }
238  }
241  }
244  }
247  }
250  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
251  } else {
253  }
254  }
257  }
260  }
263  }
266  }
269  }
272  }
275  }
278  }
281  }
284  }
287  }
290  }
293  }
294  if (wasSet(VTYPEPARS_LANE_CHANGE_MODEL_SET) || lcParameter.size() != 0) {
296  std::vector<SumoXMLAttr> attrs;
297  for (SubParams::const_iterator i = lcParameter.begin(); i != lcParameter.end(); ++i) {
298  attrs.push_back(i->first);
299  }
300  std::sort(attrs.begin(), attrs.end());
301  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
302  dev.writeAttr(*i, lcParameter.find(*i)->second);
303  }
304  }
305  if (wasSet(VTYPEPARS_CAR_FOLLOW_MODEL) || cfParameter.size() != 0) {
306  dev.openTag(cfModel);
307  std::vector<SumoXMLAttr> attrs;
308  for (SubParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
309  attrs.push_back(i->first);
310  }
311  std::sort(attrs.begin(), attrs.end());
312  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
313  dev.writeAttr(*i, cfParameter.find(*i)->second);
314  }
315  dev.closeTag();
316  }
317  writeParams(dev);
318  dev.closeTag();
319 }
320 
321 
322 SUMOReal
323 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
324  if (cfParameter.count(attr)) {
325  return cfParameter.find(attr)->second;
326  } else {
327  return defaultValue;
328  }
329 }
330 
331 SUMOReal
332 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
333  if (lcParameter.count(attr)) {
334  return lcParameter.find(attr)->second;
335  } else {
336  return defaultValue;
337  }
338 }
339 
340 
341 
342 SUMOReal
344  switch (vc) {
345  case SVC_PEDESTRIAN:
346  return 1.5;
347  case SVC_BICYCLE:
348  return 1.2;
349  case SVC_MOTORCYCLE:
350  return 6.;
351  case SVC_MOPED:
352  return 1.1;
353  case SVC_TRUCK:
354  return 1.3;
355  case SVC_TRAILER:
356  return 1.1;
357  case SVC_BUS:
358  return 1.2;
359  case SVC_COACH:
360  return 2.;
361  case SVC_TRAM:
362  return 1.;
363  case SVC_RAIL_URBAN:
364  return 1.;
365  case SVC_RAIL:
366  return 0.25;
367  case SVC_RAIL_ELECTRIC:
368  return 0.5;
369  case SVC_SHIP:
370  return 0.1;
371  default:
372  return 2.6;//2.9;
373  }
374 }
375 
376 
377 SUMOReal
379  switch (vc) {
380  case SVC_PEDESTRIAN:
381  return 2.;
382  case SVC_BICYCLE:
383  return 3.;
384  case SVC_MOPED:
385  return 7.;
386  case SVC_MOTORCYCLE:
387  return 10.;
388  case SVC_TRUCK:
389  return 4.;
390  case SVC_TRAILER:
391  return 4.;
392  case SVC_BUS:
393  return 4.;
394  case SVC_COACH:
395  return 4.;
396  case SVC_TRAM:
397  return 3.;
398  case SVC_RAIL_URBAN:
399  return 3.;
400  case SVC_RAIL:
401  return 1.3;
402  case SVC_RAIL_ELECTRIC:
403  return 1.3;
404  case SVC_SHIP:
405  return 0.15;
406  default:
407  return 4.5;//7.5;
408  }
409 }
410 
411 
412 SUMOReal
414  switch (vc) {
415  case SVC_TRAM:
416  case SVC_RAIL_URBAN:
417  case SVC_RAIL:
418  case SVC_RAIL_ELECTRIC:
419  case SVC_SHIP:
420  return 0.;
421  default:
422  return 0.5;
423  }
424 }
425 
426 
427 const SUMOVTypeParameter&
429  static SUMOVTypeParameter defaultParams("");
430  return defaultParams;
431 }
432 
433 
434 /****************************************************************************/
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
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
SUMOReal getCFParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
SUMOVTypeParameter(const std::string &vtid, const SUMOVehicleClass vc=SVC_IGNORING)
Constructor.
render as a transport vehicle
SUMOReal speedDev
The standard deviation for speed variations.
vehicle is a bicycle
vehicle is a small delivery vehicle
int containerCapacity
The container capacity of the vehicle.
SUMOReal length
The physical vehicle length.
const int VTYPEPARS_BOARDING_DURATION
vehicle is a light rail
const SUMOReal DEFAULT_PEDESTRIAN_SPEED
SUMOReal getLCParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
const SUMOReal DEFAULT_VEH_PROB
render as a delivery vehicle
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
SUMOReal width
This class&#39; width.
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
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 SUMOReal 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...
#define EMPREFIX
SUMOReal speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
#define max(a, b)
Definition: polyfonts.c:65
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
render as a bus
std::string osgFile
3D model file for this class
not defined
SUMOReal maxSpeedLat
The vehicle type&#39;s maximum lateral speed [m/s].
render as a bicycle
std::string imgFile
Image file for this class.
render as a (city) rail without locomotive
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
render as a passenger vehicle
const int VTYPEPARS_SPEEDDEVIATION_SET
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) ...
const int VTYPEPARS_SPEEDFACTOR_SET
is an arbitrary ship
vehicle is a moped
void write(OutputDevice &dev) const
Writes the vtype.
drive in the middle
SUMOReal maxSpeed
The vehicle type&#39;s maximum speed [m/s].
int personCapacity
The person capacity of the vehicle.
vehicle is a bus
render as a pedestrian
render as a moped
static SUMOReal getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
SUMOReal impatience
The vehicle&#39;s impatience (willingness to obstruct others)
SUMOReal minGapLat
The vehicle type&#39;s minimum lateral gap [m].
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.
bool wasSet(int what) const
Returns whether the given parameter was set.
SUMOReal defaultProbability
The probability when being added to a distribution without an explicit probability.
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.
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.
#define SUMOReal
Definition: config.h:208
static SUMOReal getDefaultAccel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default acceleration for the given vehicle class This needs to be a function because the ...
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
SUMOReal height
This class&#39; height.
public emergency vehicles
const int VTYPEPARS_LENGTH_SET
const int VTYPEPARS_VEHICLECLASS_SET
void writeParams(OutputDevice &out) const
render as a coach
A color information.
const int VTYPEPARS_EMISSIONCLASS_SET
const int VTYPEPARS_COLOR_SET
render as a semi-trailer transport vehicle ("Sattelschlepper")
const int VTYPEPARS_SHAPE_SET
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.
SUMOReal minGap
This class&#39; free space in front of the vehicle itself.
is an electric vehicle