Eclipse SUMO - Simulation of Urban MObility
libsumo/Vehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2012-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 /****************************************************************************/
19 // C++ Vehicle API
20 /****************************************************************************/
21 #include <config.h>
22 
23 #include <foreign/tcpip/storage.h>
24 #include <utils/geom/GeomHelper.h>
35 #include <microsim/MSStop.h>
36 #include <microsim/MSVehicle.h>
39 #include <microsim/MSVehicleType.h>
41 #include <microsim/MSNet.h>
42 #include <microsim/MSEdge.h>
43 #include <microsim/MSLane.h>
44 #include <microsim/MSParkingArea.h>
48 #include <mesosim/MEVehicle.h>
49 #include <libsumo/TraCIDefs.h>
50 #include <libsumo/TraCIConstants.h>
51 #include "Helper.h"
52 #include "Route.h"
53 #include "Polygon.h"
54 #include "Vehicle.h"
55 
56 #define CALL_MICRO_FUN(veh, fun, mesoResult) ((dynamic_cast<MSVehicle*>(veh) == nullptr ? (mesoResult) : dynamic_cast<MSVehicle*>(veh)->fun))
57 #define CALL_MESO_FUN(veh, fun, microResult) ((dynamic_cast<MEVehicle*>(veh) == nullptr ? (microResult) : dynamic_cast<MEVehicle*>(veh)->fun))
58 
59 // ===========================================================================
60 // debug defines
61 // ===========================================================================
62 //#define DEBUG_NEIGHBORS
63 //#define DEBUG_DYNAMIC_SHAPES
64 //#define DEBUG_MOVEXY
65 #define DEBUG_COND (veh->isSelected())
66 
67 
68 
69 namespace libsumo {
70 // ===========================================================================
71 // static member initializations
72 // ===========================================================================
73 SubscriptionResults Vehicle::mySubscriptionResults;
74 ContextSubscriptionResults Vehicle::myContextSubscriptionResults;
75 
76 
77 // ===========================================================================
78 // static member definitions
79 // ===========================================================================
80 bool
81 Vehicle::isVisible(const SUMOVehicle* veh) {
82  return veh->isOnRoad() || veh->isParking() || veh->wasRemoteControlled();
83 }
84 
85 
86 bool
87 Vehicle::isOnInit(const std::string& vehID) {
89  return sumoVehicle == nullptr || sumoVehicle->getLane() == nullptr;
90 }
91 
92 
93 std::vector<std::string>
94 Vehicle::getIDList() {
95  std::vector<std::string> ids;
97  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
98  if (isVisible((*i).second)) {
99  ids.push_back((*i).first);
100  }
101  }
102  return ids;
103 }
104 
105 int
106 Vehicle::getIDCount() {
107  return (int)getIDList().size();
108 }
109 
110 
111 double
112 Vehicle::getSpeed(const std::string& vehID) {
113  MSBaseVehicle* veh = Helper::getVehicle(vehID);
114  return isVisible(veh) ? veh->getSpeed() : INVALID_DOUBLE_VALUE;
115 }
116 
117 double
118 Vehicle::getLateralSpeed(const std::string& vehID) {
119  MSBaseVehicle* veh = Helper::getVehicle(vehID);
120  return isVisible(veh) ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSpeedLat(), 0) : INVALID_DOUBLE_VALUE;
121 }
122 
123 
124 double
125 Vehicle::getAcceleration(const std::string& vehID) {
126  MSBaseVehicle* veh = Helper::getVehicle(vehID);
127  return isVisible(veh) ? CALL_MICRO_FUN(veh, getAcceleration(), 0) : INVALID_DOUBLE_VALUE;
128 }
129 
130 
131 double
132 Vehicle::getSpeedWithoutTraCI(const std::string& vehID) {
133  MSBaseVehicle* veh = Helper::getVehicle(vehID);
134  return isVisible(veh) ? CALL_MICRO_FUN(veh, getSpeedWithoutTraciInfluence(), veh->getSpeed()) : INVALID_DOUBLE_VALUE;
135 }
136 
137 
138 TraCIPosition
139 Vehicle::getPosition(const std::string& vehID, const bool includeZ) {
140  MSBaseVehicle* veh = Helper::getVehicle(vehID);
141  if (isVisible(veh)) {
142  return Helper::makeTraCIPosition(veh->getPosition(), includeZ);
143  }
144  return TraCIPosition();
145 }
146 
147 
148 TraCIPosition
149 Vehicle::getPosition3D(const std::string& vehID) {
150  return getPosition(vehID, true);
151 }
152 
153 
154 double
155 Vehicle::getAngle(const std::string& vehID) {
156  MSBaseVehicle* veh = Helper::getVehicle(vehID);
157  return isVisible(veh) ? GeomHelper::naviDegree(veh->getAngle()) : INVALID_DOUBLE_VALUE;
158 }
159 
160 
161 double
162 Vehicle::getSlope(const std::string& vehID) {
163  MSBaseVehicle* veh = Helper::getVehicle(vehID);
164  return (veh->isOnRoad() || veh->isParking()) ? veh->getSlope() : INVALID_DOUBLE_VALUE;
165 }
166 
167 
168 std::string
169 Vehicle::getRoadID(const std::string& vehID) {
170  MSBaseVehicle* veh = Helper::getVehicle(vehID);
171  return isVisible(veh) ? CALL_MICRO_FUN(veh, getLane()->getEdge().getID(), veh->getEdge()->getID()) : "";
172 }
173 
174 
175 std::string
176 Vehicle::getLaneID(const std::string& vehID) {
177  MSBaseVehicle* veh = Helper::getVehicle(vehID);
178  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getID(), "") : "";
179 }
180 
181 
182 int
183 Vehicle::getLaneIndex(const std::string& vehID) {
184  MSBaseVehicle* veh = Helper::getVehicle(vehID);
185  if (veh->isOnRoad()) {
186  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
187  if (microVeh != nullptr) {
188  return microVeh->getLane()->getIndex();
189  } else {
190  MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
191  return mesoVeh->getQueIndex();
192  }
193  } else {
194  return INVALID_INT_VALUE;
195  }
196 }
197 
198 std::string
199 Vehicle::getSegmentID(const std::string& vehID) {
200  MSBaseVehicle* veh = Helper::getVehicle(vehID);
201  return veh->isOnRoad() ? CALL_MESO_FUN(veh, getSegment()->getID(), "") : "";
202 }
203 
204 int
205 Vehicle::getSegmentIndex(const std::string& vehID) {
206  MSBaseVehicle* veh = Helper::getVehicle(vehID);
207  return veh->isOnRoad() ? CALL_MESO_FUN(veh, getSegment()->getIndex(), INVALID_INT_VALUE) : INVALID_INT_VALUE;
208 }
209 
210 std::string
211 Vehicle::getTypeID(const std::string& vehID) {
212  return Helper::getVehicleType(vehID).getID();
213 }
214 
215 
216 std::string
217 Vehicle::getRouteID(const std::string& vehID) {
218  return Helper::getVehicle(vehID)->getRoute().getID();
219 }
220 
221 
222 double
223 Vehicle::getDeparture(const std::string& vehID) {
224  MSBaseVehicle* veh = Helper::getVehicle(vehID);
225  return veh->hasDeparted() ? STEPS2TIME(veh->getDeparture()) : INVALID_DOUBLE_VALUE;
226 }
227 
228 
229 double
230 Vehicle::getDepartDelay(const std::string& vehID) {
231  return STEPS2TIME(Helper::getVehicle(vehID)->getDepartDelay());
232 }
233 
234 
235 int
236 Vehicle::getRouteIndex(const std::string& vehID) {
237  MSBaseVehicle* veh = Helper::getVehicle(vehID);
238  return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
239 }
240 
241 
242 TraCIColor
243 Vehicle::getColor(const std::string& vehID) {
244  return Helper::makeTraCIColor(Helper::getVehicle(vehID)->getParameter().color);
245 }
246 
247 double
248 Vehicle::getLanePosition(const std::string& vehID) {
249  MSBaseVehicle* veh = Helper::getVehicle(vehID);
250  return (veh->isOnRoad() || veh->isParking()) ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
251 }
252 
253 double
254 Vehicle::getLateralLanePosition(const std::string& vehID) {
255  MSBaseVehicle* veh = Helper::getVehicle(vehID);
256  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLateralPositionOnLane(), 0) : INVALID_DOUBLE_VALUE;
257 }
258 
259 double
260 Vehicle::getCO2Emission(const std::string& vehID) {
261  MSBaseVehicle* veh = Helper::getVehicle(vehID);
262  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO2>() : INVALID_DOUBLE_VALUE;
263 }
264 
265 double
266 Vehicle::getCOEmission(const std::string& vehID) {
267  MSBaseVehicle* veh = Helper::getVehicle(vehID);
268  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO>() : INVALID_DOUBLE_VALUE;
269 }
270 
271 double
272 Vehicle::getHCEmission(const std::string& vehID) {
273  MSBaseVehicle* veh = Helper::getVehicle(vehID);
274  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::HC>() : INVALID_DOUBLE_VALUE;
275 }
276 
277 double
278 Vehicle::getPMxEmission(const std::string& vehID) {
279  MSBaseVehicle* veh = Helper::getVehicle(vehID);
280  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::PM_X>() : INVALID_DOUBLE_VALUE;
281 }
282 
283 double
284 Vehicle::getNOxEmission(const std::string& vehID) {
285  MSBaseVehicle* veh = Helper::getVehicle(vehID);
286  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::NO_X>() : INVALID_DOUBLE_VALUE;
287 }
288 
289 double
290 Vehicle::getFuelConsumption(const std::string& vehID) {
291  MSBaseVehicle* veh = Helper::getVehicle(vehID);
292  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::FUEL>() : INVALID_DOUBLE_VALUE;
293 }
294 
295 double
296 Vehicle::getNoiseEmission(const std::string& vehID) {
297  MSBaseVehicle* veh = Helper::getVehicle(vehID);
298  return isVisible(veh) ? veh->getHarmonoise_NoiseEmissions() : INVALID_DOUBLE_VALUE;
299 }
300 
301 double
302 Vehicle::getElectricityConsumption(const std::string& vehID) {
303  MSBaseVehicle* veh = Helper::getVehicle(vehID);
304  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::ELEC>() : INVALID_DOUBLE_VALUE;
305 }
306 
307 int
308 Vehicle::getPersonNumber(const std::string& vehID) {
309  return Helper::getVehicle(vehID)->getPersonNumber();
310 }
311 
312 int
313 Vehicle::getPersonCapacity(const std::string& vehID) {
315 }
316 
317 
318 double
319 Vehicle::getBoardingDuration(const std::string& vehID) {
320  return STEPS2TIME(Helper::getVehicleType(vehID).getLoadingDuration(true));
321 }
322 
323 
324 std::vector<std::string>
325 Vehicle::getPersonIDList(const std::string& vehID) {
326  return Helper::getVehicle(vehID)->getPersonIDList();
327 }
328 
329 std::pair<std::string, double>
330 Vehicle::getLeader(const std::string& vehID, double dist) {
331  MSBaseVehicle* veh = Helper::getVehicle(vehID);
332  if (veh->isOnRoad()) {
333  std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist);
334  const std::string leaderID = leaderInfo.first != nullptr ? leaderInfo.first->getID() : "";
335  double gap = leaderInfo.second;
336  if (leaderInfo.first != nullptr
337  && leaderInfo.first->getLane() != nullptr
338  && leaderInfo.first->getLane()->isInternal()
339  && veh->getLane() != nullptr
340  && (!veh->getLane()->isInternal()
341  || (veh->getLane()->getLinkCont().front()->getIndex() != leaderInfo.first->getLane()->getLinkCont().front()->getIndex()))) {
342  // leader is a linkLeader (see MSLink::getLeaderInfo)
343  // avoid internal gap values which may be negative (or -inf)
344  gap = MAX2(0.0, gap);
345  }
346  return std::make_pair(leaderID, gap);
347  } else {
348  return std::make_pair("", -1);
349  }
350 }
351 
352 
353 std::pair<std::string, double>
354 Vehicle::getFollower(const std::string& vehID, double dist) {
355  MSBaseVehicle* veh = Helper::getVehicle(vehID);
356  if (veh->isOnRoad()) {
357  std::pair<const MSVehicle* const, double> leaderInfo = veh->getFollower(dist);
358  return std::make_pair(
359  leaderInfo.first != nullptr ? leaderInfo.first->getID() : "",
360  leaderInfo.second);
361  } else {
362  return std::make_pair("", -1);
363  }
364 }
365 
366 
367 std::vector<TraCIJunctionFoe>
368 Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
369  std::vector<TraCIJunctionFoe> result;
370  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
371  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
372  if (veh == nullptr) {
373  WRITE_WARNING("getJunctionFoes not applicable for meso");
374  } else if (veh->isOnRoad()) {
375  if (dist == 0) {
376  dist = veh->getCarFollowModel().brakeGap(veh->getSpeed()) + veh->getVehicleType().getMinGap();
377  }
378  const std::vector<const MSLane*> internalLanes;
379  // distance to the end of the lane
380  double curDist = -veh->getPositionOnLane();
381  for (const MSLane* lane : veh->getUpcomingLanesUntil(dist)) {
382  curDist += lane->getLength();
383  if (lane->isInternal()) {
384  const MSLink* exitLink = lane->getLinkCont().front();
385  int foeIndex = 0;
386  const std::vector<MSLink::ConflictInfo>& conflicts = exitLink->getConflicts();
387  const MSJunctionLogic* logic = exitLink->getJunction()->getLogic();
388  for (const MSLane* foeLane : exitLink->getFoeLanes()) {
389  const MSLink::ConflictInfo& ci = conflicts[foeIndex];
391  continue;
392  }
393  const double distBehindCrossing = ci.lengthBehindCrossing;
394  const MSLink* foeExitLink = foeLane->getLinkCont().front();
395  const double distToCrossing = curDist - distBehindCrossing;
396  const double foeDistBehindCrossing = ci.getFoeLengthBehindCrossing(foeExitLink);
397  for (auto item : foeExitLink->getApproaching()) {
398  const SUMOVehicle* foe = item.first;
399  TraCIJunctionFoe jf;
400  jf.foeId = foe->getID();
401  jf.egoDist = distToCrossing;
402  // approach information is from the start of the previous step
403  // but the foe vehicle then moved within that steop
404  const double prevFoeDist = SPEED2DIST(MSGlobals::gSemiImplicitEulerUpdate
405  ? foe->getSpeed()
406  : (foe->getSpeed() + foe->getPreviousSpeed()) / 2);
407  jf.foeDist = item.second.dist - foeDistBehindCrossing - prevFoeDist;
408  jf.egoExitDist = jf.egoDist + ci.conflictSize;
409  jf.foeExitDist = jf.foeDist + ci.getFoeConflictSize(foeExitLink);
410  jf.egoLane = lane->getID();
411  jf.foeLane = foeLane->getID();
412  jf.egoResponse = logic->getResponseFor(exitLink->getIndex()).test(foeExitLink->getIndex());
413  jf.foeResponse = logic->getResponseFor(foeExitLink->getIndex()).test(exitLink->getIndex());
414  result.push_back(jf);
415  }
416  foeIndex++;
417  }
418  }
419  }
420  }
421  return result;
422 }
423 
424 
425 double
426 Vehicle::getWaitingTime(const std::string& vehID) {
427  return STEPS2TIME(Helper::getVehicle(vehID)->getWaitingTime());
428 }
429 
430 
431 double
432 Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
433  MSBaseVehicle* veh = Helper::getVehicle(vehID);
434  return CALL_MICRO_FUN(veh, getAccumulatedWaitingSeconds(), INVALID_DOUBLE_VALUE);
435 }
436 
437 
438 double
439 Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
440  MSEdge* edge = Helper::getEdge(edgeID);
441  double value = INVALID_DOUBLE_VALUE;
443  return value;
444 }
445 
446 
447 double
448 Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
449  MSEdge* edge = Helper::getEdge(edgeID);
450  double value = INVALID_DOUBLE_VALUE;
451  Helper::getVehicle(vehID)->getWeightsStorage().retrieveExistingEffort(edge, time, value);
452  return value;
453 }
454 
455 
456 bool
457 Vehicle::isRouteValid(const std::string& vehID) {
458  std::string msg;
459  return Helper::getVehicle(vehID)->hasValidRoute(msg);
460 }
461 
462 
463 std::vector<std::string>
464 Vehicle::getRoute(const std::string& vehID) {
465  std::vector<std::string> result;
466  MSBaseVehicle* veh = Helper::getVehicle(vehID);
467  const MSRoute& r = veh->getRoute();
468  for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
469  result.push_back((*i)->getID());
470  }
471  return result;
472 }
473 
474 
475 int
476 Vehicle::getSignals(const std::string& vehID) {
477  MSBaseVehicle* veh = Helper::getVehicle(vehID);
478  return CALL_MICRO_FUN(veh, getSignals(), MSVehicle::VEH_SIGNAL_NONE);
479 }
480 
481 
482 std::vector<TraCIBestLanesData>
483 Vehicle::getBestLanes(const std::string& vehID) {
484  std::vector<TraCIBestLanesData> result;
485  MSVehicle* veh = dynamic_cast<MSVehicle*>(Helper::getVehicle(vehID));
486  if (veh != nullptr && veh->isOnRoad()) {
487  for (const MSVehicle::LaneQ& lq : veh->getBestLanes()) {
488  TraCIBestLanesData bld;
489  bld.laneID = lq.lane->getID();
490  bld.length = lq.length;
491  bld.occupation = lq.nextOccupation;
492  bld.bestLaneOffset = lq.bestLaneOffset;
493  bld.allowsContinuation = lq.allowsContinuation;
494  for (const MSLane* const lane : lq.bestContinuations) {
495  if (lane != nullptr) {
496  bld.continuationLanes.push_back(lane->getID());
497  }
498  }
499  result.emplace_back(bld);
500  }
501  }
502  return result;
503 }
504 
505 
506 std::vector<TraCINextTLSData>
507 Vehicle::getNextTLS(const std::string& vehID) {
508  std::vector<TraCINextTLSData> result;
509  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
510  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
511  if (veh != nullptr) {
512  int view = 1;
513  double seen = veh->getEdge()->getLength() - veh->getPositionOnLane();
514  if (vehicle->isOnRoad()) {
515  const MSLane* lane = veh->getLane();
516  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
517  seen = lane->getLength() - veh->getPositionOnLane();
518  std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
519  while (!lane->isLinkEnd(linkIt)) {
520  if (!lane->getEdge().isInternal()) {
521  if ((*linkIt)->isTLSControlled()) {
522  TraCINextTLSData ntd;
523  ntd.id = (*linkIt)->getTLLogic()->getID();
524  ntd.tlIndex = (*linkIt)->getTLIndex();
525  ntd.dist = seen;
526  ntd.state = (char)(*linkIt)->getState();
527  result.push_back(ntd);
528  }
529  }
530  lane = (*linkIt)->getViaLaneOrLane();
531  if (!lane->getEdge().isInternal()) {
532  view++;
533  }
534  seen += lane->getLength();
535  linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
536  }
537  }
538  // consider edges beyond bestLanes
539  const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
540  //std::cout << SIMTIME << " remainingEdges=" << remainingEdges << " seen=" << seen << " view=" << view << " best=" << toString(bestLaneConts) << "\n";
541  for (int i = 0; i < remainingEdges; i++) {
542  const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
543  const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
544  const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
545  if (allowed != nullptr && allowed->size() != 0) {
546  for (const MSLink* const link : allowed->front()->getLinkCont()) {
547  if (&link->getLane()->getEdge() == next) {
548  if (link->isTLSControlled()) {
549  TraCINextTLSData ntd;
550  ntd.id = link->getTLLogic()->getID();
551  ntd.tlIndex = link->getTLIndex();
552  ntd.dist = seen;
553  ntd.state = (char)link->getState();
554  result.push_back(ntd);
555  }
556  seen += next->getLength() + link->getInternalLengthsAfter();
557  break;
558  }
559  }
560  } else {
561  // invalid route, cannot determine nextTLS
562  break;
563  }
564  }
565 
566  } else {
567  WRITE_WARNING("getNextTLS not yet implemented for meso");
568  }
569  return result;
570 }
571 
572 std::vector<TraCINextStopData>
573 Vehicle::getNextStops(const std::string& vehID) {
574  return getStops(vehID, 0);
575 }
576 
577 std::vector<libsumo::TraCIConnection>
578 Vehicle::getNextLinks(const std::string& vehID) {
579  std::vector<libsumo::TraCIConnection> result;
580  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
581  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
582  if (!vehicle->isOnRoad()) {
583  return result;
584  }
585  if (veh != nullptr) {
586  const MSLane* lane = veh->getLane();
587  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
588  int view = 1;
589  const SUMOTime currTime = MSNet::getInstance()->getCurrentTimeStep();
590  std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
591  while (!lane->isLinkEnd(linkIt)) {
592  if (!lane->getEdge().isInternal()) {
593  const MSLink* link = (*linkIt);
594  const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
595  const bool hasPrio = link->havePriority();
596  const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
597  const bool isOpen = link->opened(currTime, speed, speed, SUMOVTypeParameter::getDefault().length,
599  const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
600  const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
601  const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
602  const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
603  const double length = link->getLength();
604  result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
605  }
606  lane = (*linkIt)->getViaLaneOrLane();
607  if (!lane->getEdge().isInternal()) {
608  view++;
609  }
610  linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
611  }
612  // consider edges beyond bestLanes
613  const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
614  for (int i = 0; i < remainingEdges; i++) {
615  const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
616  const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
617  const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
618  if (allowed != nullptr && allowed->size() != 0) {
619  for (const MSLink* const link : allowed->front()->getLinkCont()) {
620  if (&link->getLane()->getEdge() == next) {
621  const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
622  const bool hasPrio = link->havePriority();
623  const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
624  const bool isOpen = link->opened(currTime, speed, speed, SUMOVTypeParameter::getDefault().length,
626  const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
627  const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
628  const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
629  const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
630  const double length = link->getLength();
631  result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
632  }
633  }
634  } else {
635  // invalid route, cannot determine nextTLS
636  break;
637  }
638  }
639  } else {
640  WRITE_WARNING("getNextLinks not yet implemented for meso");
641  }
642  return result;
643 }
644 
645 std::vector<TraCINextStopData>
646 Vehicle::getStops(const std::string& vehID, int limit) {
647  std::vector<TraCINextStopData> result;
648  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
649  if (limit < 0) {
650  // return past stops up to the given limit
651  const std::vector<SUMOVehicleParameter::Stop>& pastStops = vehicle->getPastStops();
652  const int n = (int)pastStops.size();
653  for (int i = MAX2(0, n + limit); i < n; i++) {
654  result.push_back(Helper::buildStopData(pastStops[i]));
655  }
656  } else {
657  for (const MSStop& stop : vehicle->getStops()) {
658  if (!stop.pars.collision) {
659  TraCINextStopData nsd = Helper::buildStopData(stop.pars);
660  nsd.duration = STEPS2TIME(stop.duration);
661  result.push_back(nsd);
662  if (limit > 0 && (int)result.size() >= limit) {
663  break;
664  }
665  }
666  }
667  }
668  return result;
669 }
670 
671 
672 int
673 Vehicle::getStopState(const std::string& vehID) {
674  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
675  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
676  if (veh == nullptr) {
677  WRITE_WARNING("getStopState not yet implemented for meso");
678  return 0;
679  }
680  int result = 0;
681  if (veh->isStopped()) {
682  const MSStop& stop = veh->getNextStop();
683  result = stop.getStateFlagsOld();
684  }
685  return result;
686 }
687 
688 
689 double
690 Vehicle::getDistance(const std::string& vehID) {
691  MSBaseVehicle* veh = Helper::getVehicle(vehID);
692  if (veh->hasDeparted()) {
693  return veh->getOdometer();
694  } else {
695  return INVALID_DOUBLE_VALUE;
696  }
697 }
698 
699 
700 double
701 Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
702  MSBaseVehicle* veh = Helper::getVehicle(vehID);
703  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
704  if (veh->isOnRoad()) {
705  const MSLane* lane = microVeh != nullptr ? veh->getLane() : veh->getEdge()->getLanes()[0];
706  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), pos,
707  lane, Helper::getLaneChecking(edgeID, laneIndex, pos), veh->getRoutePosition());
708  if (distance == std::numeric_limits<double>::max()) {
709  return INVALID_DOUBLE_VALUE;
710  }
711  return distance;
712  } else {
713  return INVALID_DOUBLE_VALUE;
714  }
715 }
716 
717 
718 double
719 Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
720  MSBaseVehicle* veh = Helper::getVehicle(vehID);
721  if (veh == nullptr) {
722  return INVALID_DOUBLE_VALUE;
723  }
724  if (veh->isOnRoad()) {
725  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
726  const MSLane* lane = microVeh != nullptr ? veh->getLane() : veh->getEdge()->getLanes()[0];
727  std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y), veh->getVehicleType().getVehicleClass());
728  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
729  lane, roadPos.first, veh->getRoutePosition());
730  if (distance == std::numeric_limits<double>::max()) {
731  return INVALID_DOUBLE_VALUE;
732  }
733  return distance;
734  } else {
735  return INVALID_DOUBLE_VALUE;
736  }
737 }
738 
739 
740 double
741 Vehicle::getAllowedSpeed(const std::string& vehID) {
742  MSBaseVehicle* veh = Helper::getVehicle(vehID);
743  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getVehicleMaxSpeed(veh), veh->getEdge()->getVehicleMaxSpeed(veh)) : INVALID_DOUBLE_VALUE;
744 }
745 
746 
747 double
748 Vehicle::getSpeedFactor(const std::string& vehID) {
749  return Helper::getVehicle(vehID)->getChosenSpeedFactor();
750 }
751 
752 
753 int
754 Vehicle::getSpeedMode(const std::string& vehID) {
755  MSBaseVehicle* veh = Helper::getVehicle(vehID);
756  return CALL_MICRO_FUN(veh, getInfluencer().getSpeedMode(), INVALID_INT_VALUE);
757 }
758 
759 
760 int
761 Vehicle::getLaneChangeMode(const std::string& vehID) {
762  MSBaseVehicle* veh = Helper::getVehicle(vehID);
763  return CALL_MICRO_FUN(veh, getInfluencer().getLaneChangeMode(), INVALID_INT_VALUE);
764 }
765 
766 
767 int
768 Vehicle::getRoutingMode(const std::string& vehID) {
769  return Helper::getVehicle(vehID)->getRoutingMode();
770 }
771 
772 
773 std::string
774 Vehicle::getLine(const std::string& vehID) {
775  return Helper::getVehicle(vehID)->getParameter().line;
776 }
777 
778 
779 std::vector<std::string>
780 Vehicle::getVia(const std::string& vehID) {
781  return Helper::getVehicle(vehID)->getParameter().via;
782 }
783 
784 
785 std::pair<int, int>
786 Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
787  MSBaseVehicle* veh = Helper::getVehicle(vehID);
788  auto undefined = std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
789  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSavedState(direction), undefined) : undefined;
790 }
791 
792 
793 std::string
794 Vehicle::getParameter(const std::string& vehID, const std::string& key) {
795  MSBaseVehicle* veh = Helper::getVehicle(vehID);
796  std::string error;
797  std::string result = veh->getPrefixedParameter(key, error);
798  if (error != "") {
799  throw TraCIException(error);
800  }
801  return result;
802 }
803 
804 
806 
807 
808 std::vector<std::pair<std::string, double> >
809 Vehicle::getNeighbors(const std::string& vehID, const int mode) {
810  int dir = (1 & mode) != 0 ? -1 : 1;
811  bool queryLeaders = (2 & mode) != 0;
812  bool blockersOnly = (4 & mode) != 0;
813  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
814  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
815  std::vector<std::pair<std::string, double> > result;
816  if (veh == nullptr) {
817  return result;
818  }
819 #ifdef DEBUG_NEIGHBORS
820  if (DEBUG_COND) {
821  std::cout << "getNeighbors() for veh '" << vehID << "': dir=" << dir
822  << ", queryLeaders=" << queryLeaders
823  << ", blockersOnly=" << blockersOnly << std::endl;
824  }
825 #endif
826  if (veh->getLaneChangeModel().isOpposite()) {
827  // getParallelLane works relative to lane forward direction
828  dir *= -1;
829  }
830 
831  MSLane* targetLane = veh->getLane()->getParallelLane(dir);
832  if (targetLane == nullptr) {
833  return result;
834  }
835  // need to recompute leaders and followers (#8119)
836  const bool opposite = &veh->getLane()->getEdge() != &targetLane->getEdge();
837  MSLeaderDistanceInfo neighbors(targetLane->getWidth(), nullptr, 0.);
838  if (queryLeaders) {
839  if (opposite) {
840  double pos = targetLane->getOppositePos(veh->getPositionOnLane());
841  neighbors = targetLane->getFollowersOnConsecutive(veh, pos, true);
842  } else {
843  targetLane->addLeaders(veh, veh->getPositionOnLane(), neighbors);
844  }
845  } else {
846  if (opposite) {
847  double pos = targetLane->getOppositePos(veh->getPositionOnLane());
848  targetLane->addLeaders(veh, pos, neighbors);
849  neighbors.fixOppositeGaps(true);
850  } else {
851  neighbors = targetLane->getFollowersOnConsecutive(veh, veh->getBackPositionOnLane(), true);
852  }
853  }
854  if (blockersOnly) {
855  // filter out vehicles that aren't blocking
856  MSLeaderDistanceInfo blockers(targetLane->getWidth(), nullptr, 0.);
857  for (int i = 0; i < neighbors.numSublanes(); i++) {
858  CLeaderDist n = neighbors[i];
859  if (n.first != nullptr) {
860  const MSVehicle* follower = veh;
861  const MSVehicle* leader = n.first;
862  if (!queryLeaders) {
863  std::swap(follower, leader);
864  }
865  const double secureGap = (follower->getCarFollowModel().getSecureGap(
866  follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel())
867  * follower->getLaneChangeModel().getSafetyFactor());
868  if (n.second < secureGap) {
869  blockers.addLeader(n.first, n.second, 0, i);
870  }
871  }
872  }
873  neighbors = blockers;
874  }
875 
876  if (neighbors.hasVehicles()) {
877  for (int i = 0; i < neighbors.numSublanes(); i++) {
878  CLeaderDist n = neighbors[i];
879  if (n.first != nullptr &&
880  // avoid duplicates
881  (result.size() == 0 || result.back().first != n.first->getID())) {
882  result.push_back(std::make_pair(n.first->getID(), n.second));
883  }
884  }
885  }
886  return result;
887 }
888 
889 
890 double
891 Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
892  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
893  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
894  if (veh == nullptr) {
895  WRITE_ERROR("getFollowSpeed not applicable for meso");
896  return INVALID_DOUBLE_VALUE;
897  }
898  MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
899  return veh->getCarFollowModel().followSpeed(veh, speed, gap, leaderSpeed, leaderMaxDecel, leader, MSCFModel::CalcReason::FUTURE);
900 }
901 
902 
903 double
904 Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
905  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
906  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
907  if (veh == nullptr) {
908  WRITE_ERROR("getSecureGap not applicable for meso");
909  return INVALID_DOUBLE_VALUE;
910  }
911  MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
912  return veh->getCarFollowModel().getSecureGap(veh, leader, speed, leaderSpeed, leaderMaxDecel);
913 }
914 
915 
916 double
917 Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
918  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
919  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
920  if (veh == nullptr) {
921  WRITE_ERROR("getStopSpeed not applicable for meso");
922  return INVALID_DOUBLE_VALUE;
923  }
924  return veh->getCarFollowModel().stopSpeed(veh, speed, gap, MSCFModel::CalcReason::FUTURE);
925 }
926 
927 double
928 Vehicle::getStopDelay(const std::string& vehID) {
929  return Helper::getVehicle(vehID)->getStopDelay();
930 }
931 
932 
933 double
934 Vehicle::getImpatience(const std::string& vehID) {
935  return Helper::getVehicle(vehID)->getImpatience();
936 }
937 
938 
939 double
940 Vehicle::getStopArrivalDelay(const std::string& vehID) {
941  double result = Helper::getVehicle(vehID)->getStopArrivalDelay();
942  if (result == INVALID_DOUBLE) {
943  return INVALID_DOUBLE_VALUE;
944  } else {
945  return result;
946  }
947 }
948 
949 double
950 Vehicle::getTimeLoss(const std::string& vehID) {
951  return Helper::getVehicle(vehID)->getTimeLossSeconds();
952 }
953 
954 std::vector<std::string>
955 Vehicle::getTaxiFleet(int taxiState) {
956  std::vector<std::string> result;
957  for (MSDevice_Taxi* taxi : MSDevice_Taxi::getFleet()) {
958  if (taxi->getHolder().hasDeparted()) {
959  if (taxiState == -1
960  || (taxiState == 0 && taxi->getState() == 0)
961  || (taxiState != 0 && (taxi->getState() & taxiState) == taxiState)) {
962  result.push_back(taxi->getHolder().getID());
963  }
964  }
965  }
966  return result;
967 }
968 
969 std::vector<std::string>
970 Vehicle::getLoadedIDList() {
971  std::vector<std::string> ids;
973  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
974  ids.push_back(i->first);
975  }
976  return ids;
977 }
978 
979 std::vector<std::string>
980 Vehicle::getTeleportingIDList() {
981  std::vector<std::string> ids;
983  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
984  SUMOVehicle* veh = i->second;
985  if (veh->hasDeparted() && !isVisible(veh)) {
986  ids.push_back(veh->getID());
987  }
988  }
989  return ids;
990 }
991 
992 std::string
993 Vehicle::getEmissionClass(const std::string& vehID) {
994  return PollutantsInterface::getName(Helper::getVehicleType(vehID).getEmissionClass());
995 }
996 
997 std::string
998 Vehicle::getShapeClass(const std::string& vehID) {
999  return getVehicleShapeName(Helper::getVehicleType(vehID).getGuiShape());
1000 }
1001 
1002 
1003 double
1004 Vehicle::getLength(const std::string& vehID) {
1005  return Helper::getVehicleType(vehID).getLength();
1006 }
1007 
1008 
1009 double
1010 Vehicle::getAccel(const std::string& vehID) {
1012 }
1013 
1014 
1015 double
1016 Vehicle::getDecel(const std::string& vehID) {
1018 }
1019 
1020 
1021 double Vehicle::getEmergencyDecel(const std::string& vehID) {
1023 }
1024 
1025 
1026 double Vehicle::getApparentDecel(const std::string& vehID) {
1028 }
1029 
1030 
1031 double Vehicle::getActionStepLength(const std::string& vehID) {
1033 }
1034 
1035 
1036 double Vehicle::getLastActionTime(const std::string& vehID) {
1037  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1038  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
1039  if (microVeh != nullptr) {
1040  return STEPS2TIME(microVeh->getLastActionTime());
1041  } else {
1042  MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
1043  return STEPS2TIME(mesoVeh->getEventTime());
1044  }
1045 }
1046 
1047 
1048 double
1049 Vehicle::getTau(const std::string& vehID) {
1051 }
1052 
1053 
1054 double
1055 Vehicle::getImperfection(const std::string& vehID) {
1057 }
1058 
1059 
1060 double
1061 Vehicle::getSpeedDeviation(const std::string& vehID) {
1062  return Helper::getVehicleType(vehID).getSpeedFactor().getParameter()[1];
1063 }
1064 
1065 
1066 std::string
1067 Vehicle::getVehicleClass(const std::string& vehID) {
1068  return toString(Helper::getVehicleType(vehID).getVehicleClass());
1069 }
1070 
1071 
1072 double
1073 Vehicle::getMinGap(const std::string& vehID) {
1074  return Helper::getVehicleType(vehID).getMinGap();
1075 }
1076 
1077 
1078 double
1079 Vehicle::getMinGapLat(const std::string& vehID) {
1080  try {
1081  return StringUtils::toDouble(getParameter(vehID, "laneChangeModel.minGapLat"));
1082  } catch (const TraCIException&) {
1083  // legacy behavior
1084  return Helper::getVehicleType(vehID).getMinGapLat();
1085  }
1086 }
1087 
1088 
1089 double
1090 Vehicle::getMaxSpeed(const std::string& vehID) {
1091  return Helper::getVehicleType(vehID).getMaxSpeed();
1092 }
1093 
1094 
1095 double
1096 Vehicle::getMaxSpeedLat(const std::string& vehID) {
1097  return Helper::getVehicleType(vehID).getMaxSpeedLat();
1098 }
1099 
1100 
1101 std::string
1102 Vehicle::getLateralAlignment(const std::string& vehID) {
1103  return toString(Helper::getVehicleType(vehID).getPreferredLateralAlignment());
1104 }
1105 
1106 
1107 double
1108 Vehicle::getWidth(const std::string& vehID) {
1109  return Helper::getVehicleType(vehID).getWidth();
1110 }
1111 
1112 
1113 double
1114 Vehicle::getHeight(const std::string& vehID) {
1115  return Helper::getVehicleType(vehID).getHeight();
1116 }
1117 
1118 
1119 double
1120 Vehicle::getMass(const std::string& vehID) {
1121  return Helper::getVehicleType(vehID).getMass();
1122 }
1123 
1124 
1125 void
1126 Vehicle::setStop(const std::string& vehID,
1127  const std::string& edgeID,
1128  double pos,
1129  int laneIndex,
1130  double duration,
1131  int flags,
1132  double startPos,
1133  double until) {
1134  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1136  pos, laneIndex, startPos, flags, duration, until);
1137  std::string error;
1138  if (!vehicle->addTraciStop(stopPars, error)) {
1139  throw TraCIException(error);
1140  }
1141 }
1142 
1143 
1144 void
1145 Vehicle::replaceStop(const std::string& vehID,
1146  int nextStopIndex,
1147  const std::string& edgeID,
1148  double pos,
1149  int laneIndex,
1150  double duration,
1151  int flags,
1152  double startPos,
1153  double until,
1154  int teleport) {
1155  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1156  std::string error;
1157  if (edgeID == "") {
1158  // only remove stop
1159  const bool ok = vehicle->abortNextStop(nextStopIndex);
1160  if (teleport != 0) {
1161  if (!vehicle->rerouteBetweenStops(nextStopIndex, "traci:replaceStop", (teleport & 1), error)) {
1162  throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
1163  }
1164  } else {
1165  MSVehicle* msVeh = dynamic_cast<MSVehicle*>(vehicle);
1166  if (msVeh->getLane() != nullptr) {
1167  msVeh->updateBestLanes(true);
1168  }
1169  }
1170  if (!ok) {
1171  throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (invalid nextStopIndex).");
1172  }
1173  } else {
1175  pos, laneIndex, startPos, flags, duration, until);
1176 
1177  if (!vehicle->replaceStop(nextStopIndex, stopPars, "traci:replaceStop", teleport != 0, error)) {
1178  throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
1179  }
1180  }
1181 }
1182 
1183 
1184 void
1185 Vehicle::insertStop(const std::string& vehID,
1186  int nextStopIndex,
1187  const std::string& edgeID,
1188  double pos,
1189  int laneIndex,
1190  double duration,
1191  int flags,
1192  double startPos,
1193  double until,
1194  int teleport) {
1195  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1197  pos, laneIndex, startPos, flags, duration, until);
1198 
1199  std::string error;
1200  if (!vehicle->insertStop(nextStopIndex, stopPars, "traci:insertStop", teleport != 0, error)) {
1201  throw TraCIException("Stop insertion failed for vehicle '" + vehID + "' (" + error + ").");
1202  }
1203 }
1204 
1205 
1206 std::string
1207 Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
1208  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1209  try {
1210  if (nextStopIndex >= (int)vehicle->getStops().size() || (nextStopIndex < 0 && -nextStopIndex > (int)vehicle->getPastStops().size())) {
1211  throw ProcessError("Invalid stop index " + toString(nextStopIndex)
1212  + " (has " + toString(vehicle->getPastStops().size()) + " past stops and " + toString(vehicle->getStops().size()) + " remaining stops)");
1213 
1214  }
1215  const SUMOVehicleParameter::Stop& pars = (nextStopIndex >= 0
1216  ? vehicle->getStop(nextStopIndex).pars
1217  : vehicle->getPastStops()[vehicle->getPastStops().size() + nextStopIndex]);
1218  if (customParam) {
1219  // custom user parameter
1220  return pars.getParameter(param, "");
1221  }
1222 
1223  if (param == toString(SUMO_ATTR_EDGE)) {
1224  return pars.edge;
1225  } else if (param == toString(SUMO_ATTR_LANE)) {
1227  } else if (param == toString(SUMO_ATTR_BUS_STOP)
1228  || param == toString(SUMO_ATTR_TRAIN_STOP)) {
1229  return pars.busstop;
1230  } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
1231  return pars.containerstop;
1232  } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
1233  return pars.chargingStation;
1234  } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
1235  return pars.parkingarea;
1236  } else if (param == toString(SUMO_ATTR_STARTPOS)) {
1237  return toString(pars.startPos);
1238  } else if (param == toString(SUMO_ATTR_ENDPOS)) {
1239  return toString(pars.endPos);
1240  } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
1241  return toString(pars.posLat == INVALID_DOUBLE ? INVALID_DOUBLE_VALUE : pars.posLat);
1242  } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
1243  return pars.arrival < 0 ? "-1" : time2string(pars.arrival);
1244  } else if (param == toString(SUMO_ATTR_DURATION)) {
1245  return pars.duration < 0 ? "-1" : time2string(pars.duration);
1246  } else if (param == toString(SUMO_ATTR_UNTIL)) {
1247  return pars.until < 0 ? "-1" : time2string(pars.until);
1248  } else if (param == toString(SUMO_ATTR_EXTENSION)) {
1249  return pars.extension < 0 ? "-1" : time2string(pars.extension);
1250  } else if (param == toString(SUMO_ATTR_INDEX)) {
1251  return toString(nextStopIndex + vehicle->getPastStops().size());
1252  } else if (param == toString(SUMO_ATTR_PARKING)) {
1253  return toString(pars.parking);
1254  } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
1255  return joinToString(pars.getTriggers(), " ");
1256  } else if (param == toString(SUMO_ATTR_EXPECTED)) {
1257  return joinToString(pars.awaitedPersons, " ");
1258  } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
1259  return joinToString(pars.awaitedContainers, " ");
1260  } else if (param == toString(SUMO_ATTR_PERMITTED)) {
1261  return joinToString(pars.permitted, " ");
1262  } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
1263  return pars.actType;
1264  } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
1265  return pars.tripId;
1266  } else if (param == toString(SUMO_ATTR_SPLIT)) {
1267  return pars.split;
1268  } else if (param == toString(SUMO_ATTR_JOIN)) {
1269  return pars.join;
1270  } else if (param == toString(SUMO_ATTR_LINE)) {
1271  return pars.line;
1272  } else if (param == toString(SUMO_ATTR_SPEED)) {
1273  return toString(pars.speed);
1274  } else if (param == toString(SUMO_ATTR_STARTED)) {
1275  return pars.started < 0 ? "-1" : time2string(pars.started);
1276  } else if (param == toString(SUMO_ATTR_ENDED)) {
1277  return pars.ended < 0 ? "-1" : time2string(pars.ended);
1278  } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
1279  return toString(pars.onDemand);
1280  } else {
1281  throw ProcessError(TLF("Unsupported parameter '%'", param));
1282  }
1283  } catch (ProcessError& e) {
1284  throw TraCIException("Could not get stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
1285  }
1286 }
1287 
1288 
1289 
1290 void
1291 Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
1292  const std::string& param, const std::string& value,
1293  bool customParam) {
1294  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1295  try {
1296  MSStop& stop = vehicle->getStop(nextStopIndex);
1297  SUMOVehicleParameter::Stop& pars = const_cast<SUMOVehicleParameter::Stop&>(stop.pars);
1298  if (customParam) {
1299  pars.setParameter(param, value);
1300  return;
1301  }
1302  std::string error;
1303  if (param == toString(SUMO_ATTR_EDGE)
1304  || param == toString(SUMO_ATTR_BUS_STOP)
1305  || param == toString(SUMO_ATTR_TRAIN_STOP)
1306  || param == toString(SUMO_ATTR_CONTAINER_STOP)
1308  || param == toString(SUMO_ATTR_PARKING_AREA)
1309  || param == toString(SUMO_ATTR_LANE)
1310  ) {
1311  int laneIndex = stop.lane->getIndex();
1312  int flags = pars.getFlags() & 3;
1313  std::string edgeOrStopID = value;
1314  if (param == toString(SUMO_ATTR_LANE)) {
1315  laneIndex = StringUtils::toInt(value);
1316  edgeOrStopID = pars.edge;
1317  } else if (param == toString(SUMO_ATTR_BUS_STOP)
1318  || param == toString(SUMO_ATTR_TRAIN_STOP)) {
1319  flags |= 8;
1320  } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
1321  flags |= 16;
1322  } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
1323  flags |= 32;
1324  } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
1325  flags |= 64;
1326  }
1327  // special case: replace stop
1328  replaceStop(vehID, nextStopIndex, edgeOrStopID, pars.endPos, laneIndex, STEPS2TIME(pars.duration),
1329  flags, pars.startPos, STEPS2TIME(pars.until), 0);
1330 
1331  } else if (param == toString(SUMO_ATTR_STARTPOS)) {
1332  pars.startPos = StringUtils::toDouble(value);
1333  pars.parametersSet |= STOP_START_SET;
1334  } else if (param == toString(SUMO_ATTR_ENDPOS)) {
1335  pars.endPos = StringUtils::toDouble(value);
1336  pars.parametersSet |= STOP_END_SET;
1337  } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
1338  pars.posLat = StringUtils::toDouble(value);
1340  } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
1341  pars.arrival = string2time(value);
1343  } else if (param == toString(SUMO_ATTR_DURATION)) {
1344  pars.duration = string2time(value);
1346  // also update dynamic value
1347  stop.initPars(pars);
1348  } else if (param == toString(SUMO_ATTR_UNTIL)) {
1349  pars.until = string2time(value);
1350  pars.parametersSet |= STOP_UNTIL_SET;
1351  } else if (param == toString(SUMO_ATTR_EXTENSION)) {
1352  pars.extension = string2time(value);
1354  } else if (param == toString(SUMO_ATTR_INDEX)) {
1355  throw TraCIException("Changing stop index is not supported");
1356  } else if (param == toString(SUMO_ATTR_PARKING)) {
1359  } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
1360  if (pars.speed > 0 && value != "") {
1361  throw ProcessError(TLF("Waypoint (speed = %) at index % does not support triggers", pars.speed, nextStopIndex));
1362  }
1363  SUMOVehicleParameter::parseStopTriggers(StringTokenizer(value).getVector(), false, pars);
1365  // also update dynamic value
1366  stop.initPars(pars);
1367  } else if (param == toString(SUMO_ATTR_EXPECTED)) {
1368  pars.awaitedPersons = StringTokenizer(value).getSet();
1370  // also update dynamic value
1371  stop.initPars(pars);
1372  } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
1373  pars.awaitedContainers = StringTokenizer(value).getSet();
1375  // also update dynamic value
1376  stop.initPars(pars);
1377  } else if (param == toString(SUMO_ATTR_PERMITTED)) {
1378  pars.permitted = StringTokenizer(value).getSet();
1380  } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
1381  pars.actType = value;
1382  } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
1383  pars.tripId = value;
1385  } else if (param == toString(SUMO_ATTR_SPLIT)) {
1386  pars.split = value;
1387  pars.parametersSet |= STOP_SPLIT_SET;
1388  } else if (param == toString(SUMO_ATTR_JOIN)) {
1389  pars.join = value;
1390  pars.parametersSet |= STOP_JOIN_SET;
1391  // also update dynamic value
1392  stop.initPars(pars);
1393  } else if (param == toString(SUMO_ATTR_LINE)) {
1394  pars.line = value;
1395  pars.parametersSet |= STOP_LINE_SET;
1396  } else if (param == toString(SUMO_ATTR_SPEED)) {
1397  const double speed = StringUtils::toDouble(value);
1398  if (speed > 0 && pars.getTriggers().size() > 0) {
1399  throw ProcessError(TLF("Triggered stop at index % cannot be changed into a waypoint by setting speed to %", nextStopIndex, speed));
1400  }
1401  pars.speed = speed;
1402  pars.parametersSet |= STOP_SPEED_SET;
1403  } else if (param == toString(SUMO_ATTR_STARTED)) {
1404  pars.started = string2time(value);
1406  } else if (param == toString(SUMO_ATTR_ENDED)) {
1407  pars.ended = string2time(value);
1408  pars.parametersSet |= STOP_ENDED_SET;
1409  } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
1410  pars.onDemand = StringUtils::toBool(value);
1412  } else if (param == toString(SUMO_ATTR_JUMP)) {
1413  pars.jump = string2time(value);
1414  pars.parametersSet |= STOP_JUMP_SET;
1415  } else {
1416  throw ProcessError(TLF("Unsupported parameter '%'", param));
1417  }
1418  } catch (ProcessError& e) {
1419  throw TraCIException("Could not set stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
1420  }
1421 }
1422 
1423 
1424 void
1425 Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
1426  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1427  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1428  if (veh == nullptr) {
1429  WRITE_WARNING("rerouteParkingArea not yet implemented for meso");
1430  return;
1431  }
1432  std::string error;
1433  // Forward command to vehicle
1434  if (!veh->rerouteParkingArea(parkingAreaID, error)) {
1435  throw TraCIException(error);
1436  }
1437 }
1438 
1439 void
1440 Vehicle::resume(const std::string& vehID) {
1441  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1442  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1443  if (veh == nullptr) {
1444  WRITE_WARNING("resume not yet implemented for meso");
1445  return;
1446  }
1447  if (!veh->hasStops()) {
1448  throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
1449  }
1450  if (!veh->resumeFromStopping()) {
1451  MSStop& sto = veh->getNextStop();
1452  std::ostringstream strs;
1453  strs << "reached: " << sto.reached;
1454  strs << ", duration:" << sto.duration;
1455  strs << ", edge:" << (*sto.edge)->getID();
1456  strs << ", startPos: " << sto.pars.startPos;
1457  std::string posStr = strs.str();
1458  throw TraCIException("Failed to resume from stopping for vehicle '" + veh->getID() + "', " + posStr);
1459  }
1460 }
1461 
1462 
1463 void
1464 Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
1465  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1466  const MSEdge* destEdge = MSEdge::dictionary(edgeID);
1467  const bool onInit = isOnInit(vehID);
1468  if (destEdge == nullptr) {
1469  throw TraCIException("Destination edge '" + edgeID + "' is not known.");
1470  }
1471  // change the final edge of the route and reroute
1472  try {
1473  const bool success = veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
1474  veh->getRouterTT(), onInit, false, false, destEdge);
1475  if (!success) {
1476  throw TraCIException("ChangeTarget failed for vehicle '" + veh->getID() + "', destination edge '" + edgeID + "' unreachable.");
1477  }
1478  } catch (ProcessError& e) {
1479  throw TraCIException(e.what());
1480  }
1481 }
1482 
1483 
1484 void
1485 Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
1486  try {
1487  checkTimeBounds(duration);
1488  } catch (ProcessError&) {
1489  throw TraCIException("Duration parameter exceeds the time value range.");
1490  }
1491  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1492  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1493  if (veh == nullptr) {
1494  WRITE_ERROR("changeLane not applicable for meso");
1495  return;
1496  }
1497 
1498  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1499  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1500  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
1501  veh->getInfluencer().setLaneTimeLine(laneTimeLine);
1502 }
1503 
1504 void
1505 Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
1506  try {
1507  checkTimeBounds(duration);
1508  } catch (ProcessError&) {
1509  throw TraCIException("Duration parameter exceeds the time value range.");
1510  }
1511  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1512  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1513  if (veh == nullptr) {
1514  WRITE_ERROR("changeLaneRelative not applicable for meso");
1515  return;
1516  }
1517 
1518  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1519  int laneIndex = veh->getLaneIndex() + indexOffset;
1520  if (laneIndex < 0 && !veh->getLaneChangeModel().isOpposite()) {
1521  if (veh->getLaneIndex() == -1) {
1522  WRITE_WARNINGF(TL("Ignoring changeLaneRelative for vehicle '%' that isn't on the road"), vehID);
1523  } else {
1524  WRITE_WARNINGF(TL("Ignoring indexOffset % for vehicle '%' on laneIndex %."), indexOffset, vehID, veh->getLaneIndex());
1525  }
1526  } else {
1527  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1528  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
1529  veh->getInfluencer().setLaneTimeLine(laneTimeLine);
1530  }
1531 }
1532 
1533 
1534 void
1535 Vehicle::changeSublane(const std::string& vehID, double latDist) {
1536  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1537  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1538  if (veh == nullptr) {
1539  WRITE_ERROR("changeSublane not applicable for meso");
1540  return;
1541  }
1542 
1543  veh->getInfluencer().setSublaneChange(latDist);
1544 }
1545 
1546 
1547 void
1548 Vehicle::add(const std::string& vehID,
1549  const std::string& routeID,
1550  const std::string& typeID,
1551  const std::string& depart,
1552  const std::string& departLane,
1553  const std::string& departPos,
1554  const std::string& departSpeed,
1555  const std::string& arrivalLane,
1556  const std::string& arrivalPos,
1557  const std::string& arrivalSpeed,
1558  const std::string& fromTaz,
1559  const std::string& toTaz,
1560  const std::string& line,
1561  int /*personCapacity*/,
1562  int personNumber) {
1564  if (veh != nullptr) {
1565  throw TraCIException("The vehicle '" + vehID + "' to add already exists.");
1566  }
1567 
1568  SUMOVehicleParameter vehicleParams;
1569  vehicleParams.id = vehID;
1570  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1571  if (!vehicleType) {
1572  throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehID + "'.");
1573  }
1574  if (typeID != "DEFAULT_VEHTYPE") {
1575  vehicleParams.vtypeid = typeID;
1576  vehicleParams.parametersSet |= VEHPARS_VTYPE_SET;
1577  }
1579  WRITE_WARNINGF(TL("Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
1580  }
1581  ConstMSRoutePtr route = MSRoute::dictionary(routeID);
1582  if (!route) {
1583  if (routeID == "") {
1584  // assume, route was intentionally left blank because the caller
1585  // intends to control the vehicle remotely
1586  SUMOVehicleClass vclass = vehicleType->getVehicleClass();
1587  const std::string dummyRouteID = "DUMMY_ROUTE_" + SumoVehicleClassStrings.getString(vclass);
1588  route = MSRoute::dictionary(dummyRouteID);
1589  if (route == nullptr) {
1590  for (MSEdge* e : MSEdge::getAllEdges()) {
1591  if (e->getFunction() == SumoXMLEdgeFunc::NORMAL && (e->getPermissions() & vclass) == vclass) {
1592  std::vector<std::string> edges;
1593  edges.push_back(e->getID());
1594  libsumo::Route::add(dummyRouteID, edges);
1595  break;
1596  }
1597  }
1598  }
1599  route = MSRoute::dictionary(dummyRouteID);
1600  if (!route) {
1601  throw TraCIException("Could not build dummy route for vehicle class: '" + SumoVehicleClassStrings.getString(vehicleType->getVehicleClass()) + "'");
1602  }
1603  } else {
1604  throw TraCIException("Invalid route '" + routeID + "' for vehicle '" + vehID + "'.");
1605  }
1606  }
1607  // check if the route implies a trip
1608  if (route->getEdges().size() == 2) {
1609  const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
1610  if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
1611  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1612  }
1613  }
1614  if (fromTaz != "" || toTaz != "") {
1615  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1616  }
1617  std::string error;
1618  if (!SUMOVehicleParameter::parseDepart(depart, "vehicle", vehID, vehicleParams.depart, vehicleParams.departProcedure, error)) {
1619  throw TraCIException(error);
1620  }
1621  if (vehicleParams.departProcedure == DepartDefinition::GIVEN && vehicleParams.depart < MSNet::getInstance()->getCurrentTimeStep()) {
1622  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1623  WRITE_WARNINGF(TL("Departure time for vehicle '%' is in the past; using current time instead."), vehID);
1624  } else if (vehicleParams.departProcedure == DepartDefinition::NOW) {
1625  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1626  }
1627  if (!SUMOVehicleParameter::parseDepartLane(departLane, "vehicle", vehID, vehicleParams.departLane, vehicleParams.departLaneProcedure, error)) {
1628  throw TraCIException(error);
1629  }
1630  if (!SUMOVehicleParameter::parseDepartPos(departPos, "vehicle", vehID, vehicleParams.departPos, vehicleParams.departPosProcedure, error)) {
1631  throw TraCIException(error);
1632  }
1633  if (!SUMOVehicleParameter::parseDepartSpeed(departSpeed, "vehicle", vehID, vehicleParams.departSpeed, vehicleParams.departSpeedProcedure, error)) {
1634  throw TraCIException(error);
1635  }
1636  if (!SUMOVehicleParameter::parseArrivalLane(arrivalLane, "vehicle", vehID, vehicleParams.arrivalLane, vehicleParams.arrivalLaneProcedure, error)) {
1637  throw TraCIException(error);
1638  }
1639  if (!SUMOVehicleParameter::parseArrivalPos(arrivalPos, "vehicle", vehID, vehicleParams.arrivalPos, vehicleParams.arrivalPosProcedure, error)) {
1640  throw TraCIException(error);
1641  }
1642  if (!SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeed, "vehicle", vehID, vehicleParams.arrivalSpeed, vehicleParams.arrivalSpeedProcedure, error)) {
1643  throw TraCIException(error);
1644  }
1645  // mark non-default attributes
1646  if (departLane != "first") {
1647  vehicleParams.parametersSet |= VEHPARS_DEPARTLANE_SET;
1648  }
1649  if (departPos != "base") {
1650  vehicleParams.parametersSet |= VEHPARS_DEPARTPOS_SET;
1651  }
1652  if (departSpeed != "0") {
1653  vehicleParams.parametersSet |= VEHPARS_DEPARTSPEED_SET;
1654  }
1655  if (arrivalLane != "current") {
1656  vehicleParams.parametersSet |= VEHPARS_ARRIVALLANE_SET;
1657  }
1658  if (arrivalPos != "max") {
1659  vehicleParams.parametersSet |= VEHPARS_ARRIVALPOS_SET;
1660  }
1661  if (arrivalSpeed != "current") {
1662  vehicleParams.parametersSet |= VEHPARS_ARRIVALSPEED_SET;
1663  }
1664  if (fromTaz != "") {
1665  vehicleParams.parametersSet |= VEHPARS_FROM_TAZ_SET;
1666  }
1667  if (toTaz != "") {
1668  vehicleParams.parametersSet |= VEHPARS_TO_TAZ_SET;
1669  }
1670  if (line != "") {
1671  vehicleParams.parametersSet |= VEHPARS_LINE_SET;
1672  }
1673  if (personNumber != 0) {
1674  vehicleParams.parametersSet |= VEHPARS_PERSON_NUMBER_SET;
1675  }
1676  // build vehicle
1677  vehicleParams.fromTaz = fromTaz;
1678  vehicleParams.toTaz = toTaz;
1679  vehicleParams.line = line;
1680  //vehicleParams.personCapacity = personCapacity;
1681  vehicleParams.personNumber = personNumber;
1682 
1683  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
1684  SUMOVehicle* vehicle = nullptr;
1685  try {
1686  vehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(params, route, vehicleType, true, MSVehicleControl::VehicleDefinitionSource::LIBSUMO);
1687  if (fromTaz == "" && !route->getEdges().front()->validateDepartSpeed(*vehicle)) {
1689  throw TraCIException("Departure speed for vehicle '" + vehID + "' is too high for the departure edge '" + route->getEdges().front()->getID() + "'.");
1690  }
1691  std::string msg;
1692  if (vehicle->getRouteValidity(true, true, &msg) != MSBaseVehicle::ROUTE_VALID) {
1694  throw TraCIException("Vehicle '" + vehID + "' has no valid route (" + msg + "). ");
1695  }
1696  MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
1699  }
1700  } catch (ProcessError& e) {
1701  if (vehicle != nullptr) {
1703  }
1704  throw TraCIException(e.what());
1705  }
1706 }
1707 
1708 
1709 void
1710 Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
1711  const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
1712  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1713  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1714  if (veh == nullptr) {
1715  WRITE_WARNING("moveToXY not yet implemented for meso");
1716  return;
1717  }
1718  const bool doKeepRoute = (keepRoute & 1) != 0 && veh->getID() != "VTD_EGO";
1719  const bool mayLeaveNetwork = (keepRoute & 2) != 0;
1720  const bool ignorePermissions = (keepRoute & 4) != 0;
1721  const bool setLateralPos = (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork);
1722  SUMOVehicleClass vClass = ignorePermissions ? SVC_IGNORING : veh->getVClass();
1723  // process
1724  const std::string origID = edgeID + "_" + toString(laneIndex);
1725  // @todo add an interpretation layer for OSM derived origID values (without lane index)
1726  Position pos(x, y);
1727 #ifdef DEBUG_MOVEXY
1728  const double origAngle = angle;
1729 #endif
1730  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
1731  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
1732  if (angle != INVALID_DOUBLE_VALUE) {
1733  while (angle >= 360.) {
1734  angle -= 360.;
1735  }
1736  while (angle < 0.) {
1737  angle += 360.;
1738  }
1739  }
1740 
1741 #ifdef DEBUG_MOVEXY
1742  std::cout << std::endl << SIMTIME << " moveToXY veh=" << veh->getID() << " vehPos=" << veh->getPosition()
1743  << " lane=" << Named::getIDSecure(veh->getLane()) << " lanePos=" << vehicle->getPositionOnLane() << std::endl;
1744  std::cout << " wantedPos=" << pos << " origID=" << origID << " laneIndex=" << laneIndex << " origAngle=" << origAngle << " angle=" << angle << " keepRoute=" << keepRoute << std::endl;
1745 #endif
1746 
1747  ConstMSEdgeVector edges;
1748  MSLane* lane = nullptr;
1749  double lanePos;
1750  double lanePosLat = 0;
1751  double bestDistance = std::numeric_limits<double>::max();
1752  int routeOffset = 0;
1753  bool found;
1754  double maxRouteDistance = matchThreshold;
1755  /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
1756  if (doKeepRoute) {
1757  // case a): vehicle is on its earlier route
1758  // we additionally assume it is moving forward (SUMO-limit);
1759  // note that the route ("edges") is not changed in this case
1760 
1761  found = Helper::moveToXYMap_matchingRoutePosition(pos, origID,
1762  veh->getRoute().getEdges(), veh->getRoutePosition(),
1763  vClass, setLateralPos,
1764  bestDistance, &lane, lanePos, routeOffset);
1765  // @note silenty ignoring mapping failure
1766  } else {
1767  const double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
1768  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
1769  speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
1770  vClass, setLateralPos,
1771  bestDistance, &lane, lanePos, routeOffset, edges);
1772  }
1773  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1774  // optionally compute lateral offset
1775  pos.setz(veh->getPosition().z());
1776  if (found && setLateralPos) {
1777  const double perpDist = lane->getShape().distance2D(pos, false);
1778  if (perpDist != GeomHelper::INVALID_OFFSET) {
1779  lanePosLat = perpDist;
1780  if (!mayLeaveNetwork) {
1781  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
1782  }
1783  // figure out whether the offset is to the left or to the right
1784  PositionVector tmp = lane->getShape();
1785  try {
1786  tmp.move2side(-lanePosLat); // moved to left
1787  } catch (ProcessError&) {
1788  WRITE_WARNINGF(TL("Could not determine position on lane '%' at lateral position %."), lane->getID(), toString(-lanePosLat));
1789  }
1790  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
1791  if (tmp.distance2D(pos) > perpDist) {
1792  lanePosLat = -lanePosLat;
1793  }
1794  }
1795  pos.setz(lane->geometryPositionAtOffset(lanePos).z());
1796  }
1797  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
1798  // mapped position may differ from pos
1799  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1800  }
1801  assert((found && lane != 0) || (!found && lane == 0));
1802  assert(!std::isnan(lanePos));
1803  if (angle == INVALID_DOUBLE_VALUE) {
1804  if (lane != nullptr) {
1805  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
1806  } else {
1807  // compute angle outside road network from old and new position
1808  angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
1809  }
1810  }
1811  // use the best we have
1812 #ifdef DEBUG_MOVEXY
1813  std::cout << SIMTIME << " veh=" << vehID + " moveToXYResult lane='" << Named::getIDSecure(lane) << "' lanePos=" << lanePos << " lanePosLat=" << lanePosLat << "\n";
1814 #endif
1815  Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
1816  if (!veh->isOnRoad()) {
1818  }
1819  } else {
1820  if (lane == nullptr) {
1821  throw TraCIException("Could not map vehicle '" + vehID + "', no road found within " + toString(maxRouteDistance) + "m.");
1822  } else {
1823  throw TraCIException("Could not map vehicle '" + vehID + "', distance to road is " + toString(bestDistance) + ".");
1824  }
1825  }
1826 }
1827 
1828 void
1829 Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
1830  try {
1831  checkTimeBounds(duration);
1832  } catch (ProcessError&) {
1833  throw TraCIException("Duration parameter exceeds the time value range.");
1834  }
1835  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1836  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1837  if (veh == nullptr) {
1838  WRITE_ERROR("slowDown not applicable for meso");
1839  return;
1840  }
1841 
1842  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1843  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1844  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), speed));
1845  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1846 }
1847 
1848 void
1849 Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
1850  try {
1851  checkTimeBounds(duration);
1852  } catch (ProcessError&) {
1853  throw TraCIException("Duration parameter exceeds the time value range.");
1854  }
1855  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1856  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1857  if (veh == nullptr) {
1858  WRITE_ERROR("openGap not applicable for meso");
1859  return;
1860  }
1861 
1862  MSVehicle* refVeh = nullptr;
1863  if (referenceVehID != "") {
1864  refVeh = dynamic_cast<MSVehicle*>(Helper::getVehicle(referenceVehID));
1865  }
1866  const double originalTau = veh->getVehicleType().getCarFollowModel().getHeadwayTime();
1867  if (newTimeHeadway == -1) {
1868  newTimeHeadway = originalTau;
1869  }
1870  if (originalTau > newTimeHeadway) {
1871  WRITE_WARNING("Ignoring openGap(). New time headway must not be smaller than the original.");
1872  return;
1873  }
1874  veh->getInfluencer().activateGapController(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
1875 }
1876 
1877 void
1878 Vehicle::deactivateGapControl(const std::string& vehID) {
1879  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1880  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1881  if (veh == nullptr) {
1882  WRITE_ERROR("deactivateGapControl not applicable for meso");
1883  return;
1884  }
1885 
1886  if (veh->hasInfluencer()) {
1888  }
1889 }
1890 
1891 void
1892 Vehicle::requestToC(const std::string& vehID, double leadTime) {
1893  setParameter(vehID, "device.toc.requestToC", toString(leadTime));
1894 }
1895 
1896 void
1897 Vehicle::setSpeed(const std::string& vehID, double speed) {
1898  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1899  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1900  if (veh == nullptr) {
1901  WRITE_WARNING("setSpeed not yet implemented for meso");
1902  return;
1903  }
1904 
1905  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1906  if (speed >= 0) {
1907  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), speed));
1908  speedTimeLine.push_back(std::make_pair(SUMOTime_MAX - DELTA_T, speed));
1909  }
1910  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1911 }
1912 
1913 void
1914 Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
1915  try {
1916  checkTimeBounds(duration);
1917  } catch (ProcessError&) {
1918  throw TraCIException("Duration parameter exceeds the time value range.");
1919  }
1920  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1921  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1922  if (veh == nullptr) {
1923  WRITE_WARNING("setAcceleration not yet implemented for meso");
1924  return;
1925  }
1926 
1927  double targetSpeed = std::max(veh->getSpeed() + acceleration * duration, 0.0);
1928  std::vector<std::pair<SUMOTime, double>> speedTimeLine;
1929  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1930  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), targetSpeed));
1931  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1932 }
1933 
1934 void
1935 Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
1936  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1937  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1938  if (veh == nullptr) {
1939  WRITE_WARNING("setPreviousSpeed not yet implemented for meso");
1940  return;
1941  }
1942  if (prevAcceleration == INVALID_DOUBLE_VALUE) {
1943  prevAcceleration = std::numeric_limits<double>::min();
1944  }
1945  veh->setPreviousSpeed(prevSpeed, prevAcceleration);
1946 }
1947 
1948 void
1949 Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
1950  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1951  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1952  if (veh == nullptr) {
1953  WRITE_WARNING("setSpeedMode not yet implemented for meso");
1954  return;
1955  }
1956 
1957  veh->getInfluencer().setSpeedMode(speedMode);
1958 }
1959 
1960 void
1961 Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
1962  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1963  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1964  if (veh == nullptr) {
1965  WRITE_ERROR("setLaneChangeMode not applicable for meso");
1966  return;
1967  }
1968 
1969  veh->getInfluencer().setLaneChangeMode(laneChangeMode);
1970 }
1971 
1972 void
1973 Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
1974  Helper::getVehicle(vehID)->setRoutingMode(routingMode);
1975 }
1976 
1977 void
1978 Vehicle::setType(const std::string& vehID, const std::string& typeID) {
1979  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1980  if (vehicleType == nullptr) {
1981  throw TraCIException("Vehicle type '" + typeID + "' is not known");
1982  }
1983  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1984  veh->replaceVehicleType(vehicleType);
1985  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
1986  if (microVeh != nullptr && microVeh->isOnRoad()) {
1987  microVeh->updateBestLanes(true);
1988  microVeh->updateLaneBruttoSum();
1989  }
1990 }
1991 
1992 void
1993 Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
1994  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1995  ConstMSRoutePtr r = MSRoute::dictionary(routeID);
1996  if (r == nullptr) {
1997  throw TraCIException("The route '" + routeID + "' is not known.");
1998  }
2000  WRITE_WARNINGF(TL("Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
2001  }
2002  std::string msg;
2003  if (!veh->hasValidRoute(msg, r)) {
2004  WRITE_WARNINGF(TL("Invalid route replacement for vehicle '%'. %"), veh->getID(), msg);
2006  throw TraCIException("Route replacement failed for " + veh->getID());
2007  }
2008  }
2009 
2010  std::string errorMsg;
2011  if (!veh->replaceRoute(r, "traci:setRouteID", veh->getLane() == nullptr, 0, true, true, &errorMsg)) {
2012  throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
2013  }
2014 }
2015 
2016 void
2017 Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
2018  setRoute(vehID, std::vector<std::string>({edgeID}));
2019 }
2020 
2021 
2022 void
2023 Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
2024  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2025  ConstMSEdgeVector edges;
2026  const bool onInit = veh->getLane() == nullptr;
2027  try {
2028  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
2029  if (edges.size() > 0 && edges.front()->isInternal()) {
2030  if (edges.size() == 1) {
2031  // avoid crashing due to lack of normal edges in route (#5390)
2032  edges.push_back(edges.back()->getLanes()[0]->getNextNormal());
2033  } else {
2034  // avoid internal edge in final route
2035  if (edges.front() == &veh->getLane()->getEdge()) {
2036  edges.erase(edges.begin());
2037  }
2038  }
2039  }
2040  } catch (ProcessError& e) {
2041  throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
2042  }
2043  std::string errorMsg;
2044  if (!veh->replaceRouteEdges(edges, -1, 0, "traci:setRoute", onInit, true, true, &errorMsg)) {
2045  throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
2046  }
2047 }
2048 
2049 
2050 void
2051 Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
2052  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2053  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2054  if (veh != nullptr) {
2055  veh->setLateralPositionOnLane(posLat);
2056  } else {
2057  WRITE_ERROR("setLateralLanePosition not applicable for meso");
2058  }
2059 }
2060 
2061 
2062 void
2063 Vehicle::updateBestLanes(const std::string& vehID) {
2064  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2065  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2066  if (veh == nullptr) {
2067  WRITE_ERROR("updateBestLanes not applicable for meso");
2068  return;
2069  }
2070  if (veh->isOnRoad()) {
2071  veh->updateBestLanes(true);
2072  }
2073 }
2074 
2075 
2076 void
2077 Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
2078  double time, double begSeconds, double endSeconds) {
2079  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2080  MSEdge* edge = MSEdge::dictionary(edgeID);
2081  if (edge == nullptr) {
2082  throw TraCIException("Edge '" + edgeID + "' is not known.");
2083  }
2084  if (time != INVALID_DOUBLE_VALUE) {
2085  // add time
2086  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2087  // clean up old values before setting whole range
2088  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
2089  veh->getWeightsStorage().removeTravelTime(edge);
2090  }
2091  }
2092  veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
2093  } else {
2094  // remove time
2095  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
2096  veh->getWeightsStorage().removeTravelTime(edge);
2097  }
2098  }
2099 }
2100 
2101 
2102 void
2103 Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
2104  double effort, double begSeconds, double endSeconds) {
2105  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2106  MSEdge* edge = MSEdge::dictionary(edgeID);
2107  if (edge == nullptr) {
2108  throw TraCIException("Edge '" + edgeID + "' is not known.");
2109  }
2110  if (effort != INVALID_DOUBLE_VALUE) {
2111  // add effort
2112  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2113  // clean up old values before setting whole range
2114  while (veh->getWeightsStorage().knowsEffort(edge)) {
2115  veh->getWeightsStorage().removeEffort(edge);
2116  }
2117  }
2118  veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
2119  } else {
2120  // remove effort
2121  while (veh->getWeightsStorage().knowsEffort(edge)) {
2122  veh->getWeightsStorage().removeEffort(edge);
2123  }
2124  }
2125 }
2126 
2127 
2128 void
2129 Vehicle::rerouteTraveltime(const std::string& vehID, const bool currentTravelTimes) {
2130  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2131  const int routingMode = veh->getRoutingMode();
2132  if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
2134  }
2135  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteTraveltime",
2136  veh->getRouterTT(), isOnInit(vehID));
2137  if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
2138  veh->setRoutingMode(routingMode);
2139  }
2140 }
2141 
2142 
2143 void
2144 Vehicle::rerouteEffort(const std::string& vehID) {
2145  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2146  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteEffort",
2147  MSNet::getInstance()->getRouterEffort(veh->getRNGIndex()), isOnInit(vehID));
2148 }
2149 
2150 
2151 void
2152 Vehicle::setSignals(const std::string& vehID, int signals) {
2153  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2154  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2155  if (veh == nullptr) {
2156  WRITE_ERROR("setSignals not applicable for meso");
2157  return;
2158  }
2159 
2160  // set influencer to make the change persistent
2161  veh->getInfluencer().setSignals(signals);
2162  // set them now so that getSignals returns the correct value
2163  veh->switchOffSignal(0x0fffffff);
2164  if (signals >= 0) {
2165  veh->switchOnSignal(signals);
2166  }
2167 }
2168 
2169 
2170 void
2171 Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double pos, int reason) {
2172  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2173  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2174  if (veh == nullptr) {
2175  WRITE_WARNING("moveTo not yet implemented for meso");
2176  return;
2177  }
2178 
2179  MSLane* l = MSLane::dictionary(laneID);
2180  if (l == nullptr) {
2181  throw TraCIException("Unknown lane '" + laneID + "'.");
2182  }
2183  if (veh->getLane() == l) {
2185  return;
2186  }
2187  MSEdge* destinationEdge = &l->getEdge();
2188  const MSEdge* destinationRouteEdge = destinationEdge->getNormalBefore();
2189  if (!veh->isOnRoad() && veh->getParameter().wasSet(VEHPARS_FORCE_REROUTE) && veh->getRoute().getEdges().size() == 2) {
2190  // it's a trip that wasn't routeted yet (likely because the vehicle was added in this step. Find a route now
2191  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:moveTo-tripInsertion",
2192  veh->getRouterTT(), true);
2193  }
2194  // find edge in the remaining route
2195  MSRouteIterator it = std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), destinationRouteEdge);
2196  if (it == veh->getRoute().end()) {
2197  // find edge in the edges that were already passed
2198  it = std::find(veh->getRoute().begin(), veh->getRoute().end(), destinationRouteEdge);
2199  }
2200  if (it == veh->getRoute().end() ||
2201  // internal edge must continue the route
2202  (destinationEdge->isInternal() &&
2203  ((it + 1) == veh->getRoute().end()
2204  || l->getNextNormal() != *(it + 1)))) {
2205  throw TraCIException("Lane '" + laneID + "' is not on the route of vehicle '" + vehID + "'.");
2206  }
2207  Position oldPos = vehicle->getPosition();
2209  if (veh->getLane() != nullptr) {
2210  // correct odometer which gets incremented via onRemovalFromNet->leaveLane
2211  veh->addToOdometer(-veh->getLane()->getLength());
2213  } else {
2214  veh->setTentativeLaneAndPosition(l, pos);
2215  }
2216  const int oldRouteIndex = veh->getRoutePosition();
2217  const int newRouteIndex = (int)(it - veh->getRoute().begin());
2218  if (oldRouteIndex > newRouteIndex) {
2219  // more odometer correction needed
2220  veh->addToOdometer(-l->getLength());
2221  }
2222  veh->resetRoutePosition(newRouteIndex, veh->getParameter().departLaneProcedure);
2223  if (!veh->isOnRoad()) {
2226  }
2227  MSMoveReminder::Notification moveReminderReason;
2228  if (veh->hasDeparted()) {
2229  if (reason == MOVE_TELEPORT) {
2230  moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
2231  } else if (reason == MOVE_NORMAL) {
2232  moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
2233  } else if (reason == MOVE_AUTOMATIC) {
2234  Position newPos = l->geometryPositionAtOffset(pos);
2235  const double dist = newPos.distanceTo2D(oldPos);
2236  if (dist < SPEED2DIST(veh->getMaxSpeed())) {
2237  moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
2238  } else {
2239  moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
2240  }
2241  } else {
2242  throw TraCIException("Invalid moveTo reason '" + toString(reason) + "' for vehicle '" + vehID + "'.");
2243  }
2244  } else {
2245  moveReminderReason = MSMoveReminder::NOTIFICATION_DEPARTED;
2246  }
2247  l->forceVehicleInsertion(veh, pos, moveReminderReason);
2248 }
2249 
2250 
2251 void
2252 Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
2253  if (actionStepLength < 0.0) {
2254  WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
2255  return;
2256  }
2257  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2258  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2259  if (veh == nullptr) {
2260  WRITE_ERROR("setActionStepLength not applicable for meso");
2261  return;
2262  }
2263 
2264  if (actionStepLength == 0.) {
2265  veh->resetActionOffset();
2266  } else {
2267  veh->setActionStepLength(actionStepLength, resetActionOffset);
2268  }
2269 }
2270 
2271 
2272 void
2273 Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration) {
2274  try {
2275  checkTimeBounds(boardingDuration);
2276  } catch (ProcessError&) {
2277  throw TraCIException("BoardingDuration parameter exceeds the time value range.");
2278  }
2280 }
2281 
2282 
2283 void
2284 Vehicle::setImpatience(const std::string& vehID, double impatience) {
2285  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2286  const double normalImpatience = vehicle->getImpatience();
2287  vehicle->getBaseInfluencer().setExtraImpatience(impatience - normalImpatience);
2288 }
2289 
2290 
2291 void
2292 Vehicle::remove(const std::string& vehID, char reason) {
2293  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2295  switch (reason) {
2296  case REMOVE_TELEPORT:
2297  // XXX semantics unclear
2298  // n = MSMoveReminder::NOTIFICATION_TELEPORT;
2300  break;
2301  case REMOVE_PARKING:
2302  // XXX semantics unclear
2303  // n = MSMoveReminder::NOTIFICATION_PARKING;
2305  break;
2306  case REMOVE_ARRIVED:
2308  break;
2309  case REMOVE_VAPORIZED:
2311  break;
2314  break;
2315  default:
2316  throw TraCIException("Unknown removal status.");
2317  }
2318  if (veh->hasDeparted()) {
2319  veh->onRemovalFromNet(n);
2320  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2321  if (microVeh != nullptr) {
2322  if (veh->getLane() != nullptr) {
2323  microVeh->getMutableLane()->removeVehicle(dynamic_cast<MSVehicle*>(veh), n);
2324  }
2326  }
2328  } else {
2331  }
2332 }
2333 
2334 
2335 void
2336 Vehicle::setColor(const std::string& vehID, const TraCIColor& col) {
2338  p.color.set((unsigned char)col.r, (unsigned char)col.g, (unsigned char)col.b, (unsigned char)col.a);
2340 }
2341 
2342 
2343 void
2344 Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
2345  Helper::getVehicle(vehID)->setChosenSpeedFactor(factor);
2346 }
2347 
2348 
2349 void
2350 Vehicle::setLine(const std::string& vehID, const std::string& line) {
2351  Helper::getVehicle(vehID)->getParameter().line = line;
2352 }
2353 
2354 
2355 void
2356 Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
2357  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2358  try {
2359  // ensure edges exist
2360  ConstMSEdgeVector edges;
2361  MSEdge::parseEdgesList(edgeList, edges, "<via-edges>");
2362  } catch (ProcessError& e) {
2363  throw TraCIException(e.what());
2364  }
2365  veh->getParameter().via = edgeList;
2366 }
2367 
2368 
2369 void
2370 Vehicle::setLength(const std::string& vehID, double length) {
2371  Helper::getVehicle(vehID)->getSingularType().setLength(length);
2372 }
2373 
2374 
2375 void
2376 Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
2378 }
2379 
2380 
2381 void
2382 Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
2383  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2385  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2386  if (microVeh != nullptr && microVeh->isOnRoad()) {
2387  microVeh->updateBestLanes(true);
2388  }
2389 }
2390 
2391 
2392 void
2393 Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
2395 }
2396 
2397 
2398 void
2399 Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
2401 }
2402 
2403 
2404 void
2405 Vehicle::setWidth(const std::string& vehID, double width) {
2406  Helper::getVehicle(vehID)->getSingularType().setWidth(width);
2407 }
2408 
2409 
2410 void
2411 Vehicle::setHeight(const std::string& vehID, double height) {
2412  Helper::getVehicle(vehID)->getSingularType().setHeight(height);
2413 }
2414 
2415 
2416 void
2417 Vehicle::setMass(const std::string& vehID, double mass) {
2418  Helper::getVehicle(vehID)->getSingularType().setMass(mass);
2419 }
2420 
2421 
2422 void
2423 Vehicle::setMinGap(const std::string& vehID, double minGap) {
2424  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2425  veh->getSingularType().setMinGap(minGap);
2426  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2427  if (microVeh != nullptr && microVeh->isOnRoad()) {
2428  microVeh->updateLaneBruttoSum();
2429  }
2430 }
2431 
2432 
2433 void
2434 Vehicle::setAccel(const std::string& vehID, double accel) {
2435  Helper::getVehicle(vehID)->getSingularType().setAccel(accel);
2436 }
2437 
2438 
2439 void
2440 Vehicle::setDecel(const std::string& vehID, double decel) {
2441  VehicleType::setDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2442 }
2443 
2444 
2445 void
2446 Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
2447  VehicleType::setEmergencyDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2448 }
2449 
2450 
2451 void
2452 Vehicle::setApparentDecel(const std::string& vehID, double decel) {
2454 }
2455 
2456 
2457 void
2458 Vehicle::setImperfection(const std::string& vehID, double imperfection) {
2459  Helper::getVehicle(vehID)->getSingularType().setImperfection(imperfection);
2460 }
2461 
2462 
2463 void
2464 Vehicle::setTau(const std::string& vehID, double tau) {
2465  Helper::getVehicle(vehID)->getSingularType().setTau(tau);
2466 }
2467 
2468 
2469 void
2470 Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
2471  try {
2472  setParameter(vehID, "laneChangeModel.minGapLat", toString(minGapLat));
2473  } catch (TraCIException&) {
2474  // legacy behavior
2475  Helper::getVehicle(vehID)->getSingularType().setMinGapLat(minGapLat);
2476  }
2477 }
2478 
2479 
2480 void
2481 Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
2483 }
2484 
2485 
2486 void
2487 Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
2488  double lao;
2490  if (SUMOVTypeParameter::parseLatAlignment(latAlignment, lao, lad)) {
2492  } else {
2493  throw TraCIException("Unknown value '" + latAlignment + "' when setting latAlignment for vehID '" + vehID + "';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
2494  }
2495 }
2496 
2497 
2498 void
2499 Vehicle::setParameter(const std::string& vehID, const std::string& key, const std::string& value) {
2500  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2501  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2502  if (StringUtils::startsWith(key, "device.")) {
2503  StringTokenizer tok(key, ".");
2504  if (tok.size() < 3) {
2505  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehID + "'");
2506  }
2507  try {
2508  veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
2509  } catch (InvalidArgument& e) {
2510  throw TraCIException("Vehicle '" + vehID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
2511  }
2512  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
2513  if (microVeh == nullptr) {
2514  throw TraCIException("Meso Vehicle '" + vehID + "' does not support laneChangeModel parameters.");
2515  }
2516  const std::string attrName = key.substr(16);
2517  try {
2518  microVeh->getLaneChangeModel().setParameter(attrName, value);
2519  } catch (InvalidArgument& e) {
2520  throw TraCIException("Vehicle '" + vehID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
2521  }
2522  } else if (StringUtils::startsWith(key, "carFollowModel.")) {
2523  if (microVeh == nullptr) {
2524  throw TraCIException("Meso Vehicle '" + vehID + "' does not support carFollowModel parameters.");
2525  }
2526  try {
2527  veh->setCarFollowModelParameter(key, value);
2528  } catch (InvalidArgument& e) {
2529  throw TraCIException("Vehicle '" + vehID + "' does not support carFollowModel parameter '" + key + "' (" + e.what() + ").");
2530  }
2531  } else if (StringUtils::startsWith(key, "junctionModel.")) {
2532  try {
2533  // use the whole key (including junctionModel prefix)
2534  veh->setJunctionModelParameter(key, value);
2535  } catch (InvalidArgument& e) {
2536  // error message includes id since it is also used for xml input
2537  throw TraCIException(e.what());
2538  }
2539  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
2540  StringTokenizer tok(key, ".");
2541  if (tok.size() != 3) {
2542  throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
2543  }
2544  const std::string deviceName = tok.get(1);
2545  bool create;
2546  try {
2547  create = StringUtils::toBool(value);
2548  } catch (BoolFormatException&) {
2549  throw TraCIException("Changing device status requires a 'true' or 'false'");
2550  }
2551  if (!create) {
2552  throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
2553  }
2554  try {
2555  veh->createDevice(deviceName);
2556  } catch (InvalidArgument& e) {
2557  throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
2558  }
2559  } else {
2560  ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
2561  }
2562 }
2563 
2564 
2565 void
2566 Vehicle::highlight(const std::string& vehID, const TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
2567 
2568  // NOTE: Code is duplicated in large parts in POI.cpp
2569  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2570 
2571  // Center of the highlight circle
2572  Position center = veh->getPosition();
2573  const double l2 = veh->getLength() * 0.5;
2574  center.sub(cos(veh->getAngle())*l2, sin(veh->getAngle())*l2);
2575  // Size of the highlight circle
2576  if (size <= 0) {
2577  size = veh->getLength() * 0.7;
2578  }
2579  // Make polygon shape
2580  const unsigned int nPoints = 34;
2581  const PositionVector circlePV = GeomHelper::makeRing(size, size + 1., center, nPoints);
2582  TraCIPositionVector circle = Helper::makeTraCIPositionVector(circlePV);
2583 
2584 #ifdef DEBUG_DYNAMIC_SHAPES
2585  std::cout << SIMTIME << " Vehicle::highlight() for vehicle '" << vehID << "'\n"
2586  << " circle: " << circlePV << std::endl;
2587 #endif
2588 
2589  // Find a free polygon id
2590  int i = 0;
2591  std::string polyID = veh->getID() + "_hl" + toString(i);
2592  while (Polygon::exists(polyID)) {
2593  polyID = veh->getID() + "_hl" + toString(++i);
2594  }
2595  // Line width
2596  double lw = 0.;
2597  // Layer
2598  double lyr = 0.;
2599  if (MSNet::getInstance()->isGUINet()) {
2600  lyr = GLO_VEHICLE + 0.01;
2601  lyr += (type + 1) / 257.;
2602  }
2603  // Make Polygon
2604  Polygon::addHighlightPolygon(vehID, type, polyID, circle, col, true, "highlight", (int)lyr, lw);
2605 
2606  // Animation time line
2607  double maxAttack = 1.0; // maximal fade-in time
2608  std::vector<double> timeSpan;
2609  if (duration > 0.) {
2610  timeSpan = {0, MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
2611  }
2612  // Alpha time line
2613  std::vector<double> alphaSpan;
2614  if (alphaMax > 0.) {
2615  alphaSpan = {0., (double) alphaMax, (double)(alphaMax) / 3., 0.};
2616  }
2617  // Attach dynamics
2618  Polygon::addDynamics(polyID, vehID, timeSpan, alphaSpan, false, true);
2619 }
2620 
2621 void
2622 Vehicle::dispatchTaxi(const std::string& vehID, const std::vector<std::string>& reservations) {
2623  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2624  MSDevice_Taxi* taxi = static_cast<MSDevice_Taxi*>(veh->getDevice(typeid(MSDevice_Taxi)));
2625  if (!veh->hasDeparted()) {
2626  throw TraCIException("Vehicle '" + vehID + "' has not yet departed");
2627  }
2628  if (taxi == nullptr) {
2629  throw TraCIException("Vehicle '" + vehID + "' is not a taxi");
2630  }
2632  if (dispatcher == nullptr) {
2633  throw TraCIException("Cannot dispatch taxi because no reservations have been made");
2634  }
2635  MSDispatch_TraCI* traciDispatcher = dynamic_cast<MSDispatch_TraCI*>(dispatcher);
2636  if (traciDispatcher == nullptr) {
2637  throw TraCIException("device.taxi.dispatch-algorithm 'traci' has not been loaded");
2638  }
2639  if (reservations.size() == 0) {
2640  throw TraCIException("No reservations have been specified for vehicle '" + vehID + "'");
2641  }
2642  try {
2643  traciDispatcher->interpretDispatch(taxi, reservations);
2644  } catch (InvalidArgument& e) {
2645  throw TraCIException("Could not interpret reservations for vehicle '" + vehID + "' (" + e.what() + ").");
2646  }
2647 }
2648 
2650 
2651 
2652 void
2653 Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
2654  subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
2655  libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
2656 }
2657 
2658 
2659 void
2660 Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
2662  if (s != nullptr) {
2663  s->filterLanes = lanes;
2664  }
2665  if (noOpposite) {
2666  addSubscriptionFilterNoOpposite();
2667  }
2668  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2669  addSubscriptionFilterDownstreamDistance(downstreamDist);
2670  }
2671  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2672  addSubscriptionFilterUpstreamDistance(upstreamDist);
2673  }
2674 }
2675 
2676 
2677 void
2678 Vehicle::addSubscriptionFilterNoOpposite() {
2680 }
2681 
2682 
2683 void
2684 Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
2686  if (s != nullptr) {
2687  s->filterDownstreamDist = dist;
2688  }
2689 }
2690 
2691 
2692 void
2693 Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
2695  if (s != nullptr) {
2696  s->filterUpstreamDist = dist;
2697  }
2698 }
2699 
2700 
2701 void
2702 Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
2703  addSubscriptionFilterLeadFollow(std::vector<int>({0}));
2704  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2705  addSubscriptionFilterDownstreamDistance(downstreamDist);
2706  }
2707  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2708  addSubscriptionFilterUpstreamDistance(upstreamDist);
2709  }
2710 
2711 }
2712 
2713 
2714 void
2715 Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
2716  std::vector<int> lanes;
2717  if (direction == INVALID_INT_VALUE) {
2718  // Using default: both directions
2719  lanes = std::vector<int>({-1, 0, 1});
2720  } else if (direction != -1 && direction != 1) {
2721  WRITE_WARNINGF(TL("Ignoring lane change subscription filter with non-neighboring lane offset direction=%."), direction);
2722  } else {
2723  lanes = std::vector<int>({0, direction});
2724  }
2725  addSubscriptionFilterLeadFollow(lanes);
2726  if (noOpposite) {
2727  addSubscriptionFilterNoOpposite();
2728  }
2729  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2730  addSubscriptionFilterDownstreamDistance(downstreamDist);
2731  }
2732  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2733  addSubscriptionFilterUpstreamDistance(upstreamDist);
2734  }
2735 }
2736 
2737 
2738 void
2739 Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
2741  addSubscriptionFilterLanes(lanes);
2742 }
2743 
2744 
2745 void
2746 Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
2748  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2749  addSubscriptionFilterDownstreamDistance(downstreamDist);
2750  }
2751  if (foeDistToJunction != INVALID_DOUBLE_VALUE) {
2752  s->filterFoeDistToJunction = foeDistToJunction;
2753  }
2754 }
2755 
2756 
2757 void
2758 Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
2760  if (s != nullptr) {
2761  s->filterVClasses = parseVehicleClasses(vClasses);
2762  }
2763 }
2764 
2765 
2766 void
2767 Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
2769  if (s != nullptr) {
2770  s->filterVTypes.insert(vTypes.begin(), vTypes.end());
2771  }
2772 }
2773 
2774 
2775 void
2776 Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
2778  if (s != nullptr) {
2779  s->filterFieldOfVisionOpeningAngle = openingAngle;
2780  }
2781 }
2782 
2783 
2784 void
2785 Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
2787  if (s != nullptr) {
2788  s->filterLateralDist = lateralDist;
2789  }
2790  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2791  addSubscriptionFilterDownstreamDistance(downstreamDist);
2792  }
2793  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2794  addSubscriptionFilterUpstreamDistance(upstreamDist);
2795  }
2796 }
2797 
2798 
2799 void
2800 Vehicle::storeShape(const std::string& id, PositionVector& shape) {
2801  shape.push_back(Helper::getVehicle(id)->getPosition());
2802 }
2803 
2804 
2805 std::shared_ptr<VariableWrapper>
2806 Vehicle::makeWrapper() {
2807  return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
2808 }
2809 
2810 
2811 bool
2812 Vehicle::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData) {
2813  switch (variable) {
2814  case TRACI_ID_LIST:
2815  return wrapper->wrapStringList(objID, variable, getIDList());
2816  case ID_COUNT:
2817  return wrapper->wrapInt(objID, variable, getIDCount());
2818  case VAR_POSITION:
2819  return wrapper->wrapPosition(objID, variable, getPosition(objID));
2820  case VAR_POSITION3D:
2821  return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
2822  case VAR_ANGLE:
2823  return wrapper->wrapDouble(objID, variable, getAngle(objID));
2824  case VAR_SPEED:
2825  return wrapper->wrapDouble(objID, variable, getSpeed(objID));
2826  case VAR_SPEED_LAT:
2827  return wrapper->wrapDouble(objID, variable, getLateralSpeed(objID));
2828  case VAR_ROAD_ID:
2829  return wrapper->wrapString(objID, variable, getRoadID(objID));
2831  return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
2832  case VAR_SLOPE:
2833  return wrapper->wrapDouble(objID, variable, getSlope(objID));
2834  case VAR_LANE_ID:
2835  return wrapper->wrapString(objID, variable, getLaneID(objID));
2836  case VAR_LANE_INDEX:
2837  return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
2838  case VAR_SEGMENT_ID:
2839  return wrapper->wrapString(objID, variable, getSegmentID(objID));
2840  case VAR_SEGMENT_INDEX:
2841  return wrapper->wrapInt(objID, variable, getSegmentIndex(objID));
2842  case VAR_TYPE:
2843  return wrapper->wrapString(objID, variable, getTypeID(objID));
2844  case VAR_ROUTE_ID:
2845  return wrapper->wrapString(objID, variable, getRouteID(objID));
2846  case VAR_DEPARTURE:
2847  return wrapper->wrapDouble(objID, variable, getDeparture(objID));
2848  case VAR_DEPART_DELAY:
2849  return wrapper->wrapDouble(objID, variable, getDepartDelay(objID));
2850  case VAR_ROUTE_INDEX:
2851  return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
2852  case VAR_COLOR:
2853  return wrapper->wrapColor(objID, variable, getColor(objID));
2854  case VAR_LANEPOSITION:
2855  return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
2856  case VAR_LANEPOSITION_LAT:
2857  return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
2858  case VAR_CO2EMISSION:
2859  return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
2860  case VAR_COEMISSION:
2861  return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
2862  case VAR_HCEMISSION:
2863  return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
2864  case VAR_PMXEMISSION:
2865  return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
2866  case VAR_NOXEMISSION:
2867  return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
2868  case VAR_FUELCONSUMPTION:
2869  return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
2870  case VAR_NOISEEMISSION:
2871  return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
2873  return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
2874  case VAR_PERSON_NUMBER:
2875  return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
2876  case VAR_PERSON_CAPACITY:
2877  return wrapper->wrapInt(objID, variable, getPersonCapacity(objID));
2878  case VAR_BOARDING_DURATION:
2879  return wrapper->wrapDouble(objID, variable, getBoardingDuration(objID));
2881  return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
2882  case VAR_WAITING_TIME:
2883  return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
2885  return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
2886  case VAR_ROUTE_VALID:
2887  return wrapper->wrapInt(objID, variable, isRouteValid(objID));
2888  case VAR_EDGES:
2889  return wrapper->wrapStringList(objID, variable, getRoute(objID));
2890  case VAR_SIGNALS:
2891  return wrapper->wrapInt(objID, variable, getSignals(objID));
2892  case VAR_STOPSTATE:
2893  return wrapper->wrapInt(objID, variable, getStopState(objID));
2894  case VAR_DISTANCE:
2895  return wrapper->wrapDouble(objID, variable, getDistance(objID));
2896  case VAR_ALLOWED_SPEED:
2897  return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
2898  case VAR_SPEED_FACTOR:
2899  return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
2900  case VAR_SPEEDSETMODE:
2901  return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
2902  case VAR_LANECHANGE_MODE:
2903  return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
2904  case VAR_ROUTING_MODE:
2905  return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
2906  case VAR_LINE:
2907  return wrapper->wrapString(objID, variable, getLine(objID));
2908  case VAR_VIA:
2909  return wrapper->wrapStringList(objID, variable, getVia(objID));
2910  case VAR_ACCELERATION:
2911  return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
2912  case VAR_LASTACTIONTIME:
2913  return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
2914  case VAR_STOP_DELAY:
2915  return wrapper->wrapDouble(objID, variable, getStopDelay(objID));
2916  case VAR_IMPATIENCE:
2917  return wrapper->wrapDouble(objID, variable, getImpatience(objID));
2918  case VAR_STOP_ARRIVALDELAY:
2919  return wrapper->wrapDouble(objID, variable, getStopArrivalDelay(objID));
2920  case VAR_TIMELOSS:
2921  return wrapper->wrapDouble(objID, variable, getTimeLoss(objID));
2922  case VAR_MINGAP_LAT:
2923  return wrapper->wrapDouble(objID, variable, getMinGapLat(objID));
2924  case VAR_LEADER: {
2925  paramData->readUnsignedByte();
2926  const double dist = paramData->readDouble();
2927  return wrapper->wrapStringDoublePair(objID, variable, getLeader(objID, dist));
2928  }
2929  case VAR_FOLLOWER: {
2930  paramData->readUnsignedByte();
2931  const double dist = paramData->readDouble();
2932  return wrapper->wrapStringDoublePair(objID, variable, getFollower(objID, dist));
2933  }
2934  case VAR_LOADED_LIST:
2935  return wrapper->wrapStringList(objID, variable, getLoadedIDList());
2936  case VAR_TELEPORTING_LIST:
2937  return wrapper->wrapStringList(objID, variable, getTeleportingIDList());
2939  paramData->readUnsignedByte();
2940  return wrapper->wrapString(objID, variable, getParameter(objID, paramData->readString()));
2942  paramData->readUnsignedByte();
2943  return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->readString()));
2944  case VAR_TAXI_FLEET:
2945  // we cannot use the general fall through here because we do not have an object id
2946  return false;
2947  default:
2948  return VehicleType::handleVariableWithID(objID, getTypeID(objID), variable, wrapper, paramData);
2949  }
2950 }
2951 
2952 
2953 }
2954 
2955 
2956 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
@ GLO_VEHICLE
a vehicle
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:32
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:56
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:31
void checkTimeBounds(const double time)
check the valid SUMOTime range of double input and throw an error if out of bounds
Definition: SUMOTime.cpp:150
SUMOTime DELTA_T
Definition: SUMOTime.cpp:38
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:46
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 SPEED2DIST(x)
Definition: SUMOTime.h:45
#define SUMOTime_MAX
Definition: SUMOTime.h:34
#define SIMTIME
Definition: SUMOTime.h:62
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int VEHPARS_COLOR_SET
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const int VEHPARS_TO_TAZ_SET
const int STOP_SPEED_SET
const int STOP_UNTIL_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const int VEHPARS_DEPARTPOS_SET
const int STOP_PERMITTED_SET
const int VEHPARS_ARRIVALLANE_SET
const int VEHPARS_DEPARTLANE_SET
const int STOP_SPLIT_SET
const int STOP_START_SET
const int VEHPARS_FROM_TAZ_SET
const int STOP_JOIN_SET
const int VEHPARS_ARRIVALSPEED_SET
const int STOP_EXTENSION_SET
const int VEHPARS_FORCE_REROUTE
const int STOP_ENDED_SET
const int STOP_TRIGGER_SET
const int STOP_JUMP_SET
const int STOP_ONDEMAND_SET
const int STOP_END_SET
const int VEHPARS_LINE_SET
const int STOP_STARTED_SET
const int VEHPARS_PERSON_NUMBER_SET
const int STOP_EXPECTED_CONTAINERS_SET
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_VTYPE_SET
const int VEHPARS_ARRIVALPOS_SET
@ GIVEN
The time is given.
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
@ LCA_UNKNOWN
The action has not been determined.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_PARKING
@ SUMO_ATTR_EXTENSION
@ SUMO_ATTR_LANE
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_SPLIT
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_POSITION_LAT
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_ONDEMAND
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_PERMITTED
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_JUMP
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
T MIN2(T a, T b)
Definition: StdDefs.h:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:283
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
Definition: TraCIDefs.h:76
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
Definition: TraCIDefs.h:123
std::vector< double > & getParameter()
Returns the parameters of this distribution.
static PositionVector makeRing(const double radius1, const double radius2, const Position &center, unsigned int nPoints)
Definition: GeomHelper.cpp:252
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:50
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:191
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:42
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition: MEVehicle.h:228
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
Definition: MEVehicle.h:202
virtual double getSafetyFactor() const
return factor for modifying the safety constraints of the car-following model
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
void setExtraImpatience(double value)
Sets routing behavior.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:57
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
double getImpatience() const
Returns this vehicles impatience.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
virtual BaseInfluencer & getBaseInfluencer()=0
Returns the velocity/lane influencer.
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
void setCarFollowModelParameter(const std::string &key, const std::string &value)
set individual carFollow model parameters (not type related)
void setRoutingMode(int value)
Sets routing behavior.
virtual double getStopDelay() const
Returns the estimated public transport stop (departure) delay in seconds.
bool rerouteBetweenStops(int nextStopIndex, const std::string &info, bool teleport, std::string &errorMsg)
const std::list< MSStop > & getStops() const
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
virtual std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual double getTimeLossSeconds() const
Returns the time loss in seconds.
double getOdometer() const
Returns the distance that was already driven by this vehicle.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
virtual void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const
Validates the current or given route.
virtual void onRemovalFromNet(const MSMoveReminder::Notification)
Called when the vehicle is removed from the network.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
int getPersonNumber() const
Returns the number of persons.
virtual std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
bool hasDeparted() const
Returns whether this vehicle has already departed.
MSStop & getNextStop()
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
void addToOdometer(double value)
Manipulate the odometer.
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
MSStop & getStop(int nextStopIndex)
bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
int getRoutingMode() const
return routing mode (configures router choice but also handling of transient permission changes)
int getRoutePosition() const
return index of edge within route
double getEmissions() const
Returns emissions of the current state The value is always per 1s, so multiply by step length if nece...
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const std::vector< SUMOVehicleParameter::Stop > & getPastStops() const
const MSRoute & getRoute() const
Returns the current route.
bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)
Performs a rerouting using the given router.
int getRNGIndex() const
void createDevice(const std::string &deviceName)
create device of the given type
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given edges.
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
Definition: MSCFModel.h:272
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
Definition: MSCFModel.cpp:166
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
Definition: MSCFModel.h:280
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Definition: MSCFModel.h:256
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition: MSCFModel.h:380
virtual double getImperfection() const
Get the driver's imperfection.
Definition: MSCFModel.h:303
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:264
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
Definition: MSCFModel.h:168
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
Definition: MSCFModel.h:311
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Taxi.h:49
static const std::vector< MSDevice_Taxi * > & getFleet()
static MSDispatch * getDispatchAlgorithm()
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
void interpretDispatch(MSDevice_Taxi *taxi, const std::vector< std::string > &reservationsIDs)
trigger taxi dispatch.
An algorithm that performs distpach for a taxi fleet.
Definition: MSDispatch.h:112
A road/street connecting two junctions.
Definition: MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:1034
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition: MSEdge.cpp:1058
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:479
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
double getLength() const
return the length of the edge
Definition: MSEdge.h:670
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:268
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:995
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:1118
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
Definition: MSEdge.cpp:885
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
void addTravelTime(const MSEdge *const e, double begin, double end, double value)
Adds a travel time information for an edge and a time span.
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
void addEffort(const MSEdge *const e, double begin, double end, double value)
Adds an effort information for an edge and a time span.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
static bool gCheckRoutes
Definition: MSGlobals.h:88
static double gLateralResolution
Definition: MSGlobals.h:97
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:53
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
virtual const MSJunctionLogic * getLogic() const
Definition: MSJunction.h:141
virtual const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:716
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition: MSLane.cpp:2754
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2736
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:2600
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1340
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:584
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:2371
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition: MSLane.cpp:4045
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition: MSLane.h:845
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:634
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:4292
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:2395
bool isInternal() const
Definition: MSLane.cpp:2526
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:756
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition: MSLane.cpp:3706
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:627
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:552
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:294
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:144
void fixOppositeGaps(bool isFollower)
subtract vehicle length from all gaps if the leader vehicle is driving in the opposite direction
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
int numSublanes() const
Definition: MSLeaderInfo.h:86
bool hasVehicles() const
Definition: MSLeaderInfo.h:94
Notification
Definition of a vehicle state.
@ NOTIFICATION_VAPORIZED_TRACI
The vehicle got removed via TraCI.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:184
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:378
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:320
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:431
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:79
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:109
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:73
double getDistanceBetween(double fromPos, double toPos, const MSLane *fromLane, const MSLane *toLane, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
Definition: MSRoute.cpp:311
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
Definition: MSStop.h:44
const MSLane * lane
The lane to stop at (microsim only)
Definition: MSStop.h:50
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
Definition: MSStop.cpp:112
int getStateFlagsOld() const
return flags as used by Vehicle::getStopState
Definition: MSStop.cpp:128
bool reached
Information whether the stop has been reached.
Definition: MSStop.h:75
MSRouteIterator edge
The edge in the route to stop at.
Definition: MSStop.h:48
SUMOTime duration
The stopping duration.
Definition: MSStop.h:67
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSStop.h:65
void setLaneChangeMode(int value)
Sets lane changing behavior.
Definition: MSVehicle.cpp:791
void deactivateGapController()
Deactivates the gap control.
Definition: MSVehicle.cpp:413
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:780
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
Definition: MSVehicle.cpp:420
void setSublaneChange(double latDist)
Sets a new sublane-change request.
Definition: MSVehicle.cpp:434
void setSignals(int signals)
Definition: MSVehicle.h:1586
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:399
void activateGapController(double originalTau, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, MSVehicle *refVeh=nullptr)
Activates the gap control with the given parameters,.
Definition: MSVehicle.cpp:405
The class responsible for building and deletion of vehicles.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void removePending()
Removes a vehicle after it has ended.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:5798
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
Definition: MSVehicle.cpp:6318
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:608
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
Definition: MSVehicle.h:544
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
Definition: MSVehicle.cpp:6673
void setPreviousSpeed(double prevSpeed, double prevAcceleration)
Sets the influenced previous speed.
Definition: MSVehicle.cpp:7679
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5774
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Definition: MSVehicle.h:592
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:1244
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:6290
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:1045
bool resumeFromStopping()
Definition: MSVehicle.cpp:7186
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
Definition: MSVehicle.h:401
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
Definition: MSVehicle.cpp:2065
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
Definition: MSVehicle.cpp:7072
void switchOffSignal(int signal)
Switches the given signal off.
Definition: MSVehicle.h:1177
@ VEH_SIGNAL_NONE
Everything is switched off.
Definition: MSVehicle.h:1114
Influencer & getInfluencer()
Definition: MSVehicle.cpp:7251
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
Definition: MSVehicle.cpp:1449
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:416
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:493
void updateLaneBruttoSum()
Update the lane brutto occupancy after a change in minGap.
Definition: MSVehicle.cpp:6228
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:5792
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:377
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:584
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:977
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSVehicle.h:1685
void setLateralPositionOnLane(double posLat)
Definition: MSVehicle.h:420
void switchOnSignal(int signal)
Switches the given signal on.
Definition: MSVehicle.h:1169
int getLaneIndex() const
Definition: MSVehicle.cpp:6667
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void remove(MSVehicle *veh)
Remove a vehicle from this transfer object.
The car-following model and parameter.
Definition: MSVehicleType.h:63
void setHeight(const double &height)
Set a new value for this type's height.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
int getPersonCapacity() const
Get this vehicle type's person capacity.
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
double getMinGap() const
Get the free space in front of vehicles of this class.
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
void setBoardingDuration(SUMOTime duration, bool isPerson=true)
Set a new value for this type's boardingDuration.
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
void setLength(const double &length)
Set a new value for this type's length.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
void setAccel(double accel)
Set a new value for this type's acceleration.
void setWidth(const double &width)
Set a new value for this type's width.
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
void setTau(double tau)
Set a new value for this type's headway.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:91
double getLength() const
Get vehicle's length [m].
void setMass(double mass)
Set a new value for this type's mass.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
double getMass() const
Get this vehicle type's mass.
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:67
const std::string & getID() const
Returns the id.
Definition: Named.h:74
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:276
void sub(double dx, double dy)
Subtracts the given position from this one.
Definition: Position.h:152
void setz(double z)
set position z
Definition: Position.h:80
double z() const
Returns the z-position.
Definition: Position.h:65
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition: Position.h:286
A list of positions.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition: RGBColor.cpp:98
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual double getPreviousSpeed() const =0
Returns the object's previous speed.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
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 ...
static const SUMOVTypeParameter & getDefault()
return the default parameters, this is a function due to the http://www.parashift....
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
Representation of a vehicle.
Definition: SUMOVehicle.h:62
virtual int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)=0
computes validity attributes for the current route
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
int getFlags() const
return flags as per Vehicle::getStops
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at.
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::vector< std::string > getTriggers() const
write trigger attribute
std::set< std::string > permitted
IDs of persons or containers that may board/load at this stop.
int parametersSet
Information for the output which parameter were set.
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
std::string vtypeid
The vehicle's type id.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
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.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
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.
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 personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
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.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
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.
std::string id
The vehicle's id.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
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.
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
static ParkingType parseParkingType(const std::string &value)
parses parking type value
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
static bool isInternalRouteID(const std::string &id)
Checks whether the route ID uses the syntax of internal routes.
static StringBijection< LinkState > LinkStates
link states
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID
static StringBijection< LinkDirection > LinkDirections
link directions
const std::string & getString(const T key) const
std::set< std::string > getSet()
return set of strings
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 startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
C++ TraCI client API implementation.
Definition: Vehicle.h:34
static MSEdge * getEdge(const std::string &edgeID)
Definition: Helper.cpp:393
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition: Helper.cpp:377
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
Definition: Helper.cpp:1731
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
Definition: Helper.cpp:337
static MSBaseVehicle * getVehicle(const std::string &id)
Definition: Helper.cpp:477
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: Helper.cpp:360
static TraCINextStopData buildStopData(const SUMOVehicleParameter::Stop &stopPar)
Definition: Helper.cpp:643
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition: Helper.cpp:1383
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
Definition: Helper.cpp:512
static bool moveToXYMap(const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector &currentRoute, const int routePosition, const MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
Definition: Helper.cpp:1423
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition: Helper.cpp:420
static SUMOVehicleParameter::Stop buildStopParameters(const std::string &edgeOrStoppingPlaceID, double pos, int laneIndex, double startPos, int flags, double duration, double until)
Definition: Helper.cpp:537
static Subscription * addSubscriptionFilter(SubscriptionFilterType filter)
Definition: Helper.cpp:210
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition: Helper.cpp:403
virtual std::string readString()
Definition: storage.cpp:180
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual double readDouble()
Definition: storage.cpp:362
#define CALL_MESO_FUN(veh, fun, microResult)
#define CALL_MICRO_FUN(veh, fun, mesoResult)
#define DEBUG_COND
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int VAR_LASTACTIONTIME
TRACI_CONST int VAR_EDGES
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int MOVE_AUTOMATIC
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_SEGMENT_ID
TRACI_CONST int VAR_TYPE
TRACI_CONST int VAR_DEPARTURE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int VAR_LINE
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:338
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int MOVE_NORMAL
TRACI_CONST int VAR_TIMELOSS
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_STOP_ARRIVALDELAY
TRACI_CONST int VAR_SPEED_LAT
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_ALLOWED_SPEED
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int MOVE_TELEPORT
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_LEADER
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int VAR_TELEPORTING_LIST
TRACI_CONST int REMOVE_TELEPORT
TRACI_CONST int VAR_TAXI_FLEET
TRACI_CONST int VAR_ROUTE_VALID
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int VAR_FUELCONSUMPTION
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:337
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int REMOVE_PARKING
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_ROUTE_INDEX
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int REMOVE_ARRIVED
@ SUBS_FILTER_LEAD_FOLLOW
Definition: Subscription.h:49
@ SUBS_FILTER_UPSTREAM_DIST
Definition: Subscription.h:47
@ SUBS_FILTER_VTYPE
Definition: Subscription.h:55
@ SUBS_FILTER_LANES
Definition: Subscription.h:41
@ SUBS_FILTER_NOOPPOSITE
Definition: Subscription.h:43
@ SUBS_FILTER_DOWNSTREAM_DIST
Definition: Subscription.h:45
@ SUBS_FILTER_LATERAL_DIST
Definition: Subscription.h:60
@ SUBS_FILTER_TURN
Definition: Subscription.h:51
@ SUBS_FILTER_VCLASS
Definition: Subscription.h:53
@ SUBS_FILTER_FIELD_OF_VISION
Definition: Subscription.h:58
TRACI_CONST int VAR_SEGMENT_INDEX
TRACI_CONST int ROUTING_MODE_DEFAULT
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int VAR_STOP_DELAY
TRACI_CONST int REMOVE_TELEPORT_ARRIVED
TRACI_CONST int REMOVE_VAPORIZED
TRACI_CONST int VAR_STOPSTATE
TRACI_CONST int VAR_FOLLOWER
TRACI_CONST int VAR_LOADED_LIST
TRACI_CONST int VAR_DEPART_DELAY
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:335
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int ROUTING_MODE_AGGREGATED_CUSTOM
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int VAR_VIA
@ key
the parser read a key of a value in an object
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:21884
A structure representing the best lanes for continuing the current route starting at 'lane'.
Definition: MSVehicle.h:865