SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2015 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),
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.25;
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  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;
85  break;
86  case SVC_MOTORCYCLE:
87  length = 2.2;
88  width = 0.9;
89  height = 1.5;
91  personCapacity = 1;
92  break;
93  case SVC_TRUCK:
94  length = 7.1;
95  maxSpeed = 130. / 3.6;
96  width = 2.4;
97  height = 2.4;
98  shape = SVS_TRUCK;
99  personCapacity = 2;
100  containerCapacity = 1;
101  break;
102  case SVC_TRAILER:
103  length = 16.5;
104  maxSpeed = 130. / 3.6;
105  width = 2.55;
106  height = 4.;
108  personCapacity = 2;
109  containerCapacity = 2;
110  break;
111  case SVC_BUS:
112  length = 12.;
113  maxSpeed = 100. / 3.6;
114  width = 2.5;
115  height = 3.4;
116  shape = SVS_BUS;
117  personCapacity = 85;
118  break;
119  case SVC_COACH:
120  length = 14.;
121  maxSpeed = 100. / 3.6;
122  width = 2.6;
123  height = 4.;
125  personCapacity = 70;
126  break;
127  case SVC_TRAM:
128  length = 22.;
129  maxSpeed = 80. / 3.6;
130  width = 2.4;
131  height = 3.2;
133  personCapacity = 120;
134  break;
135  case SVC_RAIL_URBAN:
136  length = 36.5 * 3;
137  maxSpeed = 100. / 3.6;
138  width = 3.0;
139  height = 3.6;
141  personCapacity = 300;
142  break;
143  case SVC_RAIL:
144  length = 67.5 * 2;
145  maxSpeed = 160. / 3.6;
146  width = 2.84;
147  height = 3.75;
148  shape = SVS_RAIL;
149  personCapacity = 434;
150  break;
151  case SVC_RAIL_ELECTRIC:
152  length = 25. * 8;
153  maxSpeed = 330. / 3.6;
154  width = 2.95;
155  height = 3.89;
156  shape = SVS_RAIL;
157  personCapacity = 425;
158  break;
159  case SVC_DELIVERY:
160  length = 6.5;
161  width = 2.16;
162  height = 2.86;
164  personCapacity = 2;
165  break;
166  case SVC_EMERGENCY:
167  length = 6.5;
168  width = 2.16;
169  height = 2.86;
171  personCapacity = 2;
172  break;
173  case SVC_PASSENGER:
175  break;
176  case SVC_E_VEHICLE:
178  break;
179  case SVC_SHIP:
180  length = 17;
181  width = 4;
182  maxSpeed = 8 / 1.94; // 8 knots
183  height = 4;
184  shape = SVS_SHIP;
185  break;
186  default:
187  break;
188  }
189 }
190 
191 
192 void
194  if (onlyReferenced) {
195  return;
196  }
197  dev.openTag(SUMO_TAG_VTYPE);
198  dev.writeAttr(SUMO_ATTR_ID, id);
201  }
204  }
207  }
210  }
213  }
216  }
219  }
222  }
225  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
226  } else {
228  }
229  }
232  }
235  }
238  }
241  }
244  }
247  }
250  }
253  }
256  }
259  }
262  }
263 
264  if (cfParameter.size() != 0) {
265  dev.openTag(cfModel);
266  std::vector<SumoXMLAttr> attrs;
267  for (CFParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
268  attrs.push_back(i->first);
269  }
270  std::sort(attrs.begin(), attrs.end());
271  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
272  dev.writeAttr(*i, cfParameter.find(*i)->second);
273  }
274  dev.closeTag();
275  }
276  for (std::map<std::string, std::string>::const_iterator j = getMap().begin(); j != getMap().end(); ++j) {
277  dev.openTag(SUMO_TAG_PARAM);
278  dev.writeAttr(SUMO_ATTR_KEY, (*j).first);
279  dev.writeAttr(SUMO_ATTR_VALUE, (*j).second);
280  dev.closeTag();
281  }
282  dev.closeTag();
283 }
284 
285 
286 SUMOReal
287 SUMOVTypeParameter::get(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
288  if (cfParameter.count(attr)) {
289  return cfParameter.find(attr)->second;
290  } else {
291  return defaultValue;
292  }
293 }
294 
295 
296 SUMOReal
298  switch (vc) {
299  case SVC_PEDESTRIAN:
300  return 1.5;
301  case SVC_BICYCLE:
302  return 1.2;
303  case SVC_MOTORCYCLE:
304  return 6.;
305  case SVC_MOPED:
306  return 1.1;
307  case SVC_TRUCK:
308  return 1.3;
309  case SVC_TRAILER:
310  return 1.1;
311  case SVC_BUS:
312  return 1.2;
313  case SVC_COACH:
314  return 2.;
315  case SVC_TRAM:
316  return 1.;
317  case SVC_RAIL_URBAN:
318  return 1.;
319  case SVC_RAIL:
320  return 0.25;
321  case SVC_RAIL_ELECTRIC:
322  return 0.5;
323  case SVC_SHIP:
324  return 0.1;
325  default:
326  return 2.6;//2.9;
327  }
328 }
329 
330 
331 SUMOReal
333  switch (vc) {
334  case SVC_PEDESTRIAN:
335  return 2.;
336  case SVC_BICYCLE:
337  return 3.;
338  case SVC_MOPED:
339  return 7.;
340  case SVC_MOTORCYCLE:
341  return 10.;
342  case SVC_TRUCK:
343  return 4.;
344  case SVC_TRAILER:
345  return 4.;
346  case SVC_BUS:
347  return 4.;
348  case SVC_COACH:
349  return 4.;
350  case SVC_TRAM:
351  return 3.;
352  case SVC_RAIL_URBAN:
353  return 3.;
354  case SVC_RAIL:
355  return 1.3;
356  case SVC_RAIL_ELECTRIC:
357  return 1.3;
358  case SVC_SHIP:
359  return 0.15;
360  default:
361  return 4.5;//7.5;
362  }
363 }
364 
365 
366 SUMOReal
368  switch (vc) {
369  case SVC_TRAM:
370  case SVC_RAIL_URBAN:
371  case SVC_RAIL:
372  case SVC_RAIL_ELECTRIC:
373  case SVC_SHIP:
374  return 0.;
375  default:
376  return 0.5;
377  }
378 }
379 
380 
381 const SUMOVTypeParameter&
383  static SUMOVTypeParameter defaultParams("");
384  return defaultParams;
385 }
386 
387 
388 /****************************************************************************/
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.
const int VTYPEPARS_BOARDING_DURATION
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.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
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
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
render as a bicycle
std::string imgFile
Image file for this class.
render as a (city) rail without locomotive
unsigned int containerCapacity
The container capacity of the vehicle.
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:53
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'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)
render as a arbitrary ship
bool wasSet(int what) const
Returns whether the given parameter was set.
unsigned int personCapacity
The person capacity of the vehicle.
SUMOReal defaultProbability
The probability when being added to a distribution without an explicit probability.
const int VTYPEPARS_IMGFILE_SET
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
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:218
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