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 
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  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getIndex(), INVALID_INT_VALUE) : INVALID_INT_VALUE;
186 }
187 
188 
189 std::string
190 Vehicle::getTypeID(const std::string& vehID) {
191  return Helper::getVehicleType(vehID).getID();
192 }
193 
194 
195 std::string
196 Vehicle::getRouteID(const std::string& vehID) {
197  return Helper::getVehicle(vehID)->getRoute().getID();
198 }
199 
200 
201 double
202 Vehicle::getDeparture(const std::string& vehID) {
203  MSBaseVehicle* veh = Helper::getVehicle(vehID);
204  return veh->hasDeparted() ? STEPS2TIME(veh->getDeparture()) : INVALID_DOUBLE_VALUE;
205 }
206 
207 
208 double
209 Vehicle::getDepartDelay(const std::string& vehID) {
210  return STEPS2TIME(Helper::getVehicle(vehID)->getDepartDelay());
211 }
212 
213 
214 int
215 Vehicle::getRouteIndex(const std::string& vehID) {
216  MSBaseVehicle* veh = Helper::getVehicle(vehID);
217  return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
218 }
219 
220 
221 TraCIColor
222 Vehicle::getColor(const std::string& vehID) {
223  return Helper::makeTraCIColor(Helper::getVehicle(vehID)->getParameter().color);
224 }
225 
226 double
227 Vehicle::getLanePosition(const std::string& vehID) {
228  MSBaseVehicle* veh = Helper::getVehicle(vehID);
229  return veh->isOnRoad() ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
230 }
231 
232 double
233 Vehicle::getLateralLanePosition(const std::string& vehID) {
234  MSBaseVehicle* veh = Helper::getVehicle(vehID);
235  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLateralPositionOnLane(), 0) : INVALID_DOUBLE_VALUE;
236 }
237 
238 double
239 Vehicle::getCO2Emission(const std::string& vehID) {
240  MSBaseVehicle* veh = Helper::getVehicle(vehID);
241  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO2>() : INVALID_DOUBLE_VALUE;
242 }
243 
244 double
245 Vehicle::getCOEmission(const std::string& vehID) {
246  MSBaseVehicle* veh = Helper::getVehicle(vehID);
247  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO>() : INVALID_DOUBLE_VALUE;
248 }
249 
250 double
251 Vehicle::getHCEmission(const std::string& vehID) {
252  MSBaseVehicle* veh = Helper::getVehicle(vehID);
253  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::HC>() : INVALID_DOUBLE_VALUE;
254 }
255 
256 double
257 Vehicle::getPMxEmission(const std::string& vehID) {
258  MSBaseVehicle* veh = Helper::getVehicle(vehID);
259  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::PM_X>() : INVALID_DOUBLE_VALUE;
260 }
261 
262 double
263 Vehicle::getNOxEmission(const std::string& vehID) {
264  MSBaseVehicle* veh = Helper::getVehicle(vehID);
265  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::NO_X>() : INVALID_DOUBLE_VALUE;
266 }
267 
268 double
269 Vehicle::getFuelConsumption(const std::string& vehID) {
270  MSBaseVehicle* veh = Helper::getVehicle(vehID);
271  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::FUEL>() : INVALID_DOUBLE_VALUE;
272 }
273 
274 double
275 Vehicle::getNoiseEmission(const std::string& vehID) {
276  MSBaseVehicle* veh = Helper::getVehicle(vehID);
277  return isVisible(veh) ? veh->getHarmonoise_NoiseEmissions() : INVALID_DOUBLE_VALUE;
278 }
279 
280 double
281 Vehicle::getElectricityConsumption(const std::string& vehID) {
282  MSBaseVehicle* veh = Helper::getVehicle(vehID);
283  return isVisible(veh) ? veh->getEmissions<PollutantsInterface::ELEC>() : INVALID_DOUBLE_VALUE;
284 }
285 
286 int
287 Vehicle::getPersonNumber(const std::string& vehID) {
288  return Helper::getVehicle(vehID)->getPersonNumber();
289 }
290 
291 int
292 Vehicle::getPersonCapacity(const std::string& vehID) {
294 }
295 
296 
297 double
298 Vehicle::getBoardingDuration(const std::string& vehID) {
299  return STEPS2TIME(Helper::getVehicleType(vehID).getLoadingDuration(true));
300 }
301 
302 
303 std::vector<std::string>
304 Vehicle::getPersonIDList(const std::string& vehID) {
305  return Helper::getVehicle(vehID)->getPersonIDList();
306 }
307 
308 std::pair<std::string, double>
309 Vehicle::getLeader(const std::string& vehID, double dist) {
310  MSBaseVehicle* veh = Helper::getVehicle(vehID);
311  if (veh->isOnRoad()) {
312  std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist);
313  const std::string leaderID = leaderInfo.first != nullptr ? leaderInfo.first->getID() : "";
314  double gap = leaderInfo.second;
315  if (leaderInfo.first != nullptr
316  && leaderInfo.first->getLane() != nullptr
317  && leaderInfo.first->getLane()->isInternal()
318  && veh->getLane() != nullptr
319  && (!veh->getLane()->isInternal()
320  || (veh->getLane()->getLinkCont().front()->getIndex() != leaderInfo.first->getLane()->getLinkCont().front()->getIndex()))) {
321  // leader is a linkLeader (see MSLink::getLeaderInfo)
322  // avoid internal gap values which may be negative (or -inf)
323  gap = MAX2(0.0, gap);
324  }
325  return std::make_pair(leaderID, gap);
326  } else {
327  return std::make_pair("", -1);
328  }
329 }
330 
331 
332 std::pair<std::string, double>
333 Vehicle::getFollower(const std::string& vehID, double dist) {
334  MSBaseVehicle* veh = Helper::getVehicle(vehID);
335  if (veh->isOnRoad()) {
336  std::pair<const MSVehicle* const, double> leaderInfo = veh->getFollower(dist);
337  return std::make_pair(
338  leaderInfo.first != nullptr ? leaderInfo.first->getID() : "",
339  leaderInfo.second);
340  } else {
341  return std::make_pair("", -1);
342  }
343 }
344 
345 
346 std::vector<TraCIJunctionFoe>
347 Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
348  std::vector<TraCIJunctionFoe> result;
349  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
350  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
351  if (veh == nullptr) {
352  WRITE_WARNING("getJunctionFoes not applicable for meso");
353  } else if (veh->isOnRoad()) {
354  if (dist == 0) {
355  dist = veh->getCarFollowModel().brakeGap(veh->getSpeed()) + veh->getVehicleType().getMinGap();
356  }
357  const std::vector<const MSLane*> internalLanes;
358  // distance to the end of the lane
359  double curDist = -veh->getPositionOnLane();
360  for (const MSLane* lane : veh->getUpcomingLanesUntil(dist)) {
361  curDist += lane->getLength();
362  if (lane->isInternal()) {
363  const MSLink* exitLink = lane->getLinkCont().front();
364  int foeIndex = 0;
365  const std::vector<MSLink::ConflictInfo>& conflicts = exitLink->getConflicts();
366  const MSJunctionLogic* logic = exitLink->getJunction()->getLogic();
367  for (const MSLane* foeLane : exitLink->getFoeLanes()) {
368  const MSLink::ConflictInfo& ci = conflicts[foeIndex];
370  continue;
371  }
372  const double distBehindCrossing = ci.lengthBehindCrossing;
373  const MSLink* foeExitLink = foeLane->getLinkCont().front();
374  const double distToCrossing = curDist - distBehindCrossing;
375  const double foeDistBehindCrossing = ci.getFoeLengthBehindCrossing(foeExitLink);
376  for (auto item : foeExitLink->getApproaching()) {
377  const SUMOVehicle* foe = item.first;
378  TraCIJunctionFoe jf;
379  jf.foeId = foe->getID();
380  jf.egoDist = distToCrossing;
381  // approach information is from the start of the previous step
382  // but the foe vehicle then moved within that steop
383  const double prevFoeDist = SPEED2DIST(MSGlobals::gSemiImplicitEulerUpdate
384  ? foe->getSpeed()
385  : (foe->getSpeed() + foe->getPreviousSpeed()) / 2);
386  jf.foeDist = item.second.dist - foeDistBehindCrossing - prevFoeDist;
387  jf.egoExitDist = jf.egoDist + ci.conflictSize;
388  jf.foeExitDist = jf.foeDist + ci.getFoeConflictSize(foeExitLink);
389  jf.egoLane = lane->getID();
390  jf.foeLane = foeLane->getID();
391  jf.egoResponse = logic->getResponseFor(exitLink->getIndex()).test(foeExitLink->getIndex());
392  jf.foeResponse = logic->getResponseFor(foeExitLink->getIndex()).test(exitLink->getIndex());
393  result.push_back(jf);
394  }
395  foeIndex++;
396  }
397  }
398  }
399  }
400  return result;
401 }
402 
403 
404 double
405 Vehicle::getWaitingTime(const std::string& vehID) {
406  return STEPS2TIME(Helper::getVehicle(vehID)->getWaitingTime());
407 }
408 
409 
410 double
411 Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
412  MSBaseVehicle* veh = Helper::getVehicle(vehID);
413  return CALL_MICRO_FUN(veh, getAccumulatedWaitingSeconds(), INVALID_DOUBLE_VALUE);
414 }
415 
416 
417 double
418 Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
419  MSEdge* edge = Helper::getEdge(edgeID);
420  double value = INVALID_DOUBLE_VALUE;
422  return value;
423 }
424 
425 
426 double
427 Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
428  MSEdge* edge = Helper::getEdge(edgeID);
429  double value = INVALID_DOUBLE_VALUE;
430  Helper::getVehicle(vehID)->getWeightsStorage().retrieveExistingEffort(edge, time, value);
431  return value;
432 }
433 
434 
435 bool
436 Vehicle::isRouteValid(const std::string& vehID) {
437  std::string msg;
438  return Helper::getVehicle(vehID)->hasValidRoute(msg);
439 }
440 
441 
442 std::vector<std::string>
443 Vehicle::getRoute(const std::string& vehID) {
444  std::vector<std::string> result;
445  MSBaseVehicle* veh = Helper::getVehicle(vehID);
446  const MSRoute& r = veh->getRoute();
447  for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
448  result.push_back((*i)->getID());
449  }
450  return result;
451 }
452 
453 
454 int
455 Vehicle::getSignals(const std::string& vehID) {
456  MSBaseVehicle* veh = Helper::getVehicle(vehID);
457  return CALL_MICRO_FUN(veh, getSignals(), MSVehicle::VEH_SIGNAL_NONE);
458 }
459 
460 
461 std::vector<TraCIBestLanesData>
462 Vehicle::getBestLanes(const std::string& vehID) {
463  std::vector<TraCIBestLanesData> result;
464  MSVehicle* veh = dynamic_cast<MSVehicle*>(Helper::getVehicle(vehID));
465  if (veh != nullptr && veh->isOnRoad()) {
466  for (const MSVehicle::LaneQ& lq : veh->getBestLanes()) {
467  TraCIBestLanesData bld;
468  bld.laneID = lq.lane->getID();
469  bld.length = lq.length;
470  bld.occupation = lq.nextOccupation;
471  bld.bestLaneOffset = lq.bestLaneOffset;
472  bld.allowsContinuation = lq.allowsContinuation;
473  for (const MSLane* const lane : lq.bestContinuations) {
474  if (lane != nullptr) {
475  bld.continuationLanes.push_back(lane->getID());
476  }
477  }
478  result.emplace_back(bld);
479  }
480  }
481  return result;
482 }
483 
484 
485 std::vector<TraCINextTLSData>
486 Vehicle::getNextTLS(const std::string& vehID) {
487  std::vector<TraCINextTLSData> result;
488  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
489  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
490  if (!vehicle->isOnRoad()) {
491  return result;
492  }
493  if (veh != nullptr) {
494  const MSLane* lane = veh->getLane();
495  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
496  double seen = lane->getLength() - veh->getPositionOnLane();
497  int view = 1;
498  std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
499  while (!lane->isLinkEnd(linkIt)) {
500  if (!lane->getEdge().isInternal()) {
501  if ((*linkIt)->isTLSControlled()) {
502  TraCINextTLSData ntd;
503  ntd.id = (*linkIt)->getTLLogic()->getID();
504  ntd.tlIndex = (*linkIt)->getTLIndex();
505  ntd.dist = seen;
506  ntd.state = (char)(*linkIt)->getState();
507  result.push_back(ntd);
508  }
509  }
510  lane = (*linkIt)->getViaLaneOrLane();
511  if (!lane->getEdge().isInternal()) {
512  view++;
513  }
514  seen += lane->getLength();
515  linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
516  }
517  // consider edges beyond bestLanes
518  const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
519  //std::cout << SIMTIME << " remainingEdges=" << remainingEdges << " seen=" << seen << " view=" << view << " best=" << toString(bestLaneConts) << "\n";
520  for (int i = 0; i < remainingEdges; i++) {
521  const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
522  const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
523  const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
524  if (allowed != nullptr && allowed->size() != 0) {
525  for (const MSLink* const link : allowed->front()->getLinkCont()) {
526  if (&link->getLane()->getEdge() == next) {
527  if (link->isTLSControlled()) {
528  TraCINextTLSData ntd;
529  ntd.id = link->getTLLogic()->getID();
530  ntd.tlIndex = link->getTLIndex();
531  ntd.dist = seen;
532  ntd.state = (char)link->getState();
533  result.push_back(ntd);
534  }
535  seen += next->getLength() + link->getInternalLengthsAfter();
536  break;
537  }
538  }
539  } else {
540  // invalid route, cannot determine nextTLS
541  break;
542  }
543  }
544 
545  } else {
546  WRITE_WARNING("getNextTLS not yet implemented for meso");
547  }
548  return result;
549 }
550 
551 std::vector<TraCINextStopData>
552 Vehicle::getNextStops(const std::string& vehID) {
553  return getStops(vehID, 0);
554 }
555 
556 std::vector<libsumo::TraCIConnection>
557 Vehicle::getNextLinks(const std::string& vehID) {
558  std::vector<libsumo::TraCIConnection> result;
559  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
560  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
561  if (!vehicle->isOnRoad()) {
562  return result;
563  }
564  if (veh != nullptr) {
565  const MSLane* lane = veh->getLane();
566  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
567  int view = 1;
568  const SUMOTime currTime = MSNet::getInstance()->getCurrentTimeStep();
569  std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
570  while (!lane->isLinkEnd(linkIt)) {
571  if (!lane->getEdge().isInternal()) {
572  const MSLink* link = (*linkIt);
573  const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
574  const bool hasPrio = link->havePriority();
575  const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
576  const bool isOpen = link->opened(currTime, speed, speed, SUMOVTypeParameter::getDefault().length,
578  const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
579  const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
580  const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
581  const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
582  const double length = link->getLength();
583  result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
584  }
585  lane = (*linkIt)->getViaLaneOrLane();
586  if (!lane->getEdge().isInternal()) {
587  view++;
588  }
589  linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
590  }
591  // consider edges beyond bestLanes
592  const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
593  for (int i = 0; i < remainingEdges; i++) {
594  const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
595  const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
596  const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
597  if (allowed != nullptr && allowed->size() != 0) {
598  for (const MSLink* const link : allowed->front()->getLinkCont()) {
599  if (&link->getLane()->getEdge() == next) {
600  const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
601  const bool hasPrio = link->havePriority();
602  const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
603  const bool isOpen = link->opened(currTime, speed, speed, SUMOVTypeParameter::getDefault().length,
605  const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
606  const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
607  const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
608  const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
609  const double length = link->getLength();
610  result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
611  }
612  }
613  } else {
614  // invalid route, cannot determine nextTLS
615  break;
616  }
617  }
618  } else {
619  WRITE_WARNING("getNextLinks not yet implemented for meso");
620  }
621  return result;
622 }
623 
624 std::vector<TraCINextStopData>
625 Vehicle::getStops(const std::string& vehID, int limit) {
626  std::vector<TraCINextStopData> result;
627  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
628  if (limit < 0) {
629  // return past stops up to the given limit
630  const std::vector<SUMOVehicleParameter::Stop>& pastStops = vehicle->getPastStops();
631  const int n = (int)pastStops.size();
632  for (int i = MAX2(0, n + limit); i < n; i++) {
633  result.push_back(Helper::buildStopData(pastStops[i]));
634  }
635  } else {
636  for (const MSStop& stop : vehicle->getStops()) {
637  if (!stop.pars.collision) {
638  TraCINextStopData nsd = Helper::buildStopData(stop.pars);
639  nsd.duration = STEPS2TIME(stop.duration);
640  result.push_back(nsd);
641  if (limit > 0 && (int)result.size() >= limit) {
642  break;
643  }
644  }
645  }
646  }
647  return result;
648 }
649 
650 
651 int
652 Vehicle::getStopState(const std::string& vehID) {
653  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
654  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
655  if (veh == nullptr) {
656  WRITE_WARNING("getStopState not yet implemented for meso");
657  return 0;
658  }
659  int result = 0;
660  if (veh->isStopped()) {
661  const MSStop& stop = veh->getNextStop();
662  result = stop.getStateFlagsOld();
663  }
664  return result;
665 }
666 
667 
668 double
669 Vehicle::getDistance(const std::string& vehID) {
670  MSBaseVehicle* veh = Helper::getVehicle(vehID);
671  if (veh->isOnRoad()) {
672  return veh->getOdometer();
673  } else {
674  return INVALID_DOUBLE_VALUE;
675  }
676 }
677 
678 
679 double
680 Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int /* laneIndex */) {
681  MSBaseVehicle* veh = Helper::getVehicle(vehID);
682  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
683  if (veh->isOnRoad()) {
684  const MSEdge* edge = microVeh != nullptr ? &veh->getLane()->getEdge() : veh->getEdge();
685  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), pos,
686  edge, Helper::getEdge(edgeID), veh->getRoutePosition());
687  if (distance == std::numeric_limits<double>::max()) {
688  return INVALID_DOUBLE_VALUE;
689  }
690  return distance;
691  } else {
692  return INVALID_DOUBLE_VALUE;
693  }
694 }
695 
696 
697 double
698 Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
699  MSBaseVehicle* veh = Helper::getVehicle(vehID);
700  if (veh == nullptr) {
701  return INVALID_DOUBLE_VALUE;
702  }
703  if (veh->isOnRoad()) {
704  std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y), veh->getVehicleType().getVehicleClass());
705  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
706  veh->getEdge(), &roadPos.first->getEdge(), veh->getRoutePosition());
707  if (distance == std::numeric_limits<double>::max()) {
708  return INVALID_DOUBLE_VALUE;
709  }
710  return distance;
711  } else {
712  return INVALID_DOUBLE_VALUE;
713  }
714 }
715 
716 
717 double
718 Vehicle::getAllowedSpeed(const std::string& vehID) {
719  MSBaseVehicle* veh = Helper::getVehicle(vehID);
720  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getVehicleMaxSpeed(veh), veh->getEdge()->getVehicleMaxSpeed(veh)) : INVALID_DOUBLE_VALUE;
721 }
722 
723 
724 double
725 Vehicle::getSpeedFactor(const std::string& vehID) {
726  return Helper::getVehicle(vehID)->getChosenSpeedFactor();
727 }
728 
729 
730 int
731 Vehicle::getSpeedMode(const std::string& vehID) {
732  MSBaseVehicle* veh = Helper::getVehicle(vehID);
733  return CALL_MICRO_FUN(veh, getInfluencer().getSpeedMode(), INVALID_INT_VALUE);
734 }
735 
736 
737 int
738 Vehicle::getLaneChangeMode(const std::string& vehID) {
739  MSBaseVehicle* veh = Helper::getVehicle(vehID);
740  return CALL_MICRO_FUN(veh, getInfluencer().getLaneChangeMode(), INVALID_INT_VALUE);
741 }
742 
743 
744 int
745 Vehicle::getRoutingMode(const std::string& vehID) {
746  return Helper::getVehicle(vehID)->getRoutingMode();
747 }
748 
749 
750 std::string
751 Vehicle::getLine(const std::string& vehID) {
752  return Helper::getVehicle(vehID)->getParameter().line;
753 }
754 
755 
756 std::vector<std::string>
757 Vehicle::getVia(const std::string& vehID) {
758  return Helper::getVehicle(vehID)->getParameter().via;
759 }
760 
761 
762 std::pair<int, int>
763 Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
764  MSBaseVehicle* veh = Helper::getVehicle(vehID);
765  auto undefined = std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
766  return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSavedState(direction), undefined) : undefined;
767 }
768 
769 
770 std::string
771 Vehicle::getParameter(const std::string& vehID, const std::string& key) {
772  MSBaseVehicle* veh = Helper::getVehicle(vehID);
773  std::string error;
774  std::string result = veh->getPrefixedParameter(key, error);
775  if (error != "") {
776  throw TraCIException(error);
777  }
778  return result;
779 }
780 
781 
783 
784 
785 std::vector<std::pair<std::string, double> >
786 Vehicle::getNeighbors(const std::string& vehID, const int mode) {
787  int dir = (1 & mode) != 0 ? -1 : 1;
788  bool queryLeaders = (2 & mode) != 0;
789  bool blockersOnly = (4 & mode) != 0;
790  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
791  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
792  std::vector<std::pair<std::string, double> > result;
793  if (veh == nullptr) {
794  return result;
795  }
796 #ifdef DEBUG_NEIGHBORS
797  if (DEBUG_COND) {
798  std::cout << "getNeighbors() for veh '" << vehID << "': dir=" << dir
799  << ", queryLeaders=" << queryLeaders
800  << ", blockersOnly=" << blockersOnly << std::endl;
801  }
802 #endif
803  if (veh->getLaneChangeModel().isOpposite()) {
804  // getParallelLane works relative to lane forward direction
805  dir *= -1;
806  }
807 
808  MSLane* targetLane = veh->getLane()->getParallelLane(dir);
809  if (targetLane == nullptr) {
810  return result;
811  }
812  // need to recompute leaders and followers (#8119)
813  const bool opposite = &veh->getLane()->getEdge() != &targetLane->getEdge();
814  MSLeaderDistanceInfo neighbors(targetLane->getWidth(), nullptr, 0.);
815  if (queryLeaders) {
816  if (opposite) {
817  double pos = targetLane->getOppositePos(veh->getPositionOnLane());
818  neighbors = targetLane->getFollowersOnConsecutive(veh, pos, true);
819  } else {
820  targetLane->addLeaders(veh, veh->getPositionOnLane(), neighbors);
821  }
822  } else {
823  if (opposite) {
824  double pos = targetLane->getOppositePos(veh->getPositionOnLane());
825  targetLane->addLeaders(veh, pos, neighbors);
826  neighbors.fixOppositeGaps(true);
827  } else {
828  neighbors = targetLane->getFollowersOnConsecutive(veh, veh->getBackPositionOnLane(), true);
829  }
830  }
831  if (blockersOnly) {
832  // filter out vehicles that aren't blocking
833  MSLeaderDistanceInfo blockers(targetLane->getWidth(), nullptr, 0.);
834  for (int i = 0; i < neighbors.numSublanes(); i++) {
835  CLeaderDist n = neighbors[i];
836  if (n.first != nullptr) {
837  const MSVehicle* follower = veh;
838  const MSVehicle* leader = n.first;
839  if (!queryLeaders) {
840  std::swap(follower, leader);
841  }
842  const double secureGap = (follower->getCarFollowModel().getSecureGap(
843  follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel())
844  * follower->getLaneChangeModel().getSafetyFactor());
845  if (n.second < secureGap) {
846  blockers.addLeader(n.first, n.second, 0, i);
847  }
848  }
849  }
850  neighbors = blockers;
851  }
852 
853  if (neighbors.hasVehicles()) {
854  for (int i = 0; i < neighbors.numSublanes(); i++) {
855  CLeaderDist n = neighbors[i];
856  if (n.first != nullptr &&
857  // avoid duplicates
858  (result.size() == 0 || result.back().first != n.first->getID())) {
859  result.push_back(std::make_pair(n.first->getID(), n.second));
860  }
861  }
862  }
863  return result;
864 }
865 
866 
867 double
868 Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
869  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
870  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
871  if (veh == nullptr) {
872  WRITE_ERROR("getFollowSpeed not applicable for meso");
873  return INVALID_DOUBLE_VALUE;
874  }
875  MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
876  return veh->getCarFollowModel().followSpeed(veh, speed, gap, leaderSpeed, leaderMaxDecel, leader, MSCFModel::CalcReason::FUTURE);
877 }
878 
879 
880 double
881 Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
882  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
883  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
884  if (veh == nullptr) {
885  WRITE_ERROR("getSecureGap not applicable for meso");
886  return INVALID_DOUBLE_VALUE;
887  }
888  MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
889  return veh->getCarFollowModel().getSecureGap(veh, leader, speed, leaderSpeed, leaderMaxDecel);
890 }
891 
892 
893 double
894 Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
895  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
896  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
897  if (veh == nullptr) {
898  WRITE_ERROR("getStopSpeed not applicable for meso");
899  return INVALID_DOUBLE_VALUE;
900  }
901  return veh->getCarFollowModel().stopSpeed(veh, speed, gap, MSCFModel::CalcReason::FUTURE);
902 }
903 
904 double
905 Vehicle::getStopDelay(const std::string& vehID) {
906  return Helper::getVehicle(vehID)->getStopDelay();
907 }
908 
909 
910 double
911 Vehicle::getImpatience(const std::string& vehID) {
912  return Helper::getVehicle(vehID)->getImpatience();
913 }
914 
915 
916 double
917 Vehicle::getStopArrivalDelay(const std::string& vehID) {
918  double result = Helper::getVehicle(vehID)->getStopArrivalDelay();
919  if (result == INVALID_DOUBLE) {
920  return INVALID_DOUBLE_VALUE;
921  } else {
922  return result;
923  }
924 }
925 
926 double
927 Vehicle::getTimeLoss(const std::string& vehID) {
928  return Helper::getVehicle(vehID)->getTimeLossSeconds();
929 }
930 
931 std::vector<std::string>
932 Vehicle::getTaxiFleet(int taxiState) {
933  std::vector<std::string> result;
934  for (MSDevice_Taxi* taxi : MSDevice_Taxi::getFleet()) {
935  if (taxi->getHolder().hasDeparted()) {
936  if (taxiState == -1
937  || (taxiState == 0 && taxi->getState() == 0)
938  || (taxiState != 0 && (taxi->getState() & taxiState) == taxiState)) {
939  result.push_back(taxi->getHolder().getID());
940  }
941  }
942  }
943  return result;
944 }
945 
946 std::vector<std::string>
947 Vehicle::getLoadedIDList() {
948  std::vector<std::string> ids;
950  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
951  ids.push_back(i->first);
952  }
953  return ids;
954 }
955 
956 std::vector<std::string>
957 Vehicle::getTeleportingIDList() {
958  std::vector<std::string> ids;
960  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
961  SUMOVehicle* veh = i->second;
962  if (veh->hasDeparted() && !isVisible(veh)) {
963  ids.push_back(veh->getID());
964  }
965  }
966  return ids;
967 }
968 
969 std::string
970 Vehicle::getEmissionClass(const std::string& vehID) {
971  return PollutantsInterface::getName(Helper::getVehicleType(vehID).getEmissionClass());
972 }
973 
974 std::string
975 Vehicle::getShapeClass(const std::string& vehID) {
976  return getVehicleShapeName(Helper::getVehicleType(vehID).getGuiShape());
977 }
978 
979 
980 double
981 Vehicle::getLength(const std::string& vehID) {
982  return Helper::getVehicleType(vehID).getLength();
983 }
984 
985 
986 double
987 Vehicle::getAccel(const std::string& vehID) {
989 }
990 
991 
992 double
993 Vehicle::getDecel(const std::string& vehID) {
995 }
996 
997 
998 double Vehicle::getEmergencyDecel(const std::string& vehID) {
1000 }
1001 
1002 
1003 double Vehicle::getApparentDecel(const std::string& vehID) {
1005 }
1006 
1007 
1008 double Vehicle::getActionStepLength(const std::string& vehID) {
1010 }
1011 
1012 
1013 double Vehicle::getLastActionTime(const std::string& vehID) {
1014  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1015  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
1016  if (microVeh != nullptr) {
1017  return STEPS2TIME(microVeh->getLastActionTime());
1018  } else {
1019  MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
1020  return STEPS2TIME(mesoVeh->getEventTime());
1021  }
1022 }
1023 
1024 
1025 double
1026 Vehicle::getTau(const std::string& vehID) {
1028 }
1029 
1030 
1031 double
1032 Vehicle::getImperfection(const std::string& vehID) {
1034 }
1035 
1036 
1037 double
1038 Vehicle::getSpeedDeviation(const std::string& vehID) {
1039  return Helper::getVehicleType(vehID).getSpeedFactor().getParameter()[1];
1040 }
1041 
1042 
1043 std::string
1044 Vehicle::getVehicleClass(const std::string& vehID) {
1045  return toString(Helper::getVehicleType(vehID).getVehicleClass());
1046 }
1047 
1048 
1049 double
1050 Vehicle::getMinGap(const std::string& vehID) {
1051  return Helper::getVehicleType(vehID).getMinGap();
1052 }
1053 
1054 
1055 double
1056 Vehicle::getMinGapLat(const std::string& vehID) {
1057  try {
1058  return StringUtils::toDouble(getParameter(vehID, "laneChangeModel.minGapLat"));
1059  } catch (const TraCIException&) {
1060  // legacy behavior
1061  return Helper::getVehicleType(vehID).getMinGapLat();
1062  }
1063 }
1064 
1065 
1066 double
1067 Vehicle::getMaxSpeed(const std::string& vehID) {
1068  return Helper::getVehicleType(vehID).getMaxSpeed();
1069 }
1070 
1071 
1072 double
1073 Vehicle::getMaxSpeedLat(const std::string& vehID) {
1074  return Helper::getVehicleType(vehID).getMaxSpeedLat();
1075 }
1076 
1077 
1078 std::string
1079 Vehicle::getLateralAlignment(const std::string& vehID) {
1080  return toString(Helper::getVehicleType(vehID).getPreferredLateralAlignment());
1081 }
1082 
1083 
1084 double
1085 Vehicle::getWidth(const std::string& vehID) {
1086  return Helper::getVehicleType(vehID).getWidth();
1087 }
1088 
1089 
1090 double
1091 Vehicle::getHeight(const std::string& vehID) {
1092  return Helper::getVehicleType(vehID).getHeight();
1093 }
1094 
1095 
1096 void
1097 Vehicle::setStop(const std::string& vehID,
1098  const std::string& edgeID,
1099  double pos,
1100  int laneIndex,
1101  double duration,
1102  int flags,
1103  double startPos,
1104  double until) {
1105  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1107  pos, laneIndex, startPos, flags, duration, until);
1108  std::string error;
1109  if (!vehicle->addTraciStop(stopPars, error)) {
1110  throw TraCIException(error);
1111  }
1112 }
1113 
1114 
1115 void
1116 Vehicle::replaceStop(const std::string& vehID,
1117  int nextStopIndex,
1118  const std::string& edgeID,
1119  double pos,
1120  int laneIndex,
1121  double duration,
1122  int flags,
1123  double startPos,
1124  double until,
1125  int teleport) {
1126  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1127  std::string error;
1128  if (edgeID == "") {
1129  // only remove stop
1130  const bool ok = vehicle->abortNextStop(nextStopIndex);
1131  if (teleport != 0) {
1132  if (!vehicle->rerouteBetweenStops(nextStopIndex, "traci:replaceStop", (teleport & 1), error)) {
1133  throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
1134  }
1135  } else {
1136  MSVehicle* msVeh = dynamic_cast<MSVehicle*>(vehicle);
1137  if (msVeh->getLane() != nullptr) {
1138  msVeh->updateBestLanes(true);
1139  }
1140  }
1141  if (!ok) {
1142  throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (invalid nextStopIndex).");
1143  }
1144  } else {
1146  pos, laneIndex, startPos, flags, duration, until);
1147 
1148  if (!vehicle->replaceStop(nextStopIndex, stopPars, "traci:replaceStop", teleport != 0, error)) {
1149  throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
1150  }
1151  }
1152 }
1153 
1154 
1155 void
1156 Vehicle::insertStop(const std::string& vehID,
1157  int nextStopIndex,
1158  const std::string& edgeID,
1159  double pos,
1160  int laneIndex,
1161  double duration,
1162  int flags,
1163  double startPos,
1164  double until,
1165  int teleport) {
1166  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1168  pos, laneIndex, startPos, flags, duration, until);
1169 
1170  std::string error;
1171  if (!vehicle->insertStop(nextStopIndex, stopPars, "traci:insertStop", teleport != 0, error)) {
1172  throw TraCIException("Stop insertion failed for vehicle '" + vehID + "' (" + error + ").");
1173  }
1174 }
1175 
1176 
1177 std::string
1178 Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
1179  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1180  try {
1181  if (nextStopIndex >= (int)vehicle->getStops().size() || (nextStopIndex < 0 && -nextStopIndex > (int)vehicle->getPastStops().size())) {
1182  throw ProcessError("Invalid stop index " + toString(nextStopIndex)
1183  + " (has " + toString(vehicle->getPastStops().size()) + " past stops and " + toString(vehicle->getStops().size()) + " remaining stops)");
1184 
1185  }
1186  const SUMOVehicleParameter::Stop& pars = (nextStopIndex >= 0
1187  ? vehicle->getStop(nextStopIndex).pars
1188  : vehicle->getPastStops()[vehicle->getPastStops().size() + nextStopIndex]);
1189  if (customParam) {
1190  // custom user parameter
1191  return pars.getParameter(param, "");
1192  }
1193 
1194  if (param == toString(SUMO_ATTR_EDGE)) {
1195  return pars.edge;
1196  } else if (param == toString(SUMO_ATTR_LANE)) {
1198  } else if (param == toString(SUMO_ATTR_BUS_STOP)
1199  || param == toString(SUMO_ATTR_TRAIN_STOP)) {
1200  return pars.busstop;
1201  } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
1202  return pars.containerstop;
1203  } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
1204  return pars.chargingStation;
1205  } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
1206  return pars.parkingarea;
1207  } else if (param == toString(SUMO_ATTR_STARTPOS)) {
1208  return toString(pars.startPos);
1209  } else if (param == toString(SUMO_ATTR_ENDPOS)) {
1210  return toString(pars.endPos);
1211  } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
1212  return toString(pars.posLat == INVALID_DOUBLE ? INVALID_DOUBLE_VALUE : pars.posLat);
1213  } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
1214  return pars.arrival < 0 ? "-1" : time2string(pars.arrival);
1215  } else if (param == toString(SUMO_ATTR_DURATION)) {
1216  return pars.duration < 0 ? "-1" : time2string(pars.duration);
1217  } else if (param == toString(SUMO_ATTR_UNTIL)) {
1218  return pars.until < 0 ? "-1" : time2string(pars.until);
1219  } else if (param == toString(SUMO_ATTR_EXTENSION)) {
1220  return pars.extension < 0 ? "-1" : time2string(pars.extension);
1221  } else if (param == toString(SUMO_ATTR_INDEX)) {
1222  return toString(nextStopIndex + vehicle->getPastStops().size());
1223  } else if (param == toString(SUMO_ATTR_PARKING)) {
1224  return toString(pars.parking);
1225  } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
1226  return joinToString(pars.getTriggers(), " ");
1227  } else if (param == toString(SUMO_ATTR_EXPECTED)) {
1228  return joinToString(pars.awaitedPersons, " ");
1229  } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
1230  return joinToString(pars.awaitedContainers, " ");
1231  } else if (param == toString(SUMO_ATTR_PERMITTED)) {
1232  return joinToString(pars.permitted, " ");
1233  } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
1234  return pars.actType;
1235  } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
1236  return pars.tripId;
1237  } else if (param == toString(SUMO_ATTR_SPLIT)) {
1238  return pars.split;
1239  } else if (param == toString(SUMO_ATTR_JOIN)) {
1240  return pars.join;
1241  } else if (param == toString(SUMO_ATTR_LINE)) {
1242  return pars.line;
1243  } else if (param == toString(SUMO_ATTR_SPEED)) {
1244  return toString(pars.speed);
1245  } else if (param == toString(SUMO_ATTR_STARTED)) {
1246  return pars.started < 0 ? "-1" : time2string(pars.started);
1247  } else if (param == toString(SUMO_ATTR_ENDED)) {
1248  return pars.ended < 0 ? "-1" : time2string(pars.ended);
1249  } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
1250  return toString(pars.onDemand);
1251  } else {
1252  throw ProcessError(TLF("Unsupported parameter '%'", param));
1253  }
1254  } catch (ProcessError& e) {
1255  throw TraCIException("Could not get stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
1256  }
1257 }
1258 
1259 
1260 
1261 void
1262 Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
1263  const std::string& param, const std::string& value,
1264  bool customParam) {
1265  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1266  try {
1267  MSStop& stop = vehicle->getStop(nextStopIndex);
1268  SUMOVehicleParameter::Stop& pars = const_cast<SUMOVehicleParameter::Stop&>(stop.pars);
1269  if (customParam) {
1270  pars.setParameter(param, value);
1271  return;
1272  }
1273  std::string error;
1274  if (param == toString(SUMO_ATTR_EDGE)
1275  || param == toString(SUMO_ATTR_BUS_STOP)
1276  || param == toString(SUMO_ATTR_TRAIN_STOP)
1277  || param == toString(SUMO_ATTR_CONTAINER_STOP)
1279  || param == toString(SUMO_ATTR_PARKING_AREA)
1280  || param == toString(SUMO_ATTR_LANE)
1281  ) {
1282  int laneIndex = stop.lane->getIndex();
1283  int flags = pars.getFlags() & 3;
1284  std::string edgeOrStopID = value;
1285  if (param == toString(SUMO_ATTR_LANE)) {
1286  laneIndex = StringUtils::toInt(value);
1287  edgeOrStopID = pars.edge;
1288  } else if (param == toString(SUMO_ATTR_BUS_STOP)
1289  || param == toString(SUMO_ATTR_TRAIN_STOP)) {
1290  flags |= 8;
1291  } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
1292  flags |= 16;
1293  } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
1294  flags |= 32;
1295  } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
1296  flags |= 64;
1297  }
1298  // special case: replace stop
1299  replaceStop(vehID, nextStopIndex, edgeOrStopID, pars.endPos, laneIndex, STEPS2TIME(pars.duration),
1300  flags, pars.startPos, STEPS2TIME(pars.until), 0);
1301 
1302  } else if (param == toString(SUMO_ATTR_STARTPOS)) {
1303  pars.startPos = StringUtils::toDouble(value);
1304  pars.parametersSet |= STOP_START_SET;
1305  } else if (param == toString(SUMO_ATTR_ENDPOS)) {
1306  pars.endPos = StringUtils::toDouble(value);
1307  pars.parametersSet |= STOP_END_SET;
1308  } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
1309  pars.posLat = StringUtils::toDouble(value);
1311  } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
1312  pars.arrival = string2time(value);
1314  } else if (param == toString(SUMO_ATTR_DURATION)) {
1315  pars.duration = string2time(value);
1317  // also update dynamic value
1318  stop.initPars(pars);
1319  } else if (param == toString(SUMO_ATTR_UNTIL)) {
1320  pars.until = string2time(value);
1321  pars.parametersSet |= STOP_UNTIL_SET;
1322  } else if (param == toString(SUMO_ATTR_EXTENSION)) {
1323  pars.extension = string2time(value);
1325  } else if (param == toString(SUMO_ATTR_INDEX)) {
1326  throw TraCIException("Changing stop index is not supported");
1327  } else if (param == toString(SUMO_ATTR_PARKING)) {
1330  } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
1331  if (pars.speed > 0 && value != "") {
1332  throw ProcessError(TLF("Waypoint (speed = %) at index % does not support triggers", pars.speed, nextStopIndex));
1333  }
1334  SUMOVehicleParameter::parseStopTriggers(StringTokenizer(value).getVector(), false, pars);
1336  // also update dynamic value
1337  stop.initPars(pars);
1338  } else if (param == toString(SUMO_ATTR_EXPECTED)) {
1339  pars.awaitedPersons = StringTokenizer(value).getSet();
1341  } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
1342  pars.awaitedContainers = StringTokenizer(value).getSet();
1344  // also update dynamic value
1345  stop.initPars(pars);
1346  } else if (param == toString(SUMO_ATTR_PERMITTED)) {
1347  pars.permitted = StringTokenizer(value).getSet();
1349  } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
1350  pars.actType = value;
1351  } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
1352  pars.tripId = value;
1354  } else if (param == toString(SUMO_ATTR_SPLIT)) {
1355  pars.split = value;
1356  pars.parametersSet |= STOP_SPLIT_SET;
1357  } else if (param == toString(SUMO_ATTR_JOIN)) {
1358  pars.join = value;
1359  pars.parametersSet |= STOP_JOIN_SET;
1360  } else if (param == toString(SUMO_ATTR_LINE)) {
1361  pars.line = value;
1362  pars.parametersSet |= STOP_LINE_SET;
1363  } else if (param == toString(SUMO_ATTR_SPEED)) {
1364  const double speed = StringUtils::toDouble(value);
1365  if (speed > 0 && pars.getTriggers().size() > 0) {
1366  throw ProcessError(TLF("Triggered stop at index % cannot be changed into a waypoint by setting speed to %", nextStopIndex, speed));
1367  }
1368  pars.speed = speed;
1369  pars.parametersSet |= STOP_SPEED_SET;
1370  } else if (param == toString(SUMO_ATTR_STARTED)) {
1371  pars.started = string2time(value);
1373  } else if (param == toString(SUMO_ATTR_ENDED)) {
1374  pars.ended = string2time(value);
1375  pars.parametersSet |= STOP_ENDED_SET;
1376  } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
1377  pars.onDemand = StringUtils::toBool(value);
1379  } else if (param == toString(SUMO_ATTR_JUMP)) {
1380  pars.jump = string2time(value);
1381  pars.parametersSet |= STOP_JUMP_SET;
1382  } else {
1383  throw ProcessError(TLF("Unsupported parameter '%'", param));
1384  }
1385  } catch (ProcessError& e) {
1386  throw TraCIException("Could not set stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
1387  }
1388 }
1389 
1390 
1391 void
1392 Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
1393  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1394  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1395  if (veh == nullptr) {
1396  WRITE_WARNING("rerouteParkingArea not yet implemented for meso");
1397  return;
1398  }
1399  std::string error;
1400  // Forward command to vehicle
1401  if (!veh->rerouteParkingArea(parkingAreaID, error)) {
1402  throw TraCIException(error);
1403  }
1404 }
1405 
1406 void
1407 Vehicle::resume(const std::string& vehID) {
1408  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1409  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1410  if (veh == nullptr) {
1411  WRITE_WARNING("resume not yet implemented for meso");
1412  return;
1413  }
1414  if (!veh->hasStops()) {
1415  throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
1416  }
1417  if (!veh->resumeFromStopping()) {
1418  MSStop& sto = veh->getNextStop();
1419  std::ostringstream strs;
1420  strs << "reached: " << sto.reached;
1421  strs << ", duration:" << sto.duration;
1422  strs << ", edge:" << (*sto.edge)->getID();
1423  strs << ", startPos: " << sto.pars.startPos;
1424  std::string posStr = strs.str();
1425  throw TraCIException("Failed to resume from stopping for vehicle '" + veh->getID() + "', " + posStr);
1426  }
1427 }
1428 
1429 
1430 void
1431 Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
1432  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1433  const MSEdge* destEdge = MSEdge::dictionary(edgeID);
1434  const bool onInit = isOnInit(vehID);
1435  if (destEdge == nullptr) {
1436  throw TraCIException("Destination edge '" + edgeID + "' is not known.");
1437  }
1438  // build a new route between the vehicle's current edge and destination edge
1439  ConstMSEdgeVector newRoute;
1440  const MSEdge* currentEdge = *veh->getRerouteOrigin();
1441  veh->getRouterTT().compute(
1442  currentEdge, destEdge, veh, MSNet::getInstance()->getCurrentTimeStep(), newRoute);
1443  // replace the vehicle's route by the new one (cost is updated by call to reroute())
1444  std::string errorMsg;
1445  if (!veh->replaceRouteEdges(newRoute, -1, 0, "traci:changeTarget", onInit, false, true, &errorMsg)) {
1446  throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
1447  }
1448  // route again to ensure usage of via/stops
1449  try {
1450  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
1451  veh->getRouterTT(), onInit);
1452  } catch (ProcessError& e) {
1453  throw TraCIException(e.what());
1454  }
1455 }
1456 
1457 
1458 void
1459 Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
1460  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1461  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1462  if (veh == nullptr) {
1463  WRITE_ERROR("changeLane not applicable for meso");
1464  return;
1465  }
1466 
1467  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1468  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1469  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
1470  veh->getInfluencer().setLaneTimeLine(laneTimeLine);
1471 }
1472 
1473 void
1474 Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
1475  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1476  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1477  if (veh == nullptr) {
1478  WRITE_ERROR("changeLaneRelative not applicable for meso");
1479  return;
1480  }
1481 
1482  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1483  int laneIndex = veh->getLaneIndex() + indexOffset;
1484  if (laneIndex < 0 && !veh->getLaneChangeModel().isOpposite()) {
1485  if (veh->getLaneIndex() == -1) {
1486  WRITE_WARNINGF(TL("Ignoring changeLaneRelative for vehicle '%' that isn't on the road"), vehID);
1487  } else {
1488  WRITE_WARNINGF(TL("Ignoring indexOffset % for vehicle '%' on laneIndex %."), indexOffset, vehID, veh->getLaneIndex());
1489  }
1490  } else {
1491  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1492  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
1493  veh->getInfluencer().setLaneTimeLine(laneTimeLine);
1494  }
1495 }
1496 
1497 
1498 void
1499 Vehicle::changeSublane(const std::string& vehID, double latDist) {
1500  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1501  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1502  if (veh == nullptr) {
1503  WRITE_ERROR("changeSublane not applicable for meso");
1504  return;
1505  }
1506 
1507  veh->getInfluencer().setSublaneChange(latDist);
1508 }
1509 
1510 
1511 void
1512 Vehicle::add(const std::string& vehID,
1513  const std::string& routeID,
1514  const std::string& typeID,
1515  const std::string& depart,
1516  const std::string& departLane,
1517  const std::string& departPos,
1518  const std::string& departSpeed,
1519  const std::string& arrivalLane,
1520  const std::string& arrivalPos,
1521  const std::string& arrivalSpeed,
1522  const std::string& fromTaz,
1523  const std::string& toTaz,
1524  const std::string& line,
1525  int /*personCapacity*/,
1526  int personNumber) {
1528  if (veh != nullptr) {
1529  throw TraCIException("The vehicle '" + vehID + "' to add already exists.");
1530  }
1531 
1532  SUMOVehicleParameter vehicleParams;
1533  vehicleParams.id = vehID;
1534  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1535  if (!vehicleType) {
1536  throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehID + "'.");
1537  }
1538  if (typeID != "DEFAULT_VEHTYPE") {
1539  vehicleParams.vtypeid = typeID;
1540  vehicleParams.parametersSet |= VEHPARS_VTYPE_SET;
1541  }
1543  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);
1544  }
1545  ConstMSRoutePtr route = MSRoute::dictionary(routeID);
1546  if (!route) {
1547  if (routeID == "") {
1548  // assume, route was intentionally left blank because the caller
1549  // intends to control the vehicle remotely
1550  SUMOVehicleClass vclass = vehicleType->getVehicleClass();
1551  const std::string dummyRouteID = "DUMMY_ROUTE_" + SumoVehicleClassStrings.getString(vclass);
1552  route = MSRoute::dictionary(dummyRouteID);
1553  if (route == nullptr) {
1554  for (MSEdge* e : MSEdge::getAllEdges()) {
1555  if (e->getFunction() == SumoXMLEdgeFunc::NORMAL && (e->getPermissions() & vclass) == vclass) {
1556  std::vector<std::string> edges;
1557  edges.push_back(e->getID());
1558  libsumo::Route::add(dummyRouteID, edges);
1559  break;
1560  }
1561  }
1562  }
1563  route = MSRoute::dictionary(dummyRouteID);
1564  if (!route) {
1565  throw TraCIException("Could not build dummy route for vehicle class: '" + SumoVehicleClassStrings.getString(vehicleType->getVehicleClass()) + "'");
1566  }
1567  } else {
1568  throw TraCIException("Invalid route '" + routeID + "' for vehicle '" + vehID + "'.");
1569  }
1570  }
1571  // check if the route implies a trip
1572  if (route->getEdges().size() == 2) {
1573  const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
1574  if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
1575  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1576  }
1577  }
1578  if (fromTaz != "" || toTaz != "") {
1579  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1580  }
1581  std::string error;
1582  if (!SUMOVehicleParameter::parseDepart(depart, "vehicle", vehID, vehicleParams.depart, vehicleParams.departProcedure, error)) {
1583  throw TraCIException(error);
1584  }
1585  if (vehicleParams.departProcedure == DepartDefinition::GIVEN && vehicleParams.depart < MSNet::getInstance()->getCurrentTimeStep()) {
1586  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1587  WRITE_WARNINGF(TL("Departure time for vehicle '%' is in the past; using current time instead."), vehID);
1588  } else if (vehicleParams.departProcedure == DepartDefinition::NOW) {
1589  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1590  }
1591  if (!SUMOVehicleParameter::parseDepartLane(departLane, "vehicle", vehID, vehicleParams.departLane, vehicleParams.departLaneProcedure, error)) {
1592  throw TraCIException(error);
1593  }
1594  if (!SUMOVehicleParameter::parseDepartPos(departPos, "vehicle", vehID, vehicleParams.departPos, vehicleParams.departPosProcedure, error)) {
1595  throw TraCIException(error);
1596  }
1597  if (!SUMOVehicleParameter::parseDepartSpeed(departSpeed, "vehicle", vehID, vehicleParams.departSpeed, vehicleParams.departSpeedProcedure, error)) {
1598  throw TraCIException(error);
1599  }
1600  if (!SUMOVehicleParameter::parseArrivalLane(arrivalLane, "vehicle", vehID, vehicleParams.arrivalLane, vehicleParams.arrivalLaneProcedure, error)) {
1601  throw TraCIException(error);
1602  }
1603  if (!SUMOVehicleParameter::parseArrivalPos(arrivalPos, "vehicle", vehID, vehicleParams.arrivalPos, vehicleParams.arrivalPosProcedure, error)) {
1604  throw TraCIException(error);
1605  }
1606  if (!SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeed, "vehicle", vehID, vehicleParams.arrivalSpeed, vehicleParams.arrivalSpeedProcedure, error)) {
1607  throw TraCIException(error);
1608  }
1609  // mark non-default attributes
1610  if (departLane != "first") {
1611  vehicleParams.parametersSet |= VEHPARS_DEPARTLANE_SET;
1612  }
1613  if (departPos != "base") {
1614  vehicleParams.parametersSet |= VEHPARS_DEPARTPOS_SET;
1615  }
1616  if (departSpeed != "0") {
1617  vehicleParams.parametersSet |= VEHPARS_DEPARTSPEED_SET;
1618  }
1619  if (arrivalLane != "current") {
1620  vehicleParams.parametersSet |= VEHPARS_ARRIVALLANE_SET;
1621  }
1622  if (arrivalPos != "max") {
1623  vehicleParams.parametersSet |= VEHPARS_ARRIVALPOS_SET;
1624  }
1625  if (arrivalSpeed != "current") {
1626  vehicleParams.parametersSet |= VEHPARS_ARRIVALSPEED_SET;
1627  }
1628  if (fromTaz != "") {
1629  vehicleParams.parametersSet |= VEHPARS_FROM_TAZ_SET;
1630  }
1631  if (toTaz != "") {
1632  vehicleParams.parametersSet |= VEHPARS_TO_TAZ_SET;
1633  }
1634  if (line != "") {
1635  vehicleParams.parametersSet |= VEHPARS_LINE_SET;
1636  }
1637  if (personNumber != 0) {
1638  vehicleParams.parametersSet |= VEHPARS_PERSON_NUMBER_SET;
1639  }
1640  // build vehicle
1641  vehicleParams.fromTaz = fromTaz;
1642  vehicleParams.toTaz = toTaz;
1643  vehicleParams.line = line;
1644  //vehicleParams.personCapacity = personCapacity;
1645  vehicleParams.personNumber = personNumber;
1646 
1647  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
1648  SUMOVehicle* vehicle = nullptr;
1649  try {
1650  vehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(params, route, vehicleType, true, false);
1651  if (fromTaz == "" && !route->getEdges().front()->validateDepartSpeed(*vehicle)) {
1653  throw TraCIException("Departure speed for vehicle '" + vehID + "' is too high for the departure edge '" + route->getEdges().front()->getID() + "'.");
1654  }
1655  std::string msg;
1656  if (vehicle->getRouteValidity(true, true, &msg) != MSBaseVehicle::ROUTE_VALID) {
1658  throw TraCIException("Vehicle '" + vehID + "' has no valid route (" + msg + "). ");
1659  }
1660  MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
1663  }
1664  } catch (ProcessError& e) {
1665  if (vehicle != nullptr) {
1667  }
1668  throw TraCIException(e.what());
1669  }
1670 }
1671 
1672 
1673 void
1674 Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
1675  const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
1676  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1677  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1678  if (veh == nullptr) {
1679  WRITE_WARNING("moveToXY not yet implemented for meso");
1680  return;
1681  }
1682  const bool doKeepRoute = (keepRoute & 1) != 0 && veh->getID() != "VTD_EGO";
1683  const bool mayLeaveNetwork = (keepRoute & 2) != 0;
1684  const bool ignorePermissions = (keepRoute & 4) != 0;
1685  const bool setLateralPos = (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork);
1686  SUMOVehicleClass vClass = ignorePermissions ? SVC_IGNORING : veh->getVClass();
1687  // process
1688  const std::string origID = edgeID + "_" + toString(laneIndex);
1689  // @todo add an interpretation layer for OSM derived origID values (without lane index)
1690  Position pos(x, y);
1691 #ifdef DEBUG_MOVEXY
1692  const double origAngle = angle;
1693 #endif
1694  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
1695  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
1696  if (angle != INVALID_DOUBLE_VALUE) {
1697  while (angle >= 360.) {
1698  angle -= 360.;
1699  }
1700  while (angle < 0.) {
1701  angle += 360.;
1702  }
1703  }
1704 
1705 #ifdef DEBUG_MOVEXY
1706  std::cout << std::endl << SIMTIME << " moveToXY veh=" << veh->getID() << " vehPos=" << veh->getPosition()
1707  << " lane=" << Named::getIDSecure(veh->getLane()) << " lanePos=" << vehicle->getPositionOnLane() << std::endl;
1708  std::cout << " wantedPos=" << pos << " origID=" << origID << " laneIndex=" << laneIndex << " origAngle=" << origAngle << " angle=" << angle << " keepRoute=" << keepRoute << std::endl;
1709 #endif
1710 
1711  ConstMSEdgeVector edges;
1712  MSLane* lane = nullptr;
1713  double lanePos;
1714  double lanePosLat = 0;
1715  double bestDistance = std::numeric_limits<double>::max();
1716  int routeOffset = 0;
1717  bool found;
1718  double maxRouteDistance = matchThreshold;
1719  /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
1720  if (doKeepRoute) {
1721  // case a): vehicle is on its earlier route
1722  // we additionally assume it is moving forward (SUMO-limit);
1723  // note that the route ("edges") is not changed in this case
1724 
1725  found = Helper::moveToXYMap_matchingRoutePosition(pos, origID,
1726  veh->getRoute().getEdges(), veh->getRoutePosition(),
1727  vClass, setLateralPos,
1728  bestDistance, &lane, lanePos, routeOffset);
1729  // @note silenty ignoring mapping failure
1730  } else {
1731  const double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
1732  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
1733  speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
1734  vClass, setLateralPos,
1735  bestDistance, &lane, lanePos, routeOffset, edges);
1736  }
1737  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1738  // optionally compute lateral offset
1739  pos.setz(veh->getPosition().z());
1740  if (found && setLateralPos) {
1741  const double perpDist = lane->getShape().distance2D(pos, false);
1742  if (perpDist != GeomHelper::INVALID_OFFSET) {
1743  lanePosLat = perpDist;
1744  if (!mayLeaveNetwork) {
1745  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
1746  }
1747  // figure out whether the offset is to the left or to the right
1748  PositionVector tmp = lane->getShape();
1749  try {
1750  tmp.move2side(-lanePosLat); // moved to left
1751  } catch (ProcessError&) {
1752  WRITE_WARNINGF(TL("Could not determine position on lane '%' at lateral position %."), lane->getID(), toString(-lanePosLat));
1753  }
1754  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
1755  if (tmp.distance2D(pos) > perpDist) {
1756  lanePosLat = -lanePosLat;
1757  }
1758  }
1759  pos.setz(lane->geometryPositionAtOffset(lanePos).z());
1760  }
1761  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
1762  // mapped position may differ from pos
1763  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1764  }
1765  assert((found && lane != 0) || (!found && lane == 0));
1766  assert(!std::isnan(lanePos));
1767  if (angle == INVALID_DOUBLE_VALUE) {
1768  if (lane != nullptr) {
1769  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
1770  } else {
1771  // compute angle outside road network from old and new position
1772  angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
1773  }
1774  }
1775  // use the best we have
1776 #ifdef DEBUG_MOVEXY
1777  std::cout << SIMTIME << " veh=" << vehID + " moveToXYResult lane='" << Named::getIDSecure(lane) << "' lanePos=" << lanePos << " lanePosLat=" << lanePosLat << "\n";
1778 #endif
1779  Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
1780  if (!veh->isOnRoad()) {
1782  }
1783  } else {
1784  if (lane == nullptr) {
1785  throw TraCIException("Could not map vehicle '" + vehID + "', no road found within " + toString(maxRouteDistance) + "m.");
1786  } else {
1787  throw TraCIException("Could not map vehicle '" + vehID + "', distance to road is " + toString(bestDistance) + ".");
1788  }
1789  }
1790 }
1791 
1792 void
1793 Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
1794  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1795  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1796  if (veh == nullptr) {
1797  WRITE_ERROR("slowDown not applicable for meso");
1798  return;
1799  }
1800 
1801  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1802  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1803  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), speed));
1804  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1805 }
1806 
1807 void
1808 Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
1809  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1810  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1811  if (veh == nullptr) {
1812  WRITE_ERROR("openGap not applicable for meso");
1813  return;
1814  }
1815 
1816  MSVehicle* refVeh = nullptr;
1817  if (referenceVehID != "") {
1818  refVeh = dynamic_cast<MSVehicle*>(Helper::getVehicle(referenceVehID));
1819  }
1820  const double originalTau = veh->getVehicleType().getCarFollowModel().getHeadwayTime();
1821  if (newTimeHeadway == -1) {
1822  newTimeHeadway = originalTau;
1823  }
1824  if (originalTau > newTimeHeadway) {
1825  WRITE_WARNING("Ignoring openGap(). New time headway must not be smaller than the original.");
1826  return;
1827  }
1828  veh->getInfluencer().activateGapController(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
1829 }
1830 
1831 void
1832 Vehicle::deactivateGapControl(const std::string& vehID) {
1833  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1834  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1835  if (veh == nullptr) {
1836  WRITE_ERROR("deactivateGapControl not applicable for meso");
1837  return;
1838  }
1839 
1840  if (veh->hasInfluencer()) {
1842  }
1843 }
1844 
1845 void
1846 Vehicle::requestToC(const std::string& vehID, double leadTime) {
1847  setParameter(vehID, "device.toc.requestToC", toString(leadTime));
1848 }
1849 
1850 void
1851 Vehicle::setSpeed(const std::string& vehID, double speed) {
1852  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1853  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1854  if (veh == nullptr) {
1855  WRITE_WARNING("setSpeed not yet implemented for meso");
1856  return;
1857  }
1858 
1859  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1860  if (speed >= 0) {
1861  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), speed));
1862  speedTimeLine.push_back(std::make_pair(SUMOTime_MAX - DELTA_T, speed));
1863  }
1864  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1865 }
1866 
1867 void
1868 Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
1869  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1870  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1871  if (veh == nullptr) {
1872  WRITE_WARNING("setAcceleration not yet implemented for meso");
1873  return;
1874  }
1875 
1876  double targetSpeed = std::max(veh->getSpeed() + acceleration * duration, 0.0);
1877  std::vector<std::pair<SUMOTime, double>> speedTimeLine;
1878  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1879  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), targetSpeed));
1880  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1881 }
1882 
1883 void
1884 Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
1885  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1886  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1887  if (veh == nullptr) {
1888  WRITE_WARNING("setPreviousSpeed not yet implemented for meso");
1889  return;
1890  }
1891  if (prevAcceleration == INVALID_DOUBLE_VALUE) {
1892  prevAcceleration = std::numeric_limits<double>::min();
1893  }
1894  veh->setPreviousSpeed(prevSpeed, prevAcceleration);
1895 }
1896 
1897 void
1898 Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
1899  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1900  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1901  if (veh == nullptr) {
1902  WRITE_WARNING("setSpeedMode not yet implemented for meso");
1903  return;
1904  }
1905 
1906  veh->getInfluencer().setSpeedMode(speedMode);
1907 }
1908 
1909 void
1910 Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
1911  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1912  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1913  if (veh == nullptr) {
1914  WRITE_ERROR("setLaneChangeMode not applicable for meso");
1915  return;
1916  }
1917 
1918  veh->getInfluencer().setLaneChangeMode(laneChangeMode);
1919 }
1920 
1921 void
1922 Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
1923  Helper::getVehicle(vehID)->setRoutingMode(routingMode);
1924 }
1925 
1926 void
1927 Vehicle::setType(const std::string& vehID, const std::string& typeID) {
1928  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1929  if (vehicleType == nullptr) {
1930  throw TraCIException("Vehicle type '" + typeID + "' is not known");
1931  }
1932  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1933  veh->replaceVehicleType(vehicleType);
1934  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
1935  if (microVeh != nullptr && microVeh->isOnRoad()) {
1936  microVeh->updateBestLanes(true);
1937  }
1938 }
1939 
1940 void
1941 Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
1942  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1943  ConstMSRoutePtr r = MSRoute::dictionary(routeID);
1944  if (r == nullptr) {
1945  throw TraCIException("The route '" + routeID + "' is not known.");
1946  }
1948  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);
1949  }
1950  std::string msg;
1951  if (!veh->hasValidRoute(msg, r)) {
1952  WRITE_WARNINGF(TL("Invalid route replacement for vehicle '%'. %"), veh->getID(), msg);
1954  throw TraCIException("Route replacement failed for " + veh->getID());
1955  }
1956  }
1957 
1958  std::string errorMsg;
1959  if (!veh->replaceRoute(r, "traci:setRouteID", veh->getLane() == nullptr, 0, true, true, &errorMsg)) {
1960  throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
1961  }
1962 }
1963 
1964 void
1965 Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
1966  setRoute(vehID, std::vector<std::string>({edgeID}));
1967 }
1968 
1969 
1970 void
1971 Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
1972  MSBaseVehicle* veh = Helper::getVehicle(vehID);
1973  ConstMSEdgeVector edges;
1974  const bool onInit = veh->getLane() == nullptr;
1975  try {
1976  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
1977  if (edges.size() > 0 && edges.front()->isInternal()) {
1978  if (edges.size() == 1) {
1979  // avoid crashing due to lack of normal edges in route (#5390)
1980  edges.push_back(edges.back()->getLanes()[0]->getNextNormal());
1981  } else {
1982  // avoid internal edge in final route
1983  if (edges.front() == &veh->getLane()->getEdge()) {
1984  edges.erase(edges.begin());
1985  }
1986  }
1987  }
1988  } catch (ProcessError& e) {
1989  throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
1990  }
1991  std::string errorMsg;
1992  if (!veh->replaceRouteEdges(edges, -1, 0, "traci:setRoute", onInit, true, true, &errorMsg)) {
1993  throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
1994  }
1995 }
1996 
1997 
1998 void
1999 Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
2000  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2001  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2002  if (veh != nullptr) {
2003  veh->setLateralPositionOnLane(posLat);
2004  } else {
2005  WRITE_ERROR("setLateralLanePosition not applicable for meso");
2006  }
2007 }
2008 
2009 
2010 void
2011 Vehicle::updateBestLanes(const std::string& vehID) {
2012  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2013  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2014  if (veh == nullptr) {
2015  WRITE_ERROR("updateBestLanes not applicable for meso");
2016  return;
2017  }
2018  if (veh->isOnRoad()) {
2019  veh->updateBestLanes(true);
2020  }
2021 }
2022 
2023 
2024 void
2025 Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
2026  double time, double begSeconds, double endSeconds) {
2027  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2028  MSEdge* edge = MSEdge::dictionary(edgeID);
2029  if (edge == nullptr) {
2030  throw TraCIException("Edge '" + edgeID + "' is not known.");
2031  }
2032  if (time != INVALID_DOUBLE_VALUE) {
2033  // add time
2034  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2035  // clean up old values before setting whole range
2036  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
2037  veh->getWeightsStorage().removeTravelTime(edge);
2038  }
2039  }
2040  veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
2041  } else {
2042  // remove time
2043  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
2044  veh->getWeightsStorage().removeTravelTime(edge);
2045  }
2046  }
2047 }
2048 
2049 
2050 void
2051 Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
2052  double effort, double begSeconds, double endSeconds) {
2053  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2054  MSEdge* edge = MSEdge::dictionary(edgeID);
2055  if (edge == nullptr) {
2056  throw TraCIException("Edge '" + edgeID + "' is not known.");
2057  }
2058  if (effort != INVALID_DOUBLE_VALUE) {
2059  // add effort
2060  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2061  // clean up old values before setting whole range
2062  while (veh->getWeightsStorage().knowsEffort(edge)) {
2063  veh->getWeightsStorage().removeEffort(edge);
2064  }
2065  }
2066  veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
2067  } else {
2068  // remove effort
2069  while (veh->getWeightsStorage().knowsEffort(edge)) {
2070  veh->getWeightsStorage().removeEffort(edge);
2071  }
2072  }
2073 }
2074 
2075 
2076 void
2077 Vehicle::rerouteTraveltime(const std::string& vehID, const bool currentTravelTimes) {
2078  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2079  const int routingMode = veh->getRoutingMode();
2080  if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
2082  }
2083  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteTraveltime",
2084  veh->getRouterTT(), isOnInit(vehID));
2085  if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
2086  veh->setRoutingMode(routingMode);
2087  }
2088 }
2089 
2090 
2091 void
2092 Vehicle::rerouteEffort(const std::string& vehID) {
2093  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2094  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteEffort",
2095  MSNet::getInstance()->getRouterEffort(veh->getRNGIndex()), isOnInit(vehID));
2096 }
2097 
2098 
2099 void
2100 Vehicle::setSignals(const std::string& vehID, int signals) {
2101  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2102  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2103  if (veh == nullptr) {
2104  WRITE_ERROR("setSignals not applicable for meso");
2105  return;
2106  }
2107 
2108  // set influencer to make the change persistent
2109  veh->getInfluencer().setSignals(signals);
2110  // set them now so that getSignals returns the correct value
2111  veh->switchOffSignal(0x0fffffff);
2112  if (signals >= 0) {
2113  veh->switchOnSignal(signals);
2114  }
2115 }
2116 
2117 
2118 void
2119 Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double position, int reason) {
2120  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2121  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2122  if (veh == nullptr) {
2123  WRITE_WARNING("moveTo not yet implemented for meso");
2124  return;
2125  }
2126 
2127  MSLane* l = MSLane::dictionary(laneID);
2128  if (l == nullptr) {
2129  throw TraCIException("Unknown lane '" + laneID + "'.");
2130  }
2131  if (veh->getLane() == l) {
2132  veh->setTentativeLaneAndPosition(l, position, veh->getLateralPositionOnLane());
2133  return;
2134  }
2135  MSEdge* destinationEdge = &l->getEdge();
2136  const MSEdge* destinationRouteEdge = destinationEdge->getNormalBefore();
2137  if (!veh->isOnRoad() && veh->getParameter().wasSet(VEHPARS_FORCE_REROUTE) && veh->getRoute().getEdges().size() == 2) {
2138  // it's a trip that wasn't routeted yet (likely because the vehicle was added in this step. Find a route now
2139  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:moveTo-tripInsertion",
2140  veh->getRouterTT(), true);
2141  }
2142  // find edge in the remaining route
2143  MSRouteIterator it = std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), destinationRouteEdge);
2144  if (it == veh->getRoute().end()) {
2145  // find edge in the edges that were already passed
2146  it = std::find(veh->getRoute().begin(), veh->getRoute().end(), destinationRouteEdge);
2147  }
2148  if (it == veh->getRoute().end() ||
2149  // internal edge must continue the route
2150  (destinationEdge->isInternal() &&
2151  ((it + 1) == veh->getRoute().end()
2152  || l->getNextNormal() != *(it + 1)))) {
2153  throw TraCIException("Lane '" + laneID + "' is not on the route of vehicle '" + vehID + "'.");
2154  }
2155  Position oldPos = vehicle->getPosition();
2157  if (veh->getLane() != nullptr) {
2158  // correct odometer which gets incremented via onRemovalFromNet->leaveLane
2159  veh->addToOdometer(-veh->getLane()->getLength());
2161  } else {
2162  veh->setTentativeLaneAndPosition(l, position);
2163  }
2164  const int oldRouteIndex = veh->getRoutePosition();
2165  const int newRouteIndex = (int)(it - veh->getRoute().begin());
2166  if (oldRouteIndex > newRouteIndex) {
2167  // more odometer correction needed
2168  veh->addToOdometer(-l->getLength());
2169  }
2170  veh->resetRoutePosition(newRouteIndex, veh->getParameter().departLaneProcedure);
2171  if (!veh->isOnRoad()) {
2174  }
2175  MSMoveReminder::Notification moveReminderReason;
2176  if (veh->hasDeparted()) {
2177  if (reason == MOVE_TELEPORT) {
2178  moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
2179  } else if (reason == MOVE_NORMAL) {
2180  moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
2181  } else if (reason == MOVE_AUTOMATIC) {
2182  Position newPos = l->geometryPositionAtOffset(position);
2183  const double dist = newPos.distanceTo2D(oldPos);
2184  if (dist < SPEED2DIST(veh->getMaxSpeed())) {
2185  moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
2186  } else {
2187  moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
2188  }
2189  } else {
2190  throw TraCIException("Invalid moveTo reason '" + toString(reason) + "' for vehicle '" + vehID + "'.");
2191  }
2192  } else {
2193  moveReminderReason = MSMoveReminder::NOTIFICATION_DEPARTED;
2194  }
2195  l->forceVehicleInsertion(veh, position, moveReminderReason);
2196 }
2197 
2198 
2199 void
2200 Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
2201  if (actionStepLength < 0.0) {
2202  WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
2203  return;
2204  }
2205  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2206  MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2207  if (veh == nullptr) {
2208  WRITE_ERROR("setActionStepLength not applicable for meso");
2209  return;
2210  }
2211 
2212  if (actionStepLength == 0.) {
2213  veh->resetActionOffset();
2214  } else {
2215  veh->setActionStepLength(actionStepLength, resetActionOffset);
2216  }
2217 }
2218 
2219 
2220 void
2221 Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration) {
2223 }
2224 
2225 
2226 void
2227 Vehicle::setImpatience(const std::string& vehID, double impatience) {
2228  MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2229  const double normalImpatience = vehicle->getImpatience();
2230  vehicle->getBaseInfluencer().setExtraImpatience(impatience - normalImpatience);
2231 }
2232 
2233 
2234 void
2235 Vehicle::remove(const std::string& vehID, char reason) {
2236  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2238  switch (reason) {
2239  case REMOVE_TELEPORT:
2240  // XXX semantics unclear
2241  // n = MSMoveReminder::NOTIFICATION_TELEPORT;
2243  break;
2244  case REMOVE_PARKING:
2245  // XXX semantics unclear
2246  // n = MSMoveReminder::NOTIFICATION_PARKING;
2248  break;
2249  case REMOVE_ARRIVED:
2251  break;
2252  case REMOVE_VAPORIZED:
2254  break;
2257  break;
2258  default:
2259  throw TraCIException("Unknown removal status.");
2260  }
2261  if (veh->hasDeparted()) {
2262  veh->onRemovalFromNet(n);
2263  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2264  if (microVeh != nullptr) {
2265  if (veh->getLane() != nullptr) {
2266  microVeh->getMutableLane()->removeVehicle(dynamic_cast<MSVehicle*>(veh), n);
2267  }
2269  }
2271  } else {
2274  }
2275 }
2276 
2277 
2278 void
2279 Vehicle::setColor(const std::string& vehID, const TraCIColor& col) {
2281  p.color.set((unsigned char)col.r, (unsigned char)col.g, (unsigned char)col.b, (unsigned char)col.a);
2283 }
2284 
2285 
2286 void
2287 Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
2288  Helper::getVehicle(vehID)->setChosenSpeedFactor(factor);
2289 }
2290 
2291 
2292 void
2293 Vehicle::setLine(const std::string& vehID, const std::string& line) {
2294  Helper::getVehicle(vehID)->getParameter().line = line;
2295 }
2296 
2297 
2298 void
2299 Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
2300  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2301  try {
2302  // ensure edges exist
2303  ConstMSEdgeVector edges;
2304  MSEdge::parseEdgesList(edgeList, edges, "<via-edges>");
2305  } catch (ProcessError& e) {
2306  throw TraCIException(e.what());
2307  }
2308  veh->getParameter().via = edgeList;
2309 }
2310 
2311 
2312 void
2313 Vehicle::setLength(const std::string& vehID, double length) {
2314  Helper::getVehicle(vehID)->getSingularType().setLength(length);
2315 }
2316 
2317 
2318 void
2319 Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
2321 }
2322 
2323 
2324 void
2325 Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
2326  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2328  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2329  if (microVeh != nullptr && microVeh->isOnRoad()) {
2330  microVeh->updateBestLanes(true);
2331  }
2332 }
2333 
2334 
2335 void
2336 Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
2338 }
2339 
2340 
2341 void
2342 Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
2344 }
2345 
2346 
2347 void
2348 Vehicle::setWidth(const std::string& vehID, double width) {
2349  Helper::getVehicle(vehID)->getSingularType().setWidth(width);
2350 }
2351 
2352 
2353 void
2354 Vehicle::setHeight(const std::string& vehID, double height) {
2355  Helper::getVehicle(vehID)->getSingularType().setHeight(height);
2356 }
2357 
2358 
2359 void
2360 Vehicle::setMinGap(const std::string& vehID, double minGap) {
2361  Helper::getVehicle(vehID)->getSingularType().setMinGap(minGap);
2362 }
2363 
2364 
2365 void
2366 Vehicle::setAccel(const std::string& vehID, double accel) {
2367  Helper::getVehicle(vehID)->getSingularType().setAccel(accel);
2368 }
2369 
2370 
2371 void
2372 Vehicle::setDecel(const std::string& vehID, double decel) {
2373  VehicleType::setDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2374 }
2375 
2376 
2377 void
2378 Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
2379  VehicleType::setEmergencyDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2380 }
2381 
2382 
2383 void
2384 Vehicle::setApparentDecel(const std::string& vehID, double decel) {
2386 }
2387 
2388 
2389 void
2390 Vehicle::setImperfection(const std::string& vehID, double imperfection) {
2391  Helper::getVehicle(vehID)->getSingularType().setImperfection(imperfection);
2392 }
2393 
2394 
2395 void
2396 Vehicle::setTau(const std::string& vehID, double tau) {
2397  Helper::getVehicle(vehID)->getSingularType().setTau(tau);
2398 }
2399 
2400 
2401 void
2402 Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
2403  try {
2404  setParameter(vehID, "laneChangeModel.minGapLat", toString(minGapLat));
2405  } catch (TraCIException&) {
2406  // legacy behavior
2407  Helper::getVehicle(vehID)->getSingularType().setMinGapLat(minGapLat);
2408  }
2409 }
2410 
2411 
2412 void
2413 Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
2415 }
2416 
2417 
2418 void
2419 Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
2420  double lao;
2422  if (SUMOVTypeParameter::parseLatAlignment(latAlignment, lao, lad)) {
2424  } else {
2425  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)");
2426  }
2427 }
2428 
2429 
2430 void
2431 Vehicle::setParameter(const std::string& vehID, const std::string& key, const std::string& value) {
2432  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2433  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2434  if (StringUtils::startsWith(key, "device.")) {
2435  StringTokenizer tok(key, ".");
2436  if (tok.size() < 3) {
2437  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehID + "'");
2438  }
2439  try {
2440  veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
2441  } catch (InvalidArgument& e) {
2442  throw TraCIException("Vehicle '" + vehID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
2443  }
2444  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
2445  if (microVeh == nullptr) {
2446  throw TraCIException("Meso Vehicle '" + vehID + "' does not support laneChangeModel parameters.");
2447  }
2448  const std::string attrName = key.substr(16);
2449  try {
2450  microVeh->getLaneChangeModel().setParameter(attrName, value);
2451  } catch (InvalidArgument& e) {
2452  throw TraCIException("Vehicle '" + vehID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
2453  }
2454  } else if (StringUtils::startsWith(key, "carFollowModel.")) {
2455  if (microVeh == nullptr) {
2456  throw TraCIException("Meso Vehicle '" + vehID + "' does not support carFollowModel parameters.");
2457  }
2458  try {
2459  veh->setCarFollowModelParameter(key, value);
2460  } catch (InvalidArgument& e) {
2461  throw TraCIException("Vehicle '" + vehID + "' does not support carFollowModel parameter '" + key + "' (" + e.what() + ").");
2462  }
2463  } else if (StringUtils::startsWith(key, "junctionModel.")) {
2464  try {
2465  // use the whole key (including junctionModel prefix)
2466  veh->setJunctionModelParameter(key, value);
2467  } catch (InvalidArgument& e) {
2468  // error message includes id since it is also used for xml input
2469  throw TraCIException(e.what());
2470  }
2471  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
2472  StringTokenizer tok(key, ".");
2473  if (tok.size() != 3) {
2474  throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
2475  }
2476  const std::string deviceName = tok.get(1);
2477  bool create;
2478  try {
2479  create = StringUtils::toBool(value);
2480  } catch (BoolFormatException&) {
2481  throw TraCIException("Changing device status requires a 'true' or 'false'");
2482  }
2483  if (!create) {
2484  throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
2485  }
2486  try {
2487  veh->createDevice(deviceName);
2488  } catch (InvalidArgument& e) {
2489  throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
2490  }
2491  } else {
2492  ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
2493  }
2494 }
2495 
2496 
2497 void
2498 Vehicle::highlight(const std::string& vehID, const TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
2499  // NOTE: Code is duplicated in large parts in POI.cpp
2500  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2501 
2502  // Center of the highlight circle
2503  Position center = veh->getPosition();
2504  const double l2 = veh->getLength() * 0.5;
2505  center.sub(cos(veh->getAngle())*l2, sin(veh->getAngle())*l2);
2506  // Size of the highlight circle
2507  if (size <= 0) {
2508  size = veh->getLength() * 0.7;
2509  }
2510  // Make polygon shape
2511  const unsigned int nPoints = 34;
2512  const PositionVector circlePV = GeomHelper::makeRing(size, size + 1., center, nPoints);
2513  TraCIPositionVector circle = Helper::makeTraCIPositionVector(circlePV);
2514 
2515 #ifdef DEBUG_DYNAMIC_SHAPES
2516  std::cout << SIMTIME << " Vehicle::highlight() for vehicle '" << vehID << "'\n"
2517  << " circle: " << circlePV << std::endl;
2518 #endif
2519 
2520  // Find a free polygon id
2521  int i = 0;
2522  std::string polyID = veh->getID() + "_hl" + toString(i);
2523  while (Polygon::exists(polyID)) {
2524  polyID = veh->getID() + "_hl" + toString(++i);
2525  }
2526  // Line width
2527  double lw = 0.;
2528  // Layer
2529  double lyr = 0.;
2530  if (MSNet::getInstance()->isGUINet()) {
2531  lyr = GLO_VEHICLE + 0.01;
2532  lyr += (type + 1) / 257.;
2533  }
2534  // Make Polygon
2535  Polygon::addHighlightPolygon(vehID, type, polyID, circle, col, true, "highlight", (int)lyr, lw);
2536 
2537  // Animation time line
2538  double maxAttack = 1.0; // maximal fade-in time
2539  std::vector<double> timeSpan;
2540  if (duration > 0.) {
2541  timeSpan = {0, MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
2542  }
2543  // Alpha time line
2544  std::vector<double> alphaSpan;
2545  if (alphaMax > 0.) {
2546  alphaSpan = {0., (double) alphaMax, (double)(alphaMax) / 3., 0.};
2547  }
2548  // Attach dynamics
2549  Polygon::addDynamics(polyID, vehID, timeSpan, alphaSpan, false, true);
2550 }
2551 
2552 void
2553 Vehicle::dispatchTaxi(const std::string& vehID, const std::vector<std::string>& reservations) {
2554  MSBaseVehicle* veh = Helper::getVehicle(vehID);
2555  MSDevice_Taxi* taxi = static_cast<MSDevice_Taxi*>(veh->getDevice(typeid(MSDevice_Taxi)));
2556  if (taxi == nullptr) {
2557  throw TraCIException("Vehicle '" + vehID + "' is not a taxi");
2558  }
2560  if (dispatcher == nullptr) {
2561  throw TraCIException("Cannot dispatch taxi because no reservations have been made");
2562  }
2563  MSDispatch_TraCI* traciDispatcher = dynamic_cast<MSDispatch_TraCI*>(dispatcher);
2564  if (traciDispatcher == nullptr) {
2565  throw TraCIException("device.taxi.dispatch-algorithm 'traci' has not been loaded");
2566  }
2567  if (reservations.size() == 0) {
2568  throw TraCIException("No reservations have been specified for vehicle '" + vehID + "'");
2569  }
2570  try {
2571  traciDispatcher->interpretDispatch(taxi, reservations);
2572  } catch (InvalidArgument& e) {
2573  throw TraCIException("Could not interpret reservations for vehicle '" + vehID + "' (" + e.what() + ").");
2574  }
2575 }
2576 
2578 
2579 
2580 void
2581 Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
2582  subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
2583  libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
2584 }
2585 
2586 
2587 void
2588 Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
2590  if (s != nullptr) {
2591  s->filterLanes = lanes;
2592  }
2593  if (noOpposite) {
2594  addSubscriptionFilterNoOpposite();
2595  }
2596  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2597  addSubscriptionFilterDownstreamDistance(downstreamDist);
2598  }
2599  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2600  addSubscriptionFilterUpstreamDistance(upstreamDist);
2601  }
2602 }
2603 
2604 
2605 void
2606 Vehicle::addSubscriptionFilterNoOpposite() {
2608 }
2609 
2610 
2611 void
2612 Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
2614  if (s != nullptr) {
2615  s->filterDownstreamDist = dist;
2616  }
2617 }
2618 
2619 
2620 void
2621 Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
2623  if (s != nullptr) {
2624  s->filterUpstreamDist = dist;
2625  }
2626 }
2627 
2628 
2629 void
2630 Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
2631  addSubscriptionFilterLeadFollow(std::vector<int>({0}));
2632  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2633  addSubscriptionFilterDownstreamDistance(downstreamDist);
2634  }
2635  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2636  addSubscriptionFilterUpstreamDistance(upstreamDist);
2637  }
2638 
2639 }
2640 
2641 
2642 void
2643 Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
2644  std::vector<int> lanes;
2645  if (direction == INVALID_INT_VALUE) {
2646  // Using default: both directions
2647  lanes = std::vector<int>({-1, 0, 1});
2648  } else if (direction != -1 && direction != 1) {
2649  WRITE_WARNINGF(TL("Ignoring lane change subscription filter with non-neighboring lane offset direction=%."), direction);
2650  } else {
2651  lanes = std::vector<int>({0, direction});
2652  }
2653  addSubscriptionFilterLeadFollow(lanes);
2654  if (noOpposite) {
2655  addSubscriptionFilterNoOpposite();
2656  }
2657  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2658  addSubscriptionFilterDownstreamDistance(downstreamDist);
2659  }
2660  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2661  addSubscriptionFilterUpstreamDistance(upstreamDist);
2662  }
2663 }
2664 
2665 
2666 void
2667 Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
2669  addSubscriptionFilterLanes(lanes);
2670 }
2671 
2672 
2673 void
2674 Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
2676  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2677  addSubscriptionFilterDownstreamDistance(downstreamDist);
2678  }
2679  if (foeDistToJunction != INVALID_DOUBLE_VALUE) {
2680  s->filterFoeDistToJunction = foeDistToJunction;
2681  }
2682 }
2683 
2684 
2685 void
2686 Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
2688  if (s != nullptr) {
2689  s->filterVClasses = parseVehicleClasses(vClasses);
2690  }
2691 }
2692 
2693 
2694 void
2695 Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
2697  if (s != nullptr) {
2698  s->filterVTypes.insert(vTypes.begin(), vTypes.end());
2699  }
2700 }
2701 
2702 
2703 void
2704 Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
2706  if (s != nullptr) {
2707  s->filterFieldOfVisionOpeningAngle = openingAngle;
2708  }
2709 }
2710 
2711 
2712 void
2713 Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
2715  if (s != nullptr) {
2716  s->filterLateralDist = lateralDist;
2717  }
2718  if (downstreamDist != INVALID_DOUBLE_VALUE) {
2719  addSubscriptionFilterDownstreamDistance(downstreamDist);
2720  }
2721  if (upstreamDist != INVALID_DOUBLE_VALUE) {
2722  addSubscriptionFilterUpstreamDistance(upstreamDist);
2723  }
2724 }
2725 
2726 
2727 void
2728 Vehicle::storeShape(const std::string& id, PositionVector& shape) {
2729  shape.push_back(Helper::getVehicle(id)->getPosition());
2730 }
2731 
2732 
2733 std::shared_ptr<VariableWrapper>
2734 Vehicle::makeWrapper() {
2735  return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
2736 }
2737 
2738 
2739 bool
2740 Vehicle::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData) {
2741  switch (variable) {
2742  case TRACI_ID_LIST:
2743  return wrapper->wrapStringList(objID, variable, getIDList());
2744  case ID_COUNT:
2745  return wrapper->wrapInt(objID, variable, getIDCount());
2746  case VAR_POSITION:
2747  return wrapper->wrapPosition(objID, variable, getPosition(objID));
2748  case VAR_POSITION3D:
2749  return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
2750  case VAR_ANGLE:
2751  return wrapper->wrapDouble(objID, variable, getAngle(objID));
2752  case VAR_SPEED:
2753  return wrapper->wrapDouble(objID, variable, getSpeed(objID));
2754  case VAR_SPEED_LAT:
2755  return wrapper->wrapDouble(objID, variable, getLateralSpeed(objID));
2756  case VAR_ROAD_ID:
2757  return wrapper->wrapString(objID, variable, getRoadID(objID));
2759  return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
2760  case VAR_SLOPE:
2761  return wrapper->wrapDouble(objID, variable, getSlope(objID));
2762  case VAR_LANE_ID:
2763  return wrapper->wrapString(objID, variable, getLaneID(objID));
2764  case VAR_LANE_INDEX:
2765  return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
2766  case VAR_TYPE:
2767  return wrapper->wrapString(objID, variable, getTypeID(objID));
2768  case VAR_ROUTE_ID:
2769  return wrapper->wrapString(objID, variable, getRouteID(objID));
2770  case VAR_DEPARTURE:
2771  return wrapper->wrapDouble(objID, variable, getDeparture(objID));
2772  case VAR_DEPART_DELAY:
2773  return wrapper->wrapDouble(objID, variable, getDepartDelay(objID));
2774  case VAR_ROUTE_INDEX:
2775  return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
2776  case VAR_COLOR:
2777  return wrapper->wrapColor(objID, variable, getColor(objID));
2778  case VAR_LANEPOSITION:
2779  return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
2780  case VAR_LANEPOSITION_LAT:
2781  return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
2782  case VAR_CO2EMISSION:
2783  return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
2784  case VAR_COEMISSION:
2785  return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
2786  case VAR_HCEMISSION:
2787  return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
2788  case VAR_PMXEMISSION:
2789  return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
2790  case VAR_NOXEMISSION:
2791  return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
2792  case VAR_FUELCONSUMPTION:
2793  return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
2794  case VAR_NOISEEMISSION:
2795  return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
2797  return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
2798  case VAR_PERSON_NUMBER:
2799  return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
2800  case VAR_PERSON_CAPACITY:
2801  return wrapper->wrapInt(objID, variable, getPersonCapacity(objID));
2802  case VAR_BOARDING_DURATION:
2803  return wrapper->wrapDouble(objID, variable, getBoardingDuration(objID));
2805  return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
2806  case VAR_WAITING_TIME:
2807  return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
2809  return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
2810  case VAR_ROUTE_VALID:
2811  return wrapper->wrapInt(objID, variable, isRouteValid(objID));
2812  case VAR_EDGES:
2813  return wrapper->wrapStringList(objID, variable, getRoute(objID));
2814  case VAR_SIGNALS:
2815  return wrapper->wrapInt(objID, variable, getSignals(objID));
2816  case VAR_STOPSTATE:
2817  return wrapper->wrapInt(objID, variable, getStopState(objID));
2818  case VAR_DISTANCE:
2819  return wrapper->wrapDouble(objID, variable, getDistance(objID));
2820  case VAR_ALLOWED_SPEED:
2821  return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
2822  case VAR_SPEED_FACTOR:
2823  return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
2824  case VAR_SPEEDSETMODE:
2825  return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
2826  case VAR_LANECHANGE_MODE:
2827  return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
2828  case VAR_ROUTING_MODE:
2829  return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
2830  case VAR_LINE:
2831  return wrapper->wrapString(objID, variable, getLine(objID));
2832  case VAR_VIA:
2833  return wrapper->wrapStringList(objID, variable, getVia(objID));
2834  case VAR_ACCELERATION:
2835  return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
2836  case VAR_LASTACTIONTIME:
2837  return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
2838  case VAR_STOP_DELAY:
2839  return wrapper->wrapDouble(objID, variable, getStopDelay(objID));
2840  case VAR_IMPATIENCE:
2841  return wrapper->wrapDouble(objID, variable, getImpatience(objID));
2842  case VAR_STOP_ARRIVALDELAY:
2843  return wrapper->wrapDouble(objID, variable, getStopArrivalDelay(objID));
2844  case VAR_TIMELOSS:
2845  return wrapper->wrapDouble(objID, variable, getTimeLoss(objID));
2846  case VAR_MINGAP_LAT:
2847  return wrapper->wrapDouble(objID, variable, getMinGapLat(objID));
2848  case VAR_LEADER: {
2849  paramData->readUnsignedByte();
2850  const double dist = paramData->readDouble();
2851  return wrapper->wrapStringDoublePair(objID, variable, getLeader(objID, dist));
2852  }
2853  case VAR_FOLLOWER: {
2854  paramData->readUnsignedByte();
2855  const double dist = paramData->readDouble();
2856  return wrapper->wrapStringDoublePair(objID, variable, getFollower(objID, dist));
2857  }
2858  case VAR_LOADED_LIST:
2859  return wrapper->wrapStringList(objID, variable, getLoadedIDList());
2860  case VAR_TELEPORTING_LIST:
2861  return wrapper->wrapStringList(objID, variable, getTeleportingIDList());
2863  paramData->readUnsignedByte();
2864  return wrapper->wrapString(objID, variable, getParameter(objID, paramData->readString()));
2866  paramData->readUnsignedByte();
2867  return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->readString()));
2868  case VAR_TAXI_FLEET:
2869  // we cannot use the general fall through here because we do not have an object id
2870  return false;
2871  default:
2872  return VehicleType::handleVariableWithID(objID, getTypeID(objID), variable, wrapper, paramData);
2873  }
2874 }
2875 
2876 
2877 }
2878 
2879 
2880 /****************************************************************************/
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
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
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
Definition: MEVehicle.h:200
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:55
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
double getImpatience() const
Returns this vehicles impatience.
virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
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 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 replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)
Performs a rerouting using the given router.
const std::vector< SUMOVehicleParameter::Stop > & getPastStops() const
const MSRoute & getRoute() const
Returns the current route.
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:1022
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:1046
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:474
double getLength() const
return the length of the edge
Definition: MSEdge.h:662
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:265
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:983
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:1106
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
Definition: MSEdge.cpp:873
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:712
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:2714
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2696
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:2560
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1316
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:2331
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition: MSLane.cpp:3994
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition: MSLane.h:841
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:4241
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:2355
bool isInternal() const
Definition: MSLane.cpp:2486
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:752
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:3655
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:182
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
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
Definition: MSRoute.cpp:311
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:73
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:790
void deactivateGapController()
Deactivates the gap control.
Definition: MSVehicle.cpp:412
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:779
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
Definition: MSVehicle.cpp:419
void setSublaneChange(double latDist)
Sets a new sublane-change request.
Definition: MSVehicle.cpp:433
void setSignals(int signals)
Definition: MSVehicle.h:1579
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:398
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:404
The class responsible for building and deletion of vehicles.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true, bool addRouteStops=true)
Builds a vehicle, increases the number of built 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 void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
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.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
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:5744
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:6259
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:6614
void setPreviousSpeed(double prevSpeed, double prevAcceleration)
Sets the influenced previous speed.
Definition: MSVehicle.cpp:7605
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5720
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:1242
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:6231
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:1043
bool resumeFromStopping()
Definition: MSVehicle.cpp:7119
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:2052
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
Definition: MSVehicle.cpp:7005
void switchOffSignal(int signal)
Switches the given signal off.
Definition: MSVehicle.h:1170
@ VEH_SIGNAL_NONE
Everything is switched off.
Definition: MSVehicle.h:1107
Influencer & getInfluencer()
Definition: MSVehicle.cpp:7183
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
Definition: MSVehicle.cpp:1443
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
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:5738
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:974
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSVehicle.h:1678
void setLateralPositionOnLane(double posLat)
Definition: MSVehicle.h:420
void switchOnSignal(int signal)
Switches the given signal on.
Definition: MSVehicle.h:1162
int getLaneIndex() const
Definition: MSVehicle.cpp:6608
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].
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
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:271
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:281
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 bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
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:60
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:1725
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:637
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition: Helper.cpp:1377
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:1417
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
virtual std::string readString()
Definition: storage.cpp:180
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual double readDouble()
Definition: storage.cpp:362
#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_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 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