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  boardingFactor(1),
346  parametersSet(0),
347  saved(false),
348  onlyReferenced(false) {
349  const OptionsCont& oc = OptionsCont::getOptions();
350  if (oc.exists("carfollow.model")) {
351  // check for valid value has been performed in MSFrame
352  cfModel = SUMOXMLDefinitions::CarFollowModels.get(oc.getString("carfollow.model"));
353  }
354  // obtain default values depending of vclass
355  VClassDefaultValues defaultValues(vclass);
356  // overwrite SUMOVTypeParameter with VClassDefaultValues
357  length = defaultValues.length;
358  minGap = defaultValues.minGap;
359  minGapLat = defaultValues.minGapLat;
360  maxSpeed = defaultValues.maxSpeed;
361  desiredMaxSpeed = defaultValues.desiredMaxSpeed;
362  width = defaultValues.width;
363  height = defaultValues.height;
364  shape = defaultValues.shape;
365  emissionClass = defaultValues.emissionClass;
366  mass = defaultValues.mass;
367  speedFactor = defaultValues.speedFactor;
368  personCapacity = defaultValues.personCapacity;
369  containerCapacity = defaultValues.containerCapacity;
370  osgFile = defaultValues.osgFile;
371  carriageLength = defaultValues.carriageLength;
372  locomotiveLength = defaultValues.locomotiveLength;
373  carriageDoors = defaultValues.carriageDoors;
375  // check if default speeddev was defined
376  if (oc.exists("default.speeddev")) {
377  const double defaultSpeedDev = oc.getFloat("default.speeddev");
378  if (defaultSpeedDev >= 0) {
379  speedFactor.getParameter()[1] = defaultSpeedDev;
380  }
381  } else {
382  speedFactor.getParameter()[1] = -1;
383  }
384  setManoeuverAngleTimes(vclass);
385 }
386 
387 void
389 
390  myManoeuverAngleTimes.clear();
398  switch (vclass) {
399  case SVC_PASSENGER:
400  case SVC_HOV:
401  case SVC_TAXI:
402  case SVC_E_VEHICLE:
403  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
404  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
405  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
406  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
407  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
408  break;
409  case SVC_TRUCK:
410  case SVC_TRAILER:
411  case SVC_BUS:
412  case SVC_COACH:
413  case SVC_DELIVERY:
414  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
415  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(2000, 21000))); // straight in
416  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(21000, 2000))); // optional forwards/backwards
417  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(14000, 5000))); // backwards into obtuse space
418  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
419  break;
420  case SVC_PEDESTRIAN:
421  case SVC_MOPED:
422  case SVC_BICYCLE:
423  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(1000, 1000))); // no dependence on angle
424  break;
425  default:
426  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
427  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
428  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
429  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
430  myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
431  break;
432  }
433 }
434 
435 void
437  // first check if vehicle type can be written
438  if (onlyReferenced) {
439  return;
440  }
441  // open vehicle tag
442  dev.openTag(SUMO_TAG_VTYPE);
443  // write ID (always needed)
444  dev.writeAttr(SUMO_ATTR_ID, id);
445  // write parameters depending if is set
448  }
451  }
454  }
457  }
460  }
463  }
465  // Note: action step length is only exposed in seconds to the user
467  }
470  }
473  }
474  if (wasSet(VTYPEPARS_MASS_SET)) {
476  }
478  if (impatience == -std::numeric_limits<double>::max()) {
479  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
480  } else {
482  }
483  }
486  }
489  }
492  }
495  }
498  }
501  }
504  }
507  }
510  }
513  }
516  }
518  switch (latAlignmentProcedure) {
521  break;
523  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "right");
524  break;
526  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "center");
527  break;
529  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "arbitrary");
530  break;
532  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "nice");
533  break;
535  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "compact");
536  break;
538  dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "left");
539  break;
541  default:
542  break;
543  }
544  }
547  }
550  }
553  }
554  if (wasSet(VTYPEPARS_TTT_SET)) {
556  }
559  }
562  }
565  }
568  }
569  // Write Lane Change Model parameters
570  for (const auto& lcParam : lcParameter) {
571  dev.writeAttr(lcParam.first, lcParam.second);
572  }
573  // Write Junction Model parameter
574  for (const auto& jmParam : jmParameter) {
575  dev.writeAttr(jmParam.first, jmParam.second);
576  }
579  }
580  // Write Car Following Model parameters
581  for (const auto& cfParam : cfParameter) {
582  dev.writeAttr(cfParam.first, cfParam.second);
583  }
584  // Write carriage length
586  dev.openTag(SUMO_TAG_PARAM);
589  dev.closeTag();
590  }
591  // Write locomotive length
593  dev.openTag(SUMO_TAG_PARAM);
596  dev.closeTag();
597  }
598  // Write carriage gap
600  dev.openTag(SUMO_TAG_PARAM);
603  dev.closeTag();
604  }
605  // Write carriage doors
607  dev.openTag(SUMO_TAG_PARAM);
610  dev.closeTag();
611  }
612  // Write rest of parameters
613  writeParams(dev);
614  // close tag
615  dev.closeTag();
616 }
617 
618 
619 double
620 SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
621  if (cfParameter.count(attr)) {
622  return StringUtils::toDouble(cfParameter.find(attr)->second);
623  } else {
624  return defaultValue;
625  }
626 }
627 
628 
629 std::string
630 SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
631  if (cfParameter.count(attr)) {
632  return cfParameter.find(attr)->second;
633  } else {
634  return defaultValue;
635  }
636 }
637 
638 
639 double
640 SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
641  if (lcParameter.count(attr)) {
642  return StringUtils::toDouble(lcParameter.find(attr)->second);
643  } else {
644  return defaultValue;
645  }
646 }
647 
648 
649 std::string
650 SUMOVTypeParameter::getLCParamString(const SumoXMLAttr attr, const std::string& defaultValue) const {
651  if (lcParameter.count(attr)) {
652  return lcParameter.find(attr)->second;
653  } else {
654  return defaultValue;
655  }
656 }
657 
658 
661  return lcParameter;
662 }
663 
664 
665 double
666 SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
667  if (jmParameter.count(attr)) {
668  return StringUtils::toDouble(jmParameter.find(attr)->second);
669  } else {
670  return defaultValue;
671  }
672 }
673 
674 
675 std::string
676 SUMOVTypeParameter::getJMParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
677  if (jmParameter.count(attr)) {
678  return jmParameter.find(attr)->second;
679  } else {
680  return defaultValue;
681  }
682 }
683 
684 SUMOTime
686  SUMOTime last = 0;
687  for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
688  if (angle <= angleTime.first) {
689  return (angleTime.second.first);
690  } else {
691  last = angleTime.second.first;
692  }
693  }
694  return (last);
695 }
696 
697 SUMOTime
699  SUMOTime last = 0;
700  for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
701  if (angle <= angleTime.first) {
702  return (angleTime.second.second);
703  } else {
704  last = angleTime.second.second;
705  }
706  }
707  return (last);
708 }
709 
710 std::string
712  std::stringstream stream;
713 
714  stream << std::fixed << std::setprecision(1);
715  int count = 0;
716  for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
717  if (count++ > 0) {
718  stream << ",";
719  }
720  stream << toString(angleTime.first) + " " << STEPS2TIME(angleTime.second.first) << " " << STEPS2TIME(angleTime.second.second);
721  }
722  std::string triplets = stream.str();
723  return triplets;
724 }
725 
726 
727 void
728 SUMOVTypeParameter::cacheParamRestrictions(const std::vector<std::string>& restrictionKeys) {
729  for (const std::string& key : restrictionKeys) {
731  }
732 }
733 
734 
735 void
737  if (hasParameter("carriageLength")) {
740  } else {
741  switch (shape) {
743  carriageLength = 8.25; // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
744  carriageGap = 0;
745  break;
748  carriageLength = 24.5;
749  locomotiveLength = 19.100; // https://en.wikipedia.org/wiki/DB_Class_101
750  } else if (vehicleClass == SVC_RAIL_FAST) {
751  carriageLength = 24.775; // http://de.wikipedia.org/wiki/ICE_3
752  locomotiveLength = 25.835;
753  } else {
754  carriageLength = 24.5; // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
755  locomotiveLength = 16.4; // https://en.wikipedia.org/wiki/DB_Class_218
756  }
757  break;
759  if (vehicleClass == SVC_TRAM) {
760  carriageLength = 5.71; // http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
761  locomotiveLength = 5.71;
762  } else if (vehicleClass == SVC_RAIL_URBAN) {
763  carriageLength = 18.4; // https://en.wikipedia.org/wiki/DBAG_Class_481
764  locomotiveLength = 18.4;
765  } else {
766  carriageLength = 16.85; // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
767  }
768  break;
770  carriageLength = 13.86; // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
771  break;
773  carriageLength = 13.5;
774  locomotiveLength = 2.5;
775  carriageGap = 0.5;
776  break;
778  carriageLength = 6.75;
779  locomotiveLength = 2.5 + 6.75;
780  carriageGap = 0.5;
781  break;
782  default:
783  break;
784  }
785  }
786  if (hasParameter("locomotiveLength")) {
787  locomotiveLength = StringUtils::toDouble(getParameter("locomotiveLength"));
789  } else if (locomotiveLength < 0) {
791  }
792  if (hasParameter("carriageGap")) {
795  }
796  if (hasParameter("frontSeatPos")) {
799  } else {
800  switch (shape) {
802  frontSeatPos = 5;
803  break;
805  frontSeatPos = 1.2;
806  break;
808  frontSeatPos = 0.6;
809  break;
812  frontSeatPos = 0.9;
813  break;
818  frontSeatPos = 0.5;
819  break;
823  frontSeatPos = 0.8;
824  break;
825  default:
826  break;
827  }
828  }
829 
830  if (hasParameter("seatingWidth")) {
833  }
834 }
835 
836 
837 double
839  switch (vc) {
840  case SVC_PEDESTRIAN:
841  case SVC_WHEELCHAIR:
842  return 1.5;
843  case SVC_BICYCLE:
844  case SVC_SCOOTER:
845  return 1.2;
846  case SVC_MOTORCYCLE:
847  return 6.;
848  case SVC_MOPED:
849  return 1.1;
850  case SVC_TRUCK:
851  return 1.3;
852  case SVC_TRAILER:
853  return 1.1;
854  case SVC_BUS:
855  return 1.2;
856  case SVC_COACH:
857  return 2.;
858  case SVC_TRAM:
859  return 1.;
860  case SVC_RAIL_URBAN:
861  return 1.;
862  case SVC_RAIL:
863  return 0.25;
864  case SVC_RAIL_ELECTRIC:
865  case SVC_RAIL_FAST:
866  return 0.5;
867  case SVC_SHIP:
868  return 0.1;
869  default:
870  return 2.6;//2.9;
871  }
872 }
873 
874 
875 double
877  switch (vc) {
878  case SVC_PEDESTRIAN:
879  case SVC_WHEELCHAIR:
880  return 2.;
881  case SVC_BICYCLE:
882  case SVC_SCOOTER:
883  return 3.;
884  case SVC_MOPED:
885  return 7.;
886  case SVC_MOTORCYCLE:
887  return 10.;
888  case SVC_TRUCK:
889  case SVC_TRAILER:
890  case SVC_BUS:
891  case SVC_COACH:
892  return 4.;
893  case SVC_TRAM:
894  case SVC_RAIL_URBAN:
895  return 3.;
896  case SVC_RAIL:
897  case SVC_RAIL_ELECTRIC:
898  case SVC_RAIL_FAST:
899  return 1.3;
900  case SVC_SHIP:
901  return 0.15;
902  default:
903  return 4.5;//7.5;
904  }
905 }
906 
907 
908 double
909 SUMOVTypeParameter::getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption) {
910  if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT) {
911  double vcDecel;
912  switch (vc) {
913  case SVC_PEDESTRIAN:
914  case SVC_WHEELCHAIR:
915  vcDecel = 5.;
916  break;
917  case SVC_BICYCLE:
918  case SVC_SCOOTER:
919  vcDecel = 7.;
920  break;
921  case SVC_MOPED:
922  case SVC_MOTORCYCLE:
923  vcDecel = 10.;
924  break;
925  case SVC_TRUCK:
926  case SVC_TRAILER:
927  case SVC_BUS:
928  case SVC_COACH:
929  case SVC_TRAM:
930  case SVC_RAIL_URBAN:
931  vcDecel = 7.;
932  break;
933  case SVC_RAIL:
934  case SVC_RAIL_ELECTRIC:
935  case SVC_RAIL_FAST:
936  vcDecel = 5.;
937  break;
938  case SVC_SHIP:
939  vcDecel = 1.;
940  break;
941  default:
942  vcDecel = 9.;
943  }
944  return MAX2(decel, vcDecel);
945  } else if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL) {
946  return decel;
947  } else {
948  // value already checked in MSFrame::checkOptions
949  return MAX2(decel, defaultOption);
950  }
951 }
952 
953 
954 
955 double
957  switch (vc) {
958  case SVC_TRAM:
959  case SVC_RAIL_URBAN:
960  case SVC_RAIL:
961  case SVC_RAIL_ELECTRIC:
962  case SVC_RAIL_FAST:
963  case SVC_SHIP:
964  return 0.;
965  default:
966  return 0.5;
967  }
968 }
969 
970 const SUMOVTypeParameter&
972  static SUMOVTypeParameter defaultParams("");
973  return defaultParams;
974 }
975 
976 bool
977 SUMOVTypeParameter::parseLatAlignment(const std::string& val, double& lao, LatAlignmentDefinition& lad) {
978  bool ok = true;
979  lao = 0.0;
981  if (val == "right") {
983  } else if (val == "center") {
985  } else if (val == "arbitrary") {
987  } else if (val == "nice") {
989  } else if (val == "compact") {
991  } else if (val == "left") {
993  } else {
994  try {
995  lao = StringUtils::toDouble(val);
996  } catch (...) {
997  ok = false;
998  }
999  }
1000  return ok;
1001 }
1002 
1003 
1004 SUMOTime
1006  return timeToTeleport == TTT_UNSET ? defaultValue : timeToTeleport;
1007 }
1008 
1009 SUMOTime
1011  return timeToTeleportBidi == TTT_UNSET ? defaultValue : timeToTeleportBidi;
1012 }
1013 
1014 /****************************************************************************/
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_BOARDING_FACTOR_SET
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_BOARDING_FACTOR
@ 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].
double boardingFactor
factor for boardingDuration / loadingDuration
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