Eclipse SUMO - Simulation of Urban MObility
SUMOVTypeParameter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 /****************************************************************************/
20 // Structure representing possible vehicle parameter
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include <algorithm>
26 #include <utils/common/ToString.h>
33 
34 #define EMPREFIX std::string("HBEFA3/")
35 #define TTT_UNSET SUMOTime_MIN
36 
37 // ===========================================================================
38 // static value definitions
39 // ===========================================================================
40 std::set<SumoXMLAttr> SUMOVTypeParameter::AllowedJMAttrs({
52 });
53 
54 
55 // ===========================================================================
56 // member method definitions
57 // ===========================================================================
58 
60  length(getDefaultVehicleLength(vclass)),
61  minGap(2.5),
62  minGapLat(0.6),
63  maxSpeed(200. / 3.6),
64  desiredMaxSpeed(10000 / 3.6), // backward-compatibility: do not influence speeds by default
65  width(1.8),
66  height(1.5),
67  shape(SUMOVehicleShape::UNKNOWN),
68  emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)),
69  mass(1500.),
70  speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
71  personCapacity(4),
72  containerCapacity(0),
73  osgFile("car-normal-citrus.obj"),
74  carriageLength(-1),
75  locomotiveLength(-1),
76  carriageDoors(2),
77  latAlignmentProcedure(LatAlignmentDefinition::CENTER) {
78  // update default values
79  switch (vclass) {
80  case SVC_PEDESTRIAN:
81  minGap = 0.25;
82  maxSpeed = 37.58 / 3.6; // Usain Bolt
84  width = 0.478;
85  height = 1.719;
87  osgFile = "humanResting.obj";
89  mass = 70.; // https://en.wikipedia.org/wiki/Human_body_weight for Europe
90  speedFactor.getParameter()[1] = 0.1;
91  break;
92  case SVC_WHEELCHAIR:
93  minGap = 0.5;
94  maxSpeed = 30.0 / 3.6; // https://en.wikipedia.org/wiki/Wheelchair_racing
96  width = 0.8;
97  height = 1.5;
99  osgFile = "humanResting.obj";
101  mass = 90.; //
102  speedFactor.getParameter()[1] = 0.1;
103  break;
104  case SVC_BICYCLE:
105  minGap = 0.5;
106  minGapLat = 0.35;
107  maxSpeed = 50. / 3.6;
109  width = 0.65;
110  height = 1.7;
112  personCapacity = 1;
114  mass = 10.;
115  speedFactor.getParameter()[1] = 0.1;
117  break;
118  case SVC_SCOOTER:
119  minGap = 0.5;
120  minGapLat = 0.35;
121  maxSpeed = 25 / 3.6;
123  width = 0.5;
124  height = 1.7;
126  personCapacity = 1;
128  mass = 10.;
129  speedFactor.getParameter()[1] = 0.1;
131  break;
132  case SVC_MOPED:
133  maxSpeed = 60. / 3.6;
134  width = 0.78;
135  height = 1.7;
137  personCapacity = 1;
139  mass = 80.;
140  speedFactor.getParameter()[1] = 0.1;
141  break;
142  case SVC_MOTORCYCLE:
143  width = 0.9;
144  height = 1.5;
146  personCapacity = 1;
148  mass = 200.;
149  speedFactor.getParameter()[1] = 0.1;
150  break;
151  case SVC_TRUCK:
152  maxSpeed = 130. / 3.6;
153  width = 2.4;
154  height = 2.4;
156  osgFile = "car-microcargo-citrus.obj";
157  personCapacity = 2;
158  containerCapacity = 1;
160  mass = 12000.;
161  speedFactor.getParameter()[1] = 0.05;
162  break;
163  case SVC_TRAILER:
164  maxSpeed = 130. / 3.6;
165  width = 2.55;
166  height = 4.;
168  osgFile = "car-microcargo-citrus.obj";
169  personCapacity = 2;
170  containerCapacity = 2;
172  mass = 15000.;
173  speedFactor.getParameter()[1] = 0.05;
174  break;
175  case SVC_BUS:
176  maxSpeed = 100. / 3.6;
177  width = 2.5;
178  height = 3.4;
180  osgFile = "car-minibus-citrus.obj";
181  personCapacity = 85;
183  mass = 7500.;
184  break;
185  case SVC_COACH:
186  maxSpeed = 100. / 3.6;
187  width = 2.6;
188  height = 4.;
190  osgFile = "car-minibus-citrus.obj";
191  personCapacity = 70;
193  mass = 12000.;
194  speedFactor.getParameter()[1] = 0.05;
195  break;
196  case SVC_TRAM:
197  maxSpeed = 80. / 3.6;
198  width = 2.4;
199  height = 3.2;
201  osgFile = "tram.obj";
202  personCapacity = 120;
204  mass = 37900.;
205  break;
206  case SVC_RAIL_URBAN:
207  case SVC_SUBWAY:
208  maxSpeed = 100. / 3.6;
209  minGap = 5;
210  width = 3.0;
211  height = 3.6;
213  personCapacity = 300;
215  mass = 59000.;
216  break;
217  case SVC_RAIL:
218  maxSpeed = 160. / 3.6;
219  minGap = 5;
220  width = 2.84;
221  height = 3.75;
223  personCapacity = 434;
224  // slight understatement (-:
226  mass = 79500.; // only locomotive
227  break;
228  case SVC_RAIL_ELECTRIC:
229  maxSpeed = 220. / 3.6;
230  minGap = 5;
231  width = 2.95;
232  height = 3.89;
234  personCapacity = 425;
236  mass = 83000.; // only locomotive
237  break;
238  case SVC_RAIL_FAST:
239  maxSpeed = 330. / 3.6;
240  minGap = 5;
241  width = 2.95;
242  height = 3.89;
244  personCapacity = 425;
246  mass = 409000.;
247  break;
248  case SVC_DELIVERY:
249  width = 2.16;
250  height = 2.86;
252  personCapacity = 2;
254  mass = 5000.;
255  speedFactor.getParameter()[1] = 0.05;
256  break;
257  case SVC_EMERGENCY:
258  width = 2.16;
259  height = 2.86;
261  personCapacity = 2;
263  mass = 5000.;
264  break;
265  case SVC_PRIVATE:
266  case SVC_VIP:
267  case SVC_PASSENGER:
268  case SVC_HOV:
269  case SVC_CUSTOM1:
270  case SVC_CUSTOM2:
272  speedFactor.getParameter()[1] = 0.1;
273  break;
274  case SVC_TAXI:
276  speedFactor.getParameter()[1] = 0.05;
277  break;
278  case SVC_E_VEHICLE:
281  speedFactor.getParameter()[1] = 0.1;
282  break;
283  case SVC_CONTAINER:
284  width = 2.5908;
285  break;
286  case SVC_DRONE:
287  width = 0.5;
288  break;
289  case SVC_AIRCRAFT:
290  // Airbus A380
292  width = 79.8;
293  break;
294  case SVC_SHIP:
295  width = 4;
296  maxSpeed = 8 / 1.94; // 8 knots
297  height = 4;
299  // slight understatement (-:
301  mass = 100000.;
302  speedFactor.getParameter()[1] = 0.1;
303  break;
304  default:
305  break;
306  }
307 }
308 
309 
311  speedFactor("normc", 1.0, 0.0, 0.2, 2.0) {}
312 
313 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
314  : id(vtid),
315  actionStepLength(0),
317  speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
318  emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)),
319  color(RGBColor::DEFAULT_COLOR),
320  vehicleClass(vclass),
321  impatience(0.0),
322  personCapacity(4),
324  boardingDuration(500),
325  loadingDuration(90000),
326  scale(1),
327  width(1.8),
328  height(1.5),
330  osgFile("car-normal-citrus.obj"),
333  maxSpeedLat(1.0),
334  latAlignmentOffset(0.0),
336  carriageLength(-1),
337  locomotiveLength(-1),
338  carriageGap(1),
339  carriageDoors(2),
343  frontSeatPos(1.7),
344  seatingWidth(-1),
345  parametersSet(0),
346  saved(false),
347  onlyReferenced(false) {
348  const OptionsCont& oc = OptionsCont::getOptions();
349  if (oc.exists("carfollow.model")) {
350  // check for valid value has been performed in MSFrame
351  cfModel = SUMOXMLDefinitions::CarFollowModels.get(oc.getString("carfollow.model"));
352  }
353  // obtain default values depending of vclass
354  VClassDefaultValues defaultValues(vclass);
355  // overwrite SUMOVTypeParameter with VClassDefaultValues
356  length = defaultValues.length;
357  minGap = defaultValues.minGap;
358  minGapLat = defaultValues.minGapLat;
359  maxSpeed = defaultValues.maxSpeed;
360  desiredMaxSpeed = defaultValues.desiredMaxSpeed;
361  width = defaultValues.width;
362  height = defaultValues.height;
363  shape = defaultValues.shape;
364  emissionClass = defaultValues.emissionClass;
365  mass = defaultValues.mass;
366  speedFactor = defaultValues.speedFactor;
367  personCapacity = defaultValues.personCapacity;
368  containerCapacity = defaultValues.containerCapacity;
369  osgFile = defaultValues.osgFile;
370  carriageLength = defaultValues.carriageLength;
371  locomotiveLength = defaultValues.locomotiveLength;
372  carriageDoors = defaultValues.carriageDoors;
374  // check if default speeddev was defined
375  if (oc.exists("default.speeddev")) {
376  const double defaultSpeedDev = oc.getFloat("default.speeddev");
377  if (defaultSpeedDev >= 0) {
378  speedFactor.getParameter()[1] = defaultSpeedDev;
379  }
380  } else {
381  speedFactor.getParameter()[1] = -1;
382  }
383  setManoeuverAngleTimes(vclass);
384 }
385 
386 void
388 
389  myManoeuverAngleTimes.clear();
397  switch (vclass) {
398  case SVC_PASSENGER:
399  case SVC_HOV:
400  case SVC_TAXI:
401  case SVC_E_VEHICLE:
402  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
403  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
404  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
405  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
406  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
407  break;
408  case SVC_TRUCK:
409  case SVC_TRAILER:
410  case SVC_BUS:
411  case SVC_COACH:
412  case SVC_DELIVERY:
413  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
414  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(2000, 21000))); // straight in
415  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(21000, 2000))); // optional forwards/backwards
416  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(14000, 5000))); // backwards into obtuse space
417  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
418  break;
419  case SVC_PEDESTRIAN:
420  case SVC_MOPED:
421  case SVC_BICYCLE:
422  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(1000, 1000))); // no dependence on angle
423  break;
424  default:
425  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
426  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
427  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
428  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
429  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
430  break;
431  }
432 }
433 
434 void
436  // first check if vehicle type can be written
437  if (onlyReferenced) {
438  return;
439  }
440  // open vehicle tag
441  dev.openTag(SUMO_TAG_VTYPE);
442  // write ID (always needed)
443  dev.writeAttr(SUMO_ATTR_ID, id);
444  // write parameters depending if is set
447  }
450  }
453  }
456  }
459  }
462  }
464  // Note: action step length is only exposed in seconds to the user
466  }
469  }
472  }
473  if (wasSet(VTYPEPARS_MASS_SET)) {
475  }
477  if (impatience == -std::numeric_limits<double>::max()) {
478  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
479  } else {
481  }
482  }
485  }
488  }
491  }
494  }
497  }
500  }
503  }
506  }
509  }
512  }
515  }
517  switch (latAlignmentProcedure) {
520  break;
522  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "right");
523  break;
525  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "center");
526  break;
528  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "arbitrary");
529  break;
531  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "nice");
532  break;
534  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "compact");
535  break;
537  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "left");
538  break;
540  default:
541  break;
542  }
543  }
546  }
549  }
552  }
553  if (wasSet(VTYPEPARS_TTT_SET)) {
555  }
558  }
561  }
564  }
565  // Write Lane Change Model parameters
566  for (const auto& lcParam : lcParameter) {
567  dev.writeAttr(lcParam.first, lcParam.second);
568  }
569  // Write Junction Model parameter
570  for (const auto& jmParam : jmParameter) {
571  dev.writeAttr(jmParam.first, jmParam.second);
572  }
575  }
576  // Write Car Following Model parameters
577  for (const auto& cfParam : cfParameter) {
578  dev.writeAttr(cfParam.first, cfParam.second);
579  }
580  // Write carriage length
582  dev.openTag(SUMO_TAG_PARAM);
585  dev.closeTag();
586  }
587  // Write locomotive length
589  dev.openTag(SUMO_TAG_PARAM);
592  dev.closeTag();
593  }
594  // Write carriage gap
596  dev.openTag(SUMO_TAG_PARAM);
599  dev.closeTag();
600  }
601  // Write carriage doors
603  dev.openTag(SUMO_TAG_PARAM);
606  dev.closeTag();
607  }
608  // Write rest of parameters
609  writeParams(dev);
610  // close tag
611  dev.closeTag();
612 }
613 
614 
615 double
616 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
617  if (cfParameter.count(attr)) {
618  return StringUtils::toDouble(cfParameter.find(attr)->second);
619  } else {
620  return defaultValue;
621  }
622 }
623 
624 
625 std::string
626 SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
627  if (cfParameter.count(attr)) {
628  return cfParameter.find(attr)->second;
629  } else {
630  return defaultValue;
631  }
632 }
633 
634 
635 double
636 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
637  if (lcParameter.count(attr)) {
638  return StringUtils::toDouble(lcParameter.find(attr)->second);
639  } else {
640  return defaultValue;
641  }
642 }
643 
644 
645 std::string
646 SUMOVTypeParameter::getLCParamString(const SumoXMLAttr attr, const std::string& defaultValue) const {
647  if (lcParameter.count(attr)) {
648  return lcParameter.find(attr)->second;
649  } else {
650  return defaultValue;
651  }
652 }
653 
654 
657  return lcParameter;
658 }
659 
660 
661 double
662 SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
663  if (jmParameter.count(attr)) {
664  return StringUtils::toDouble(jmParameter.find(attr)->second);
665  } else {
666  return defaultValue;
667  }
668 }
669 
670 
671 std::string
672 SUMOVTypeParameter::getJMParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
673  if (jmParameter.count(attr)) {
674  return jmParameter.find(attr)->second;
675  } else {
676  return defaultValue;
677  }
678 }
679 
680 SUMOTime
682  SUMOTime last = 0;
683  for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
684  if (angle <= angleTime.first) {
685  return (angleTime.second.first);
686  } else {
687  last = angleTime.second.first;
688  }
689  }
690  return (last);
691 }
692 
693 SUMOTime
695  SUMOTime last = 0;
696  for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
697  if (angle <= angleTime.first) {
698  return (angleTime.second.second);
699  } else {
700  last = angleTime.second.second;
701  }
702  }
703  return (last);
704 }
705 
706 std::string
708  std::stringstream stream;
709 
710  stream << std::fixed << std::setprecision(1);
711  int count = 0;
712  for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
713  if (count++ > 0) {
714  stream << ",";
715  }
716  stream << toString(angleTime.first) + " " << STEPS2TIME(angleTime.second.first) << " " << STEPS2TIME(angleTime.second.second);
717  }
718  std::string triplets = stream.str();
719  return triplets;
720 }
721 
722 
723 void
724 SUMOVTypeParameter::cacheParamRestrictions(const std::vector<std::string>& restrictionKeys) {
725  for (const std::string& key : restrictionKeys) {
727  }
728 }
729 
730 
731 void
733  if (hasParameter("carriageLength")) {
736  } else {
737  switch (shape) {
739  carriageLength = 8.25; // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
740  carriageGap = 0;
741  break;
744  carriageLength = 24.5;
745  locomotiveLength = 19.100; // https://en.wikipedia.org/wiki/DB_Class_101
746  } else if (vehicleClass == SVC_RAIL_FAST) {
747  carriageLength = 24.775; // http://de.wikipedia.org/wiki/ICE_3
748  locomotiveLength = 25.835;
749  } else {
750  carriageLength = 24.5; // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
751  locomotiveLength = 16.4; // https://en.wikipedia.org/wiki/DB_Class_218
752  }
753  break;
755  if (vehicleClass == SVC_TRAM) {
756  carriageLength = 5.71; // http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
757  locomotiveLength = 5.71;
758  } else if (vehicleClass == SVC_RAIL_URBAN) {
759  carriageLength = 18.4; // https://en.wikipedia.org/wiki/DBAG_Class_481
760  locomotiveLength = 18.4;
761  } else {
762  carriageLength = 16.85; // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
763  }
764  break;
766  carriageLength = 13.86; // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
767  break;
769  carriageLength = 13.5;
770  locomotiveLength = 2.5;
771  carriageGap = 0.5;
772  break;
774  carriageLength = 6.75;
775  locomotiveLength = 2.5 + 6.75;
776  carriageGap = 0.5;
777  break;
778  default:
779  break;
780  }
781  }
782  if (hasParameter("locomotiveLength")) {
783  locomotiveLength = StringUtils::toDouble(getParameter("locomotiveLength"));
785  } else if (locomotiveLength < 0) {
787  }
788  if (hasParameter("carriageGap")) {
791  }
792  if (hasParameter("frontSeatPos")) {
795  } else {
796  switch (shape) {
798  frontSeatPos = 5;
799  break;
801  frontSeatPos = 1.2;
802  break;
804  frontSeatPos = 0.6;
805  break;
808  frontSeatPos = 0.9;
809  break;
814  frontSeatPos = 0.5;
815  break;
819  frontSeatPos = 0.8;
820  break;
821  default:
822  break;
823  }
824  }
825 
826  if (hasParameter("seatingWidth")) {
829  }
830 }
831 
832 
833 double
835  switch (vc) {
836  case SVC_PEDESTRIAN:
837  case SVC_WHEELCHAIR:
838  return 1.5;
839  case SVC_BICYCLE:
840  case SVC_SCOOTER:
841  return 1.2;
842  case SVC_MOTORCYCLE:
843  return 6.;
844  case SVC_MOPED:
845  return 1.1;
846  case SVC_TRUCK:
847  return 1.3;
848  case SVC_TRAILER:
849  return 1.1;
850  case SVC_BUS:
851  return 1.2;
852  case SVC_COACH:
853  return 2.;
854  case SVC_TRAM:
855  return 1.;
856  case SVC_RAIL_URBAN:
857  return 1.;
858  case SVC_RAIL:
859  return 0.25;
860  case SVC_RAIL_ELECTRIC:
861  case SVC_RAIL_FAST:
862  return 0.5;
863  case SVC_SHIP:
864  return 0.1;
865  default:
866  return 2.6;//2.9;
867  }
868 }
869 
870 
871 double
873  switch (vc) {
874  case SVC_PEDESTRIAN:
875  case SVC_WHEELCHAIR:
876  return 2.;
877  case SVC_BICYCLE:
878  case SVC_SCOOTER:
879  return 3.;
880  case SVC_MOPED:
881  return 7.;
882  case SVC_MOTORCYCLE:
883  return 10.;
884  case SVC_TRUCK:
885  case SVC_TRAILER:
886  case SVC_BUS:
887  case SVC_COACH:
888  return 4.;
889  case SVC_TRAM:
890  case SVC_RAIL_URBAN:
891  return 3.;
892  case SVC_RAIL:
893  case SVC_RAIL_ELECTRIC:
894  case SVC_RAIL_FAST:
895  return 1.3;
896  case SVC_SHIP:
897  return 0.15;
898  default:
899  return 4.5;//7.5;
900  }
901 }
902 
903 
904 double
905 SUMOVTypeParameter::getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption) {
906  if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT) {
907  double vcDecel;
908  switch (vc) {
909  case SVC_PEDESTRIAN:
910  case SVC_WHEELCHAIR:
911  vcDecel = 5.;
912  break;
913  case SVC_BICYCLE:
914  case SVC_SCOOTER:
915  vcDecel = 7.;
916  break;
917  case SVC_MOPED:
918  case SVC_MOTORCYCLE:
919  vcDecel = 10.;
920  break;
921  case SVC_TRUCK:
922  case SVC_TRAILER:
923  case SVC_BUS:
924  case SVC_COACH:
925  case SVC_TRAM:
926  case SVC_RAIL_URBAN:
927  vcDecel = 7.;
928  break;
929  case SVC_RAIL:
930  case SVC_RAIL_ELECTRIC:
931  case SVC_RAIL_FAST:
932  vcDecel = 5.;
933  break;
934  case SVC_SHIP:
935  vcDecel = 1.;
936  break;
937  default:
938  vcDecel = 9.;
939  }
940  return MAX2(decel, vcDecel);
941  } else if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL) {
942  return decel;
943  } else {
944  // value already checked in MSFrame::checkOptions
945  return MAX2(decel, defaultOption);
946  }
947 }
948 
949 
950 
951 double
953  switch (vc) {
954  case SVC_TRAM:
955  case SVC_RAIL_URBAN:
956  case SVC_RAIL:
957  case SVC_RAIL_ELECTRIC:
958  case SVC_RAIL_FAST:
959  case SVC_SHIP:
960  return 0.;
961  default:
962  return 0.5;
963  }
964 }
965 
966 const SUMOVTypeParameter&
968  static SUMOVTypeParameter defaultParams("");
969  return defaultParams;
970 }
971 
972 bool
973 SUMOVTypeParameter::parseLatAlignment(const std::string& val, double& lao, LatAlignmentDefinition& lad) {
974  bool ok = true;
975  lao = 0.0;
977  if (val == "right") {
979  } else if (val == "center") {
981  } else if (val == "arbitrary") {
983  } else if (val == "nice") {
985  } else if (val == "compact") {
987  } else if (val == "left") {
989  } else {
990  try {
991  lao = StringUtils::toDouble(val);
992  } catch (...) {
993  ok = false;
994  }
995  }
996  return ok;
997 }
998 
999 
1000 SUMOTime
1002  return timeToTeleport == TTT_UNSET ? defaultValue : timeToTeleport;
1003 }
1004 
1005 SUMOTime
1007  return timeToTeleportBidi == TTT_UNSET ? defaultValue : timeToTeleportBidi;
1008 }
1009 
1010 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
@ DEFAULT
default cursor
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition: SUMOTime.cpp:69
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
#define TTT_UNSET
#define EMPREFIX
const long long int VTYPEPARS_TTT_SET
const long long int VTYPEPARS_SHAPE_SET
const long long int VTYPEPARS_LOADING_DURATION
const long long int VTYPEPARS_TTT_BIDI_SET
const long long int VTYPEPARS_SCALE_SET
const long long int VTYPEPARS_PERSON_CAPACITY
const long long int VTYPEPARS_CAR_FOLLOW_MODEL
const long long int VTYPEPARS_FRONT_SEAT_POS_SET
const long long int VTYPEPARS_WIDTH_SET
const long long int VTYPEPARS_CARRIAGE_LENGTH_SET
const long long int VTYPEPARS_ACTIONSTEPLENGTH_SET
const long long int VTYPEPARS_MAXSPEED_LAT_SET
const long long int VTYPEPARS_MAXSPEED_SET
const long long int VTYPEPARS_EMISSIONCLASS_SET
const int VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT
const long long int VTYPEPARS_LATALIGNMENT_SET
const long long int VTYPEPARS_COLOR_SET
const long long int VTYPEPARS_LANE_CHANGE_MODEL_SET
const long long int VTYPEPARS_DESIRED_MAXSPEED_SET
const long long int VTYPEPARS_OSGFILE_SET
const long long int VTYPEPARS_MANEUVER_ANGLE_TIMES_SET
const long long int VTYPEPARS_SPEEDFACTOR_PREMATURE_SET
const long long int VTYPEPARS_SPEEDFACTOR_SET
const long long int VTYPEPARS_CARRIAGE_GAP_SET
const long long int VTYPEPARS_MINGAP_SET
const long long int VTYPEPARS_PROBABILITY_SET
const long long int VTYPEPARS_HEIGHT_SET
const int VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL
const long long int VTYPEPARS_MASS_SET
const long long int VTYPEPARS_BOARDING_DURATION
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
@ RIGHT
drive on the right side
@ GIVEN
The alignment as offset is given.
@ DEFAULT
No information given; use default.
@ LEFT
drive on the left side
@ ARBITRARY
maintain the current alignment
@ NICE
align with the closest sublane border
@ COMPACT
align with the rightmost sublane that allows keeping the current speed
@ CENTER
drive in the middle
const long long int VTYPEPARS_VEHICLECLASS_SET
const long long int VTYPEPARS_IMPATIENCE_SET
const long long int VTYPEPARS_LENGTH_SET
const long long int VTYPEPARS_SEATING_WIDTH_SET
const long long int VTYPEPARS_IMGFILE_SET
const long long int VTYPEPARS_CONTAINER_CAPACITY
const long long int VTYPEPARS_MINGAP_LAT_SET
const long long int VTYPEPARS_CARRIAGE_DOORS_SET
const long long int VTYPEPARS_LOCOMOTIVE_LENGTH_SET
double getDefaultVehicleLength(const SUMOVehicleClass vc)
Returns the default vehicle length This put into a function so it can be used by NBVehicle.
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
const double DEFAULT_VEH_PROB
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
@ BUS
render as a bus
@ RAIL_CARGO
render as a cargo train
@ RAIL
render as a rail
@ PASSENGER
render as a passenger vehicle
@ SCOOTER
render as a scooter
@ RAIL_CAR
render as a (city) rail without locomotive
@ SHIP
render as a arbitrary ship
@ DELIVERY
render as a delivery vehicle
@ BICYCLE
render as a bicycle
@ MOTORCYCLE
render as a motorcycle
@ UNKNOWN
not defined
@ BUS_TROLLEY
render as a trolley bus
@ TAXI
automated car (with cruise controllers)
@ E_VEHICLE
render as a (futuristic) e-vehicle
@ TRUCK
render as a transport vehicle
@ AIRCRAFT
render as aircraft
@ MOPED
render as a moped
@ BUS_FLEXIBLE
render as a flexible city bus
@ TRUCK_1TRAILER
render as a transport vehicle with one trailer
@ BUS_COACH
render as a coach
@ TRUCK_SEMITRAILER
render as a semi-trailer transport vehicle ("Sattelschlepper")
@ PEDESTRIAN
render as a pedestrian
const double DEFAULT_PEDESTRIAN_SPEED
const double DEFAULT_BICYCLE_SPEED
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_SHIP
is an arbitrary ship
@ SVC_PRIVATE
private vehicles
@ SVC_VIP
vip vehicles
@ SVC_HOV
vehicle is a HOV
@ SVC_TRUCK
vehicle is a large transport vehicle
@ SVC_CUSTOM2
is a user-defined type
@ SVC_WHEELCHAIR
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_COACH
vehicle is a coach
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_CONTAINER
@ SVC_SCOOTER
@ SVC_RAIL_FAST
vehicle that is allowed to drive on high-speed rail tracks
@ SVC_TRAILER
vehicle is a large transport vehicle
@ SVC_CUSTOM1
is a user-defined type
@ SVC_DRONE
@ SVC_RAIL_ELECTRIC
rail vehicle that requires electrified tracks
@ SVC_DELIVERY
vehicle is a small delivery vehicle
@ SVC_RAIL_URBAN
vehicle is a city rail
@ SVC_MOTORCYCLE
vehicle is a motorcycle
@ SVC_EMERGENCY
public emergency vehicles
@ SVC_MOPED
vehicle is a moped
@ SVC_TRAM
vehicle is a light rail
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
@ SVC_E_VEHICLE
is an electric vehicle
@ SVC_AIRCRAFT
@ SVC_SUBWAY
@ SVC_PEDESTRIAN
pedestrian
@ CENTER
At the center of the lane.
@ SUMO_TAG_CF_KRAUSS
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_PARAM
parameter associated to a certain key
LaneChangeModel
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_EMISSIONCLASS
@ SUMO_ATTR_JM_IGNORE_FOE_SPEED
@ SUMO_ATTR_JM_IGNORE_KEEPCLEAR_TIME
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_LANE_CHANGE_MODEL
@ SUMO_ATTR_JM_STOPLINE_GAP
@ SUMO_ATTR_SCALE
@ SUMO_ATTR_MAXSPEED_LAT
@ SUMO_ATTR_ACTIONSTEPLENGTH
@ SUMO_ATTR_MINGAP
@ SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME
@ SUMO_ATTR_MASS
@ SUMO_ATTR_LOADING_DURATION
@ SUMO_ATTR_MANEUVER_ANGLE_TIMES
Class specific timing values for vehicle maneuvering through angle ranges.
@ SUMO_ATTR_TIME_TO_TELEPORT_BIDI
@ SUMO_ATTR_CAR_FOLLOW_MODEL
@ SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_DESIRED_MAXSPEED
@ SUMO_ATTR_JM_IGNORE_FOE_PROB
@ SUMO_ATTR_CARRIAGE_DOORS
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_MINGAP_LAT
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_JM_CROSSING_GAP
@ SUMO_ATTR_CARRIAGE_LENGTH
@ SUMO_ATTR_LATALIGNMENT
@ SUMO_ATTR_IMPATIENCE
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_BOARDING_DURATION
@ SUMO_ATTR_JM_SIGMA_MINOR
@ SUMO_ATTR_PROB
@ SUMO_ATTR_TIME_TO_TELEPORT
@ SUMO_ATTR_SPEEDFACTOR
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_SPEEDFACTOR_PREMATURE
@ SUMO_ATTR_OSGFILE
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_JM_IGNORE_JUNCTION_FOE_PROB
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_KEY
@ SUMO_ATTR_LOCOMOTIVE_LENGTH
@ SUMO_ATTR_JM_DRIVE_RED_SPEED
@ SUMO_ATTR_JM_TIMEGAP_MINOR
@ SUMO_ATTR_CARRIAGE_GAP
T MAX2(T a, T b)
Definition: StdDefs.h:82
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
std::vector< double > & getParameter()
Returns the parameters of this distribution.
A storage for options typed value containers)
Definition: OptionsCont.h:89
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
Helper methods for PHEMlight-based emission computation.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
Structure representing possible vehicle parameter.
SUMOTime getExitManoeuvreTime(const int angle) const
Returns the time that will be needed for the vehicle type to execute the (exit) manoeuvre (and be blo...
double width
This class' width.
SubParams cfParameter
Car-following parameter.
void write(OutputDevice &dev) const
Writes the vtype.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
SUMOTime actionStepLength
The vehicle type's default actionStepLength [ms], i.e. the interval between two control actions....
void cacheParamRestrictions(const std::vector< std::string > &restrictionKeys)
bool saved
Information whether this type was already saved (needed by routers)
SUMOTime getTimeToTeleport(SUMOTime defaultValue) const
return time-to-teleport (either custom or default)
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double height
This class' height.
double desiredMaxSpeed
The vehicle type's desired maximum speed [m/s].
SUMOEmissionClass emissionClass
The emission class of this vehicle.
double frontSeatPos
the offset of the first person seat from the front of the vehicle
double latAlignmentOffset
(optional) The vehicle's desired lateral alignment as offset in m from center line
std::string getJMParamString(const SumoXMLAttr attr, const std::string defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
double carriageLength
the length of train carriages and locomotive
static std::set< SumoXMLAttr > AllowedJMAttrs
allowed attrs for the junction model
double seatingWidth
width to be used when comping seats
SUMOTime getTimeToTeleportBidi(SUMOTime defaultValue) const
return time-to-teleport.bidi (either custom or default)
double length
The physical vehicle length.
double maxSpeedLat
The vehicle type's maximum lateral speed [m/s].
double speedFactorPremature
the possible speed reduction when a train is ahead of schedule
std::vector< double > paramRestrictions
cached value of parameters which may restrict access to certain edges
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
SUMOTime getEntryManoeuvreTime(const int angle) const
Returns the time that will be needed for the vehicle type to execute the (entry) manoeuvre (and be bl...
RGBColor color
The color.
long long int parametersSet
Information for the router which parameter were set.
double minGap
This class' free space in front of the vehicle itself.
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
std::string imgFile
Image file for this class.
void initRailVisualizationParameters()
init Rail Visualization Parameters
SUMOVehicleShape shape
This class' shape.
int personCapacity
The person capacity of the vehicle.
int carriageDoors
the number of doors per carriage
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers)
double scale
individual scaling factor (-1 for undefined)
double getLCParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
SUMOTime timeToTeleport
the custom time-to-teleport for this type
std::string osgFile
3D model file for this class
double maxSpeed
The vehicle type's (technical) maximum speed [m/s].
static double getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption)
Returns the default emergency deceleration for the given vehicle class This needs to be a function be...
SUMOTime timeToTeleportBidi
the custom time-to-teleport.bidi for this type
void setManoeuverAngleTimes(const SUMOVehicleClass vclass)
Initialise the default mapping between manoeuver angle and times dependant on vehicle class.
int containerCapacity
The container capacity of the vehicle.
static const SUMOVTypeParameter & getDefault()
return the default parameters, this is a function due to the http://www.parashift....
SUMOTime boardingDuration
The time a person needs to board the vehicle.
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
double minGapLat
The vehicle type's minimum lateral gap [m].
SUMOVehicleClass vehicleClass
The vehicle's class.
SUMOVTypeParameter(const std::string &vtid, const SUMOVehicleClass vc=SVC_IGNORING)
Constructor.
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
double mass
The mass.
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
std::string getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
std::string id
The vehicle type's id.
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
const SubParams & getLCParams() const
Returns the LC parameter.
std::string getLCParamString(const SumoXMLAttr attr, const std::string &defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
SubParams lcParameter
Lane-changing parameter.
LatAlignmentDefinition latAlignmentProcedure
Information on how the vehicle shall choose the lateral alignment.
static double getDefaultImperfection(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default driver's imperfection (sigma or epsilon in Krauss' model) for the given vehicle c...
SubParams jmParameter
Junction-model parameter.
double impatience
The vehicle's impatience (willingness to obstruct others)
std::string getManoeuverAngleTimesS() const
Returns myManoeuverAngleTimes as a string for xml output.
std::map< int, std::pair< SUMOTime, SUMOTime > > myManoeuverAngleTimes
Map of manoeuver angles versus the times (entry, exit) to execute the manoeuver.
LaneChangeModel lcModel
The lane-change model to use.
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
static double getDefaultAccel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default acceleration for the given vehicle class This needs to be a function because the ...
static StringBijection< SumoXMLTag > CarFollowModels
car following models
T get(const std::string &str) const
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
struct for default values that depend of VClass
int carriageDoors
the number of doors per carriage
int personCapacity
The person capacity of the vehicle.
double carriageLength
the length of train carriages
double desiredMaxSpeed
The vehicle type's desired maximum speed [m/s].
std::string osgFile
3D model file for this class
SUMOEmissionClass emissionClass
The emission class of this vehicle.
double minGap
This class' free space in front of the vehicle itself.
int containerCapacity
The container capacity of the vehicle.
double maxSpeed
The vehicle type's maximum speed [m/s] (technical limit, not subject to speed deviation)
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
double length
The physical vehicle length.
SUMOVehicleShape shape
This class' shape.
double minGapLat
The vehicle type's minimum lateral gap [m].
LatAlignmentDefinition latAlignmentProcedure
the lateral alignment procedure
double locomotiveLength
the length of train locomotive