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 385876 : SUMOVTypeParameter::VClassDefaultValues::VClassDefaultValues(SUMOVehicleClass vclass) :
67 385876 : length(getDefaultVehicleLength(vclass)),
68 385876 : minGap(2.5),
69 385876 : minGapLat(0.6),
70 385876 : maxSpeed(200. / 3.6),
71 385876 : desiredMaxSpeed(10000 / 3.6), // backward-compatibility: do not influence speeds by default
72 385876 : width(DEFAULT_VEH_WIDTH),
73 385876 : height(DEFAULT_VEH_HEIGHT),
74 385876 : shape(SUMOVehicleShape::UNKNOWN),
75 771752 : emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "default", vclass)),
76 385876 : mass(DEFAULT_VEH_MASS),
77 385876 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
78 385876 : personCapacity(4),
79 385876 : containerCapacity(0),
80 385876 : osgFile("car-normal-citrus.obj"),
81 385876 : carriageLength(-1),
82 385876 : locomotiveLength(-1),
83 385876 : carriageDoors(2),
84 385876 : carriageDoorWidth(1.5),
85 385876 : maxPlatformDistance(3.),
86 385876 : latAlignmentProcedure(LatAlignmentDefinition::CENTER) {
87 : // sources for the default values should be in docs/Vehicle_Type_Parameter_Defaults.md
88 385876 : switch (vclass) {
89 101347 : case SVC_PEDESTRIAN:
90 101347 : minGap = 0.25;
91 101347 : maxSpeed = 37.58 / 3.6; // Usain Bolt
92 101347 : desiredMaxSpeed = DEFAULT_PEDESTRIAN_SPEED;
93 101347 : width = 0.478;
94 101347 : height = 1.719;
95 101347 : shape = SUMOVehicleShape::PEDESTRIAN;
96 : osgFile = "humanResting.obj";
97 202694 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
98 101347 : mass = 70.; // https://en.wikipedia.org/wiki/Human_body_weight for Europe
99 101347 : speedFactor.setParameter(1, 0.1);
100 : break;
101 89 : case SVC_WHEELCHAIR:
102 89 : minGap = 0.5;
103 89 : maxSpeed = 30.0 / 3.6; // https://en.wikipedia.org/wiki/Wheelchair_racing
104 89 : desiredMaxSpeed = DEFAULT_PEDESTRIAN_SPEED;
105 89 : width = 0.72;
106 89 : height = 1.2;
107 89 : shape = SUMOVehicleShape::PEDESTRIAN;
108 : osgFile = "humanResting.obj";
109 178 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
110 89 : mass = 90.; // 20 (empty) + 70 (person)
111 89 : speedFactor.setParameter(1, 0.1);
112 : break;
113 49405 : case SVC_BICYCLE:
114 49405 : minGap = 0.5;
115 49405 : minGapLat = 0.35;
116 49405 : maxSpeed = 50. / 3.6;
117 49405 : desiredMaxSpeed = DEFAULT_BICYCLE_SPEED;
118 49405 : width = 0.65;
119 49405 : height = 1.7;
120 49405 : shape = SUMOVehicleShape::BICYCLE;
121 49405 : personCapacity = 1;
122 98810 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
123 49405 : mass = 10.;
124 49405 : speedFactor.setParameter(1, 0.1);
125 49405 : latAlignmentProcedure = LatAlignmentDefinition::RIGHT;
126 49405 : 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 545 : case SVC_TRUCK:
161 545 : maxSpeed = 130. / 3.6;
162 545 : width = 2.4;
163 545 : height = 2.4;
164 545 : shape = SUMOVehicleShape::TRUCK;
165 : osgFile = "car-microcargo-citrus.obj";
166 545 : personCapacity = 2;
167 545 : containerCapacity = 1;
168 1090 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "RT_le7.5t_Euro-VI_A-C", vclass);
169 545 : mass = 4500.;
170 545 : speedFactor.setParameter(1, 0.05);
171 : break;
172 71 : case SVC_TRAILER:
173 71 : maxSpeed = 130. / 3.6;
174 71 : width = 2.55;
175 71 : height = 4.;
176 71 : shape = SUMOVehicleShape::TRUCK_1TRAILER;
177 : osgFile = "car-microcargo-citrus.obj";
178 71 : personCapacity = 2;
179 71 : containerCapacity = 2;
180 142 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "TT_AT_gt34-40t_Euro-VI_A-C", vclass);
181 71 : mass = 13000.;
182 71 : speedFactor.setParameter(1, 0.05);
183 : break;
184 1241 : case SVC_BUS:
185 1241 : maxSpeed = 100. / 3.6;
186 1241 : width = 2.5;
187 1241 : height = 3.4;
188 1241 : shape = SUMOVehicleShape::BUS;
189 : osgFile = "car-minibus-citrus.obj";
190 1241 : 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 2482 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "UBus_Std_gt15-18t_Euro-VI_A-C", vclass);
194 1241 : mass = 12000.;
195 1241 : 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 260 : case SVC_TRAM:
208 260 : maxSpeed = 80. / 3.6;
209 260 : width = 2.4;
210 260 : height = 3.2;
211 260 : shape = SUMOVehicleShape::RAIL_CAR;
212 : osgFile = "tram.obj";
213 260 : personCapacity = 120;
214 520 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
215 260 : mass = 37900.;
216 260 : break;
217 687 : case SVC_RAIL_URBAN:
218 : case SVC_SUBWAY:
219 687 : maxSpeed = 100. / 3.6;
220 687 : minGap = 5;
221 687 : width = 3.0;
222 687 : height = 3.6;
223 687 : shape = SUMOVehicleShape::RAIL_CAR;
224 687 : personCapacity = 300;
225 1374 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
226 687 : mass = 59000.;
227 687 : break;
228 51203 : case SVC_RAIL:
229 51203 : maxSpeed = 160. / 3.6;
230 51203 : minGap = 5;
231 51203 : width = 2.84;
232 51203 : height = 3.75;
233 51203 : shape = SUMOVehicleShape::RAIL;
234 51203 : personCapacity = 434;
235 : // slight understatement (-:
236 51203 : emissionClass = PollutantsInterface::getClassByName("HBEFA3/HDV_D_EU0", vclass);
237 51203 : mass = 79500.; // only locomotive
238 51203 : 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 260 : case SVC_EMERGENCY:
269 260 : width = 2.16;
270 260 : height = 2.86;
271 260 : shape = SUMOVehicleShape::DELIVERY;
272 260 : personCapacity = 2;
273 520 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LCV_diesel_N1-III_Euro-6ab", vclass);
274 260 : mass = 5000.;
275 260 : break;
276 79221 : case SVC_PRIVATE:
277 : case SVC_VIP:
278 : case SVC_PASSENGER:
279 : case SVC_HOV:
280 : case SVC_CUSTOM1:
281 : case SVC_CUSTOM2:
282 79221 : shape = SUMOVehicleShape::PASSENGER;
283 79221 : speedFactor.setParameter(1, 0.1);
284 : break;
285 49670 : case SVC_TAXI:
286 49670 : shape = SUMOVehicleShape::TAXI;
287 49670 : 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 43724 : case SVC_CONTAINER:
295 : // ISO Container TEU
296 43724 : width = 2.438;
297 43724 : height = 2.591;
298 43724 : break;
299 24 : case SVC_DRONE:
300 24 : width = 0.5;
301 24 : break;
302 26 : case SVC_AIRCRAFT:
303 : // Airbus A380
304 26 : shape = SUMOVehicleShape::AIRCRAFT;
305 26 : width = 79.8;
306 26 : break;
307 337 : case SVC_SHIP:
308 337 : width = 4;
309 337 : maxSpeed = 8 / 1.94; // 8 knots
310 337 : height = 4;
311 337 : shape = SUMOVehicleShape::SHIP;
312 : // slight understatement (-:
313 337 : emissionClass = PollutantsInterface::getClassByName("HBEFA3/HDV_D_EU0", vclass);
314 337 : mass = 100000.;
315 337 : speedFactor.setParameter(1, 0.1);
316 : break;
317 : default:
318 : break;
319 : }
320 385876 : }
321 :
322 :
323 0 : SUMOVTypeParameter::VClassDefaultValues::VClassDefaultValues() :
324 0 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0) {}
325 :
326 359993 : SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
327 359993 : : id(vtid),
328 359993 : actionStepLength(0),
329 359993 : defaultProbability(DEFAULT_VEH_PROB),
330 359993 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
331 719986 : emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "default", vclass)),
332 359993 : color(RGBColor::DEFAULT_COLOR),
333 359993 : vehicleClass(vclass),
334 359993 : impatience(0.0),
335 359993 : personCapacity(4),
336 359993 : containerCapacity(0),
337 359993 : boardingDuration(500),
338 359993 : loadingDuration(90000),
339 359993 : scale(1),
340 359993 : width(1.8),
341 359993 : height(1.5),
342 359993 : shape(SUMOVehicleShape::UNKNOWN),
343 359993 : osgFile("car-normal-citrus.obj"),
344 359993 : cfModel(SUMO_TAG_CF_KRAUSS),
345 359993 : lcModel(LaneChangeModel::DEFAULT),
346 359993 : maxSpeedLat(1.0),
347 359993 : latAlignmentOffset(0.0),
348 359993 : latAlignmentProcedure(LatAlignmentDefinition::CENTER),
349 359993 : scaleVisual(1),
350 359993 : carriageLength(-1),
351 359993 : locomotiveLength(-1),
352 359993 : carriageGap(1.),
353 359993 : carriageDoors(2),
354 359993 : carriageDoorWidth(1.5),
355 359993 : maxPlatformDistance(3.),
356 359993 : timeToTeleport(TTT_UNSET),
357 359993 : timeToTeleportBidi(TTT_UNSET),
358 359993 : speedFactorPremature(-1),
359 359993 : frontSeatPos(1.7),
360 359993 : seatingWidth(-1),
361 359993 : boardingFactor(1),
362 359993 : parametersSet(0),
363 359993 : saved(false),
364 359993 : onlyReferenced(false) {
365 359993 : const OptionsCont& oc = OptionsCont::getOptions();
366 719986 : if (oc.exists("carfollow.model")) {
367 : // check for valid value has been performed in MSFrame
368 664062 : cfModel = SUMOXMLDefinitions::CarFollowModels.get(oc.getString("carfollow.model"));
369 : }
370 : // obtain default values depending of vclass
371 359993 : VClassDefaultValues defaultValues(vclass);
372 : // overwrite SUMOVTypeParameter with VClassDefaultValues
373 359993 : length = defaultValues.length;
374 359993 : minGap = defaultValues.minGap;
375 359993 : minGapLat = defaultValues.minGapLat;
376 359993 : maxSpeed = defaultValues.maxSpeed;
377 359993 : desiredMaxSpeed = defaultValues.desiredMaxSpeed;
378 359993 : width = defaultValues.width;
379 359993 : height = defaultValues.height;
380 359993 : shape = defaultValues.shape;
381 359993 : emissionClass = defaultValues.emissionClass;
382 359993 : mass = defaultValues.mass;
383 : speedFactor = defaultValues.speedFactor;
384 359993 : personCapacity = defaultValues.personCapacity;
385 359993 : containerCapacity = defaultValues.containerCapacity;
386 : osgFile = defaultValues.osgFile;
387 359993 : carriageLength = defaultValues.carriageLength;
388 359993 : locomotiveLength = defaultValues.locomotiveLength;
389 359993 : carriageDoors = defaultValues.carriageDoors;
390 359993 : latAlignmentProcedure = defaultValues.latAlignmentProcedure;
391 : // check if default speeddev was defined
392 719986 : if (oc.exists("default.speeddev")) {
393 332031 : const double defaultSpeedDev = oc.getFloat("default.speeddev");
394 332031 : if (defaultSpeedDev >= 0) {
395 231904 : speedFactor.setParameter(1, defaultSpeedDev);
396 : }
397 : } else {
398 27962 : speedFactor.setParameter(1, -1.);
399 : }
400 359993 : setManoeuverAngleTimes(vclass);
401 359993 : }
402 :
403 : void
404 359993 : 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 359993 : switch (vclass) {
415 128576 : case SVC_PASSENGER:
416 : case SVC_HOV:
417 : case SVC_TAXI:
418 : case SVC_E_VEHICLE:
419 128576 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
420 128576 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
421 128576 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
422 128576 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
423 128576 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
424 128576 : break;
425 1997 : case SVC_TRUCK:
426 : case SVC_TRAILER:
427 : case SVC_BUS:
428 : case SVC_COACH:
429 : case SVC_DELIVERY:
430 1997 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
431 1997 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(2000, 21000))); // straight in
432 1997 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(21000, 2000))); // optional forwards/backwards
433 1997 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(14000, 5000))); // backwards into obtuse space
434 1997 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
435 1997 : break;
436 124987 : case SVC_PEDESTRIAN:
437 : case SVC_MOPED:
438 : case SVC_BICYCLE:
439 124987 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(1000, 1000))); // no dependence on angle
440 124987 : break;
441 104433 : default:
442 104433 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
443 104433 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
444 104433 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
445 104433 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
446 104433 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
447 104433 : break;
448 : }
449 359993 : }
450 :
451 : void
452 8296 : SUMOVTypeParameter::write(OutputDevice& dev) const {
453 : // first check if vehicle type can be written
454 8296 : if (onlyReferenced) {
455 : return;
456 : }
457 : // open vehicle tag
458 3846 : dev.openTag(SUMO_TAG_VTYPE);
459 : // write ID (always needed)
460 3846 : dev.writeAttr(SUMO_ATTR_ID, id);
461 : // write parameters depending if is set
462 3846 : if (wasSet(VTYPEPARS_LENGTH_SET)) {
463 1061 : dev.writeAttr(SUMO_ATTR_LENGTH, length);
464 : }
465 3846 : if (wasSet(VTYPEPARS_MINGAP_SET)) {
466 851 : dev.writeAttr(SUMO_ATTR_MINGAP, minGap);
467 : }
468 3846 : if (wasSet(VTYPEPARS_MAXSPEED_SET)) {
469 933 : dev.writeAttr(SUMO_ATTR_MAXSPEED, maxSpeed);
470 : }
471 3846 : if (wasSet(VTYPEPARS_DESIRED_MAXSPEED_SET)) {
472 0 : dev.writeAttr(SUMO_ATTR_DESIRED_MAXSPEED, desiredMaxSpeed);
473 : }
474 3846 : if (wasSet(VTYPEPARS_PROBABILITY_SET)) {
475 172 : dev.writeAttr(SUMO_ATTR_PROB, defaultProbability);
476 : }
477 3846 : if (wasSet(VTYPEPARS_SPEEDFACTOR_SET)) {
478 484 : dev.writeAttr(SUMO_ATTR_SPEEDFACTOR, speedFactor);
479 : }
480 3846 : if (wasSet(VTYPEPARS_ACTIONSTEPLENGTH_SET)) {
481 : // Note: action step length is only exposed in seconds to the user
482 116 : dev.writeAttr(SUMO_ATTR_ACTIONSTEPLENGTH, STEPS2TIME(actionStepLength));
483 : }
484 3846 : if (wasSet(VTYPEPARS_VEHICLECLASS_SET)) {
485 917 : dev.writeAttr(SUMO_ATTR_VCLASS, toString(vehicleClass));
486 : }
487 3846 : if (wasSet(VTYPEPARS_EMISSIONCLASS_SET)) {
488 70 : dev.writeAttr(SUMO_ATTR_EMISSIONCLASS, PollutantsInterface::getName(emissionClass));
489 : }
490 3846 : if (wasSet(VTYPEPARS_MASS_SET)) {
491 11 : dev.writeAttr(SUMO_ATTR_MASS, mass);
492 : }
493 3846 : 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 3846 : if (wasSet(VTYPEPARS_SHAPE_SET)) {
501 63 : dev.writeAttr(SUMO_ATTR_GUISHAPE, getVehicleShapeName(shape));
502 : }
503 3846 : if (wasSet(VTYPEPARS_WIDTH_SET)) {
504 48 : dev.writeAttr(SUMO_ATTR_WIDTH, width);
505 : }
506 3846 : if (wasSet(VTYPEPARS_HEIGHT_SET)) {
507 0 : dev.writeAttr(SUMO_ATTR_HEIGHT, height);
508 : }
509 3846 : if (wasSet(VTYPEPARS_COLOR_SET)) {
510 516 : dev.writeAttr(SUMO_ATTR_COLOR, color);
511 : }
512 3846 : if (wasSet(VTYPEPARS_OSGFILE_SET)) {
513 0 : dev.writeAttr(SUMO_ATTR_OSGFILE, osgFile);
514 : }
515 3846 : if (wasSet(VTYPEPARS_IMGFILE_SET)) {
516 0 : dev.writeAttr(SUMO_ATTR_IMGFILE, imgFile);
517 : }
518 3846 : if (wasSet(VTYPEPARS_PERSON_CAPACITY)) {
519 2 : dev.writeAttr(SUMO_ATTR_PERSON_CAPACITY, personCapacity);
520 : }
521 3846 : if (wasSet(VTYPEPARS_CONTAINER_CAPACITY)) {
522 0 : dev.writeAttr(SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity);
523 : }
524 3846 : if (wasSet(VTYPEPARS_BOARDING_DURATION)) {
525 104 : dev.writeAttr(SUMO_ATTR_BOARDING_DURATION, time2string(boardingDuration));
526 : }
527 3846 : if (wasSet(VTYPEPARS_LOADING_DURATION)) {
528 100 : dev.writeAttr(SUMO_ATTR_LOADING_DURATION, time2string(loadingDuration));
529 : }
530 3846 : if (wasSet(VTYPEPARS_MAXSPEED_LAT_SET)) {
531 10 : dev.writeAttr(SUMO_ATTR_MAXSPEED_LAT, maxSpeedLat);
532 : }
533 3846 : if (wasSet(VTYPEPARS_LATALIGNMENT_SET)) {
534 10 : 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 10 : case LatAlignmentDefinition::COMPACT:
551 10 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "compact");
552 10 : 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 3846 : if (wasSet(VTYPEPARS_MINGAP_LAT_SET)) {
562 10 : dev.writeAttr(SUMO_ATTR_MINGAP_LAT, minGapLat);
563 : }
564 3846 : if (wasSet(VTYPEPARS_MANEUVER_ANGLE_TIMES_SET)) {
565 0 : dev.writeAttr(SUMO_ATTR_MANEUVER_ANGLE_TIMES, getManoeuverAngleTimesS());
566 : }
567 3846 : if (wasSet(VTYPEPARS_SCALE_SET)) {
568 0 : dev.writeAttr(SUMO_ATTR_SCALE, scale);
569 : }
570 3846 : if (wasSet(VTYPEPARS_TTT_SET)) {
571 100 : dev.writeAttr(SUMO_ATTR_TIME_TO_TELEPORT, time2string(timeToTeleport));
572 : }
573 3846 : if (wasSet(VTYPEPARS_TTT_BIDI_SET)) {
574 0 : dev.writeAttr(SUMO_ATTR_TIME_TO_TELEPORT_BIDI, time2string(timeToTeleportBidi));
575 : }
576 3846 : if (wasSet(VTYPEPARS_SPEEDFACTOR_PREMATURE_SET)) {
577 0 : dev.writeAttr(SUMO_ATTR_SPEEDFACTOR_PREMATURE, speedFactorPremature);
578 : }
579 3846 : if (wasSet(VTYPEPARS_BOARDING_FACTOR_SET)) {
580 0 : dev.writeAttr(SUMO_ATTR_BOARDING_FACTOR, boardingFactor);
581 : }
582 3846 : 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 3846 : for (const auto& lcParam : lcParameter) {
587 0 : dev.writeAttr(lcParam.first, lcParam.second);
588 : }
589 : // Write Junction Model parameter
590 3846 : for (const auto& jmParam : jmParameter) {
591 0 : dev.writeAttr(jmParam.first, jmParam.second);
592 : }
593 3846 : if (wasSet(VTYPEPARS_CAR_FOLLOW_MODEL)) {
594 66 : dev.writeAttr(SUMO_ATTR_CAR_FOLLOW_MODEL, SUMOXMLDefinitions::CarFollowModels.getString(cfModel));
595 : }
596 : // Write Car Following Model parameters
597 7844 : for (const auto& cfParam : cfParameter) {
598 3998 : dev.writeAttr(cfParam.first, cfParam.second);
599 : }
600 : // Write carriage length
601 3846 : 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 3846 : 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 3846 : 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 3846 : 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 3846 : writeParams(dev);
630 : // close tag
631 7692 : dev.closeTag();
632 : }
633 :
634 :
635 : double
636 3951483 : SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
637 : if (cfParameter.count(attr)) {
638 56431 : return StringUtils::toDouble(cfParameter.find(attr)->second);
639 : } else {
640 : return defaultValue;
641 : }
642 : }
643 :
644 :
645 : std::string
646 485 : 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 80 : SUMOVTypeParameter::getCFValueTable(SumoXMLAttr attr) const {
657 : std::vector<double> result;
658 160 : const std::string values = getCFParamString(attr, "");
659 80 : if (!values.empty()) {
660 856 : for (std::string value : StringTokenizer(values).getVector()) {
661 696 : result.push_back(StringUtils::toDouble(value));
662 80 : }
663 : }
664 80 : return result;
665 0 : }
666 :
667 :
668 :
669 : LinearApproxHelpers::LinearApproxMap
670 654736 : SUMOVTypeParameter::getCFProfile(const SumoXMLAttr attr, const LinearApproxHelpers::LinearApproxMap& defaultProfile) const {
671 : if (cfParameter.count(attr)) {
672 40 : std::vector<double> speedTable = getCFValueTable(SUMO_ATTR_SPEED_TABLE);
673 40 : std::vector<double> valueTable = getCFValueTable(attr);
674 40 : 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 40 : } 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 388 : for (int i = 0; i < (int)speedTable.size(); i++) {
681 348 : result[speedTable[i]] = valueTable[i];
682 : }
683 : return result;
684 40 : } else {
685 : return defaultProfile;
686 : }
687 : }
688 :
689 :
690 : double
691 120825095 : SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
692 : if (lcParameter.count(attr)) {
693 392048 : return StringUtils::toDouble(lcParameter.find(attr)->second);
694 : } else {
695 : return defaultValue;
696 : }
697 : }
698 :
699 :
700 : std::string
701 101615 : 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 135828 : SUMOVTypeParameter::getLCParams() const {
712 135828 : return lcParameter;
713 : }
714 :
715 :
716 : double
717 3214777641 : SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
718 : if (jmParameter.count(attr)) {
719 10555656 : 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 36 : SUMOVTypeParameter::getEntryManoeuvreTime(const int angle) const {
737 : SUMOTime last = 0;
738 108 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
739 108 : 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 36 : SUMOVTypeParameter::getExitManoeuvreTime(const int angle) const {
750 : SUMOTime last = 0;
751 108 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
752 108 : 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 30 : SUMOVTypeParameter::cacheParamRestrictions(const std::vector<std::string>& restrictionKeys) {
780 60 : for (const std::string& key : restrictionKeys) {
781 60 : paramRestrictions.push_back(StringUtils::toDouble(getParameter(key, "0")));
782 : }
783 30 : }
784 :
785 :
786 : void
787 324978 : SUMOVTypeParameter::initRailVisualizationParameters(const std::string fileName) {
788 649956 : if (hasParameter("scaleVisual")) {
789 0 : scaleVisual = StringUtils::toDouble(getParameter("scaleVisual"));
790 : }
791 649956 : if (hasParameter("carriageLength")) {
792 132 : carriageLength = StringUtils::toDouble(getParameter("carriageLength"));
793 66 : parametersSet |= VTYPEPARS_CARRIAGE_LENGTH_SET;
794 : } else {
795 324912 : 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 45940 : case SUMOVehicleShape::RAIL:
801 45940 : if (vehicleClass == SVC_RAIL_ELECTRIC) {
802 24 : carriageLength = 24.5;
803 24 : locomotiveLength = 19.100; // https://en.wikipedia.org/wiki/DB_Class_101
804 45916 : } 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 45892 : carriageLength = 24.5; // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
809 45892 : locomotiveLength = 16.4; // https://en.wikipedia.org/wiki/DB_Class_218
810 : }
811 : break;
812 652 : case SUMOVehicleShape::RAIL_CAR:
813 652 : if (vehicleClass == SVC_TRAM) {
814 184 : carriageLength = 5.71; // http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
815 184 : locomotiveLength = 5.71;
816 468 : } else if (vehicleClass == SVC_RAIL_URBAN) {
817 416 : carriageLength = 18.4; // https://en.wikipedia.org/wiki/DBAG_Class_481
818 416 : 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 94 : case SUMOVehicleShape::TRUCK_1TRAILER:
832 94 : carriageLength = 6.75;
833 94 : locomotiveLength = 2.5 + 6.75;
834 94 : carriageGap = 0.5;
835 94 : break;
836 : default:
837 : break;
838 : }
839 : }
840 649956 : if (hasParameter("locomotiveLength")) {
841 62 : locomotiveLength = StringUtils::toDouble(getParameter("locomotiveLength"));
842 31 : parametersSet |= VTYPEPARS_LOCOMOTIVE_LENGTH_SET;
843 324947 : } else if (locomotiveLength < 0) {
844 278306 : locomotiveLength = carriageLength;
845 : }
846 649956 : if (hasParameter("carriageGap")) {
847 12 : carriageGap = StringUtils::toDouble(getParameter("carriageGap"));
848 6 : parametersSet |= VTYPEPARS_CARRIAGE_GAP_SET;
849 : }
850 649956 : if (hasParameter("carriageDoors")) {
851 24 : carriageDoors = StringUtils::toInt(getParameter("carriageDoors"));
852 12 : parametersSet |= VTYPEPARS_CARRIAGE_DOORS_SET;
853 : }
854 649956 : if (hasParameter("carriageDoorWidth")) {
855 0 : carriageDoorWidth = StringUtils::toDouble(getParameter("carriageDoorWidth"));
856 : }
857 649956 : if (hasParameter("maxPlatformDistance")) {
858 0 : maxPlatformDistance = StringUtils::toDouble(getParameter("maxPlatformDistance"));
859 : }
860 649956 : if (hasParameter("frontSeatPos")) {
861 30 : frontSeatPos = StringUtils::toDouble(getParameter("frontSeatPos"));
862 15 : parametersSet |= VTYPEPARS_FRONT_SEAT_POS_SET;
863 : } else {
864 324963 : switch (shape) {
865 228 : case SUMOVehicleShape::SHIP:
866 228 : frontSeatPos = 5;
867 228 : break;
868 217 : case SUMOVehicleShape::DELIVERY:
869 217 : frontSeatPos = 1.2;
870 217 : break;
871 44385 : case SUMOVehicleShape::BICYCLE:
872 44385 : frontSeatPos = 0.6;
873 44385 : break;
874 262 : case SUMOVehicleShape::MOPED:
875 : case SUMOVehicleShape::MOTORCYCLE:
876 262 : frontSeatPos = 0.9;
877 262 : break;
878 1097 : case SUMOVehicleShape::BUS:
879 : case SUMOVehicleShape::BUS_COACH:
880 : case SUMOVehicleShape::BUS_FLEXIBLE:
881 : case SUMOVehicleShape::BUS_TROLLEY:
882 1097 : frontSeatPos = 0.5;
883 1097 : break;
884 670 : case SUMOVehicleShape::TRUCK:
885 : case SUMOVehicleShape::TRUCK_1TRAILER:
886 : case SUMOVehicleShape::TRUCK_SEMITRAILER:
887 670 : frontSeatPos = 0.8;
888 670 : break;
889 : default:
890 : break;
891 : }
892 : }
893 :
894 649956 : if (hasParameter("seatingWidth")) {
895 14 : seatingWidth = StringUtils::toDouble(getParameter("seatingWidth"));
896 7 : parametersSet |= VTYPEPARS_SEATING_WIDTH_SET;
897 : }
898 649956 : 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 324978 : }
905 :
906 :
907 : double
908 327061 : SUMOVTypeParameter::getDefaultAccel(const SUMOVehicleClass vc) {
909 327061 : 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 548 : case SVC_TRUCK:
921 548 : 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 46054 : case SVC_RAIL:
933 46054 : return 0.25;
934 48 : case SVC_RAIL_ELECTRIC:
935 : case SVC_RAIL_FAST:
936 48 : return 0.5;
937 228 : case SVC_SHIP:
938 228 : return 0.1;
939 163184 : default:
940 163184 : return 2.6;//2.9;
941 : }
942 : }
943 :
944 :
945 : double
946 741342 : SUMOVTypeParameter::getDefaultDecel(const SUMOVehicleClass vc) {
947 741342 : 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 3220 : case SVC_TRUCK:
959 : case SVC_TRAILER:
960 : case SVC_BUS:
961 : case SVC_COACH:
962 3220 : return 4.;
963 : case SVC_TRAM:
964 : case SVC_RAIL_URBAN:
965 : return 3.;
966 135628 : case SVC_RAIL:
967 : case SVC_RAIL_ELECTRIC:
968 : case SVC_RAIL_FAST:
969 135628 : return 1.3;
970 456 : case SVC_SHIP:
971 456 : return 0.15;
972 370468 : default:
973 370468 : return 4.5;//7.5;
974 : }
975 : }
976 :
977 :
978 : double
979 651953 : SUMOVTypeParameter::getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption) {
980 651953 : if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT) {
981 : double vcDecel;
982 646465 : 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 456 : case SVC_SHIP:
1009 : vcDecel = 1.;
1010 456 : break;
1011 321375 : 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 315525 : SUMOVTypeParameter::getDefaultImperfection(const SUMOVehicleClass vc) {
1027 315525 : 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 270339 : default:
1036 270339 : return 0.5;
1037 : }
1038 : }
1039 :
1040 : const SUMOVTypeParameter&
1041 20396516 : SUMOVTypeParameter::getDefault() {
1042 20403570 : static SUMOVTypeParameter defaultParams("");
1043 20396516 : return defaultParams;
1044 : }
1045 :
1046 : bool
1047 1720 : SUMOVTypeParameter::parseLatAlignment(const std::string& val, double& lao, LatAlignmentDefinition& lad) {
1048 : bool ok = true;
1049 1720 : lao = 0.0;
1050 1720 : lad = LatAlignmentDefinition::GIVEN;
1051 1720 : if (val == "right") {
1052 311 : lad = LatAlignmentDefinition::RIGHT;
1053 1409 : } else if (val == "center") {
1054 675 : lad = LatAlignmentDefinition::CENTER;
1055 734 : } else if (val == "arbitrary") {
1056 345 : lad = LatAlignmentDefinition::ARBITRARY;
1057 389 : } else if (val == "nice") {
1058 46 : lad = LatAlignmentDefinition::NICE;
1059 343 : } else if (val == "compact") {
1060 245 : 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 1720 : return ok;
1071 : }
1072 :
1073 :
1074 : SUMOTime
1075 83329560 : SUMOVTypeParameter::getTimeToTeleport(SUMOTime defaultValue) const {
1076 83329560 : return timeToTeleport == TTT_UNSET ? defaultValue : timeToTeleport;
1077 : }
1078 :
1079 : SUMOTime
1080 83329560 : SUMOVTypeParameter::getTimeToTeleportBidi(SUMOTime defaultValue) const {
1081 83329560 : return timeToTeleportBidi == TTT_UNSET ? defaultValue : timeToTeleportBidi;
1082 : }
1083 :
1084 : LinearApproxHelpers::LinearApproxMap
1085 326971 : 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 326971 : return result;
1106 : }
1107 326971 : }
1108 :
1109 : LinearApproxHelpers::LinearApproxMap
1110 326971 : 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 326971 : return result;
1130 : }
1131 : }
1132 :
1133 : /****************************************************************************/
|