Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file SUMOVTypeParameter.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @date 10.09.2009
19 : ///
20 : // Structure representing possible vehicle parameter
21 : /****************************************************************************/
22 : #include <config.h>
23 :
24 : #include <algorithm>
25 : #include <utils/vehicle/SUMOVTypeParameter.h>
26 : #include <utils/common/ToString.h>
27 : #include <utils/common/StringUtils.h>
28 : #include <utils/common/StringTokenizer.h>
29 : #include <utils/common/MsgHandler.h>
30 : #include <utils/common/FileHelpers.h>
31 : #include <utils/iodevices/OutputDevice.h>
32 : #include <utils/options/OptionsCont.h>
33 : #include <utils/xml/SUMOXMLDefinitions.h>
34 : #include <utils/emissions/PollutantsInterface.h>
35 :
36 : #define EMPREFIX std::string("HBEFA4/")
37 : #define TTT_UNSET SUMOTime_MIN
38 :
39 : // ===========================================================================
40 : // static value definitions
41 : // ===========================================================================
42 : std::set<SumoXMLAttr> SUMOVTypeParameter::AllowedJMAttrs({
43 : SUMO_ATTR_JM_CROSSING_GAP,
44 : SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME,
45 : SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME,
46 : SUMO_ATTR_JM_DRIVE_RED_SPEED,
47 : SUMO_ATTR_JM_IGNORE_KEEPCLEAR_TIME,
48 : SUMO_ATTR_JM_IGNORE_FOE_SPEED,
49 : SUMO_ATTR_JM_IGNORE_FOE_PROB,
50 : SUMO_ATTR_JM_IGNORE_JUNCTION_FOE_PROB,
51 : SUMO_ATTR_JM_SIGMA_MINOR,
52 : SUMO_ATTR_JM_STOPLINE_GAP,
53 : SUMO_ATTR_JM_STOPLINE_GAP_MINOR,
54 : SUMO_ATTR_JM_TIMEGAP_MINOR,
55 : SUMO_ATTR_JM_EXTRA_GAP,
56 : SUMO_ATTR_JM_ADVANCE,
57 : SUMO_ATTR_JM_STOPSIGN_WAIT,
58 : SUMO_ATTR_JM_ALLWAYSTOP_WAIT,
59 : });
60 :
61 :
62 : // ===========================================================================
63 : // member method definitions
64 : // ===========================================================================
65 :
66 373570 : SUMOVTypeParameter::VClassDefaultValues::VClassDefaultValues(SUMOVehicleClass vclass) :
67 373570 : length(getDefaultVehicleLength(vclass)),
68 373570 : minGap(2.5),
69 373570 : minGapLat(0.6),
70 373570 : maxSpeed(200. / 3.6),
71 373570 : desiredMaxSpeed(10000 / 3.6), // backward-compatibility: do not influence speeds by default
72 373570 : width(DEFAULT_VEH_WIDTH),
73 373570 : height(DEFAULT_VEH_HEIGHT),
74 373570 : shape(SUMOVehicleShape::UNKNOWN),
75 747140 : emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "default", vclass)),
76 373570 : mass(DEFAULT_VEH_MASS),
77 373570 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
78 373570 : personCapacity(4),
79 373570 : containerCapacity(0),
80 373570 : osgFile("car-normal-citrus.obj"),
81 373570 : carriageLength(-1),
82 373570 : locomotiveLength(-1),
83 373570 : carriageDoors(2),
84 373570 : carriageDoorWidth(1.5),
85 373570 : maxPlatformDistance(3.),
86 373570 : latAlignmentProcedure(LatAlignmentDefinition::CENTER) {
87 : // sources for the default values should be in docs/Vehicle_Type_Parameter_Defaults.md
88 373570 : switch (vclass) {
89 99458 : case SVC_PEDESTRIAN:
90 99458 : minGap = 0.25;
91 99458 : maxSpeed = 37.58 / 3.6; // Usain Bolt
92 99458 : desiredMaxSpeed = DEFAULT_PEDESTRIAN_SPEED;
93 99458 : width = 0.478;
94 99458 : height = 1.719;
95 99458 : shape = SUMOVehicleShape::PEDESTRIAN;
96 : osgFile = "humanResting.obj";
97 198916 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
98 99458 : mass = 70.; // https://en.wikipedia.org/wiki/Human_body_weight for Europe
99 99458 : speedFactor.setParameter(1, 0.1);
100 : break;
101 79 : case SVC_WHEELCHAIR:
102 79 : minGap = 0.5;
103 79 : maxSpeed = 30.0 / 3.6; // https://en.wikipedia.org/wiki/Wheelchair_racing
104 79 : desiredMaxSpeed = DEFAULT_PEDESTRIAN_SPEED;
105 79 : width = 0.72;
106 79 : height = 1.2;
107 79 : shape = SUMOVehicleShape::PEDESTRIAN;
108 : osgFile = "humanResting.obj";
109 158 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
110 79 : mass = 90.; // 20 (empty) + 70 (person)
111 79 : speedFactor.setParameter(1, 0.1);
112 : break;
113 47535 : case SVC_BICYCLE:
114 47535 : minGap = 0.5;
115 47535 : minGapLat = 0.35;
116 47535 : maxSpeed = 50. / 3.6;
117 47535 : desiredMaxSpeed = DEFAULT_BICYCLE_SPEED;
118 47535 : width = 0.65;
119 47535 : height = 1.7;
120 47535 : shape = SUMOVehicleShape::BICYCLE;
121 47535 : personCapacity = 1;
122 95070 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
123 47535 : mass = 10.;
124 47535 : speedFactor.setParameter(1, 0.1);
125 47535 : latAlignmentProcedure = LatAlignmentDefinition::RIGHT;
126 47535 : break;
127 24 : case SVC_SCOOTER:
128 24 : minGap = 0.5;
129 24 : minGapLat = 0.35;
130 24 : maxSpeed = 25 / 3.6;
131 24 : desiredMaxSpeed = DEFAULT_BICYCLE_SPEED;
132 24 : width = 0.5;
133 24 : height = 1.7;
134 24 : shape = SUMOVehicleShape::SCOOTER;
135 24 : personCapacity = 1;
136 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
137 24 : mass = 10.;
138 24 : speedFactor.setParameter(1, 0.1);
139 24 : latAlignmentProcedure = LatAlignmentDefinition::RIGHT;
140 24 : break;
141 118 : case SVC_MOPED:
142 118 : maxSpeed = 60. / 3.6;
143 118 : width = 0.78;
144 118 : height = 1.7;
145 118 : shape = SUMOVehicleShape::MOPED;
146 118 : personCapacity = 1;
147 236 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "Moped_le50cc_Euro-2", vclass);
148 118 : mass = 80.;
149 118 : speedFactor.setParameter(1, 0.1);
150 : break;
151 139 : case SVC_MOTORCYCLE:
152 139 : width = 0.9;
153 139 : height = 1.5;
154 139 : shape = SUMOVehicleShape::MOTORCYCLE;
155 139 : personCapacity = 1;
156 278 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "MC_4S_gt250cc_preEuro", vclass);
157 139 : mass = 200.;
158 139 : speedFactor.setParameter(1, 0.1);
159 : break;
160 538 : case SVC_TRUCK:
161 538 : maxSpeed = 130. / 3.6;
162 538 : width = 2.4;
163 538 : height = 2.4;
164 538 : shape = SUMOVehicleShape::TRUCK;
165 : osgFile = "car-microcargo-citrus.obj";
166 538 : personCapacity = 2;
167 538 : containerCapacity = 1;
168 1076 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "RT_le7.5t_Euro-VI_A-C", vclass);
169 538 : mass = 4500.;
170 538 : speedFactor.setParameter(1, 0.05);
171 : break;
172 70 : case SVC_TRAILER:
173 70 : maxSpeed = 130. / 3.6;
174 70 : width = 2.55;
175 70 : height = 4.;
176 70 : shape = SUMOVehicleShape::TRUCK_1TRAILER;
177 : osgFile = "car-microcargo-citrus.obj";
178 70 : personCapacity = 2;
179 70 : containerCapacity = 2;
180 140 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "TT_AT_gt34-40t_Euro-VI_A-C", vclass);
181 70 : mass = 13000.;
182 70 : speedFactor.setParameter(1, 0.05);
183 : break;
184 1127 : case SVC_BUS:
185 1127 : maxSpeed = 100. / 3.6;
186 1127 : width = 2.5;
187 1127 : height = 3.4;
188 1127 : shape = SUMOVehicleShape::BUS;
189 : osgFile = "car-minibus-citrus.obj";
190 1127 : personCapacity = 85;
191 : // the following values keep better consistency with the default bus length,
192 : // although the most frequent city bus seems to have 3 axes and >18t according to the HBEFA4 data
193 2254 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "UBus_Std_gt15-18t_Euro-VI_A-C", vclass);
194 1127 : mass = 12000.;
195 1127 : break;
196 41 : case SVC_COACH:
197 41 : maxSpeed = 100. / 3.6;
198 41 : width = 2.6;
199 41 : height = 4.;
200 41 : shape = SUMOVehicleShape::BUS_COACH;
201 : osgFile = "car-minibus-citrus.obj";
202 41 : personCapacity = 70;
203 82 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "Coach_3-Axes_gt18t_Euro-VI_A-C", vclass);
204 41 : mass = 25000.;
205 41 : speedFactor.setParameter(1, 0.05);
206 : break;
207 245 : case SVC_TRAM:
208 245 : maxSpeed = 80. / 3.6;
209 245 : width = 2.4;
210 245 : height = 3.2;
211 245 : shape = SUMOVehicleShape::RAIL_CAR;
212 : osgFile = "tram.obj";
213 245 : personCapacity = 120;
214 490 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
215 245 : mass = 37900.;
216 245 : break;
217 636 : case SVC_RAIL_URBAN:
218 : case SVC_SUBWAY:
219 636 : maxSpeed = 100. / 3.6;
220 636 : minGap = 5;
221 636 : width = 3.0;
222 636 : height = 3.6;
223 636 : shape = SUMOVehicleShape::RAIL_CAR;
224 636 : personCapacity = 300;
225 1272 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
226 636 : mass = 59000.;
227 636 : break;
228 49249 : case SVC_RAIL:
229 49249 : maxSpeed = 160. / 3.6;
230 49249 : minGap = 5;
231 49249 : width = 2.84;
232 49249 : height = 3.75;
233 49249 : shape = SUMOVehicleShape::RAIL;
234 49249 : personCapacity = 434;
235 : // slight understatement (-:
236 49249 : emissionClass = PollutantsInterface::getClassByName("HBEFA3/HDV_D_EU0", vclass);
237 49249 : mass = 79500.; // only locomotive
238 49249 : break;
239 24 : case SVC_RAIL_ELECTRIC:
240 24 : maxSpeed = 220. / 3.6;
241 24 : minGap = 5;
242 24 : width = 2.95;
243 24 : height = 3.89;
244 24 : shape = SUMOVehicleShape::RAIL;
245 24 : personCapacity = 425;
246 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
247 24 : mass = 83000.; // only locomotive
248 24 : break;
249 24 : case SVC_RAIL_FAST:
250 24 : maxSpeed = 330. / 3.6;
251 24 : minGap = 5;
252 24 : width = 2.95;
253 24 : height = 3.89;
254 24 : shape = SUMOVehicleShape::RAIL;
255 24 : personCapacity = 425;
256 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
257 24 : mass = 409000.;
258 24 : break;
259 99 : case SVC_DELIVERY:
260 99 : width = 2.16;
261 99 : height = 2.86;
262 99 : shape = SUMOVehicleShape::DELIVERY;
263 99 : personCapacity = 2;
264 198 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LCV_diesel_N1-III_Euro-6ab", vclass);
265 99 : mass = 5000.;
266 99 : speedFactor.setParameter(1, 0.05);
267 : break;
268 255 : case SVC_EMERGENCY:
269 255 : width = 2.16;
270 255 : height = 2.86;
271 255 : shape = SUMOVehicleShape::DELIVERY;
272 255 : personCapacity = 2;
273 510 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LCV_diesel_N1-III_Euro-6ab", vclass);
274 255 : mass = 5000.;
275 255 : break;
276 76195 : case SVC_PRIVATE:
277 : case SVC_VIP:
278 : case SVC_PASSENGER:
279 : case SVC_HOV:
280 : case SVC_CUSTOM1:
281 : case SVC_CUSTOM2:
282 76195 : shape = SUMOVehicleShape::PASSENGER;
283 76195 : speedFactor.setParameter(1, 0.1);
284 : break;
285 47789 : case SVC_TAXI:
286 47789 : shape = SUMOVehicleShape::TAXI;
287 47789 : speedFactor.setParameter(1, 0.05);
288 : break;
289 24 : case SVC_E_VEHICLE:
290 24 : shape = SUMOVehicleShape::E_VEHICLE;
291 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
292 24 : speedFactor.setParameter(1, 0.1);
293 : break;
294 42558 : case SVC_CONTAINER:
295 : // ISO Container TEU
296 42558 : width = 2.438;
297 42558 : height = 2.591;
298 42558 : break;
299 24 : case SVC_DRONE:
300 24 : width = 0.5;
301 24 : break;
302 24 : case SVC_AIRCRAFT:
303 : // Airbus A380
304 24 : shape = SUMOVehicleShape::AIRCRAFT;
305 24 : width = 79.8;
306 24 : break;
307 316 : case SVC_SHIP:
308 316 : width = 4;
309 316 : maxSpeed = 8 / 1.94; // 8 knots
310 316 : height = 4;
311 316 : shape = SUMOVehicleShape::SHIP;
312 : // slight understatement (-:
313 316 : emissionClass = PollutantsInterface::getClassByName("HBEFA3/HDV_D_EU0", vclass);
314 316 : mass = 100000.;
315 316 : speedFactor.setParameter(1, 0.1);
316 : break;
317 : default:
318 : break;
319 : }
320 373570 : }
321 :
322 :
323 0 : SUMOVTypeParameter::VClassDefaultValues::VClassDefaultValues() :
324 0 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0) {}
325 :
326 347690 : SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
327 347690 : : id(vtid),
328 347690 : actionStepLength(0),
329 347690 : defaultProbability(DEFAULT_VEH_PROB),
330 347690 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
331 695380 : emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "default", vclass)),
332 347690 : color(RGBColor::DEFAULT_COLOR),
333 347690 : vehicleClass(vclass),
334 347690 : impatience(0.0),
335 347690 : personCapacity(4),
336 347690 : containerCapacity(0),
337 347690 : boardingDuration(500),
338 347690 : loadingDuration(90000),
339 347690 : scale(1),
340 347690 : width(1.8),
341 347690 : height(1.5),
342 347690 : shape(SUMOVehicleShape::UNKNOWN),
343 347690 : osgFile("car-normal-citrus.obj"),
344 347690 : cfModel(SUMO_TAG_CF_KRAUSS),
345 347690 : lcModel(LaneChangeModel::DEFAULT),
346 347690 : maxSpeedLat(1.0),
347 347690 : latAlignmentOffset(0.0),
348 347690 : latAlignmentProcedure(LatAlignmentDefinition::CENTER),
349 347690 : scaleVisual(1),
350 347690 : carriageLength(-1),
351 347690 : locomotiveLength(-1),
352 347690 : carriageGap(1.),
353 347690 : carriageDoors(2),
354 347690 : carriageDoorWidth(1.5),
355 347690 : maxPlatformDistance(3.),
356 347690 : timeToTeleport(TTT_UNSET),
357 347690 : timeToTeleportBidi(TTT_UNSET),
358 347690 : speedFactorPremature(-1),
359 347690 : frontSeatPos(1.7),
360 347690 : seatingWidth(-1),
361 347690 : boardingFactor(1),
362 347690 : parametersSet(0),
363 347690 : saved(false),
364 347690 : onlyReferenced(false) {
365 347690 : const OptionsCont& oc = OptionsCont::getOptions();
366 695380 : if (oc.exists("carfollow.model")) {
367 : // check for valid value has been performed in MSFrame
368 647478 : cfModel = SUMOXMLDefinitions::CarFollowModels.get(oc.getString("carfollow.model"));
369 : }
370 : // obtain default values depending of vclass
371 347690 : VClassDefaultValues defaultValues(vclass);
372 : // overwrite SUMOVTypeParameter with VClassDefaultValues
373 347690 : length = defaultValues.length;
374 347690 : minGap = defaultValues.minGap;
375 347690 : minGapLat = defaultValues.minGapLat;
376 347690 : maxSpeed = defaultValues.maxSpeed;
377 347690 : desiredMaxSpeed = defaultValues.desiredMaxSpeed;
378 347690 : width = defaultValues.width;
379 347690 : height = defaultValues.height;
380 347690 : shape = defaultValues.shape;
381 347690 : emissionClass = defaultValues.emissionClass;
382 347690 : mass = defaultValues.mass;
383 : speedFactor = defaultValues.speedFactor;
384 347690 : personCapacity = defaultValues.personCapacity;
385 347690 : containerCapacity = defaultValues.containerCapacity;
386 : osgFile = defaultValues.osgFile;
387 347690 : carriageLength = defaultValues.carriageLength;
388 347690 : locomotiveLength = defaultValues.locomotiveLength;
389 347690 : carriageDoors = defaultValues.carriageDoors;
390 347690 : latAlignmentProcedure = defaultValues.latAlignmentProcedure;
391 : // check if default speeddev was defined
392 695380 : if (oc.exists("default.speeddev")) {
393 323739 : const double defaultSpeedDev = oc.getFloat("default.speeddev");
394 323739 : if (defaultSpeedDev >= 0) {
395 224034 : speedFactor.setParameter(1, defaultSpeedDev);
396 : }
397 : } else {
398 23951 : speedFactor.setParameter(1, -1.);
399 : }
400 347690 : setManoeuverAngleTimes(vclass);
401 347690 : }
402 :
403 : void
404 347690 : SUMOVTypeParameter::setManoeuverAngleTimes(const SUMOVehicleClass vclass) {
405 :
406 : myManoeuverAngleTimes.clear();
407 : /**
408 : * Defaults assume: approaching at angles between 0-10 and 171-180 (will never be > 180) are approaching a space roughly parallel to the road
409 : * approaching at angles between 11-80 are approaching an acute angled space that is easiest to drive straight in
410 : * approaching at angles between 81-110 are approaching a space at approximately right angles to the road so the driver has a choice
411 : * approaching at angles between 111 and 170 are approaching an obtuse angled space that is easiest to drive past and reverse in
412 : * More (or less) granular angle ranges can be used - configurable as a vType parameter
413 : */
414 347690 : switch (vclass) {
415 123682 : case SVC_PASSENGER:
416 : case SVC_HOV:
417 : case SVC_TAXI:
418 : case SVC_E_VEHICLE:
419 123682 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
420 123682 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
421 123682 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
422 123682 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
423 123682 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
424 123682 : break;
425 1875 : case SVC_TRUCK:
426 : case SVC_TRAILER:
427 : case SVC_BUS:
428 : case SVC_COACH:
429 : case SVC_DELIVERY:
430 1875 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
431 1875 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(2000, 21000))); // straight in
432 1875 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(21000, 2000))); // optional forwards/backwards
433 1875 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(14000, 5000))); // backwards into obtuse space
434 1875 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
435 1875 : break;
436 121231 : case SVC_PEDESTRIAN:
437 : case SVC_MOPED:
438 : case SVC_BICYCLE:
439 121231 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(1000, 1000))); // no dependence on angle
440 121231 : break;
441 100902 : default:
442 100902 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
443 100902 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
444 100902 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
445 100902 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
446 100902 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
447 100902 : break;
448 : }
449 347690 : }
450 :
451 : void
452 6902 : SUMOVTypeParameter::write(OutputDevice& dev) const {
453 : // first check if vehicle type can be written
454 6902 : if (onlyReferenced) {
455 : return;
456 : }
457 : // open vehicle tag
458 3234 : dev.openTag(SUMO_TAG_VTYPE);
459 : // write ID (always needed)
460 3234 : dev.writeAttr(SUMO_ATTR_ID, id);
461 : // write parameters depending if is set
462 3234 : if (wasSet(VTYPEPARS_LENGTH_SET)) {
463 836 : dev.writeAttr(SUMO_ATTR_LENGTH, length);
464 : }
465 3234 : if (wasSet(VTYPEPARS_MINGAP_SET)) {
466 707 : dev.writeAttr(SUMO_ATTR_MINGAP, minGap);
467 : }
468 3234 : if (wasSet(VTYPEPARS_MAXSPEED_SET)) {
469 774 : dev.writeAttr(SUMO_ATTR_MAXSPEED, maxSpeed);
470 : }
471 3234 : if (wasSet(VTYPEPARS_DESIRED_MAXSPEED_SET)) {
472 0 : dev.writeAttr(SUMO_ATTR_DESIRED_MAXSPEED, desiredMaxSpeed);
473 : }
474 3234 : if (wasSet(VTYPEPARS_PROBABILITY_SET)) {
475 92 : dev.writeAttr(SUMO_ATTR_PROB, defaultProbability);
476 : }
477 3234 : if (wasSet(VTYPEPARS_SPEEDFACTOR_SET)) {
478 470 : dev.writeAttr(SUMO_ATTR_SPEEDFACTOR, speedFactor);
479 : }
480 3234 : if (wasSet(VTYPEPARS_ACTIONSTEPLENGTH_SET)) {
481 : // Note: action step length is only exposed in seconds to the user
482 114 : dev.writeAttr(SUMO_ATTR_ACTIONSTEPLENGTH, STEPS2TIME(actionStepLength));
483 : }
484 3234 : if (wasSet(VTYPEPARS_VEHICLECLASS_SET)) {
485 759 : dev.writeAttr(SUMO_ATTR_VCLASS, toString(vehicleClass));
486 : }
487 3234 : if (wasSet(VTYPEPARS_EMISSIONCLASS_SET)) {
488 58 : dev.writeAttr(SUMO_ATTR_EMISSIONCLASS, PollutantsInterface::getName(emissionClass));
489 : }
490 3234 : if (wasSet(VTYPEPARS_MASS_SET)) {
491 10 : dev.writeAttr(SUMO_ATTR_MASS, mass);
492 : }
493 3234 : if (wasSet(VTYPEPARS_IMPATIENCE_SET)) {
494 39 : if (impatience == -std::numeric_limits<double>::max()) {
495 0 : dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
496 : } else {
497 39 : dev.writeAttr(SUMO_ATTR_IMPATIENCE, impatience);
498 : }
499 : }
500 3234 : if (wasSet(VTYPEPARS_SHAPE_SET)) {
501 51 : dev.writeAttr(SUMO_ATTR_GUISHAPE, getVehicleShapeName(shape));
502 : }
503 3234 : if (wasSet(VTYPEPARS_WIDTH_SET)) {
504 40 : dev.writeAttr(SUMO_ATTR_WIDTH, width);
505 : }
506 3234 : if (wasSet(VTYPEPARS_HEIGHT_SET)) {
507 0 : dev.writeAttr(SUMO_ATTR_HEIGHT, height);
508 : }
509 3234 : if (wasSet(VTYPEPARS_COLOR_SET)) {
510 426 : dev.writeAttr(SUMO_ATTR_COLOR, color);
511 : }
512 3234 : if (wasSet(VTYPEPARS_OSGFILE_SET)) {
513 0 : dev.writeAttr(SUMO_ATTR_OSGFILE, osgFile);
514 : }
515 3234 : if (wasSet(VTYPEPARS_IMGFILE_SET)) {
516 0 : dev.writeAttr(SUMO_ATTR_IMGFILE, imgFile);
517 : }
518 3234 : if (wasSet(VTYPEPARS_PERSON_CAPACITY)) {
519 2 : dev.writeAttr(SUMO_ATTR_PERSON_CAPACITY, personCapacity);
520 : }
521 3234 : if (wasSet(VTYPEPARS_CONTAINER_CAPACITY)) {
522 0 : dev.writeAttr(SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity);
523 : }
524 3234 : if (wasSet(VTYPEPARS_BOARDING_DURATION)) {
525 12 : dev.writeAttr(SUMO_ATTR_BOARDING_DURATION, time2string(boardingDuration));
526 : }
527 3234 : if (wasSet(VTYPEPARS_LOADING_DURATION)) {
528 8 : dev.writeAttr(SUMO_ATTR_LOADING_DURATION, time2string(loadingDuration));
529 : }
530 3234 : if (wasSet(VTYPEPARS_MAXSPEED_LAT_SET)) {
531 8 : dev.writeAttr(SUMO_ATTR_MAXSPEED_LAT, maxSpeedLat);
532 : }
533 3234 : if (wasSet(VTYPEPARS_LATALIGNMENT_SET)) {
534 8 : switch (latAlignmentProcedure) {
535 0 : case LatAlignmentDefinition::GIVEN:
536 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, latAlignmentOffset);
537 0 : break;
538 0 : case LatAlignmentDefinition::RIGHT:
539 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "right");
540 0 : break;
541 0 : case LatAlignmentDefinition::CENTER:
542 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "center");
543 0 : break;
544 0 : case LatAlignmentDefinition::ARBITRARY:
545 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "arbitrary");
546 0 : break;
547 0 : case LatAlignmentDefinition::NICE:
548 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "nice");
549 0 : break;
550 8 : case LatAlignmentDefinition::COMPACT:
551 8 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "compact");
552 8 : break;
553 0 : case LatAlignmentDefinition::LEFT:
554 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "left");
555 0 : break;
556 : case LatAlignmentDefinition::DEFAULT:
557 : default:
558 : break;
559 : }
560 : }
561 3234 : if (wasSet(VTYPEPARS_MINGAP_LAT_SET)) {
562 8 : dev.writeAttr(SUMO_ATTR_MINGAP_LAT, minGapLat);
563 : }
564 3234 : if (wasSet(VTYPEPARS_MANEUVER_ANGLE_TIMES_SET)) {
565 0 : dev.writeAttr(SUMO_ATTR_MANEUVER_ANGLE_TIMES, getManoeuverAngleTimesS());
566 : }
567 3234 : if (wasSet(VTYPEPARS_SCALE_SET)) {
568 0 : dev.writeAttr(SUMO_ATTR_SCALE, scale);
569 : }
570 3234 : if (wasSet(VTYPEPARS_TTT_SET)) {
571 8 : dev.writeAttr(SUMO_ATTR_TIME_TO_TELEPORT, time2string(timeToTeleport));
572 : }
573 3234 : if (wasSet(VTYPEPARS_TTT_BIDI_SET)) {
574 0 : dev.writeAttr(SUMO_ATTR_TIME_TO_TELEPORT_BIDI, time2string(timeToTeleportBidi));
575 : }
576 3234 : if (wasSet(VTYPEPARS_SPEEDFACTOR_PREMATURE_SET)) {
577 0 : dev.writeAttr(SUMO_ATTR_SPEEDFACTOR_PREMATURE, speedFactorPremature);
578 : }
579 3234 : if (wasSet(VTYPEPARS_BOARDING_FACTOR_SET)) {
580 0 : dev.writeAttr(SUMO_ATTR_BOARDING_FACTOR, boardingFactor);
581 : }
582 3234 : if (wasSet(VTYPEPARS_LANE_CHANGE_MODEL_SET)) {
583 0 : dev.writeAttr(SUMO_ATTR_LANE_CHANGE_MODEL, lcModel);
584 : }
585 : // Write Lane Change Model parameters
586 3234 : for (const auto& lcParam : lcParameter) {
587 0 : dev.writeAttr(lcParam.first, lcParam.second);
588 : }
589 : // Write Junction Model parameter
590 3234 : for (const auto& jmParam : jmParameter) {
591 0 : dev.writeAttr(jmParam.first, jmParam.second);
592 : }
593 3234 : if (wasSet(VTYPEPARS_CAR_FOLLOW_MODEL)) {
594 52 : dev.writeAttr(SUMO_ATTR_CAR_FOLLOW_MODEL, SUMOXMLDefinitions::CarFollowModels.getString(cfModel));
595 : }
596 : // Write Car Following Model parameters
597 6672 : for (const auto& cfParam : cfParameter) {
598 3438 : dev.writeAttr(cfParam.first, cfParam.second);
599 : }
600 : // Write carriage length
601 3234 : if (wasSet(VTYPEPARS_CARRIAGE_LENGTH_SET)) {
602 0 : dev.openTag(SUMO_TAG_PARAM);
603 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_CARRIAGE_LENGTH));
604 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(carriageLength));
605 0 : dev.closeTag();
606 : }
607 : // Write locomotive length
608 3234 : if (wasSet(VTYPEPARS_LOCOMOTIVE_LENGTH_SET)) {
609 0 : dev.openTag(SUMO_TAG_PARAM);
610 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_LOCOMOTIVE_LENGTH));
611 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(locomotiveLength));
612 0 : dev.closeTag();
613 : }
614 : // Write carriage gap
615 3234 : if (wasSet(VTYPEPARS_CARRIAGE_GAP_SET)) {
616 0 : dev.openTag(SUMO_TAG_PARAM);
617 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_CARRIAGE_GAP));
618 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(carriageGap));
619 0 : dev.closeTag();
620 : }
621 : // Write carriage doors
622 3234 : if (wasSet(VTYPEPARS_CARRIAGE_DOORS_SET)) {
623 0 : dev.openTag(SUMO_TAG_PARAM);
624 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_CARRIAGE_DOORS));
625 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(carriageDoors));
626 0 : dev.closeTag();
627 : }
628 : // Write rest of parameters
629 3234 : writeParams(dev);
630 : // close tag
631 6468 : dev.closeTag();
632 : }
633 :
634 :
635 : double
636 4476877 : SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
637 : if (cfParameter.count(attr)) {
638 55243 : return StringUtils::toDouble(cfParameter.find(attr)->second);
639 : } else {
640 : return defaultValue;
641 : }
642 : }
643 :
644 :
645 : std::string
646 450 : SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
647 : if (cfParameter.count(attr)) {
648 : return cfParameter.find(attr)->second;
649 : } else {
650 : return defaultValue;
651 : }
652 : }
653 :
654 :
655 : std::vector<double>
656 72 : SUMOVTypeParameter::getCFValueTable(SumoXMLAttr attr) const {
657 : std::vector<double> result;
658 144 : const std::string values = getCFParamString(attr, "");
659 72 : if (!values.empty()) {
660 816 : for (std::string value : StringTokenizer(values).getVector()) {
661 672 : result.push_back(StringUtils::toDouble(value));
662 72 : }
663 : }
664 72 : return result;
665 0 : }
666 :
667 :
668 :
669 : LinearApproxHelpers::LinearApproxMap
670 638510 : SUMOVTypeParameter::getCFProfile(const SumoXMLAttr attr, const LinearApproxHelpers::LinearApproxMap& defaultProfile) const {
671 : if (cfParameter.count(attr)) {
672 36 : std::vector<double> speedTable = getCFValueTable(SUMO_ATTR_SPEED_TABLE);
673 36 : std::vector<double> valueTable = getCFValueTable(attr);
674 36 : if (valueTable.size() == 1) {
675 0 : throw ProcessError(TLF("Invalid size of % table for vType '%' (at least 2 values are required).", toString(attr), id));
676 36 : } else if (speedTable.size() != valueTable.size()) {
677 0 : throw ProcessError(TLF("Mismatching size of speedTable (%) and % table (%) for vType '%'.", speedTable.size(), toString(attr), valueTable.size(), id));
678 : }
679 : LinearApproxHelpers::LinearApproxMap result;
680 372 : for (int i = 0; i < (int)speedTable.size(); i++) {
681 336 : result[speedTable[i]] = valueTable[i];
682 : }
683 : return result;
684 36 : } else {
685 : return defaultProfile;
686 : }
687 : }
688 :
689 :
690 : double
691 114038805 : SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
692 : if (lcParameter.count(attr)) {
693 360246 : return StringUtils::toDouble(lcParameter.find(attr)->second);
694 : } else {
695 : return defaultValue;
696 : }
697 : }
698 :
699 :
700 : std::string
701 101428 : SUMOVTypeParameter::getLCParamString(const SumoXMLAttr attr, const std::string& defaultValue) const {
702 : if (lcParameter.count(attr)) {
703 : return lcParameter.find(attr)->second;
704 : } else {
705 : return defaultValue;
706 : }
707 : }
708 :
709 :
710 : const SUMOVTypeParameter::SubParams&
711 136140 : SUMOVTypeParameter::getLCParams() const {
712 136140 : return lcParameter;
713 : }
714 :
715 :
716 : double
717 3167071821 : SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
718 : if (jmParameter.count(attr)) {
719 18535408 : return StringUtils::toDouble(jmParameter.find(attr)->second);
720 : } else {
721 : return defaultValue;
722 : }
723 : }
724 :
725 :
726 : std::string
727 0 : SUMOVTypeParameter::getJMParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
728 : if (jmParameter.count(attr)) {
729 : return jmParameter.find(attr)->second;
730 : } else {
731 : return defaultValue;
732 : }
733 : }
734 :
735 : SUMOTime
736 30 : SUMOVTypeParameter::getEntryManoeuvreTime(const int angle) const {
737 : SUMOTime last = 0;
738 90 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
739 90 : if (angle <= angleTime.first) {
740 : return (angleTime.second.first);
741 : } else {
742 : last = angleTime.second.first;
743 : }
744 : }
745 0 : return (last);
746 : }
747 :
748 : SUMOTime
749 30 : SUMOVTypeParameter::getExitManoeuvreTime(const int angle) const {
750 : SUMOTime last = 0;
751 90 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
752 90 : if (angle <= angleTime.first) {
753 : return (angleTime.second.second);
754 : } else {
755 : last = angleTime.second.second;
756 : }
757 : }
758 0 : return (last);
759 : }
760 :
761 : std::string
762 0 : SUMOVTypeParameter::getManoeuverAngleTimesS() const {
763 0 : std::stringstream stream;
764 :
765 : stream << std::fixed << std::setprecision(1);
766 : int count = 0;
767 0 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
768 0 : if (count++ > 0) {
769 0 : stream << ",";
770 : }
771 0 : stream << toString(angleTime.first) + " " << STEPS2TIME(angleTime.second.first) << " " << STEPS2TIME(angleTime.second.second);
772 : }
773 : std::string triplets = stream.str();
774 0 : return triplets;
775 0 : }
776 :
777 :
778 : void
779 24 : SUMOVTypeParameter::cacheParamRestrictions(const std::vector<std::string>& restrictionKeys) {
780 48 : for (const std::string& key : restrictionKeys) {
781 48 : paramRestrictions.push_back(StringUtils::toDouble(getParameter(key, "0")));
782 : }
783 24 : }
784 :
785 :
786 : void
787 316932 : SUMOVTypeParameter::initRailVisualizationParameters(const std::string fileName) {
788 633864 : if (hasParameter("scaleVisual")) {
789 0 : scaleVisual = StringUtils::toDouble(getParameter("scaleVisual"));
790 : }
791 633864 : if (hasParameter("carriageLength")) {
792 132 : carriageLength = StringUtils::toDouble(getParameter("carriageLength"));
793 66 : parametersSet |= VTYPEPARS_CARRIAGE_LENGTH_SET;
794 : } else {
795 316866 : switch (shape) {
796 6 : case SUMOVehicleShape::BUS_FLEXIBLE:
797 6 : carriageLength = 8.25; // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
798 6 : carriageGap = 0;
799 6 : break;
800 44726 : case SUMOVehicleShape::RAIL:
801 44726 : if (vehicleClass == SVC_RAIL_ELECTRIC) {
802 24 : carriageLength = 24.5;
803 24 : locomotiveLength = 19.100; // https://en.wikipedia.org/wiki/DB_Class_101
804 44702 : } else if (vehicleClass == SVC_RAIL_FAST) {
805 24 : carriageLength = 24.775; // http://de.wikipedia.org/wiki/ICE_3
806 24 : locomotiveLength = 25.835;
807 : } else {
808 44678 : carriageLength = 24.5; // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
809 44678 : locomotiveLength = 16.4; // https://en.wikipedia.org/wiki/DB_Class_218
810 : }
811 : break;
812 634 : case SUMOVehicleShape::RAIL_CAR:
813 634 : if (vehicleClass == SVC_TRAM) {
814 182 : carriageLength = 5.71; // http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
815 182 : locomotiveLength = 5.71;
816 452 : } else if (vehicleClass == SVC_RAIL_URBAN) {
817 400 : carriageLength = 18.4; // https://en.wikipedia.org/wiki/DBAG_Class_481
818 400 : locomotiveLength = 18.4;
819 : } else {
820 52 : carriageLength = 16.85; // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
821 : }
822 : break;
823 8 : case SUMOVehicleShape::RAIL_CARGO:
824 8 : carriageLength = 13.86; // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
825 8 : break;
826 7 : case SUMOVehicleShape::TRUCK_SEMITRAILER:
827 7 : carriageLength = 13.5;
828 7 : locomotiveLength = 2.5;
829 7 : carriageGap = 0.5;
830 7 : break;
831 93 : case SUMOVehicleShape::TRUCK_1TRAILER:
832 93 : carriageLength = 6.75;
833 93 : locomotiveLength = 2.5 + 6.75;
834 93 : carriageGap = 0.5;
835 93 : break;
836 : default:
837 : break;
838 : }
839 : }
840 633864 : if (hasParameter("locomotiveLength")) {
841 62 : locomotiveLength = StringUtils::toDouble(getParameter("locomotiveLength"));
842 31 : parametersSet |= VTYPEPARS_LOCOMOTIVE_LENGTH_SET;
843 316901 : } else if (locomotiveLength < 0) {
844 271493 : locomotiveLength = carriageLength;
845 : }
846 633864 : if (hasParameter("carriageGap")) {
847 12 : carriageGap = StringUtils::toDouble(getParameter("carriageGap"));
848 6 : parametersSet |= VTYPEPARS_CARRIAGE_GAP_SET;
849 : }
850 633864 : if (hasParameter("carriageDoors")) {
851 24 : carriageDoors = StringUtils::toInt(getParameter("carriageDoors"));
852 12 : parametersSet |= VTYPEPARS_CARRIAGE_DOORS_SET;
853 : }
854 633864 : if (hasParameter("carriageDoorWidth")) {
855 0 : carriageDoorWidth = StringUtils::toDouble(getParameter("carriageDoorWidth"));
856 : }
857 633864 : if (hasParameter("maxPlatformDistance")) {
858 0 : maxPlatformDistance = StringUtils::toDouble(getParameter("maxPlatformDistance"));
859 : }
860 633864 : if (hasParameter("frontSeatPos")) {
861 30 : frontSeatPos = StringUtils::toDouble(getParameter("frontSeatPos"));
862 15 : parametersSet |= VTYPEPARS_FRONT_SEAT_POS_SET;
863 : } else {
864 316917 : switch (shape) {
865 226 : case SUMOVehicleShape::SHIP:
866 226 : frontSeatPos = 5;
867 226 : break;
868 217 : case SUMOVehicleShape::DELIVERY:
869 217 : frontSeatPos = 1.2;
870 217 : break;
871 43212 : case SUMOVehicleShape::BICYCLE:
872 43212 : frontSeatPos = 0.6;
873 43212 : break;
874 262 : case SUMOVehicleShape::MOPED:
875 : case SUMOVehicleShape::MOTORCYCLE:
876 262 : frontSeatPos = 0.9;
877 262 : break;
878 1032 : case SUMOVehicleShape::BUS:
879 : case SUMOVehicleShape::BUS_COACH:
880 : case SUMOVehicleShape::BUS_FLEXIBLE:
881 : case SUMOVehicleShape::BUS_TROLLEY:
882 1032 : frontSeatPos = 0.5;
883 1032 : break;
884 662 : case SUMOVehicleShape::TRUCK:
885 : case SUMOVehicleShape::TRUCK_1TRAILER:
886 : case SUMOVehicleShape::TRUCK_SEMITRAILER:
887 662 : frontSeatPos = 0.8;
888 662 : break;
889 : default:
890 : break;
891 : }
892 : }
893 :
894 633864 : if (hasParameter("seatingWidth")) {
895 14 : seatingWidth = StringUtils::toDouble(getParameter("seatingWidth"));
896 7 : parametersSet |= VTYPEPARS_SEATING_WIDTH_SET;
897 : }
898 633864 : if (hasParameter("carriageImages")) {
899 12 : std::vector<std::string> rawFiles = StringTokenizer(getParameter("carriageImages"), ",").getVector();
900 36 : for (const std::string& f : rawFiles) {
901 60 : carriageImages.push_back(FileHelpers::checkForRelativity(f, fileName));
902 : }
903 6 : }
904 316932 : }
905 :
906 :
907 : double
908 318975 : SUMOVTypeParameter::getDefaultAccel(const SUMOVehicleClass vc) {
909 318975 : switch (vc) {
910 : case SVC_PEDESTRIAN:
911 : case SVC_WHEELCHAIR:
912 : return 1.5;
913 : case SVC_BICYCLE:
914 : case SVC_SCOOTER:
915 : return 1.2;
916 139 : case SVC_MOTORCYCLE:
917 139 : return 6.;
918 : case SVC_MOPED:
919 : return 1.1;
920 542 : case SVC_TRUCK:
921 542 : return 1.3;
922 : case SVC_TRAILER:
923 : return 1.1;
924 : case SVC_BUS:
925 : return 1.2;
926 41 : case SVC_COACH:
927 41 : return 2.;
928 : case SVC_TRAM:
929 : return 1.;
930 : case SVC_RAIL_URBAN:
931 : return 1.;
932 44838 : case SVC_RAIL:
933 44838 : return 0.25;
934 48 : case SVC_RAIL_ELECTRIC:
935 : case SVC_RAIL_FAST:
936 48 : return 0.5;
937 226 : case SVC_SHIP:
938 226 : return 0.1;
939 158757 : default:
940 158757 : return 2.6;//2.9;
941 : }
942 : }
943 :
944 :
945 : double
946 722678 : SUMOVTypeParameter::getDefaultDecel(const SUMOVehicleClass vc) {
947 722678 : switch (vc) {
948 : case SVC_PEDESTRIAN:
949 : case SVC_WHEELCHAIR:
950 : return 2.;
951 : case SVC_BICYCLE:
952 : case SVC_SCOOTER:
953 : return 3.;
954 236 : case SVC_MOPED:
955 236 : return 7.;
956 278 : case SVC_MOTORCYCLE:
957 278 : return 10.;
958 3082 : case SVC_TRUCK:
959 : case SVC_TRAILER:
960 : case SVC_BUS:
961 : case SVC_COACH:
962 3082 : return 4.;
963 : case SVC_TRAM:
964 : case SVC_RAIL_URBAN:
965 : return 3.;
966 132028 : case SVC_RAIL:
967 : case SVC_RAIL_ELECTRIC:
968 : case SVC_RAIL_FAST:
969 132028 : return 1.3;
970 452 : case SVC_SHIP:
971 452 : return 0.15;
972 360285 : default:
973 360285 : return 4.5;//7.5;
974 : }
975 : }
976 :
977 :
978 : double
979 635821 : SUMOVTypeParameter::getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption) {
980 635821 : if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT) {
981 : double vcDecel;
982 630333 : switch (vc) {
983 : case SVC_PEDESTRIAN:
984 : case SVC_WHEELCHAIR:
985 : vcDecel = 5.;
986 : break;
987 : case SVC_BICYCLE:
988 : case SVC_SCOOTER:
989 : vcDecel = 7.;
990 : break;
991 514 : case SVC_MOPED:
992 : case SVC_MOTORCYCLE:
993 : vcDecel = 10.;
994 514 : break;
995 : case SVC_TRUCK:
996 : case SVC_TRAILER:
997 : case SVC_BUS:
998 : case SVC_COACH:
999 : case SVC_TRAM:
1000 : case SVC_RAIL_URBAN:
1001 : vcDecel = 7.;
1002 : break;
1003 : case SVC_RAIL:
1004 : case SVC_RAIL_ELECTRIC:
1005 : case SVC_RAIL_FAST:
1006 : vcDecel = 5.;
1007 : break;
1008 452 : case SVC_SHIP:
1009 : vcDecel = 1.;
1010 452 : break;
1011 312554 : default:
1012 : vcDecel = 9.;
1013 : }
1014 : return MAX2(decel, vcDecel);
1015 5488 : } else if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL) {
1016 : return decel;
1017 : } else {
1018 : // value already checked in MSFrame::checkOptions
1019 : return MAX2(decel, defaultOption);
1020 : }
1021 : }
1022 :
1023 :
1024 :
1025 : double
1026 307685 : SUMOVTypeParameter::getDefaultImperfection(const SUMOVehicleClass vc) {
1027 307685 : switch (vc) {
1028 : case SVC_TRAM:
1029 : case SVC_RAIL_URBAN:
1030 : case SVC_RAIL:
1031 : case SVC_RAIL_ELECTRIC:
1032 : case SVC_RAIL_FAST:
1033 : case SVC_SHIP:
1034 : return 0.;
1035 263680 : default:
1036 263680 : return 0.5;
1037 : }
1038 : }
1039 :
1040 : const SUMOVTypeParameter&
1041 19701396 : SUMOVTypeParameter::getDefault() {
1042 19708173 : static SUMOVTypeParameter defaultParams("");
1043 19701396 : return defaultParams;
1044 : }
1045 :
1046 : bool
1047 1719 : SUMOVTypeParameter::parseLatAlignment(const std::string& val, double& lao, LatAlignmentDefinition& lad) {
1048 : bool ok = true;
1049 1719 : lao = 0.0;
1050 1719 : lad = LatAlignmentDefinition::GIVEN;
1051 1719 : if (val == "right") {
1052 311 : lad = LatAlignmentDefinition::RIGHT;
1053 1408 : } else if (val == "center") {
1054 675 : lad = LatAlignmentDefinition::CENTER;
1055 733 : } else if (val == "arbitrary") {
1056 345 : lad = LatAlignmentDefinition::ARBITRARY;
1057 388 : } else if (val == "nice") {
1058 46 : lad = LatAlignmentDefinition::NICE;
1059 342 : } else if (val == "compact") {
1060 244 : lad = LatAlignmentDefinition::COMPACT;
1061 98 : } else if (val == "left") {
1062 84 : lad = LatAlignmentDefinition::LEFT;
1063 : } else {
1064 : try {
1065 14 : lao = StringUtils::toDouble(val);
1066 0 : } catch (...) {
1067 : ok = false;
1068 0 : }
1069 : }
1070 1719 : return ok;
1071 : }
1072 :
1073 :
1074 : SUMOTime
1075 80972613 : SUMOVTypeParameter::getTimeToTeleport(SUMOTime defaultValue) const {
1076 80972613 : return timeToTeleport == TTT_UNSET ? defaultValue : timeToTeleport;
1077 : }
1078 :
1079 : SUMOTime
1080 80972613 : SUMOVTypeParameter::getTimeToTeleportBidi(SUMOTime defaultValue) const {
1081 80972613 : return timeToTeleportBidi == TTT_UNSET ? defaultValue : timeToTeleportBidi;
1082 : }
1083 :
1084 : LinearApproxHelpers::LinearApproxMap
1085 318885 : SUMOVTypeParameter::getDefaultMaxAccelProfile(const SUMOVehicleClass vc, double maxAccel) {
1086 : UNUSED_PARAMETER(maxAccel);
1087 : LinearApproxHelpers::LinearApproxMap result;
1088 : std::vector<std::pair<double, double> > MaxAccelProfile;
1089 : switch (vc) {
1090 : case SVC_PEDESTRIAN:
1091 : case SVC_BICYCLE:
1092 : case SVC_MOTORCYCLE:
1093 : case SVC_MOPED:
1094 : case SVC_TRUCK:
1095 : case SVC_TRAILER:
1096 : case SVC_BUS:
1097 : case SVC_COACH:
1098 : case SVC_TRAM:
1099 : case SVC_RAIL_URBAN:
1100 : case SVC_RAIL:
1101 : case SVC_RAIL_ELECTRIC:
1102 : case SVC_RAIL_FAST:
1103 : case SVC_SHIP:
1104 : default:
1105 318885 : return result;
1106 : }
1107 318885 : }
1108 :
1109 : LinearApproxHelpers::LinearApproxMap
1110 318885 : SUMOVTypeParameter::getDefaultDesAccelProfile(const SUMOVehicleClass vc, double desAccel) {
1111 : UNUSED_PARAMETER(desAccel);
1112 : LinearApproxHelpers::LinearApproxMap result;
1113 : switch (vc) {
1114 : case SVC_PEDESTRIAN:
1115 : case SVC_BICYCLE:
1116 : case SVC_MOTORCYCLE:
1117 : case SVC_MOPED:
1118 : case SVC_TRUCK:
1119 : case SVC_TRAILER:
1120 : case SVC_BUS:
1121 : case SVC_COACH:
1122 : case SVC_TRAM:
1123 : case SVC_RAIL_URBAN:
1124 : case SVC_RAIL:
1125 : case SVC_RAIL_ELECTRIC:
1126 : case SVC_RAIL_FAST:
1127 : case SVC_SHIP:
1128 : default:
1129 318885 : return result;
1130 : }
1131 : }
1132 :
1133 : /****************************************************************************/
|