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-2016 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 
48 // ===========================================================================
49 // member method definitions
50 // ===========================================================================
51 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
52  : id(vtid), length(5./*4.3*/), minGap(2.5), maxSpeed(200. / 3.6),
53  defaultProbability(DEFAULT_VEH_PROB),
54  speedFactor(1.0), speedDev(0.0),
55  emissionClass(PollutantsInterface::getClassByName("unknown", vclass)), color(RGBColor::DEFAULT_COLOR),
56  vehicleClass(vclass), impatience(0.0), personCapacity(4), containerCapacity(0), boardingDuration(500),
57  loadingDuration(90000), width(1.8), height(1.5), shape(SVS_UNKNOWN), osgFile("car-normal-citrus.obj"),
58  cfModel(SUMO_TAG_CF_KRAUSS), lcModel(LCM_DEFAULT),
59  maxSpeedLat(1.0), latAlignment(LATALIGN_CENTER), minGapLat(0.12),
60  setParameter(0), saved(false), onlyReferenced(false) {
61  switch (vclass) {
62  case SVC_PEDESTRIAN:
63  length = 0.215;
64  minGap = 0.25;
66  width = 0.478;
67  height = 1.719;
69  break;
70  case SVC_BICYCLE:
71  length = 1.6;
72  minGap = 0.5;
73  maxSpeed = 20. / 3.6;
74  width = 0.65;
75  height = 1.7;
77  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;
86  break;
87  case SVC_MOTORCYCLE:
88  length = 2.2;
89  width = 0.9;
90  height = 1.5;
92  personCapacity = 1;
93  break;
94  case SVC_TRUCK:
95  length = 7.1;
96  maxSpeed = 130. / 3.6;
97  width = 2.4;
98  height = 2.4;
99  shape = SVS_TRUCK;
100  osgFile = "car-microcargo-citrus.obj";
101  personCapacity = 2;
102  containerCapacity = 1;
103  break;
104  case SVC_TRAILER:
105  length = 16.5;
106  maxSpeed = 130. / 3.6;
107  width = 2.55;
108  height = 4.;
110  osgFile = "car-microcargo-citrus.obj";
111  personCapacity = 2;
112  containerCapacity = 2;
113  break;
114  case SVC_BUS:
115  length = 12.;
116  maxSpeed = 100. / 3.6;
117  width = 2.5;
118  height = 3.4;
119  shape = SVS_BUS;
120  osgFile = "car-minibus-citrus.obj";
121  personCapacity = 85;
122  break;
123  case SVC_COACH:
124  length = 14.;
125  maxSpeed = 100. / 3.6;
126  width = 2.6;
127  height = 4.;
129  osgFile = "car-minibus-citrus.obj";
130  personCapacity = 70;
131  break;
132  case SVC_TRAM:
133  length = 22.;
134  maxSpeed = 80. / 3.6;
135  width = 2.4;
136  height = 3.2;
138  personCapacity = 120;
139  break;
140  case SVC_RAIL_URBAN:
141  length = 36.5 * 3;
142  maxSpeed = 100. / 3.6;
143  width = 3.0;
144  height = 3.6;
146  personCapacity = 300;
147  break;
148  case SVC_RAIL:
149  length = 67.5 * 2;
150  maxSpeed = 160. / 3.6;
151  width = 2.84;
152  height = 3.75;
153  shape = SVS_RAIL;
154  personCapacity = 434;
155  break;
156  case SVC_RAIL_ELECTRIC:
157  length = 25. * 8;
158  maxSpeed = 330. / 3.6;
159  width = 2.95;
160  height = 3.89;
161  shape = SVS_RAIL;
162  personCapacity = 425;
163  break;
164  case SVC_DELIVERY:
165  length = 6.5;
166  width = 2.16;
167  height = 2.86;
169  personCapacity = 2;
170  break;
171  case SVC_EMERGENCY:
172  length = 6.5;
173  width = 2.16;
174  height = 2.86;
176  personCapacity = 2;
177  break;
178  case SVC_PASSENGER:
180  break;
181  case SVC_E_VEHICLE:
183  break;
184  case SVC_SHIP:
185  length = 17;
186  width = 4;
187  maxSpeed = 8 / 1.94; // 8 knots
188  height = 4;
189  shape = SVS_SHIP;
190  break;
191  default:
192  break;
193  }
194 }
195 
196 
197 void
199  if (onlyReferenced) {
200  return;
201  }
202  dev.openTag(SUMO_TAG_VTYPE);
203  dev.writeAttr(SUMO_ATTR_ID, id);
206  }
209  }
212  }
215  }
218  }
221  }
224  }
227  }
230  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
231  } else {
233  }
234  }
237  }
240  }
243  }
246  }
249  }
252  }
255  }
258  }
261  }
264  }
267  }
270  }
273  }
274  if (wasSet(VTYPEPARS_LANE_CHANGE_MODEL_SET) || lcParameter.size() != 0) {
276  std::vector<SumoXMLAttr> attrs;
277  for (SubParams::const_iterator i = lcParameter.begin(); i != lcParameter.end(); ++i) {
278  attrs.push_back(i->first);
279  }
280  std::sort(attrs.begin(), attrs.end());
281  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
282  dev.writeAttr(*i, lcParameter.find(*i)->second);
283  }
284  }
285  if (wasSet(VTYPEPARS_CAR_FOLLOW_MODEL) || cfParameter.size() != 0) {
286  dev.openTag(cfModel);
287  std::vector<SumoXMLAttr> attrs;
288  for (SubParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
289  attrs.push_back(i->first);
290  }
291  std::sort(attrs.begin(), attrs.end());
292  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
293  dev.writeAttr(*i, cfParameter.find(*i)->second);
294  }
295  dev.closeTag();
296  }
297  for (std::map<std::string, std::string>::const_iterator j = getMap().begin(); j != getMap().end(); ++j) {
298  dev.openTag(SUMO_TAG_PARAM);
299  dev.writeAttr(SUMO_ATTR_KEY, (*j).first);
300  dev.writeAttr(SUMO_ATTR_VALUE, (*j).second);
301  dev.closeTag();
302  }
303  dev.closeTag();
304 }
305 
306 
307 SUMOReal
308 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
309  if (cfParameter.count(attr)) {
310  return cfParameter.find(attr)->second;
311  } else {
312  return defaultValue;
313  }
314 }
315 
316 SUMOReal
317 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
318  if (lcParameter.count(attr)) {
319  return lcParameter.find(attr)->second;
320  } else {
321  return defaultValue;
322  }
323 }
324 
325 
326 
327 SUMOReal
329  switch (vc) {
330  case SVC_PEDESTRIAN:
331  return 1.5;
332  case SVC_BICYCLE:
333  return 1.2;
334  case SVC_MOTORCYCLE:
335  return 6.;
336  case SVC_MOPED:
337  return 1.1;
338  case SVC_TRUCK:
339  return 1.3;
340  case SVC_TRAILER:
341  return 1.1;
342  case SVC_BUS:
343  return 1.2;
344  case SVC_COACH:
345  return 2.;
346  case SVC_TRAM:
347  return 1.;
348  case SVC_RAIL_URBAN:
349  return 1.;
350  case SVC_RAIL:
351  return 0.25;
352  case SVC_RAIL_ELECTRIC:
353  return 0.5;
354  case SVC_SHIP:
355  return 0.1;
356  default:
357  return 2.6;//2.9;
358  }
359 }
360 
361 
362 SUMOReal
364  switch (vc) {
365  case SVC_PEDESTRIAN:
366  return 2.;
367  case SVC_BICYCLE:
368  return 3.;
369  case SVC_MOPED:
370  return 7.;
371  case SVC_MOTORCYCLE:
372  return 10.;
373  case SVC_TRUCK:
374  return 4.;
375  case SVC_TRAILER:
376  return 4.;
377  case SVC_BUS:
378  return 4.;
379  case SVC_COACH:
380  return 4.;
381  case SVC_TRAM:
382  return 3.;
383  case SVC_RAIL_URBAN:
384  return 3.;
385  case SVC_RAIL:
386  return 1.3;
387  case SVC_RAIL_ELECTRIC:
388  return 1.3;
389  case SVC_SHIP:
390  return 0.15;
391  default:
392  return 4.5;//7.5;
393  }
394 }
395 
396 
397 SUMOReal
399  switch (vc) {
400  case SVC_TRAM:
401  case SVC_RAIL_URBAN:
402  case SVC_RAIL:
403  case SVC_RAIL_ELECTRIC:
404  case SVC_SHIP:
405  return 0.;
406  default:
407  return 0.5;
408  }
409 }
410 
411 
412 const SUMOVTypeParameter&
414  static SUMOVTypeParameter defaultParams("");
415  return defaultParams;
416 }
417 
418 
419 /****************************************************************************/
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:257
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
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.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
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...
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.
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
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
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.
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
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:213
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
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