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-sim.org/
12 // Copyright (C) 2001-2014 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),
57  width(1.8), height(1.5), shape(SVS_UNKNOWN),
58  cfModel(SUMO_TAG_CF_KRAUSS), lcModel(LCM_LC2013),
59  setParameter(0), saved(false), onlyReferenced(false) {
60  switch (vclass) {
61  case SVC_PEDESTRIAN:
62  length = 0.215;
63  minGap = 0.5;
65  width = 0.478;
66  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  break;
77  case SVC_MOPED:
78  length = 2.1;
79  maxSpeed = 60. / 3.6;
80  width = 0.8;
81  height = 1.7;
82  shape = SVS_MOPED;
83  break;
84  case SVC_MOTORCYCLE:
85  length = 2.2;
86  width = 0.9;
87  height = 1.5;
89  break;
90  case SVC_TRUCK:
91  length = 7.1;
92  maxSpeed = 130. / 3.6;
93  width = 2.4;
94  height = 2.4;
95  shape = SVS_TRUCK;
96  break;
97  case SVC_TRAILER:
98  length = 16.5;
99  maxSpeed = 130. / 3.6;
100  width = 2.55;
101  height = 4.;
103  break;
104  case SVC_BUS:
105  length = 12.;
106  maxSpeed = 100. / 3.6;
107  width = 2.5;
108  height = 3.4;
109  shape = SVS_BUS;
110  break;
111  case SVC_COACH:
112  length = 14.;
113  maxSpeed = 100. / 3.6;
114  width = 2.6;
115  height = 4.;
117  break;
118  case SVC_TRAM:
119  length = 22.;
120  maxSpeed = 80. / 3.6;
121  width = 2.4;
122  height = 3.2;
124  break;
125  case SVC_RAIL_URBAN:
126  length = 36.5 * 3;
127  maxSpeed = 100. / 3.6;
128  width = 3.0;
129  height = 3.6;
131  break;
132  case SVC_RAIL:
133  length = 67.5 * 2;
134  maxSpeed = 160. / 3.6;
135  width = 2.84;
136  height = 3.75;
137  shape = SVS_RAIL;
138  break;
139  case SVC_RAIL_ELECTRIC:
140  length = 25. * 8;
141  maxSpeed = 330. / 3.6;
142  width = 2.95;
143  height = 3.89;
144  shape = SVS_RAIL;
145  break;
146  case SVC_DELIVERY:
147  length = 6.5;
148  width = 2.16;
149  height = 2.86;
151  break;
152  case SVC_EMERGENCY:
153  length = 6.5;
154  width = 2.16;
155  height = 2.86;
157  break;
158  case SVC_PASSENGER:
160  break;
161  case SVC_E_VEHICLE:
163  break;
164  default:
165  break;
166  }
167 }
168 
169 
170 void
172  if (onlyReferenced) {
173  return;
174  }
175  dev.openTag(SUMO_TAG_VTYPE);
176  dev.writeAttr(SUMO_ATTR_ID, id);
179  }
182  }
185  }
188  }
191  }
194  }
197  }
200  }
203  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
204  } else {
206  }
207  }
210  }
213  }
216  }
219  }
222  }
225  }
228  }
229 
230  if (cfParameter.size() != 0) {
231  dev.openTag(cfModel);
232  std::vector<SumoXMLAttr> attrs;
233  for (CFParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
234  attrs.push_back(i->first);
235  }
236  std::sort(attrs.begin(), attrs.end());
237  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
238  dev.writeAttr(*i, cfParameter.find(*i)->second);
239  }
240  dev.closeTag();
241  dev.closeTag();
242  } else {
243  dev.closeTag();
244  }
245 }
246 
247 
248 SUMOReal
249 SUMOVTypeParameter::get(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
250  if (cfParameter.count(attr)) {
251  return cfParameter.find(attr)->second;
252  } else {
253  return defaultValue;
254  }
255 }
256 
257 
258 SUMOReal
260  switch (vc) {
261  case SVC_PEDESTRIAN:
262  return 1.5;
263  case SVC_BICYCLE:
264  return 1.2;
265  case SVC_MOTORCYCLE:
266  return 6.;
267  case SVC_MOPED:
268  return 1.1;
269  case SVC_TRUCK:
270  return 1.3;
271  case SVC_TRAILER:
272  return 1.1;
273  case SVC_BUS:
274  return 1.2;
275  case SVC_COACH:
276  return 2.;
277  case SVC_TRAM:
278  return 1.;
279  case SVC_RAIL_URBAN:
280  return 1.;
281  case SVC_RAIL:
282  return 0.25;
283  case SVC_RAIL_ELECTRIC:
284  return 0.5;
285  default:
286  return 2.6;//2.9;
287  }
288 }
289 
290 
291 SUMOReal
293  switch (vc) {
294  case SVC_PEDESTRIAN:
295  return 2.;
296  case SVC_BICYCLE:
297  return 3.;
298  case SVC_MOPED:
299  return 7.;
300  case SVC_MOTORCYCLE:
301  return 10.;
302  case SVC_TRUCK:
303  return 4.;
304  case SVC_TRAILER:
305  return 4.;
306  case SVC_BUS:
307  return 4.;
308  case SVC_COACH:
309  return 4.;
310  case SVC_TRAM:
311  return 3.;
312  case SVC_RAIL_URBAN:
313  return 3.;
314  case SVC_RAIL:
315  return 1.3;
316  case SVC_RAIL_ELECTRIC:
317  return 1.3;
318  default:
319  return 4.5;//7.5;
320  }
321 }
322 
323 
324 SUMOReal
326  switch (vc) {
327  case SVC_TRAM:
328  case SVC_RAIL_URBAN:
329  case SVC_RAIL:
330  case SVC_RAIL_ELECTRIC:
331  return 0.;
332  default:
333  return 0.5;
334  }
335 }
336 
337 
338 const SUMOVTypeParameter&
340  static SUMOVTypeParameter defaultParams("");
341  return defaultParams;
342 }
343 
344 
345 /****************************************************************************/
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.
SUMOReal get(const SumoXMLAttr attr, const SUMOReal defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
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' shape.
Structure representing possible vehicle parameter.
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
SUMOReal length
The physical vehicle length.
vehicle is a light rail
const SUMOReal DEFAULT_PEDESTRIAN_SPEED
SUMOVehicleClass vehicleClass
The vehicle's class.
const SUMOReal DEFAULT_VEH_PROB
render as a delivery vehicle
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
SUMOReal width
This class' width.
const int VTYPEPARS_OSGFILE_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's imperfection (sigma or epsilon in Krauss' 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
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 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
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
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
vehicle is a moped
void write(OutputDevice &dev) const
Writes the vtype.
SUMOReal maxSpeed
The vehicle type's maximum speed [m/s].
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's impatience (willingness to obstruct others)
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
RGBColor color
The color.
vehicle is a large transport vehicle
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:215
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' 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
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' free space in front of the vehicle itself.
is an electric vehicle