61 std::string warning =
"";
105 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
109 if (sumoVehicle ==
nullptr) {
115 if (v ==
nullptr && shouldExist) {
121 const int compoundSize =
StoHelp::readCompound(inputStorage, -1,
"Stop needs a compound object description.");
122 if (compoundSize < 4 || compoundSize > 7) {
126 const std::string edgeID =
StoHelp::readTypedString(inputStorage,
"The first stop parameter must be the edge id given as a string.");
127 const double pos =
StoHelp::readTypedDouble(inputStorage,
"The second stop parameter must be the end position along the edge given as a double.");
128 const int laneIndex =
StoHelp::readTypedByte(inputStorage,
"The third stop parameter must be the lane index given as a byte.");
129 const double duration =
StoHelp::readTypedDouble(inputStorage,
"The fourth stop parameter must be the stopping duration given as a double.");
131 if (compoundSize >= 5) {
132 stopFlags =
StoHelp::readTypedByte(inputStorage,
"The fifth stop parameter must be a byte indicating its parking/triggered status.");
135 if (compoundSize >= 6) {
136 startPos =
StoHelp::readTypedDouble(inputStorage,
"The sixth stop parameter must be the start position along the edge given as a double.");
139 if (compoundSize >= 7) {
140 until =
StoHelp::readTypedDouble(inputStorage,
"The seventh stop parameter must be the minimum departure time given as a double.");
142 libsumo::Vehicle::setStop(
id, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
156 const int compoundSize =
StoHelp::readCompound(inputStorage, -1,
"Setting stop parameter needs a compound object description.");
157 if (compoundSize != 3 && compoundSize != 4) {
160 const int nextStopIndex =
StoHelp::readTypedInt(inputStorage,
"The first setStopParameter parameter must be the nextStopIndex given as an integer.");
161 const std::string param =
StoHelp::readTypedString(inputStorage,
"The second setStopParameter parameter must be the param given as a string.");
162 const std::string value =
StoHelp::readTypedString(inputStorage,
"The third setStopParameter parameter must be the value given as a string.");
164 if (compoundSize == 4) {
165 customParam =
StoHelp::readTypedByte(inputStorage,
"The fourth setStopParameter parameter must be the customParam flag given as a byte.");
167 libsumo::Vehicle::setStopParameter(
id, nextStopIndex, param, value, customParam != 0);
171 StoHelp::readCompound(inputStorage, 1,
"Reroute to stop needs a compound object description of 1 item.");
172 libsumo::Vehicle::rerouteParkingArea(
id,
StoHelp::readTypedString(inputStorage,
"The first reroute to stop parameter must be the parking area id given as a string."));
177 libsumo::Vehicle::resume(
id);
181 const int compoundSize =
StoHelp::readCompound(inputStorage, -1,
"Lane change needs a compound object description.");
182 if (compoundSize != 3 && compoundSize != 2) {
185 const int laneIndex =
StoHelp::readTypedByte(inputStorage,
"The first lane change parameter must be the lane index given as a byte.");
186 const double duration =
StoHelp::readTypedDouble(inputStorage,
"The second lane change parameter must be the duration given as a double.");
189 if (compoundSize == 3) {
190 relative =
StoHelp::readTypedByte(inputStorage,
"The third lane change parameter must be a Byte for defining whether a relative lane change should be applied.");
193 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
198 libsumo::Vehicle::changeLane(
id, laneIndex, duration);
200 libsumo::Vehicle::changeLaneRelative(
id, laneIndex, duration);
209 StoHelp::readCompound(inputStorage, 2,
"Slow down needs a compound object description of two items.");
210 const double newSpeed =
StoHelp::readTypedDouble(inputStorage,
"The first slow down parameter must be the speed given as a double.");
214 const double duration =
StoHelp::readTypedDouble(inputStorage,
"The second slow down parameter must be the duration given as a double.");
218 libsumo::Vehicle::slowDown(
id, newSpeed, duration);
222 libsumo::Vehicle::changeTarget(
id,
StoHelp::readTypedString(inputStorage,
"Change target requires a string containing the id of the new destination edge as parameter."));
226 const int compoundSize =
StoHelp::readCompound(inputStorage, -1,
"Create gap needs a compound object description.");
227 if (compoundSize != 5 && compoundSize != 6) {
230 const double newTimeHeadway =
StoHelp::readTypedDouble(inputStorage,
"The first create gap parameter must be the new desired time headway (tau) given as a double.");
231 double newSpaceHeadway =
StoHelp::readTypedDouble(inputStorage,
"The second create gap parameter must be the new desired space headway given as a double.");
232 const double duration =
StoHelp::readTypedDouble(inputStorage,
"The third create gap parameter must be the duration given as a double.");
233 const double changeRate =
StoHelp::readTypedDouble(inputStorage,
"The fourth create gap parameter must be the change rate given as a double.");
234 const double maxDecel =
StoHelp::readTypedDouble(inputStorage,
"The fifth create gap parameter must be the maximal braking rate given as a double.");
236 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
237 libsumo::Vehicle::deactivateGapControl(
id);
239 if (newTimeHeadway <= 0) {
240 if (newTimeHeadway != -1) {
244 if (newSpaceHeadway < 0) {
250 if (changeRate <= 0) {
256 std::string refVehID =
"";
257 if (compoundSize == 6) {
258 refVehID =
StoHelp::readTypedString(inputStorage,
"The sixth create gap parameter must be a reference vehicle's ID given as a string.");
260 libsumo::Vehicle::openGap(
id, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVehID);
265 libsumo::Vehicle::setType(
id,
StoHelp::readTypedString(inputStorage,
"The vehicle type id must be given as a string."));
269 libsumo::Vehicle::setRouteID(
id,
StoHelp::readTypedString(inputStorage,
"The route id must be given as a string."));
277 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"Setting travel time requires a compound object.");
280 double endTime = std::numeric_limits<double>::max();
282 if (parameterCount == 4) {
283 begTime =
StoHelp::readTypedDouble(inputStorage,
"Setting travel time using 4 parameters requires the begin time as first parameter.");
284 endTime =
StoHelp::readTypedDouble(inputStorage,
"Setting travel time using 4 parameters requires the end time as second parameter.");
285 edgeID =
StoHelp::readTypedString(inputStorage,
"Setting travel time using 4 parameters requires the referenced edge as third parameter.");
286 value =
StoHelp::readTypedDouble(inputStorage,
"Setting travel time using 4 parameters requires the travel time as double as fourth parameter.");
287 }
else if (parameterCount == 2) {
288 edgeID =
StoHelp::readTypedString(inputStorage,
"Setting travel time using 2 parameters requires the referenced edge as first parameter.");
289 value =
StoHelp::readTypedDouble(inputStorage,
"Setting travel time using 2 parameters requires the travel time as double as second parameter.");
290 }
else if (parameterCount == 1) {
291 edgeID =
StoHelp::readTypedString(inputStorage,
"Setting travel time using 1 parameter requires the referenced edge as first parameter.");
295 libsumo::Vehicle::setAdaptedTraveltime(
id, edgeID, value, begTime, endTime);
299 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"Setting travel time requires a compound object.");
302 double endTime = std::numeric_limits<double>::max();
304 if (parameterCount == 4) {
305 begTime =
StoHelp::readTypedDouble(inputStorage,
"Setting effort using 4 parameters requires the begin time as first parameter.");
306 endTime =
StoHelp::readTypedDouble(inputStorage,
"Setting effort using 4 parameters requires the end time as second parameter.");
307 edgeID =
StoHelp::readTypedString(inputStorage,
"Setting effort using 4 parameters requires the referenced edge as third parameter.");
308 value =
StoHelp::readTypedDouble(inputStorage,
"Setting effort using 4 parameters requires the effort as double as fourth parameter.");
309 }
else if (parameterCount == 2) {
310 edgeID =
StoHelp::readTypedString(inputStorage,
"Setting effort using 2 parameters requires the referenced edge as first parameter.");
311 value =
StoHelp::readTypedDouble(inputStorage,
"Setting effort using 2 parameters requires the effort as double as second parameter.");
312 }
else if (parameterCount == 1) {
313 edgeID =
StoHelp::readTypedString(inputStorage,
"Setting effort using 1 parameter requires the referenced edge as first parameter.");
317 libsumo::Vehicle::setEffort(
id, edgeID, value, begTime, endTime);
321 StoHelp::readCompound(inputStorage, 0,
"Rerouting by travel time requires an empty compound object.");
322 libsumo::Vehicle::rerouteTraveltime(
id,
false);
327 libsumo::Vehicle::rerouteEffort(
id);
331 libsumo::Vehicle::setSignals(
id,
StoHelp::readTypedInt(inputStorage,
"Setting signals requires an integer."));
334 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"Setting position requires a compound object.");
335 if (parameterCount < 2 || parameterCount > 3) {
338 const std::string laneID =
StoHelp::readTypedString(inputStorage,
"The first parameter for setting a position must be the lane ID given as a string.");
339 const double position =
StoHelp::readTypedDouble(inputStorage,
"The second parameter for setting a position must be the position given as a double.");
341 if (parameterCount == 3) {
342 reason =
StoHelp::readTypedInt(inputStorage,
"The third parameter for setting a position must be the reason given as an int.");
345 libsumo::Vehicle::moveTo(
id, laneID, position, reason);
349 libsumo::Vehicle::setImpatience(
id,
StoHelp::readTypedDouble(inputStorage,
"Setting impatience requires a double."));
358 const double accel =
StoHelp::readTypedDouble(inputStorage,
"Setting acceleration requires the acceleration as first parameter given as a double.");
359 const double duration =
StoHelp::readTypedDouble(inputStorage,
"Setting acceleration requires the duration as second parameter given as a double.");
363 libsumo::Vehicle::setAcceleration(
id, accel, duration);
367 double prevSpeed = 0;
372 const int parameterCount = inputStorage.
readInt();
373 if (parameterCount == 2) {
374 prevSpeed =
StoHelp::readTypedDouble(inputStorage,
"Setting previous speed using 2 parameters requires the previous speed as first parameter given as a double.");
375 prevAcceleration =
StoHelp::readTypedDouble(inputStorage,
"Setting previous speed using 2 parameters requires the previous acceleration as second parameter given as a double.");
376 }
else if (parameterCount == 1) {
377 prevSpeed =
StoHelp::readTypedDouble(inputStorage,
"Setting previous speed using 1 parameter requires the previous speed as first parameter given as a double.");
390 libsumo::Vehicle::setPreviousSpeed(
id, prevSpeed, prevAcceleration);
394 libsumo::Vehicle::setSpeedMode(
id,
StoHelp::readTypedInt(inputStorage,
"Setting speed mode requires an integer."));
397 libsumo::Vehicle::setLaneChangeMode(
id,
StoHelp::readTypedInt(inputStorage,
"Setting lane change mode requires an integer."));
400 libsumo::Vehicle::setRoutingMode(
id,
StoHelp::readTypedInt(inputStorage,
"Setting routing mode requires an integer."));
403 libsumo::Vehicle::setColor(
id,
StoHelp::readTypedColor(inputStorage,
"The color must be given using the according type."));
410 const int departCode =
StoHelp::readTypedInt(inputStorage,
"Third parameter (depart) requires an integer.");
413 depart =
"triggered";
415 depart =
"containerTriggered";
424 const double departPosCode =
StoHelp::readTypedDouble(inputStorage,
"Fourth parameter (position) requires a double.");
425 std::string departPos =
toString(departPosCode);
427 departPos =
"random";
429 departPos =
"random_free";
440 const double departSpeedCode =
StoHelp::readTypedDouble(inputStorage,
"Fifth parameter (speed) requires a double.");
441 std::string departSpeed =
toString(departSpeedCode);
443 departSpeed =
"random";
447 departSpeed =
"desired";
449 departSpeed =
"speedLimit";
451 departSpeed =
"last";
456 const int departLaneCode =
StoHelp::readTypedByte(inputStorage,
"Sixth parameter (lane) requires a byte.");
457 std::string departLane =
toString(departLaneCode);
459 departLane =
"random";
463 departLane =
"allowed";
467 departLane =
"first";
469 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed);
473 const int numElements =
StoHelp::readCompound(inputStorage, -1,
"Adding a fully specified vehicle needs fourteen to eighteen parameters.");
474 if (numElements < 14 || numElements > 18) {
480 const std::string departLane =
StoHelp::readTypedString(inputStorage,
"Fourth parameter (depart lane) requires a string.");
481 const std::string departPos =
StoHelp::readTypedString(inputStorage,
"Fifth parameter (depart position) requires a string.");
482 const std::string departSpeed =
StoHelp::readTypedString(inputStorage,
"Sixth parameter (depart speed) requires a string.");
483 const std::string arrivalLane =
StoHelp::readTypedString(inputStorage,
"Seventh parameter (arrival lane) requires a string.");
484 const std::string arrivalPos =
StoHelp::readTypedString(inputStorage,
"Eighth parameter (arrival position) requires a string.");
485 const std::string arrivalSpeed =
StoHelp::readTypedString(inputStorage,
"Ninth parameter (arrival speed) requires a string.");
486 const std::string fromTaz =
StoHelp::readTypedString(inputStorage,
"Tenth parameter (from taz) requires a string.");
489 const int personCapacity =
StoHelp::readTypedInt(inputStorage,
"13th parameter (person capacity) requires an int.");
490 const int personNumber =
StoHelp::readTypedInt(inputStorage,
"14th parameter (person number) requires an int.");
491 std::string departPosLat;
492 std::string arrivalPosLat;
493 double speedFactor = -1.;
494 std::string insertionChecks;
495 if (numElements >= 15) {
498 if (numElements >= 16) {
501 if (numElements >= 17) {
504 if (numElements >= 18) {
507 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
508 fromTaz, toTaz, line, personCapacity, personNumber,
509 departPosLat, arrivalPosLat, speedFactor, insertionChecks);
513 libsumo::Vehicle::remove(
id, (
char)
StoHelp::readTypedByte(inputStorage,
"Removing a vehicle requires a byte."));
517 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"MoveToXY vehicle requires a compound object.");
518 if (parameterCount < 5 || parameterCount > 7) {
521 const std::string edgeID =
StoHelp::readTypedString(inputStorage,
"The first parameter for moveToXY must be the edge ID given as a string.");
522 const int laneIndex =
StoHelp::readTypedInt(inputStorage,
"The second parameter for moveToXY must be lane given as an int.");
523 const double x =
StoHelp::readTypedDouble(inputStorage,
"The third parameter for moveToXY must be the x-position given as a double.");
524 const double y =
StoHelp::readTypedDouble(inputStorage,
"The fourth parameter for moveToXY must be the y-position given as a double.");
525 const double angle =
StoHelp::readTypedDouble(inputStorage,
"The fifth parameter for moveToXY must be the angle given as a double.");
526 int keepRouteFlag = 1;
527 if (parameterCount >= 6) {
528 keepRouteFlag =
StoHelp::readTypedByte(inputStorage,
"The sixth parameter for moveToXY must be the keepRouteFlag given as a byte.");
530 double matchThreshold = 100.;
531 if (parameterCount == 7) {
532 matchThreshold =
StoHelp::readTypedDouble(inputStorage,
"The seventh parameter for moveToXY must be the matchThreshold given as a double.");
534 libsumo::Vehicle::moveToXY(
id, edgeID, laneIndex, x, y, angle, keepRouteFlag, matchThreshold);
538 libsumo::Vehicle::setSpeedFactor(
id,
StoHelp::readTypedDouble(inputStorage,
"Setting speed factor requires a double."));
550 StoHelp::readCompound(inputStorage, 2,
"A compound object of size 2 is needed for setting a parameter.");
551 const std::string name =
StoHelp::readTypedString(inputStorage,
"The name of the parameter must be given as a string.");
552 const std::string value =
StoHelp::readTypedString(inputStorage,
"The value of the parameter must be given as a string.");
553 libsumo::Vehicle::setParameter(
id, name, value);
557 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"A compound object is needed for highlighting an object.");
558 if (parameterCount > 5) {
563 if (parameterCount > 0) {
564 col =
StoHelp::readTypedColor(inputStorage,
"The first parameter for highlighting must be the highlight color.");
567 if (parameterCount > 1) {
571 if (parameterCount > 2) {
574 double duration = -1;
575 if (parameterCount > 3) {
576 duration =
StoHelp::readTypedDouble(inputStorage,
"The fourth parameter for highlighting must be the highlight duration.");
579 if (parameterCount > 4) {
582 libsumo::Vehicle::highlight(
id, col, size, alphaMax, duration, type);
586 libsumo::Vehicle::dispatchTaxi(
id,
StoHelp::readTypedStringList(inputStorage,
"A dispatch command must be defined as a list of reservation ids."));
591 if (fabs(value) == std::numeric_limits<double>::infinity()) {
594 bool resetActionOffset = value >= 0.0;
595 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
599 libsumo::Vehicle::setLateralLanePosition(
id,
StoHelp::readTypedDouble(inputStorage,
"Setting lateral lane position requires a double."));
603 libsumo::Vehicle::updateBestLanes(
id);
608 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
611 libsumo::Vehicle::setMinGap(
id, value);
616 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
619 libsumo::Vehicle::setMinGapLat(
id, value);