Eclipse SUMO - Simulation of Urban MObility
SUMOVehicleParserHelper.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2008-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
19 // Helper methods for parsing vehicle attributes
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
32 #include <utils/common/ToString.h>
38 
40 
41 
42 // ===========================================================================
43 // static members
44 // ===========================================================================
45 
48 std::set<SumoXMLAttr> SUMOVehicleParserHelper::allowedJMAttrs;
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 
56 SUMOVehicleParserHelper::parseFlowAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson) {
57  bool ok = true;
58  bool abortCreation = true;
59  // first parse ID
60  std::string id = parseID(attrs, SUMO_TAG_FLOW);
61  // check if ID is valid
62  if (!id.empty()) {
64  return handleError(hardFail, abortCreation, "Invalid flow id '" + id + "'.");
65  }
67  return handleError(hardFail, abortCreation,
68  "At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
69  "' and '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
70  "' has to be given in the definition of flow '" + id + "'.");
71  }
73  return handleError(hardFail, abortCreation,
74  "At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
75  "' and '" + attrs.getName(SUMO_ATTR_PROB) +
76  "' has to be given in the definition of flow '" + id + "'.");
77  }
79  return handleError(hardFail, abortCreation,
80  "At most one of '" + attrs.getName(SUMO_ATTR_PROB) +
81  "' and '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
82  "' has to be given in the definition of flow '" + id + "'.");
83  }
87  return handleError(hardFail, abortCreation,
88  "If '" + attrs.getName(SUMO_ATTR_PERIOD) +
89  "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
90  "' or '" + attrs.getName(SUMO_ATTR_PROB) +
91  "' are given at most one of '" + attrs.getName(SUMO_ATTR_END) +
92  "' and '" + attrs.getName(SUMO_ATTR_NUMBER) +
93  "' are allowed in flow '" + id + "'.");
94  }
95  } else {
96  if (!attrs.hasAttribute(SUMO_ATTR_NUMBER)) {
97  return handleError(hardFail, abortCreation,
98  "At least one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
99  "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
100  "', '" + attrs.getName(SUMO_ATTR_PROB) +
101  "', and '" + attrs.getName(SUMO_ATTR_NUMBER) +
102  "' is needed in flow '" + id + "'.");
103  }
104  }
106  ret->id = id;
107  if (isPerson) {
108  ret->vtypeid = DEFAULT_PEDTYPE_ID;
109  }
110  try {
111  parseCommonAttributes(attrs, hardFail, ret, "flow");
112  } catch (ProcessError&) {
113  delete ret;
114  throw;
115  }
116  // set tag
117  if (ret->routeid.empty()) {
118  ret->tag = SUMO_TAG_FLOW;
119  } else {
120  ret->tag = SUMO_TAG_ROUTEFLOW;
121  }
122  // parse repetition information
123  if (attrs.hasAttribute(SUMO_ATTR_PERIOD)) {
124  ret->parametersSet |= VEHPARS_PERIOD_SET;
125  ret->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok);
126  }
127  if (attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {
128  ret->parametersSet |= VEHPARS_VPH_SET;
129  const double vph = attrs.get<double>(SUMO_ATTR_VEHSPERHOUR, id.c_str(), ok);
130  if (ok && vph <= 0) {
131  delete ret;
132  return handleError(hardFail, abortCreation, "Invalid repetition rate in the definition of flow '" + id + "'.");
133  }
134  if (ok && vph != 0) {
135  ret->repetitionOffset = TIME2STEPS(3600. / vph);
136  }
137  }
139  ret->parametersSet |= VEHPARS_VPH_SET;
140  const double vph = attrs.get<double>(SUMO_ATTR_PERSONSPERHOUR, id.c_str(), ok);
141  if (ok && vph <= 0) {
142  delete ret;
143  return handleError(hardFail, abortCreation, "Invalid repetition rate in the definition of personFlow '" + id + "'.");
144  }
145  if (ok && vph != 0) {
146  ret->repetitionOffset = TIME2STEPS(3600. / vph);
147  }
148  }
149  if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
150  ret->parametersSet |= VEHPARS_PROB_SET;
151  ret->repetitionProbability = attrs.get<double>(SUMO_ATTR_PROB, id.c_str(), ok);
152  if (ok && (ret->repetitionProbability <= 0 || ret->repetitionProbability > 1)) {
153  delete ret;
154  return handleError(hardFail, abortCreation, "Invalid repetition probability in the definition of flow '" + id + "'.");
155  }
156  }
157 
158  ret->depart = beginDefault;
159  if (attrs.hasAttribute(SUMO_ATTR_BEGIN)) {
160  ret->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok);
161  }
162  if (ok && ret->depart < 0) {
163  delete ret;
164  return handleError(hardFail, abortCreation, "Negative begin time in the definition of flow '" + id + "'.");
165  }
166  ret->repetitionEnd = endDefault;
167  if (ret->repetitionEnd < 0) {
168  ret->repetitionEnd = SUMOTime_MAX;
169  }
170  if (attrs.hasAttribute(SUMO_ATTR_END)) {
171  ret->repetitionEnd = attrs.getSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok);
172  ret->parametersSet |= VEHPARS_END_SET;
173  } else if (!attrs.hasAttribute(SUMO_ATTR_NUMBER) &&
174  // see SUMOTIME_MAXSTRING (which differs slightly from SUMOTime_MAX)
175  (endDefault >= TIME2STEPS(9223372036854773) || endDefault < 0)) {
176  WRITE_WARNING("Undefined end for flow '" + id + "', defaulting to 24hour duration.");
177  ret->repetitionEnd = ret->depart + TIME2STEPS(24 * 3600);
178  }
179  if (ok && ret->repetitionEnd < ret->depart) {
180  delete ret;
181  return handleError(hardFail, abortCreation, "Flow '" + id + "' ends before its begin time.");
182  }
183  if (attrs.hasAttribute(SUMO_ATTR_NUMBER)) {
184  ret->repetitionNumber = attrs.get<int>(SUMO_ATTR_NUMBER, id.c_str(), ok);
185  ret->parametersSet |= VEHPARS_NUMBER_SET;
186  if (ret->repetitionNumber == 0) {
187  WRITE_WARNING("Flow '" + id + "' has 0 vehicles; will skip it.");
188  } else {
189  if (ok && ret->repetitionNumber < 0) {
190  delete ret;
191  return handleError(hardFail, abortCreation, "Negative repetition number in the definition of flow '" + id + "'.");
192  }
193  if (ok && ret->repetitionOffset < 0) {
194  ret->repetitionOffset = (ret->repetitionEnd - ret->depart) / ret->repetitionNumber;
195  }
196  }
197  ret->repetitionEnd = ret->depart + ret->repetitionNumber * ret->repetitionOffset;
198  } else {
199  // interpret repetitionNumber
200  if (ok && ret->repetitionProbability > 0) {
201  ret->repetitionNumber = std::numeric_limits<int>::max();
202  } else {
203  if (ok && ret->repetitionOffset <= 0) {
204  delete ret;
205  return handleError(hardFail, abortCreation, "Invalid repetition rate in the definition of flow '" + id + "'.");
206  }
207  if (ret->repetitionEnd == SUMOTime_MAX) {
208  ret->repetitionNumber = std::numeric_limits<int>::max();
209  } else {
210  const double repLength = (double)(ret->repetitionEnd - ret->depart);
211  ret->repetitionNumber = (int)ceil(repLength / ret->repetitionOffset);
212  }
213  }
214  }
215  if (!ok) {
216  delete ret;
217  return handleError(hardFail, abortCreation, "Flow cannot be created");
218  }
219  return ret;
220  } else {
221  if (hardFail) {
222  throw ProcessError("Flow cannot be created");
223  } else {
224  return nullptr;
225  }
226  }
227 }
228 
229 
231 SUMOVehicleParserHelper::parseVehicleAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID, const bool skipDepart, const bool isPerson) {
232  bool ok = true;
233  std::string id, errorMsg;
234  // for certain vehicles, ID can be optional
235  if (optionalID) {
236  id = attrs.getOpt<std::string>(SUMO_ATTR_ID, nullptr, ok, "");
237  } else {
238  // parse ID
239  id = parseID(attrs, isPerson ? SUMO_TAG_PERSON : SUMO_TAG_VEHICLE);
240  }
241  // only continue if id is valid, or if is optional
242  if (optionalID || !id.empty()) {
244  ret->id = id;
245  if (isPerson) {
247  }
248  try {
249  parseCommonAttributes(attrs, hardFail, ret, "vehicle");
250  if (!skipDepart) {
251  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPART, ret->id.c_str(), ok);
252  if (!ok || !SUMOVehicleParameter::parseDepart(helper, "vehicle", ret->id, ret->depart, ret->departProcedure, errorMsg)) {
253  throw ProcessError(errorMsg);
254  }
255  }
256  } catch (ProcessError&) {
257  delete ret;
258  if (hardFail) {
259  throw;
260  } else {
261  WRITE_ERROR(errorMsg);
262  return nullptr;
263  }
264  }
265  // set tag
266  if (isPerson) {
267  ret->tag = SUMO_TAG_PERSON;
268  } else if (ret->routeid.empty()) {
269  ret->tag = SUMO_TAG_TRIP;
270  } else {
271  ret->tag = SUMO_TAG_VEHICLE;
272  }
273  return ret;
274  } else {
275  if (hardFail) {
276  if (isPerson) {
277  throw ProcessError("Person cannot be created");
278  } else {
279  throw ProcessError("Vehicle cannot be created");
280  }
281  } else {
282  if (isPerson) {
283  WRITE_ERROR("Person cannot be created");
284  } else {
285  WRITE_ERROR("Vehicle cannot be created");
286  }
287  return nullptr;
288  }
289  }
290 }
291 
292 std::string
294  bool ok = true;
295  std::string id;
296  // first check if attrs contain an ID
297  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
298  id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
300  return id;
301  } else if (id.empty()) {
302  // add extra information for empty IDs
303  WRITE_ERROR("Invalid " + toString(element) + " id '" + id + "'.");
304  } else {
305  WRITE_ERROR("Invalid " + toString(element) + " id '" + id + "'. Contains invalid characters.");
306  }
307  } else {
308  WRITE_ERROR("Attribute '" + toString(SUMO_ATTR_ID) + "' is missing in definition of " + toString(element));
309  }
310  // return empty (invalid) ID
311  return "";
312 }
313 
314 
315 void
316 SUMOVehicleParserHelper::parseCommonAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, SUMOVehicleParameter* ret, std::string element) {
317  //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
318  bool ok = true;
319  bool abortCreation = true;
320  // parse route information
321  if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
322  ret->parametersSet |= VEHPARS_ROUTE_SET; // !!! needed?
323  ret->routeid = attrs.get<std::string>(SUMO_ATTR_ROUTE, ret->id.c_str(), ok);
324  }
325  // parse type information
326  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
327  ret->parametersSet |= VEHPARS_VTYPE_SET; // !!! needed?
328  ret->vtypeid = attrs.get<std::string>(SUMO_ATTR_TYPE, ret->id.c_str(), ok);
329  }
330  // parse line information
331  if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
332  ret->parametersSet |= VEHPARS_LINE_SET; // !!! needed?
333  ret->line = attrs.get<std::string>(SUMO_ATTR_LINE, ret->id.c_str(), ok);
334  }
335  // parse zone information
336  if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ)) {
338  ret->fromTaz = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, ret->id.c_str(), ok);
339  }
340  if (attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
342  ret->toTaz = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, ret->id.c_str(), ok);
343  }
344  // parse reroute information
345  if (attrs.getOpt<bool>(SUMO_ATTR_REROUTE, nullptr, ok, false)) {
347  }
348 
349  std::string error;
350  // parse depart lane information
351  if (attrs.hasAttribute(SUMO_ATTR_DEPARTLANE)) {
352  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTLANE, ret->id.c_str(), ok);
353  int lane;
355  if (SUMOVehicleParameter::parseDepartLane(helper, element, ret->id, lane, dld, error)) {
357  ret->departLane = lane;
358  ret->departLaneProcedure = dld;
359  } else {
360  handleError(hardFail, abortCreation, error);
361  }
362  }
363  // parse depart position information
364  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
365  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS, ret->id.c_str(), ok);
366  double pos;
368  if (SUMOVehicleParameter::parseDepartPos(helper, element, ret->id, pos, dpd, error)) {
370  ret->departPos = pos;
371  ret->departPosProcedure = dpd;
372  } else {
373  handleError(hardFail, abortCreation, error);
374  }
375  }
376  // parse lateral depart position information
378  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS_LAT, ret->id.c_str(), ok);
379  double pos;
381  if (SUMOVehicleParameter::parseDepartPosLat(helper, element, ret->id, pos, dpd, error)) {
383  ret->departPosLat = pos;
384  ret->departPosLatProcedure = dpd;
385  } else {
386  handleError(hardFail, abortCreation, error);
387  }
388  }
389  // parse depart speed information
390  if (attrs.hasAttribute(SUMO_ATTR_DEPARTSPEED)) {
391  std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTSPEED, ret->id.c_str(), ok);
392  double speed;
394  if (SUMOVehicleParameter::parseDepartSpeed(helper, element, ret->id, speed, dsd, error)) {
396  ret->departSpeed = speed;
397  ret->departSpeedProcedure = dsd;
398  } else {
399  handleError(hardFail, abortCreation, error);
400  }
401  }
402  // parse arrival lane information
403  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALLANE)) {
404  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALLANE, ret->id.c_str(), ok);
405  int lane;
407  if (SUMOVehicleParameter::parseArrivalLane(helper, element, ret->id, lane, ald, error)) {
409  ret->arrivalLane = lane;
410  ret->arrivalLaneProcedure = ald;
411  } else {
412  handleError(hardFail, abortCreation, error);
413  }
414  }
415  // parse arrival position information
416  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
417  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, ret->id.c_str(), ok);
418  double pos;
420  if (SUMOVehicleParameter::parseArrivalPos(helper, element, ret->id, pos, apd, error)) {
422  ret->arrivalPos = pos;
423  ret->arrivalPosProcedure = apd;
424  } else {
425  handleError(hardFail, abortCreation, error);
426  }
427  }
428  // parse lateral arrival position information
430  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS_LAT, ret->id.c_str(), ok);
431  double pos;
433  if (SUMOVehicleParameter::parseArrivalPosLat(helper, element, ret->id, pos, apd, error)) {
435  ret->arrivalPosLat = pos;
436  ret->arrivalPosLatProcedure = apd;
437  } else {
438  handleError(hardFail, abortCreation, error);
439  }
440  }
441  // parse arrival speed information
443  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALSPEED, ret->id.c_str(), ok);
444  double speed;
446  if (SUMOVehicleParameter::parseArrivalSpeed(helper, element, ret->id, speed, asd, error)) {
448  ret->arrivalSpeed = speed;
449  ret->arrivalSpeedProcedure = asd;
450  } else {
451  handleError(hardFail, abortCreation, error);
452  }
453  }
454  // parse color
455  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
457  ret->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, ret->id.c_str(), ok);
458  } else {
460  }
461  // parse person number
463  int personNumber = attrs.get<int>(SUMO_ATTR_PERSON_NUMBER, ret->id.c_str(), ok);
464  if (personNumber >= 0) {
466  ret->personNumber = personNumber;
467  } else {
468  handleError(hardFail, abortCreation, toString(SUMO_ATTR_PERSON_NUMBER) + " cannot be negative");
469  }
470  }
471  // parse container number
473  int containerNumber = attrs.get<int>(SUMO_ATTR_CONTAINER_NUMBER, ret->id.c_str(), ok);
474  if (containerNumber >= 0) {
476  ret->containerNumber = containerNumber;
477  } else {
478  handleError(hardFail, abortCreation, toString(SUMO_ATTR_PERSON_NUMBER) + " cannot be negative");
479  }
480  }
481  /*/ parse via
482  if (attrs.hasAttribute(SUMO_ATTR_VIA)) {
483  ret->setParameter |= VEHPARS_VIA_SET;
484  SUMOSAXAttributes::parseStringVector(attrs.get<std::string>(SUMO_ATTR_VIA, ret->id.c_str(), ok), ret->via);
485  }
486  */
487 }
488 
489 
491 SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file) {
492  bool abortCreation = true;
493  // first obtain ID
494  std::string id = parseID(attrs, SUMO_TAG_VTYPE);
495  // check if ID is valid
496  if (!id.empty()) {
498  if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
499  vClass = parseVehicleClass(attrs, id);
500  }
501  SUMOVTypeParameter* vtype = new SUMOVTypeParameter(id, vClass);
502  if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
504  }
505  if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
506  bool ok = true;
507  double length = attrs.get<double>(SUMO_ATTR_LENGTH, vtype->id.c_str(), ok);
508  if (ok) {
509  if (length <= 0) {
510  handleError(hardFail, abortCreation, toString(SUMO_ATTR_LENGTH) + " must be greater than 0");
511  } else {
512  vtype->length = length;
514  }
515  }
516  }
517  if (attrs.hasAttribute(SUMO_ATTR_MINGAP)) {
518  bool ok = true;
519  double minGap = attrs.get<double>(SUMO_ATTR_MINGAP, vtype->id.c_str(), ok);
520  if (ok) {
521  if (minGap < 0) {
522  handleError(hardFail, abortCreation, toString(SUMO_ATTR_MINGAP) + " must be equal or greater than 0");
523  } else {
524  vtype->minGap = minGap;
526  }
527  }
528  }
529  if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
530  bool ok = true;
531  double maxSpeed = attrs.get<double>(SUMO_ATTR_MAXSPEED, vtype->id.c_str(), ok);
532  if (ok) {
533  if (maxSpeed <= 0) {
534  handleError(hardFail, abortCreation, toString(SUMO_ATTR_MAXSPEED) + " must be greater than 0");
535  } else {
536  vtype->maxSpeed = maxSpeed;
538  }
539  }
540  }
541  if (attrs.hasAttribute(SUMO_ATTR_SPEEDFACTOR)) {
542  bool ok = true;
543  vtype->speedFactor.parse(attrs.get<std::string>(SUMO_ATTR_SPEEDFACTOR, vtype->id.c_str(), ok), hardFail);
544  if (ok) {
546  }
547  }
548  if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
549  bool ok = true;
550  double speedDev = attrs.get<double>(SUMO_ATTR_SPEEDDEV, vtype->id.c_str(), ok);
551  if (ok) {
552  if (speedDev < 0) {
553  handleError(hardFail, abortCreation, toString(SUMO_ATTR_SPEEDDEV) + " must be equal or greater than 0");
554  } else {
555  vtype->speedFactor.getParameter()[1] = speedDev;
557  }
558  }
559  }
560  // validate speed distribution
561  std::string error;
562  if (!vtype->speedFactor.isValid(error)) {
563  handleError(hardFail, abortCreation, "Invalid speed distribution when parsing vType '" + vtype->id + "' (" + error + ")");
564  }
566  bool ok = true;
567  double actionStepLengthSecs = attrs.get<double>(SUMO_ATTR_ACTIONSTEPLENGTH, vtype->id.c_str(), ok);
568  // processActionStepLength(...) function includes warnings
569  vtype->actionStepLength = processActionStepLength(actionStepLengthSecs);
571  }
573  bool ok = true;
574  bool hasDriverState = attrs.get<bool>(SUMO_ATTR_HASDRIVERSTATE, vtype->id.c_str(), ok);
575  if (ok) {
576  vtype->hasDriverState = hasDriverState;
578  }
579  }
581  bool ok = true;
582  std::string parsedEmissionClass = attrs.getOpt<std::string>(SUMO_ATTR_EMISSIONCLASS, id.c_str(), ok, "");
583  // check if emission class is correct
584  try {
585  vtype->emissionClass = PollutantsInterface::getClassByName(parsedEmissionClass);
587  } catch (...) {
588  if (hardFail) {
589  throw InvalidArgument(toString(SUMO_ATTR_EMISSIONCLASS) + " with name '" + parsedEmissionClass + "' doesn't exist.");
590  } else {
591  WRITE_ERROR(toString(SUMO_ATTR_EMISSIONCLASS) + " with name '" + parsedEmissionClass + "' doesn't exist.");
592  }
593  }
594  }
595  if (attrs.hasAttribute(SUMO_ATTR_IMPATIENCE)) {
596  // allow empty attribute because .sbx saves this only as float
597  bool okString;
598  bool okDouble;
599  if (attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vtype->id.c_str(), okString, false) == "off") {
600  vtype->impatience = -std::numeric_limits<double>::max();
601  } else {
602  double impatience = attrs.get<double>(SUMO_ATTR_IMPATIENCE, vtype->id.c_str(), okDouble);
603  if (okDouble) {
604  vtype->impatience = impatience;
606  }
607  }
608  }
609  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
610  bool ok = true;
611  double width = attrs.get<double>(SUMO_ATTR_WIDTH, vtype->id.c_str(), ok);
612  if (ok) {
613  if (width <= 0) {
614  handleError(hardFail, abortCreation, toString(SUMO_ATTR_WIDTH) + " must be greater than 0");
615  } else {
616  vtype->width = width;
618  }
619  }
620  }
621  if (attrs.hasAttribute(SUMO_ATTR_HEIGHT)) {
622  bool ok = true;
623  double height = attrs.get<double>(SUMO_ATTR_HEIGHT, vtype->id.c_str(), ok);
624  if (ok) {
625  if (height < 0) {
626  handleError(hardFail, abortCreation, toString(SUMO_ATTR_HEIGHT) + " must be equal or greater than 0");
627  } else {
628  vtype->height = height;
630  }
631  }
632  }
633  if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
634  vtype->shape = parseGuiShape(attrs, vtype->id);
635  if (vtype->shape != SVS_UNKNOWN) {
637  }
638  }
639  if (attrs.hasAttribute(SUMO_ATTR_OSGFILE)) {
640  bool ok = true;
641  std::string osgFile = attrs.get<std::string>(SUMO_ATTR_OSGFILE, vtype->id.c_str(), ok);
642  if (ok) {
643  vtype->osgFile = osgFile;
645  }
646  }
647  if (attrs.hasAttribute(SUMO_ATTR_IMGFILE)) {
648  bool ok = true;
649  std::string imgFile = attrs.get<std::string>(SUMO_ATTR_IMGFILE, vtype->id.c_str(), ok);
650  if (ok) {
651  // check relative path
652  if ((imgFile != "") && !FileHelpers::isAbsolute(imgFile)) {
653  imgFile = FileHelpers::getConfigurationRelative(file, imgFile);
654  }
655  vtype->imgFile = imgFile;
657  }
658  }
659  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
660  bool ok = true;
661  RGBColor color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, vtype->id.c_str(), ok);
662  if (ok) {
663  vtype->color = color;
665  }
666  } else {
667  vtype->color = RGBColor::YELLOW;
668  }
669  if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
670  bool ok = true;
671  double defaultProbability = attrs.get<double>(SUMO_ATTR_PROB, vtype->id.c_str(), ok);
672  if (ok) {
673  if (defaultProbability < 0) {
674  handleError(hardFail, abortCreation, toString(SUMO_ATTR_PROB) + " must be equal or greater than 0");
675  } else {
676  vtype->defaultProbability = defaultProbability;
678  }
679  }
680  }
682  bool ok = true;
683  std::string lcmS = attrs.get<std::string>(SUMO_ATTR_LANE_CHANGE_MODEL, vtype->id.c_str(), ok);
684  if (lcmS == "JE2013") {
685  WRITE_WARNING("Lane change model 'JE2013' is deprecated. Using default model instead.");
686  lcmS = "default";
687  }
688  if (SUMOXMLDefinitions::LaneChangeModels.hasString(lcmS)) {
691  } else {
692  handleError(hardFail, abortCreation, "Unknown lane change model '" + lcmS + "' when parsing vType '" + vtype->id + "'");
693  }
694  }
696  bool ok = true;
697  const std::string cfmValue = attrs.get<std::string>(SUMO_ATTR_CAR_FOLLOW_MODEL, vtype->id.c_str(), ok);
698  if (ok && SUMOXMLDefinitions::CarFollowModels.hasString(cfmValue)) {
701  } else {
702  handleError(hardFail, abortCreation, "Unknown car following model '" + cfmValue + "' when parsing vType '" + vtype->id + "'");
703  }
704  }
706  bool ok = true;
707  int personCapacity = attrs.get<int>(SUMO_ATTR_PERSON_CAPACITY, vtype->id.c_str(), ok);
708  if (ok) {
709  if (personCapacity < 0) {
710  handleError(hardFail, abortCreation, toString(SUMO_ATTR_PERSON_CAPACITY) + " must be equal or greater than 0");
711  } else {
712  vtype->personCapacity = personCapacity;
714  }
715  }
716  }
718  bool ok = true;
719  int containerCapacity = attrs.get<int>(SUMO_ATTR_CONTAINER_CAPACITY, vtype->id.c_str(), ok);
720  if (ok) {
721  if (containerCapacity < 0) {
722  handleError(hardFail, abortCreation, toString(SUMO_ATTR_CONTAINER_CAPACITY) + " must be equal or greater than 0");
723  } else {
724  vtype->containerCapacity = containerCapacity;
726  }
727  }
728  }
730  bool ok = true;
731  SUMOTime boardingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_BOARDING_DURATION, vtype->id.c_str(), ok);
732  if (ok) {
733  if (boardingDuration < 0) {
734  handleError(hardFail, abortCreation, toString(SUMO_ATTR_BOARDING_DURATION) + " must be equal or greater than 0");
735  } else {
736  vtype->boardingDuration = boardingDuration;
738  }
739  }
740  }
742  bool ok = true;
743  SUMOTime loadingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_LOADING_DURATION, vtype->id.c_str(), ok);
744  if (ok) {
745  if (loadingDuration < 0) {
746  handleError(hardFail, abortCreation, toString(SUMO_ATTR_LOADING_DURATION) + " must be equal or greater than 0");
747  } else {
748  vtype->loadingDuration = loadingDuration;
750  }
751  }
752  }
754  bool ok = true;
755  double maxSpeedLat = attrs.get<double>(SUMO_ATTR_MAXSPEED_LAT, vtype->id.c_str(), ok);
756  if (ok) {
757  if (maxSpeedLat <= 0) {
758  handleError(hardFail, abortCreation, toString(SUMO_ATTR_MAXSPEED_LAT) + " must be greater than 0");
759  } else {
760  vtype->maxSpeedLat = maxSpeedLat;
762  }
763  }
764  }
765  if (attrs.hasAttribute(SUMO_ATTR_MINGAP_LAT)) {
766  bool ok = true;
767  double minGapLat = attrs.get<double>(SUMO_ATTR_MINGAP_LAT, vtype->id.c_str(), ok);
768  if (ok) {
769  if (minGapLat < 0) {
770  handleError(hardFail, abortCreation, toString(SUMO_ATTR_MINGAP_LAT) + " must be equal or greater than 0");
771  } else {
772  vtype->minGapLat = minGapLat;
774  }
775  }
776  }
778  bool ok = true;
779  const std::string alignS = attrs.get<std::string>(SUMO_ATTR_LATALIGNMENT, vtype->id.c_str(), ok);
780  if (ok && SUMOXMLDefinitions::LateralAlignments.hasString(alignS)) {
783  } else {
784  handleError(hardFail, abortCreation, "Unknown lateral alignment '" + alignS + "' when parsing vType '" + vtype->id + "'");
785  }
786  }
787  // try to parse embedded vType
788  if (!parseVTypeEmbedded(*vtype, vtype->cfModel, attrs, hardFail, true)) {
789  handleError(hardFail, abortCreation, "Invalid parsing embedded VType");
790  }
791  // try to parse Lane Change Model params
792  if (!parseLCParams(*vtype, vtype->lcModel, attrs, hardFail)) {
793  handleError(hardFail, abortCreation, "Invalid Lane Change Model Parameters");
794  }
795  // try to Junction Model params
796  if (!parseJMParams(*vtype, attrs, hardFail)) {
797  handleError(hardFail, abortCreation, "Invalid Junction Model Parameters");
798  }
799  if (!abortCreation) {
800  delete vtype;
801  if (hardFail) {
802  throw ProcessError();
803  } else {
804  return nullptr;
805  }
806  }
807  return vtype;
808  } else {
809  if (hardFail) {
810  throw ProcessError("VType cannot be created");
811  } else {
812  return nullptr;
813  }
814  }
815 }
816 
817 
818 bool
819 SUMOVehicleParserHelper::parseVTypeEmbedded(SUMOVTypeParameter& into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool fromVType) {
820  const CFAttrMap& allowedCFM = getAllowedCFModelAttrs();
821  bool abortCreation = true;
822  CFAttrMap::const_iterator cf_it = allowedCFM.find(element);
823  // check if given CFM is allowed
824  if (cf_it == allowedCFM.end()) {
825  if (SUMOXMLDefinitions::Tags.has((int)element)) {
826  handleError(hardFail, abortCreation, "Unknown car following model " + toString(element) + " when parsing vType '" + into.id + "'");
827  } else {
828  handleError(hardFail, abortCreation, "Unknown car following model when parsing vType '" + into.id + "'");
829  }
830  return false;
831  }
832  // set car following model
833  if (!fromVType) {
834  into.cfModel = cf_it->first;
836  }
837  // set CFM values
838  bool ok = true;
839  for (const auto& it : cf_it->second) {
840  if (attrs.hasAttribute(it)) {
841  // first obtain CFM attribute in string format
842  std::string parsedCFMAttribute = attrs.get<std::string>(it, into.id.c_str(), ok);
843  // check if attribute is of type "train"
844  if (it == SUMO_ATTR_TRAIN_TYPE) {
845  // check if train value is valid
846  if (SUMOXMLDefinitions::TrainTypes.hasString(parsedCFMAttribute)) {
847  // add parsedCFMAttribute to cfParameter
848  into.cfParameter[it] = parsedCFMAttribute;
849  } else if (hardFail) {
850  throw ProcessError("Invalid train type '" + parsedCFMAttribute + "' used in Car-Following-Attribute " + toString(it));
851  } else {
852  WRITE_ERROR("Invalid train type '" + parsedCFMAttribute + "' used in Car-Following-Attribute " + toString(it));
853  }
854  } else if (it == SUMO_ATTR_CF_IDM_STEPPING) {
855  // declare a int in wich save CFM int attribute
856  int CFMIntAttribute = -1;
857  try {
858  // obtain CFM attribute in int format
859  CFMIntAttribute = StringUtils::toInt(parsedCFMAttribute);
860  } catch (...) {
861  ok = false;
862  if (hardFail) {
863  throw ProcessError("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to int");
864  } else {
865  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to int");
866  }
867  }
868  // now continue checking other properties
869  if (ok) {
870  if (CFMIntAttribute <= 0) {
871  ok = false;
872  if (hardFail) {
873  throw ProcessError("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
874  } else {
875  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
876  }
877  }
878  if (ok) {
879  // add parsedCFMAttribute to cfParameter
880  into.cfParameter[it] = parsedCFMAttribute;
881  }
882  }
883  } else {
884  // declare a double in wich save CFM float attribute
885  double CFMDoubleAttribute = -1;
886  try {
887  // obtain CFM attribute in double format
888  CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
889  } catch (...) {
890  ok = false;
891  if (hardFail) {
892  throw ProcessError("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to float");
893  } else {
894  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to float");
895  }
896  if (ok) {
897  // add parsedCFMAttribute to cfParameter
898  into.cfParameter[it] = parsedCFMAttribute;
899  }
900  }
901  // now continue checking other properties
902  if (ok) {
903  // check attributes of type "positiveFloatType" (> 0)
904  switch (it) {
905  case SUMO_ATTR_ACCEL:
906  case SUMO_ATTR_DECEL:
909  case SUMO_ATTR_TAU:
910  if (CFMDoubleAttribute <= 0) {
911  ok = false;
912  if (hardFail) {
913  throw ProcessError("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
914  } else {
915  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
916  }
917  }
918  default:
919  break;
920  }
921  // check attributes restricted to [0-1]
922  switch (it) {
923  case SUMO_ATTR_SIGMA:
924  if ((CFMDoubleAttribute < 0) || (CFMDoubleAttribute > 1)) {
925  ok = false;
926  if (hardFail) {
927  throw ProcessError("Invalid Car-Following-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
928  } else {
929  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
930  }
931  }
932  default:
933  break;
934  }
935  // special check for TAU attribute
936  if (it == SUMO_ATTR_TAU) {
937  // check tau in time format
938  if ((string2time(parsedCFMAttribute) < DELTA_T) && gSimulation) {
939  WRITE_WARNING("Value of tau=" + parsedCFMAttribute + " in car following model '" +
940  toString(into.cfModel) + "' lower than simulation step size may cause collisions");
941  }
942  }
943  if (ok) {
944  // add parsedCFMAttribute to cfParameter
945  into.cfParameter[it] = parsedCFMAttribute;
946  }
947  }
948  }
949  }
950  }
951  return ok;
952 }
953 
954 
957  // init on first use
958  if (allowedCFModelAttrs.size() == 0) {
959  std::set<SumoXMLAttr> kraussParams;
960  kraussParams.insert(SUMO_ATTR_ACCEL);
961  kraussParams.insert(SUMO_ATTR_DECEL);
962  kraussParams.insert(SUMO_ATTR_APPARENTDECEL);
963  kraussParams.insert(SUMO_ATTR_EMERGENCYDECEL);
964  kraussParams.insert(SUMO_ATTR_SIGMA);
965  kraussParams.insert(SUMO_ATTR_TAU);
966  allowedCFModelAttrs[SUMO_TAG_CF_KRAUSS] = kraussParams;
969  std::set<SumoXMLAttr> allParams(kraussParams);
970 
971  std::set<SumoXMLAttr> kraussXParams(kraussParams);
972  kraussXParams.insert(SUMO_ATTR_TMP1);
973  kraussXParams.insert(SUMO_ATTR_TMP2);
974  kraussXParams.insert(SUMO_ATTR_TMP3);
975  kraussXParams.insert(SUMO_ATTR_TMP4);
976  kraussXParams.insert(SUMO_ATTR_TMP5);
977  allowedCFModelAttrs[SUMO_TAG_CF_KRAUSSX] = kraussXParams;
978  allParams.insert(kraussXParams.begin(), kraussXParams.end());
979 
980  std::set<SumoXMLAttr> smartSKParams;
981  smartSKParams.insert(SUMO_ATTR_ACCEL);
982  smartSKParams.insert(SUMO_ATTR_DECEL);
983  smartSKParams.insert(SUMO_ATTR_EMERGENCYDECEL);
984  smartSKParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
985  smartSKParams.insert(SUMO_ATTR_SIGMA);
986  smartSKParams.insert(SUMO_ATTR_TAU);
987  smartSKParams.insert(SUMO_ATTR_TMP1);
988  smartSKParams.insert(SUMO_ATTR_TMP2);
989  smartSKParams.insert(SUMO_ATTR_TMP3);
990  smartSKParams.insert(SUMO_ATTR_TMP4);
991  smartSKParams.insert(SUMO_ATTR_TMP5);
992  allowedCFModelAttrs[SUMO_TAG_CF_SMART_SK] = smartSKParams;
993  allParams.insert(smartSKParams.begin(), smartSKParams.end());
994 
995  std::set<SumoXMLAttr> daniel1Params;
996  daniel1Params.insert(SUMO_ATTR_ACCEL);
997  daniel1Params.insert(SUMO_ATTR_DECEL);
998  daniel1Params.insert(SUMO_ATTR_EMERGENCYDECEL);
999  daniel1Params.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1000  daniel1Params.insert(SUMO_ATTR_SIGMA);
1001  daniel1Params.insert(SUMO_ATTR_TAU);
1002  daniel1Params.insert(SUMO_ATTR_TMP1);
1003  daniel1Params.insert(SUMO_ATTR_TMP2);
1004  daniel1Params.insert(SUMO_ATTR_TMP3);
1005  daniel1Params.insert(SUMO_ATTR_TMP4);
1006  daniel1Params.insert(SUMO_ATTR_TMP5);
1007  allowedCFModelAttrs[SUMO_TAG_CF_DANIEL1] = daniel1Params;
1008  allParams.insert(daniel1Params.begin(), daniel1Params.end());
1009 
1010  std::set<SumoXMLAttr> pwagParams;
1011  pwagParams.insert(SUMO_ATTR_ACCEL);
1012  pwagParams.insert(SUMO_ATTR_DECEL);
1013  pwagParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1014  pwagParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1015  pwagParams.insert(SUMO_ATTR_SIGMA);
1016  pwagParams.insert(SUMO_ATTR_TAU);
1017  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_TAULAST);
1018  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_APPROB);
1020  allParams.insert(pwagParams.begin(), pwagParams.end());
1021 
1022  std::set<SumoXMLAttr> idmParams;
1023  idmParams.insert(SUMO_ATTR_ACCEL);
1024  idmParams.insert(SUMO_ATTR_DECEL);
1025  idmParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1026  idmParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1027  idmParams.insert(SUMO_ATTR_TAU);
1028  idmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1029  idmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1030  allowedCFModelAttrs[SUMO_TAG_CF_IDM] = idmParams;
1031  allParams.insert(idmParams.begin(), idmParams.end());
1032 
1033  std::set<SumoXMLAttr> idmmParams;
1034  idmmParams.insert(SUMO_ATTR_ACCEL);
1035  idmmParams.insert(SUMO_ATTR_DECEL);
1036  idmmParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1037  idmmParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1038  idmmParams.insert(SUMO_ATTR_TAU);
1039  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_FACTOR);
1040  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_TIME);
1041  idmmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1042  allowedCFModelAttrs[SUMO_TAG_CF_IDMM] = idmmParams;
1043  allParams.insert(idmmParams.begin(), idmmParams.end());
1044 
1045  std::set<SumoXMLAttr> bkernerParams;
1046  bkernerParams.insert(SUMO_ATTR_ACCEL);
1047  bkernerParams.insert(SUMO_ATTR_DECEL);
1048  bkernerParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1049  bkernerParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1050  bkernerParams.insert(SUMO_ATTR_TAU);
1051  bkernerParams.insert(SUMO_ATTR_K);
1052  bkernerParams.insert(SUMO_ATTR_CF_KERNER_PHI);
1053  allowedCFModelAttrs[SUMO_TAG_CF_BKERNER] = bkernerParams;
1054  allParams.insert(bkernerParams.begin(), bkernerParams.end());
1055 
1056  std::set<SumoXMLAttr> wiedemannParams;
1057  wiedemannParams.insert(SUMO_ATTR_ACCEL);
1058  wiedemannParams.insert(SUMO_ATTR_DECEL);
1059  wiedemannParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1060  wiedemannParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1061  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_SECURITY);
1062  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_ESTIMATION);
1063  allowedCFModelAttrs[SUMO_TAG_CF_WIEDEMANN] = wiedemannParams;
1064  allParams.insert(wiedemannParams.begin(), wiedemannParams.end());
1065 
1066  std::set<SumoXMLAttr> w99Params;
1067  w99Params.insert(SUMO_ATTR_CF_W99_CC1);
1068  w99Params.insert(SUMO_ATTR_CF_W99_CC2);
1069  w99Params.insert(SUMO_ATTR_CF_W99_CC3);
1070  w99Params.insert(SUMO_ATTR_CF_W99_CC4);
1071  w99Params.insert(SUMO_ATTR_CF_W99_CC5);
1072  w99Params.insert(SUMO_ATTR_CF_W99_CC6);
1073  w99Params.insert(SUMO_ATTR_CF_W99_CC7);
1074  w99Params.insert(SUMO_ATTR_CF_W99_CC8);
1075  w99Params.insert(SUMO_ATTR_CF_W99_CC9);
1076  allowedCFModelAttrs[SUMO_TAG_CF_W99] = w99Params;
1077  allParams.insert(w99Params.begin(), w99Params.end());
1078 
1079  std::set<SumoXMLAttr> railParams;
1080  railParams.insert(SUMO_ATTR_TRAIN_TYPE);
1081  allowedCFModelAttrs[SUMO_TAG_CF_RAIL] = railParams;
1082  allParams.insert(railParams.begin(), railParams.end());
1083 
1084  std::set<SumoXMLAttr> ACCParams;
1085  ACCParams.insert(SUMO_ATTR_ACCEL);
1086  ACCParams.insert(SUMO_ATTR_DECEL);
1087  ACCParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1088  ACCParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1089  ACCParams.insert(SUMO_ATTR_TAU);
1090  ACCParams.insert(SUMO_ATTR_SC_GAIN);
1091  ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1092  ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1093  ACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1094  ACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1095  ACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1096  ACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1097  allowedCFModelAttrs[SUMO_TAG_CF_ACC] = ACCParams;
1098  allParams.insert(ACCParams.begin(), ACCParams.end());
1099 
1100  std::set<SumoXMLAttr> CACCParams;
1101  CACCParams.insert(SUMO_ATTR_ACCEL);
1102  CACCParams.insert(SUMO_ATTR_DECEL);
1103  CACCParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1104  CACCParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1105  CACCParams.insert(SUMO_ATTR_TAU);
1106  CACCParams.insert(SUMO_ATTR_SC_GAIN_CACC);
1107  CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_CACC);
1108  CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_DOT_CACC);
1109  CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_CACC);
1110  CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_DOT_CACC);
1111  CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_CACC);
1112  CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_DOT_CACC);
1113  CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1114  CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1115  CACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1116  CACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1117  CACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1118  CACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1119  CACCParams.insert(SUMO_ATTR_HEADWAY_TIME_CACC_TO_ACC);
1120  allowedCFModelAttrs[SUMO_TAG_CF_CACC] = CACCParams;
1121  allParams.insert(CACCParams.begin(), CACCParams.end());
1122 
1123  std::set<SumoXMLAttr> ccParams;
1124  ccParams.insert(SUMO_ATTR_ACCEL);
1125  ccParams.insert(SUMO_ATTR_DECEL);
1126  ccParams.insert(SUMO_ATTR_TAU);
1127  ccParams.insert(SUMO_ATTR_CF_CC_C1);
1128  ccParams.insert(SUMO_ATTR_CF_CC_CCDECEL);
1129  ccParams.insert(SUMO_ATTR_CF_CC_CONSTSPACING);
1130  ccParams.insert(SUMO_ATTR_CF_CC_KP);
1131  ccParams.insert(SUMO_ATTR_CF_CC_LAMBDA);
1132  ccParams.insert(SUMO_ATTR_CF_CC_OMEGAN);
1133  ccParams.insert(SUMO_ATTR_CF_CC_TAU);
1134  ccParams.insert(SUMO_ATTR_CF_CC_XI);
1135  ccParams.insert(SUMO_ATTR_CF_CC_LANES_COUNT);
1136  ccParams.insert(SUMO_ATTR_CF_CC_CCACCEL);
1137  ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KP);
1138  ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KD);
1139  ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_H);
1140  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KA);
1141  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KV);
1142  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KP);
1143  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_D);
1144  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_H);
1145  allowedCFModelAttrs[SUMO_TAG_CF_CC] = ccParams;
1146  allParams.insert(ccParams.begin(), ccParams.end());
1147 
1149  }
1150  return allowedCFModelAttrs;
1151 }
1152 
1153 
1154 bool
1156  if (allowedLCModelAttrs.size() == 0) {
1157  // init static map
1158  std::set<SumoXMLAttr> lc2013Params;
1159  lc2013Params.insert(SUMO_ATTR_LCA_STRATEGIC_PARAM);
1160  lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_PARAM);
1161  lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_PARAM);
1162  lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_PARAM);
1163  lc2013Params.insert(SUMO_ATTR_LCA_OPPOSITE_PARAM);
1164  lc2013Params.insert(SUMO_ATTR_LCA_LOOKAHEADLEFT);
1165  lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAINRIGHT);
1166  lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING);
1167  lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR);
1168  lc2013Params.insert(SUMO_ATTR_LCA_ASSERTIVE);
1169  lc2013Params.insert(SUMO_ATTR_LCA_OVERTAKE_RIGHT);
1170  lc2013Params.insert(SUMO_ATTR_LCA_EXPERIMENTAL1);
1171  allowedLCModelAttrs[LCM_LC2013] = lc2013Params;
1172 
1173  std::set<SumoXMLAttr> sl2015Params = lc2013Params;
1174  sl2015Params.insert(SUMO_ATTR_LCA_PUSHY);
1175  sl2015Params.insert(SUMO_ATTR_LCA_PUSHYGAP);
1176  sl2015Params.insert(SUMO_ATTR_LCA_SUBLANE_PARAM);
1177  sl2015Params.insert(SUMO_ATTR_LCA_IMPATIENCE);
1178  sl2015Params.insert(SUMO_ATTR_LCA_TIME_TO_IMPATIENCE);
1179  sl2015Params.insert(SUMO_ATTR_LCA_ACCEL_LAT);
1180  sl2015Params.insert(SUMO_ATTR_LCA_TURN_ALIGNMENT_DISTANCE);
1181  allowedLCModelAttrs[LCM_SL2015] = sl2015Params;
1182 
1183  std::set<SumoXMLAttr> noParams;
1184  allowedLCModelAttrs[LCM_DK2008] = noParams;
1185 
1186  // default model may be either LC2013 or SL2015
1187  // we allow both sets (sl2015 is a superset of lc2013Params)
1188  allowedLCModelAttrs[LCM_DEFAULT] = sl2015Params;
1189  }
1190  bool ok = true;
1191  std::set<SumoXMLAttr> allowed = allowedLCModelAttrs[model];
1192  for (const auto& it : allowed) {
1193  if (attrs.hasAttribute(it)) {
1194  // first obtain CFM attribute in string format
1195  std::string parsedLCMAttribute = attrs.get<std::string>(it, into.id.c_str(), ok);
1196  // declare a double in wich save CFM attribute
1197  double LCMAttribute = -1;
1198  try {
1199  // obtain CFM attribute in double format
1200  LCMAttribute = StringUtils::toDouble(parsedLCMAttribute);
1201  } catch (...) {
1202  ok = false;
1203  if (hardFail) {
1204  throw ProcessError("Invalid Lane-Change-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1205  } else {
1206  WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1207  }
1208  }
1209  // now continue checking other properties
1210  if (ok) {
1211  // check attributes of type "nonNegativeFloatType" (>= 0)
1212  switch (it) {
1222  if (LCMAttribute < 0) {
1223  ok = false;
1224  if (hardFail) {
1225  throw ProcessError("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1226  } else {
1227  WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1228  }
1229  }
1230  default:
1231  break;
1232  }
1233  // check attributes of type "positiveFloatType" (> 0)
1234  switch (it) {
1236  if (LCMAttribute <= 0) {
1237  ok = false;
1238  if (hardFail) {
1239  throw ProcessError("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be greater than 0");
1240  } else {
1241  WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be greater than 0");
1242  }
1243  }
1244  default:
1245  break;
1246  }
1247  if (ok) {
1248  // add parsedLCMAttribute to cfParameter
1249  into.lcParameter[it] = parsedLCMAttribute;
1250  }
1251  }
1252  }
1253  }
1254  return ok;
1255 }
1256 
1257 
1258 bool
1260  if (allowedJMAttrs.size() == 0) {
1261  // init static set (there is only one model)
1271  }
1272  bool ok = true;
1273  for (const auto& it : allowedJMAttrs) {
1274  if (attrs.hasAttribute(it)) {
1275  // first obtain CFM attribute in string format
1276  std::string parsedJMAttribute = attrs.get<std::string>(it, into.id.c_str(), ok);
1277  // declare a double in wich save CFM attribute
1278  double JMAttribute = -1;
1279  try {
1280  // obtain CFM attribute in double format
1281  JMAttribute = StringUtils::toDouble(parsedJMAttribute);
1282  } catch (...) {
1283  ok = false;
1284  if (hardFail) {
1285  throw ProcessError("Invalid Junction-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1286  } else {
1287  WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1288  }
1289  }
1290  // now continue checking other properties (-1 is the default value)
1291  if (ok && (JMAttribute != -1)) {
1292  // special case for sigma minor
1293  if (it == SUMO_ATTR_JM_SIGMA_MINOR) {
1294  // check attributes sigma minor
1295  if ((JMAttribute < 0) || (JMAttribute > 1)) {
1296  ok = false;
1297  if (hardFail) {
1298  throw ProcessError("Invalid Junction-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
1299  } else {
1300  WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
1301  }
1302  }
1303  } else {
1304  // check attributes of type "nonNegativeFloatType" (>= 0)
1305  if (JMAttribute < 0) {
1306  ok = false;
1307  if (hardFail) {
1308  throw ProcessError("Invalid Junction-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1309  } else {
1310  WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1311  }
1312  }
1313  }
1314  if (ok) {
1315  // add parsedJMAttribute to cfParameter
1316  into.jmParameter[it] = parsedJMAttribute;
1317  }
1318  }
1319  }
1320  }
1321  return ok;
1322 }
1323 
1324 
1327  SUMOVehicleClass vclass = SVC_IGNORING;
1328  try {
1329  bool ok = true;
1330  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_VCLASS, id.c_str(), ok, "");
1331  if (vclassS == "") {
1332  return vclass;
1333  }
1334  const SUMOVehicleClass result = getVehicleClassID(vclassS);
1335  const std::string& realName = SumoVehicleClassStrings.getString(result);
1336  if (realName != vclassS) {
1337  WRITE_WARNING("The vehicle class '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1338  }
1339  return result;
1340  } catch (...) {
1341  WRITE_ERROR("The class for " + attrs.getObjectType() + " '" + id + "' is not known.");
1342  }
1343  return vclass;
1344 }
1345 
1346 
1348 SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id) {
1349  bool ok = true;
1350  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_GUISHAPE, id.c_str(), ok, "");
1351  if (SumoVehicleShapeStrings.hasString(vclassS)) {
1352  const SUMOVehicleShape result = SumoVehicleShapeStrings.get(vclassS);
1353  const std::string& realName = SumoVehicleShapeStrings.getString(result);
1354  if (realName != vclassS) {
1355  WRITE_WARNING("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1356  }
1357  return result;
1358  } else {
1359  WRITE_ERROR("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
1360  return SVS_UNKNOWN;
1361  }
1362 }
1363 
1364 
1365 double
1366 SUMOVehicleParserHelper::parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng) {
1367  double result;
1368  std::string error;
1369  ArrivalPosDefinition proc;
1370  // only supports 'random' and 'max'
1371  if (!SUMOVehicleParameter::parseArrivalPos(val, toString(SUMO_TAG_WALK), id, result, proc, error)) {
1372  if (hardFail) {
1373  throw ProcessError(error);
1374  } else {
1375  WRITE_ERROR(error);
1376  }
1377  }
1378  if (proc == ARRIVAL_POS_RANDOM) {
1379  result = RandHelper::rand(maxPos, rng);
1380  } else if (proc == ARRIVAL_POS_CENTER) {
1381  result = maxPos / 2.;
1382  } else if (proc == ARRIVAL_POS_MAX) {
1383  result = maxPos;
1384  }
1385  return SUMOVehicleParameter::interpretEdgePos(result, maxPos, attr, id);
1386 }
1387 
1388 
1389 SUMOTime
1391  SUMOTime result = TIME2STEPS(given);
1392  if (result <= 0) {
1393  if (result < 0) {
1394  std::stringstream ss;
1395  ss << "The parameter action-step-length must be a non-negative multiple of the simulation step-length. Ignoring given value (="
1396  << STEPS2TIME(result) << " s.)";
1397  WRITE_WARNING(ss.str());
1398  }
1399  result = DELTA_T;
1400  } else if (result % DELTA_T != 0) {
1401  std::stringstream ss;
1402  result = (SUMOTime)(DELTA_T * floor(double(result) / double(DELTA_T)));
1403  result = MAX2(DELTA_T, result);
1404  if (fabs(given * 1000. - double(result)) > NUMERICAL_EPS) {
1405  ss << "The parameter action-step-length must be a non-negative multiple of the simulation step-length. Parsing given value ("
1406  << given << " s.) to the adjusted value "
1407  << STEPS2TIME(result) << " s.";
1408  WRITE_WARNING(ss.str());
1409  }
1410  }
1411  return result;
1412 }
1413 
1414 
1416 SUMOVehicleParserHelper::handleError(const bool hardFail, bool& abortCreation, const std::string& message) {
1417  if (hardFail) {
1418  abortCreation = true;
1419  throw ProcessError(message);
1420  } else {
1421  WRITE_ERROR(message);
1422  return nullptr;
1423  }
1424 }
1425 
1426 /****************************************************************************/
1427 
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
const int VTYPEPARS_MAXSPEED_SET
const int VEHPARS_TO_TAZ_SET
const int VTYPEPARS_MINGAP_SET
static StringBijection< SumoXMLTag > CarFollowModels
car following models
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
RGBColor color
The vehicle&#39;s color, TraCI may change this.
const int VTYPEPARS_LATALIGNMENT_SET
long long int SUMOTime
Definition: SUMOTime.h:35
const int VEHPARS_FORCE_REROUTE
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
description of a vehicle type
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
double impatience
The vehicle&#39;s impatience (willingness to obstruct others)
const int VTYPEPARS_HASDRIVERSTATE_SET
std::string vtypeid
The vehicle&#39;s type id.
static std::set< SumoXMLAttr > allowedJMAttrs
allowed attrs for the junction model
static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SVS_UNKNOWN, false)
a flow definitio nusing a from-to edges instead of a route (used by router)
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
virtual std::string getName(int attr) const =0
Converts the given attribute id into a man readable string.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
SUMOVehicleShape shape
This class&#39; shape.
Structure representing possible vehicle parameter.
const int VTYPEPARS_MINGAP_LAT_SET
a flow definition nusing a route instead of a from-to edges route (used in NETEDIT) ...
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
const int VEHPARS_PROB_SET
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
Parses a vehicle&#39;s attributes.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
int containerCapacity
The container capacity of the vehicle.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
const int VTYPEPARS_BOARDING_DURATION
static SUMOVehicleParameter * handleError(const bool hardFail, bool &abortCreation, const std::string &message)
handle error loading SUMOVehicleParameter
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
weights: time range begin
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
T MAX2(T a, T b)
Definition: StdDefs.h:80
static LCAttrMap allowedLCModelAttrs
allowed attrs for each known LC-model
std::vector< double > & getParameter()
Returns the parameters of this distribution.
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
const int VEHPARS_ARRIVALLANE_SET
const std::string & getObjectType() const
return the objecttype to which these attributes belong
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
const int VTYPEPARS_CAR_FOLLOW_MODEL
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
const int VTYPEPARS_OSGFILE_SET
DepartPosLatDefinition
ArrivalPosLatDefinition
Possible ways to choose the departure position.
const int VTYPEPARS_MAXSPEED_LAT_SET
const int VTYPEPARS_PROBABILITY_SET
const int VEHPARS_NUMBER_SET
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
double height
This class&#39; height.
std::string toTaz
The vehicle&#39;s destination zone (district)
const int VTYPEPARS_LANE_CHANGE_MODEL_SET
bool gSimulation
Definition: StdDefs.cpp:30
const int VEHPARS_ARRIVALSPEED_SET
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
double departSpeed
(optional) The initial speed of the vehicle
static const CFAttrMap & getAllowedCFModelAttrs()
returns allowed attrs for each known CF-model (init on first use)
LaneChangeModel
Half the road length.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
DepartLaneDefinition
Possible ways to choose a lane on depart.
double maxSpeed
The vehicle type&#39;s maximum speed [m/s].
double width
This class&#39; width.
SUMOTime boardingDuration
The time a person needs to board the vehicle.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
const int VTYPEPARS_ACTIONSTEPLENGTH_SET
std::string routeid
The vehicle&#39;s route id.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Encapsulated SAX-Attributes.
const int VEHPARS_DEPARTSPEED_SET
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
std::string osgFile
3D model file for this class
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:204
not defined
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Car-Following attributes map.
T get(const std::string &str) const
static SUMOVehicleParameter * parseFlowAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson=false)
Parses a flow&#39;s attributes.
std::string imgFile
Image file for this class.
static bool parseJMParams(SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses junction model attributes.
const int VEHPARS_DEPARTPOSLAT_SET
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
const int VEHPARS_ROUTE_SET
std::string fromTaz
The vehicle&#39;s origin zone (district)
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
const int VEHPARS_PERIOD_SET
const int VTYPEPARS_LOADING_DURATION
const int VTYPEPARS_CONTAINER_CAPACITY
const int VEHPARS_COLOR_SET
static std::string parseID(const SUMOSAXAttributes &attrs, const SumoXMLTag element)
parse ID
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons) ...
vehicle is a passenger car (a "normal" car)
const int VEHPARS_FROM_TAZ_SET
const int VEHPARS_END_SET
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::string line
The vehicle&#39;s line (mainly for public transport)
const int VTYPEPARS_SPEEDFACTOR_SET
double arrivalPos
(optional) The position the vehicle shall arrive on
static StringBijection< TrainType > TrainTypes
train types
DepartSpeedDefinition
Possible ways to choose the departure speed.
double maxSpeedLat
The vehicle type&#39;s maximum lateral speed [m/s].
int parametersSet
Information for the router which parameter were set.
const int VEHPARS_ARRIVALPOSLAT_SET
double departPosLat
(optional) The lateral position the vehicle shall depart from
const int VEHPARS_LINE_SET
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
const int VEHPARS_ARRIVALPOS_SET
int personCapacity
The person capacity of the vehicle.
bool hasDriverState
Whether vehicles of this type are equipped with a driver (i.e. MSDriverState))
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
double departPos
(optional) The position the vehicle shall depart from
double minGapLat
The vehicle type&#39;s minimum lateral gap [m].
static const RGBColor YELLOW
Definition: RGBColor.h:193
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, SUMOVehicleParameter *ret, std::string element)
Parses attributes common to vehicles and flows.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
Structure representing possible vehicle parameter.
#define SUMOTime_MAX
Definition: SUMOTime.h:36
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
const std::string DEFAULT_PEDTYPE_ID
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
weights: time range end
SubParams jmParameter
Junction-model parameter.
const int VTYPEPARS_IMGFILE_SET
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
SubParams cfParameter
Car-following parameter.
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
RGBColor color
The color.
SumoXMLTag tag
The vehicle tag.
const int VEHPARS_DEPARTLANE_SET
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int containerNumber
The static number of containers in the vehicle when it departs.
std::string id
The vehicle type&#39;s id.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
const int VTYPEPARS_PERSON_CAPACITY
static CFAttrMap allowedCFModelAttrs
allowed attrs for each known CF-model
LateralAlignment latAlignment
The vehicles desired lateral alignment.
SUMOTime actionStepLength
The vehicle type&#39;s default actionStepLength [ms], i.e. the interval between two control actions...
const int VEHPARS_VTYPE_SET
double minGap
This class&#39; free space in front of the vehicle itself.
description of a vehicle
const int VTYPEPARS_HEIGHT_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
#define NUMERICAL_EPS
Definition: config.h:145
const int VEHPARS_VPH_SET
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
a single trip definition (used by router)
const int VTYPEPARS_WIDTH_SET
static StringBijection< int > Tags
The names of SUMO-XML elements for use in netbuild.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_PERSON_NUMBER_SET
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
LaneChangeModel lcModel
The lane-change model to use.
const int VTYPEPARS_LENGTH_SET
DepartPosDefinition
Possible ways to choose the departure position.
const int VTYPEPARS_VEHICLECLASS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
A color information.
const int VTYPEPARS_EMISSIONCLASS_SET
The maximum arrival position is used.
static bool parseLCParams(SUMOVTypeParameter &into, LaneChangeModel model, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses lane change model attributes.
const int VTYPEPARS_COLOR_SET
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
const int VTYPEPARS_SHAPE_SET
double length
The physical vehicle length.
SubParams lcParameter
Lane-changing parameter.
static StringBijection< LaneChangeModel > LaneChangeModels
lane change models
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
SUMOEmissionClass emissionClass
The emission class of this vehicle.
vehicles ignoring classes
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
Lane-Change-Model attributes map.
bool isValid(std::string &error)
check whether the distribution is valid
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string id
The vehicle&#39;s id.
const int VTYPEPARS_IMPATIENCE_SET
static bool parseVTypeEmbedded(SUMOVTypeParameter &into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool fromVType=false)
Parses an element embedded in vtype definition.
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
The arrival position is chosen randomly.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.