Eclipse SUMO - Simulation of Urban MObility
Vehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // C++ Vehicle API
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <utils/geom/GeomHelper.h>
33 #include <microsim/MSVehicle.h>
35 #include <microsim/MSVehicleType.h>
37 #include <microsim/MSNet.h>
38 #include <microsim/MSEdge.h>
39 #include <microsim/MSLane.h>
40 #include <microsim/MSParkingArea.h>
41 #include <libsumo/TraCIDefs.h>
42 #include <libsumo/TraCIConstants.h>
43 #include "Helper.h"
44 #include "Route.h"
45 #include "Polygon.h"
46 #include "Vehicle.h"
47 
48 
49 // ===========================================================================
50 // debug defines
51 // ===========================================================================
52 //#define DEBUG_NEIGHBORS
53 //#define DEBUG_DYNAMIC_SHAPES
54 //#define DEBUG_MOVEXY
55 #define DEBUG_COND (veh->isSelected())
56 
57 
58 
59 namespace libsumo {
60 // ===========================================================================
61 // static member initializations
62 // ===========================================================================
65 
66 
67 // ===========================================================================
68 // static member definitions
69 // ===========================================================================
70 bool
72  return veh->isOnRoad() || veh->isParking() || veh->wasRemoteControlled();
73 }
74 
75 
76 bool
77 Vehicle::isOnInit(const std::string& vehicleID) {
78  SUMOVehicle* sumoVehicle = MSNet::getInstance()->getVehicleControl().getVehicle(vehicleID);
79  return sumoVehicle == nullptr || sumoVehicle->getLane() == nullptr;
80 }
81 
82 
83 std::vector<std::string>
85  std::vector<std::string> ids;
87  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
88  if (isVisible((*i).second)) {
89  ids.push_back((*i).first);
90  }
91  }
92  return ids;
93 }
94 
95 int
97  return (int)getIDList().size();
98 }
99 
100 
101 double
102 Vehicle::getSpeed(const std::string& vehicleID) {
103  MSVehicle* veh = Helper::getVehicle(vehicleID);
104  return isVisible(veh) ? veh->getSpeed() : INVALID_DOUBLE_VALUE;
105 }
106 
107 double
108 Vehicle::getLateralSpeed(const std::string& vehicleID) {
109  MSVehicle* veh = Helper::getVehicle(vehicleID);
111 }
112 
113 
114 double
115 Vehicle::getAcceleration(const std::string& vehicleID) {
116  MSVehicle* veh = Helper::getVehicle(vehicleID);
117  return isVisible(veh) ? veh->getAcceleration() : INVALID_DOUBLE_VALUE;
118 }
119 
120 
121 double
122 Vehicle::getSpeedWithoutTraCI(const std::string& vehicleID) {
123  MSVehicle* veh = Helper::getVehicle(vehicleID);
125 }
126 
127 
129 Vehicle::getPosition(const std::string& vehicleID, const bool includeZ) {
130  MSVehicle* veh = Helper::getVehicle(vehicleID);
131  if (isVisible(veh)) {
132  return Helper::makeTraCIPosition(veh->getPosition(), includeZ);
133  }
134  return TraCIPosition();
135 }
136 
137 
139 Vehicle::getPosition3D(const std::string& vehicleID) {
140  return getPosition(vehicleID, true);
141 }
142 
143 
144 double
145 Vehicle::getAngle(const std::string& vehicleID) {
146  MSVehicle* veh = Helper::getVehicle(vehicleID);
148 }
149 
150 
151 double
152 Vehicle::getSlope(const std::string& vehicleID) {
153  MSVehicle* veh = Helper::getVehicle(vehicleID);
154  return veh->isOnRoad() ? veh->getSlope() : INVALID_DOUBLE_VALUE;
155 }
156 
157 
158 std::string
159 Vehicle::getRoadID(const std::string& vehicleID) {
160  MSVehicle* veh = Helper::getVehicle(vehicleID);
161  return isVisible(veh) ? veh->getLane()->getEdge().getID() : "";
162 }
163 
164 
165 std::string
166 Vehicle::getLaneID(const std::string& vehicleID) {
167  MSVehicle* veh = Helper::getVehicle(vehicleID);
168  return veh->isOnRoad() ? veh->getLane()->getID() : "";
169 }
170 
171 
172 int
173 Vehicle::getLaneIndex(const std::string& vehicleID) {
174  MSVehicle* veh = Helper::getVehicle(vehicleID);
175  return veh->isOnRoad() ? veh->getLane()->getIndex() : INVALID_INT_VALUE;
176 }
177 
178 
179 std::string
180 Vehicle::getTypeID(const std::string& vehicleID) {
181  return Helper::getVehicleType(vehicleID).getID();
182 }
183 
184 
185 std::string
186 Vehicle::getRouteID(const std::string& vehicleID) {
187  return Helper::getVehicle(vehicleID)->getRoute().getID();
188 }
189 
190 
191 int
192 Vehicle::getRouteIndex(const std::string& vehicleID) {
193  MSVehicle* veh = Helper::getVehicle(vehicleID);
194  return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
195 }
196 
197 
199 Vehicle::getColor(const std::string& vehicleID) {
200  return Helper::makeTraCIColor(Helper::getVehicle(vehicleID)->getParameter().color);
201 }
202 
203 double
204 Vehicle::getLanePosition(const std::string& vehicleID) {
205  MSVehicle* veh = Helper::getVehicle(vehicleID);
206  return veh->isOnRoad() ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
207 }
208 
209 double
210 Vehicle::getLateralLanePosition(const std::string& vehicleID) {
211  MSVehicle* veh = Helper::getVehicle(vehicleID);
212  return veh->isOnRoad() ? veh->getLateralPositionOnLane() : INVALID_DOUBLE_VALUE;
213 }
214 
215 double
216 Vehicle::getCO2Emission(const std::string& vehicleID) {
217  MSVehicle* veh = Helper::getVehicle(vehicleID);
218  return isVisible(veh) ? veh->getCO2Emissions() : INVALID_DOUBLE_VALUE;
219 }
220 
221 double
222 Vehicle::getCOEmission(const std::string& vehicleID) {
223  MSVehicle* veh = Helper::getVehicle(vehicleID);
224  return isVisible(veh) ? veh->getCOEmissions() : INVALID_DOUBLE_VALUE;
225 }
226 
227 double
228 Vehicle::getHCEmission(const std::string& vehicleID) {
229  MSVehicle* veh = Helper::getVehicle(vehicleID);
230  return isVisible(veh) ? veh->getHCEmissions() : INVALID_DOUBLE_VALUE;
231 }
232 
233 double
234 Vehicle::getPMxEmission(const std::string& vehicleID) {
235  MSVehicle* veh = Helper::getVehicle(vehicleID);
236  return isVisible(veh) ? veh->getPMxEmissions() : INVALID_DOUBLE_VALUE;
237 }
238 
239 double
240 Vehicle::getNOxEmission(const std::string& vehicleID) {
241  MSVehicle* veh = Helper::getVehicle(vehicleID);
242  return isVisible(veh) ? veh->getNOxEmissions() : INVALID_DOUBLE_VALUE;
243 }
244 
245 double
246 Vehicle::getFuelConsumption(const std::string& vehicleID) {
247  MSVehicle* veh = Helper::getVehicle(vehicleID);
248  return isVisible(veh) ? veh->getFuelConsumption() : INVALID_DOUBLE_VALUE;
249 }
250 
251 double
252 Vehicle::getNoiseEmission(const std::string& vehicleID) {
253  MSVehicle* veh = Helper::getVehicle(vehicleID);
255 }
256 
257 double
258 Vehicle::getElectricityConsumption(const std::string& vehicleID) {
259  MSVehicle* veh = Helper::getVehicle(vehicleID);
261 }
262 
263 int
264 Vehicle::getPersonNumber(const std::string& vehicleID) {
265  return Helper::getVehicle(vehicleID)->getPersonNumber();
266 }
267 
268 int
269 Vehicle::getPersonCapacity(const std::string& vehicleID) {
270  return Helper::getVehicleType(vehicleID).getPersonCapacity();
271 }
272 
273 std::vector<std::string>
274 Vehicle::getPersonIDList(const std::string& vehicleID) {
275  return Helper::getVehicle(vehicleID)->getPersonIDList();
276 }
277 
278 std::pair<std::string, double>
279 Vehicle::getLeader(const std::string& vehicleID, double dist) {
280  MSVehicle* veh = Helper::getVehicle(vehicleID);
281  if (veh->isOnRoad()) {
282  std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist);
283  return std::make_pair(
284  leaderInfo.first != nullptr ? leaderInfo.first->getID() : "",
285  leaderInfo.second);
286  } else {
287  return std::make_pair("", -1);
288  }
289 }
290 
291 
292 double
293 Vehicle::getWaitingTime(const std::string& vehicleID) {
294  return Helper::getVehicle(vehicleID)->getWaitingSeconds();
295 }
296 
297 
298 double
299 Vehicle::getAccumulatedWaitingTime(const std::string& vehicleID) {
301 }
302 
303 
304 double
305 Vehicle::getAdaptedTraveltime(const std::string& vehicleID, double time, const std::string& edgeID) {
306  MSEdge* edge = Helper::getEdge(edgeID);
307  double value = INVALID_DOUBLE_VALUE;
308  Helper::getVehicle(vehicleID)->getWeightsStorage().retrieveExistingTravelTime(edge, time, value);
309  return value;
310 }
311 
312 
313 double
314 Vehicle::getEffort(const std::string& vehicleID, double time, const std::string& edgeID) {
315  MSEdge* edge = Helper::getEdge(edgeID);
316  double value = INVALID_DOUBLE_VALUE;
317  Helper::getVehicle(vehicleID)->getWeightsStorage().retrieveExistingEffort(edge, time, value);
318  return value;
319 }
320 
321 
322 bool
323 Vehicle::isRouteValid(const std::string& vehicleID) {
324  std::string msg;
325  return Helper::getVehicle(vehicleID)->hasValidRoute(msg);
326 }
327 
328 
329 std::vector<std::string>
330 Vehicle::getRoute(const std::string& vehicleID) {
331  std::vector<std::string> result;
332  MSVehicle* veh = Helper::getVehicle(vehicleID);
333  const MSRoute& r = veh->getRoute();
334  for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
335  result.push_back((*i)->getID());
336  }
337  return result;
338 }
339 
340 
341 int
342 Vehicle::getSignals(const std::string& vehicleID) {
343  return Helper::getVehicle(vehicleID)->getSignals();
344 }
345 
346 
347 std::vector<TraCIBestLanesData>
348 Vehicle::getBestLanes(const std::string& vehicleID) {
349  std::vector<TraCIBestLanesData> result;
350  MSVehicle* veh = Helper::getVehicle(vehicleID);
351  if (veh->isOnRoad()) {
352  const std::vector<MSVehicle::LaneQ>& bestLanes = veh->getBestLanes();
353  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
354  TraCIBestLanesData bld;
355  const MSVehicle::LaneQ& lq = *i;
356  bld.laneID = lq.lane->getID();
357  bld.length = lq.length;
358  bld.occupation = lq.nextOccupation;
361  for (std::vector<MSLane*>::const_iterator j = lq.bestContinuations.begin(); j != lq.bestContinuations.end(); ++j) {
362  if ((*j) != nullptr) {
363  bld.continuationLanes.push_back((*j)->getID());
364  }
365  }
366  result.push_back(bld);
367  }
368  }
369  return result;
370 }
371 
372 
373 std::vector<TraCINextTLSData>
374 Vehicle::getNextTLS(const std::string& vehicleID) {
375  std::vector<TraCINextTLSData> result;
376  MSVehicle* veh = Helper::getVehicle(vehicleID);
377  if (veh->isOnRoad()) {
378  const MSLane* lane = veh->getLane();
379  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
380  double seen = veh->getLane()->getLength() - veh->getPositionOnLane();
381  int view = 1;
382  MSLinkCont::const_iterator link = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
383  while (!lane->isLinkEnd(link)) {
384  if (!lane->getEdge().isInternal()) {
385  if ((*link)->isTLSControlled()) {
386  TraCINextTLSData ntd;
387  ntd.id = (*link)->getTLLogic()->getID();
388  ntd.tlIndex = (*link)->getTLIndex();
389  ntd.dist = seen;
390  ntd.state = (char)(*link)->getState();
391  result.push_back(ntd);
392  }
393  }
394  lane = (*link)->getViaLaneOrLane();
395  if (!lane->getEdge().isInternal()) {
396  view++;
397  }
398  seen += lane->getLength();
399  link = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
400  }
401  // consider edges beyond bestLanes
402  const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
403  //std::cout << SIMTIME << "remainingEdges=" << remainingEdges << " seen=" << seen << " view=" << view << " best=" << toString(bestLaneConts) << "\n";
404  for (int i = 0; i < remainingEdges; i++) {
405  const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
406  const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
407  const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
408  if (allowed != nullptr && allowed->size() != 0) {
409  for (MSLink* link : allowed->front()->getLinkCont()) {
410  if (&link->getLane()->getEdge() == next) {
411  if (link->isTLSControlled()) {
412  TraCINextTLSData ntd;
413  ntd.id = link->getTLLogic()->getID();
414  ntd.tlIndex = link->getTLIndex();
415  ntd.dist = seen;
416  ntd.state = (char)link->getState();
417  result.push_back(ntd);
418  }
419  seen += allowed->front()->getLength();
420  }
421  }
422  } else {
423  // invalid route, cannot determine nextTLS
424  break;
425  }
426  }
427  }
428  return result;
429 }
430 
431 
432 std::vector<TraCINextStopData>
433 Vehicle::getNextStops(const std::string& vehicleID) {
434  std::vector<TraCINextStopData> result;
435  MSVehicle* veh = Helper::getVehicle(vehicleID);
436  std::list<MSVehicle::Stop> stops = veh->getMyStops();
437  for (std::list<MSVehicle::Stop>::iterator it = stops.begin(); it != stops.end(); ++it) {
438  if (!it->collision) {
439  TraCINextStopData nsd;
440  nsd.lane = it->lane->getID();
441  nsd.endPos = it->getEndPos(*veh);
442  // all optionals, only one can be set
443  if (it->busstop != nullptr) {
444  nsd.stoppingPlaceID = it->busstop->getID();
445  }
446  if (it->containerstop != nullptr) {
447  nsd.stoppingPlaceID = it->containerstop->getID();
448  }
449  if (it->parkingarea != nullptr) {
450  nsd.stoppingPlaceID = it->parkingarea->getID();
451  }
452  if (it->chargingStation != nullptr) {
453  nsd.stoppingPlaceID = it->chargingStation->getID();
454  }
455  nsd.stopFlags = ((it->reached ? 1 : 0) +
456  (it->pars.parking ? 2 : 0) +
457  (it->pars.triggered ? 4 : 0) +
458  (it->pars.containerTriggered ? 8 : 0) +
459  (it->busstop != nullptr ? 16 : 0) +
460  (it->containerstop != nullptr ? 32 : 0) +
461  (it->chargingStation != nullptr ? 64 : 0) +
462  (it->parkingarea != nullptr ? 128 : 0));
463  nsd.duration = STEPS2TIME(it->reached ? it->duration : it->pars.duration);
464  nsd.until = STEPS2TIME(it->pars.until);
465  result.push_back(nsd);
466  }
467  }
468  return result;
469 }
470 
471 
472 int
473 Vehicle::getStopState(const std::string& vehicleID) {
474  MSVehicle* veh = Helper::getVehicle(vehicleID);
475  int result = 0;
476  if (veh->isStopped()) {
477  const MSVehicle::Stop& stop = veh->getNextStop();
478  result = ((stop.reached ? 1 : 0) +
479  (stop.pars.parking ? 2 : 0) +
480  (stop.pars.triggered ? 4 : 0) +
481  (stop.pars.containerTriggered ? 8 : 0) +
482  (stop.busstop != nullptr ? 16 : 0) +
483  (stop.containerstop != nullptr ? 32 : 0) +
484  (stop.chargingStation != nullptr ? 64 : 0) +
485  (stop.parkingarea != nullptr ? 128 : 0));
486  }
487  return result;
488 }
489 
490 
491 double
492 Vehicle::getDistance(const std::string& vehicleID) {
493  MSVehicle* veh = Helper::getVehicle(vehicleID);
494  if (veh->isOnRoad()) {
495  double distance;
496  if (veh->getLane()->isInternal()) {
497  // route edge still points to the edge before the intersection
498  const double normalEnd = (*veh->getCurrentRouteEdge())->getLength();
499  distance = (veh->getRoute().getDistanceBetween(veh->getDepartPos(), normalEnd,
500  veh->getRoute().begin(), veh->getCurrentRouteEdge())
501  + veh->getRoute().getDistanceBetween(normalEnd, veh->getPositionOnLane(),
502  *veh->getCurrentRouteEdge(), &veh->getLane()->getEdge()));
503  } else {
504  distance = veh->getRoute().getDistanceBetween(veh->getDepartPos(), veh->getPositionOnLane(),
505  veh->getRoute().begin(), veh->getCurrentRouteEdge());
506  }
507  if (distance == std::numeric_limits<double>::max()) {
508  return INVALID_DOUBLE_VALUE;
509  } else {
510  return distance;
511  }
512  } else {
513  return INVALID_DOUBLE_VALUE;
514  }
515 }
516 
517 
518 double
519 Vehicle::getDrivingDistance(const std::string& vehicleID, const std::string& edgeID, double position, int /* laneIndex */) {
520  MSVehicle* veh = Helper::getVehicle(vehicleID);
521  if (veh->isOnRoad()) {
522  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), position,
523  &veh->getLane()->getEdge(), Helper::getEdge(edgeID), true, veh->getRoutePosition());
524  if (distance == std::numeric_limits<double>::max()) {
525  return INVALID_DOUBLE_VALUE;
526  }
527  return distance;
528  } else {
529  return INVALID_DOUBLE_VALUE;
530  }
531 }
532 
533 
534 double
535 Vehicle::getDrivingDistance2D(const std::string& vehicleID, double x, double y) {
536  MSVehicle* veh = Helper::getVehicle(vehicleID);
537  if (veh->isOnRoad()) {
538  std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y), veh->getVehicleType().getVehicleClass());
539  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
540  veh->getEdge(), &roadPos.first->getEdge(), true, veh->getRoutePosition());
541  if (distance == std::numeric_limits<double>::max()) {
542  return INVALID_DOUBLE_VALUE;
543  }
544  return distance;
545  } else {
546  return INVALID_DOUBLE_VALUE;
547  }
548 }
549 
550 
551 double
552 Vehicle::getAllowedSpeed(const std::string& vehicleID) {
553  MSVehicle* veh = Helper::getVehicle(vehicleID);
554  if (veh->isOnRoad()) {
555  return veh->getLane()->getVehicleMaxSpeed(veh);
556  } else {
557  return INVALID_DOUBLE_VALUE;
558  }
559 }
560 
561 
562 double
563 Vehicle::getSpeedFactor(const std::string& vehicleID) {
564  return Helper::getVehicle(vehicleID)->getChosenSpeedFactor();
565 }
566 
567 
568 int
569 Vehicle::getSpeedMode(const std::string& vehicleID) {
570  return Helper::getVehicle(vehicleID)->getInfluencer().getSpeedMode();
571 }
572 
573 
574 int
575 Vehicle::getLaneChangeMode(const std::string& vehicleID) {
576  return Helper::getVehicle(vehicleID)->getInfluencer().getLaneChangeMode();
577 }
578 
579 
580 int
581 Vehicle::getRoutingMode(const std::string& vehicleID) {
582  return Helper::getVehicle(vehicleID)->getInfluencer().getRoutingMode();
583 }
584 
585 
586 std::string
587 Vehicle::getLine(const std::string& vehicleID) {
588  return Helper::getVehicle(vehicleID)->getParameter().line;
589 }
590 
591 
592 std::vector<std::string>
593 Vehicle::getVia(const std::string& vehicleID) {
594  return Helper::getVehicle(vehicleID)->getParameter().via;
595 }
596 
597 
598 std::pair<int, int>
599 Vehicle::getLaneChangeState(const std::string& vehicleID, int direction) {
600  MSVehicle* veh = Helper::getVehicle(vehicleID);
601  if (veh->isOnRoad()) {
602  return veh->getLaneChangeModel().getSavedState(direction);
603  } else {
604  return std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
605  }
606 }
607 
608 
609 std::string
610 Vehicle::getParameter(const std::string& vehicleID, const std::string& key) {
611  MSVehicle* veh = Helper::getVehicle(vehicleID);
612  if (StringUtils::startsWith(key, "device.")) {
613  StringTokenizer tok(key, ".");
614  if (tok.size() < 3) {
615  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehicleID + "'.");
616  }
617  try {
618  return veh->getDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2));
619  } catch (InvalidArgument& e) {
620  throw TraCIException("Vehicle '" + vehicleID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
621  }
622  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
623  const std::string attrName = key.substr(16);
624  try {
625  return veh->getLaneChangeModel().getParameter(attrName);
626  } catch (InvalidArgument& e) {
627  throw TraCIException("Vehicle '" + vehicleID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
628  }
629  } else if (StringUtils::startsWith(key, "carFollowModel.")) {
630  const std::string attrName = key.substr(15);
631  try {
632  return veh->getCarFollowModel().getParameter(veh, attrName);
633  } catch (InvalidArgument& e) {
634  throw TraCIException("Vehicle '" + vehicleID + "' does not support carFollowModel parameter '" + key + "' (" + e.what() + ").");
635  }
636  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
637  StringTokenizer tok(key, ".");
638  if (tok.size() != 3) {
639  throw TraCIException("Invalid check for device. Expected format is 'has.DEVICENAME.device'.");
640  }
641  return veh->hasDevice(tok.get(1)) ? "true" : "false";
642  } else {
643  return veh->getParameter().getParameter(key, "");
644  }
645 }
646 
647 
648 std::vector<std::pair<std::string, double> >
649 Vehicle::getNeighbors(const std::string& vehicleID, const int mode) {
650  int dir = (1 & mode) != 0 ? -1 : 1;
651  bool queryLeaders = (2 & mode) != 0;
652  bool blockersOnly = (4 & mode) != 0;
653 
654  MSVehicle* veh = Helper::getVehicle(vehicleID);
655  std::vector<std::pair<std::string, double> > neighs;
656  auto& lcm = veh->getLaneChangeModel();
657 
658 #ifdef DEBUG_NEIGHBORS
659  if (DEBUG_COND) {
660  std::cout << "getNeighbors() for veh '" << vehicleID << "': dir=" << dir
661  << ", queryLeaders=" << queryLeaders
662  << ", blockersOnly=" << blockersOnly << std::endl;
663  }
664 #endif
665 
666 
667 
668  if (blockersOnly) {
669  // Check if a blocking neigh exists in the given direction
670  bool blocked = false;
671  if (dir == -1) {
672  if (queryLeaders) {
673  blocked = (lcm.getOwnState() & LCA_BLOCKED_BY_RIGHT_LEADER) != 0;
674  } else {
675  blocked = (lcm.getOwnState() & LCA_BLOCKED_BY_RIGHT_FOLLOWER) != 0;
676  }
677  } else {
678  if (queryLeaders) {
679  blocked = (lcm.getOwnState() & LCA_BLOCKED_BY_LEFT_LEADER) != 0;
680  } else {
681  blocked = (lcm.getOwnState() & LCA_BLOCKED_BY_LEFT_FOLLOWER) != 0;
682  }
683  }
684 
685 #ifdef DEBUG_NEIGHBORS
686  if (DEBUG_COND) {
687  std::cout << " blocked=" << blocked << std::endl;
688  }
689 #endif
690 
691  if (!blocked) {
692  // Not blocked => return empty vector
693  return neighs;
694  }
695  }
696 
697  const std::shared_ptr<MSLeaderDistanceInfo> res = queryLeaders ? lcm.getLeaders(dir) : lcm.getFollowers(dir);
698  if (res != nullptr && res->hasVehicles()) {
699  auto distIt = begin(res->getDistances());
700  auto vehIt = begin(res->getVehicles());
701  while (distIt != end(res->getDistances())) {
702  if (*vehIt != nullptr) {
703  if (neighs.size() == 0 || neighs.back().first != (*vehIt)->getID()) {
704  neighs.push_back(std::make_pair((*vehIt)->getID(), *distIt));
705  }
706  }
707  ++vehIt;
708  ++distIt;
709  }
710  }
711  return neighs;
712 }
713 
714 
715 std::string
716 Vehicle::getEmissionClass(const std::string& vehicleID) {
717  return PollutantsInterface::getName(Helper::getVehicleType(vehicleID).getEmissionClass());
718 }
719 
720 std::string
721 Vehicle::getShapeClass(const std::string& vehicleID) {
722  return getVehicleShapeName(Helper::getVehicleType(vehicleID).getGuiShape());
723 }
724 
725 
726 double
727 Vehicle::getLength(const std::string& vehicleID) {
728  return Helper::getVehicleType(vehicleID).getLength();
729 }
730 
731 
732 double
733 Vehicle::getAccel(const std::string& vehicleID) {
735 }
736 
737 
738 double
739 Vehicle::getDecel(const std::string& vehicleID) {
741 }
742 
743 
744 double Vehicle::getEmergencyDecel(const std::string& vehicleID) {
746 }
747 
748 
749 double Vehicle::getApparentDecel(const std::string& vehicleID) {
751 }
752 
753 
754 double Vehicle::getActionStepLength(const std::string& vehicleID) {
756 }
757 
758 
759 double Vehicle::getLastActionTime(const std::string& vehicleID) {
760  return STEPS2TIME(Helper::getVehicle(vehicleID)->getLastActionTime());
761 }
762 
763 
764 double
765 Vehicle::getTau(const std::string& vehicleID) {
767 }
768 
769 
770 double
771 Vehicle::getImperfection(const std::string& vehicleID) {
773 }
774 
775 
776 double
777 Vehicle::getSpeedDeviation(const std::string& vehicleID) {
778  return Helper::getVehicleType(vehicleID).getSpeedFactor().getParameter()[1];
779 }
780 
781 
782 std::string
783 Vehicle::getVehicleClass(const std::string& vehicleID) {
784  return toString(Helper::getVehicleType(vehicleID).getVehicleClass());
785 }
786 
787 
788 double
789 Vehicle::getMinGap(const std::string& vehicleID) {
790  return Helper::getVehicleType(vehicleID).getMinGap();
791 }
792 
793 
794 double
795 Vehicle::getMinGapLat(const std::string& vehicleID) {
796  return Helper::getVehicleType(vehicleID).getMinGapLat();
797 }
798 
799 
800 double
801 Vehicle::getMaxSpeed(const std::string& vehicleID) {
802  return Helper::getVehicleType(vehicleID).getMaxSpeed();
803 }
804 
805 
806 double
807 Vehicle::getMaxSpeedLat(const std::string& vehicleID) {
808  return Helper::getVehicleType(vehicleID).getMaxSpeedLat();
809 }
810 
811 
812 std::string
813 Vehicle::getLateralAlignment(const std::string& vehicleID) {
814  return toString(Helper::getVehicleType(vehicleID).getPreferredLateralAlignment());
815 }
816 
817 
818 double
819 Vehicle::getWidth(const std::string& vehicleID) {
820  return Helper::getVehicleType(vehicleID).getWidth();
821 }
822 
823 
824 double
825 Vehicle::getHeight(const std::string& vehicleID) {
826  return Helper::getVehicleType(vehicleID).getHeight();
827 }
828 
829 
830 void
831 Vehicle::setStop(const std::string& vehicleID,
832  const std::string& edgeID,
833  double pos,
834  int laneIndex,
835  double duration,
836  int flags,
837  double startPos,
838  double until) {
839  MSVehicle* veh = Helper::getVehicle(vehicleID);
840  // optional stop flags
841  bool parking = false;
842  bool triggered = false;
843  bool containerTriggered = false;
844  SumoXMLTag stoppingPlaceType = SUMO_TAG_NOTHING;
845 
846  parking = ((flags & 1) != 0);
847  triggered = ((flags & 2) != 0);
848  containerTriggered = ((flags & 4) != 0);
849  if ((flags & 8) != 0) {
850  stoppingPlaceType = SUMO_TAG_BUS_STOP;
851  }
852  if ((flags & 16) != 0) {
853  stoppingPlaceType = SUMO_TAG_CONTAINER_STOP;
854  }
855  if ((flags & 32) != 0) {
856  stoppingPlaceType = SUMO_TAG_CHARGING_STATION;
857  }
858  if ((flags & 64) != 0) {
859  stoppingPlaceType = SUMO_TAG_PARKING_AREA;
860  }
861  const SUMOTime durationSteps = duration == INVALID_DOUBLE_VALUE ? SUMOTime_MAX : TIME2STEPS(duration);
862  const SUMOTime untilStep = until == INVALID_DOUBLE_VALUE ? -1 : TIME2STEPS(until);
863 
864  std::string error;
865  if (stoppingPlaceType != SUMO_TAG_NOTHING) {
866  // Forward command to vehicle
867  if (!veh->addTraciStopAtStoppingPlace(edgeID, durationSteps, untilStep, parking, triggered, containerTriggered, stoppingPlaceType, error)) {
868  throw TraCIException(error);
869  }
870  } else {
871  // check
872  if (startPos == INVALID_DOUBLE_VALUE) {
873  startPos = pos - POSITION_EPS;
874  }
875  if (startPos < 0.) {
876  throw TraCIException("Position on lane must not be negative.");
877  }
878  if (pos < startPos) {
879  throw TraCIException("End position on lane must be after start position.");
880  }
881  // get the actual lane that is referenced by laneIndex
882  MSEdge* road = MSEdge::dictionary(edgeID);
883  if (road == nullptr) {
884  throw TraCIException("Edge '" + edgeID + "' is not known.");
885  }
886  const std::vector<MSLane*>& allLanes = road->getLanes();
887  if ((laneIndex < 0) || laneIndex >= (int)(allLanes.size())) {
888  throw TraCIException("No lane with index '" + toString(laneIndex) + "' on edge '" + edgeID + "'.");
889  }
890  // Forward command to vehicle
891  if (!veh->addTraciStop(allLanes[laneIndex], startPos, pos, durationSteps, untilStep, parking, triggered, containerTriggered, error)) {
892  throw TraCIException(error);
893  }
894  }
895 }
896 
897 void
898 Vehicle::rerouteParkingArea(const std::string& vehicleID, const std::string& parkingAreaID) {
899  MSVehicle* veh = Helper::getVehicle(vehicleID);
900  std::string error;
901  // Forward command to vehicle
902  if (!veh->rerouteParkingArea(parkingAreaID, error)) {
903  throw TraCIException(error);
904  }
905 }
906 
907 void
908 Vehicle::resume(const std::string& vehicleID) {
909  MSVehicle* veh = Helper::getVehicle(vehicleID);
910  if (!veh->hasStops()) {
911  throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
912  }
913  if (!veh->resumeFromStopping()) {
914  MSVehicle::Stop& sto = veh->getNextStop();
915  std::ostringstream strs;
916  strs << "reached: " << sto.reached;
917  strs << ", duration:" << sto.duration;
918  strs << ", edge:" << (*sto.edge)->getID();
919  strs << ", startPos: " << sto.pars.startPos;
920  std::string posStr = strs.str();
921  throw TraCIException("Failed to resume from stopping for vehicle '" + veh->getID() + "', " + posStr);
922  }
923 }
924 
925 
926 void
927 Vehicle::changeTarget(const std::string& vehicleID, const std::string& edgeID) {
928  MSVehicle* veh = Helper::getVehicle(vehicleID);
929  const MSEdge* destEdge = MSEdge::dictionary(edgeID);
930  const bool onInit = isOnInit(vehicleID);
931  if (destEdge == nullptr) {
932  throw TraCIException("Destination edge '" + edgeID + "' is not known.");
933  }
934  // build a new route between the vehicle's current edge and destination edge
935  ConstMSEdgeVector newRoute;
936  const MSEdge* currentEdge = veh->getRerouteOrigin();
938  currentEdge, destEdge, (const MSVehicle * const)veh, MSNet::getInstance()->getCurrentTimeStep(), newRoute);
939  // replace the vehicle's route by the new one (cost is updated by call to reroute())
940  if (!veh->replaceRouteEdges(newRoute, -1, 0, "traci:changeTarget", onInit)) {
941  throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "'.");
942  }
943  // route again to ensure usage of via/stops
944  try {
945  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget", veh->getInfluencer().getRouterTT(), onInit);
946  } catch (ProcessError& e) {
947  throw TraCIException(e.what());
948  }
949 }
950 
951 
952 void
953 Vehicle::changeLane(const std::string& vehicleID, int laneIndex, double duration) {
954  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
955  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
956  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
957  Helper::getVehicle(vehicleID)->getInfluencer().setLaneTimeLine(laneTimeLine);
958 }
959 
960 void
961 Vehicle::changeLaneRelative(const std::string& vehicleID, int indexOffset, double duration) {
962  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
963  int laneIndex = Helper::getVehicle(vehicleID)->getLaneIndex() + indexOffset;
964  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
965  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
966  Helper::getVehicle(vehicleID)->getInfluencer().setLaneTimeLine(laneTimeLine);
967 }
968 
969 
970 void
971 Vehicle::changeSublane(const std::string& vehicleID, double latDist) {
972  Helper::getVehicle(vehicleID)->getInfluencer().setSublaneChange(latDist);
973 }
974 
975 
976 void
977 Vehicle::add(const std::string& vehicleID,
978  const std::string& routeID,
979  const std::string& typeID,
980  const std::string& depart,
981  const std::string& departLane,
982  const std::string& departPos,
983  const std::string& departSpeed,
984  const std::string& arrivalLane,
985  const std::string& arrivalPos,
986  const std::string& arrivalSpeed,
987  const std::string& fromTaz,
988  const std::string& toTaz,
989  const std::string& line,
990  int /*personCapacity*/,
991  int personNumber) {
993  if (veh != nullptr) {
994  throw TraCIException("The vehicle '" + vehicleID + "' to add already exists.");
995  }
996 
997  SUMOVehicleParameter vehicleParams;
998  vehicleParams.id = vehicleID;
999  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1000  if (!vehicleType) {
1001  throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehicleID + "'.");
1002  }
1003  const MSRoute* route = MSRoute::dictionary(routeID);
1004  if (!route) {
1005  if (routeID == "") {
1006  // assume, route was intentionally left blank because the caller
1007  // intends to control the vehicle remotely
1008  SUMOVehicleClass vclass = vehicleType->getVehicleClass();
1009  const std::string dummyRouteID = "DUMMY_ROUTE_" + SumoVehicleClassStrings.getString(vclass);
1010  route = MSRoute::dictionary(dummyRouteID);
1011  if (route == nullptr) {
1012  for (MSEdge* e : MSEdge::getAllEdges()) {
1013  if (e->getFunction() == EDGEFUNC_NORMAL && (e->getPermissions() & vclass) == vclass) {
1014  std::vector<std::string> edges;
1015  edges.push_back(e->getID());
1016  libsumo::Route::add(dummyRouteID, edges);
1017  break;
1018  }
1019  }
1020  }
1021  route = MSRoute::dictionary(dummyRouteID);
1022  if (!route) {
1023  throw TraCIException("Could not build dummy route for vehicle class: '" + SumoVehicleClassStrings.getString(vehicleType->getVehicleClass()) + "'");
1024  }
1025  } else {
1026  throw TraCIException("Invalid route '" + routeID + "' for vehicle '" + vehicleID + "'.");
1027  }
1028  }
1029  // check if the route implies a trip
1030  if (route->getEdges().size() == 2) {
1031  const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
1032  if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
1033  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1034  }
1035  }
1036  if (fromTaz != "" || toTaz != "") {
1037  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1038  }
1039  std::string error;
1040  if (!SUMOVehicleParameter::parseDepart(depart, "vehicle", vehicleID, vehicleParams.depart, vehicleParams.departProcedure, error)) {
1041  throw TraCIException(error);
1042  }
1043  if (vehicleParams.departProcedure == DEPART_GIVEN && vehicleParams.depart < MSNet::getInstance()->getCurrentTimeStep()) {
1044  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1045  WRITE_WARNING("Departure time for vehicle '" + vehicleID + "' is in the past; using current time instead.");
1046  } else if (vehicleParams.departProcedure == DEPART_NOW) {
1047  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1048  }
1049  if (!SUMOVehicleParameter::parseDepartLane(departLane, "vehicle", vehicleID, vehicleParams.departLane, vehicleParams.departLaneProcedure, error)) {
1050  throw TraCIException(error);
1051  }
1052  if (!SUMOVehicleParameter::parseDepartPos(departPos, "vehicle", vehicleID, vehicleParams.departPos, vehicleParams.departPosProcedure, error)) {
1053  throw TraCIException(error);
1054  }
1055  if (!SUMOVehicleParameter::parseDepartSpeed(departSpeed, "vehicle", vehicleID, vehicleParams.departSpeed, vehicleParams.departSpeedProcedure, error)) {
1056  throw TraCIException(error);
1057  }
1058  if (!SUMOVehicleParameter::parseArrivalLane(arrivalLane, "vehicle", vehicleID, vehicleParams.arrivalLane, vehicleParams.arrivalLaneProcedure, error)) {
1059  throw TraCIException(error);
1060  }
1061  if (!SUMOVehicleParameter::parseArrivalPos(arrivalPos, "vehicle", vehicleID, vehicleParams.arrivalPos, vehicleParams.arrivalPosProcedure, error)) {
1062  throw TraCIException(error);
1063  }
1064  if (!SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeed, "vehicle", vehicleID, vehicleParams.arrivalSpeed, vehicleParams.arrivalSpeedProcedure, error)) {
1065  throw TraCIException(error);
1066  }
1067  vehicleParams.fromTaz = fromTaz;
1068  vehicleParams.toTaz = toTaz;
1069  vehicleParams.line = line;
1070  //vehicleParams.personCapacity = personCapacity;
1071  vehicleParams.personNumber = personNumber;
1072 
1073  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
1074  try {
1075  SUMOVehicle* vehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(params, route, vehicleType, true, false);
1076  MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
1078  } catch (ProcessError& e) {
1079  throw TraCIException(e.what());
1080  }
1081 }
1082 
1083 
1084 void
1085 Vehicle::moveToXY(const std::string& vehicleID, const std::string& edgeID, const int laneIndex,
1086  const double x, const double y, double angle, const int keepRoute) {
1087  MSVehicle* veh = Helper::getVehicle(vehicleID);
1088  const bool doKeepRoute = (keepRoute & 1) != 0 && veh->getID() != "VTD_EGO";
1089  const bool mayLeaveNetwork = (keepRoute & 2) != 0;
1090  const bool ignorePermissions = (keepRoute & 4) != 0;
1091  SUMOVehicleClass vClass = ignorePermissions ? SVC_IGNORING : veh->getVClass();
1092  // process
1093  const std::string origID = edgeID + "_" + toString(laneIndex);
1094  // @todo add an interpretation layer for OSM derived origID values (without lane index)
1095  Position pos(x, y);
1096 #ifdef DEBUG_MOVEXY
1097  const double origAngle = angle;
1098 #endif
1099  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
1100  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
1101  if (angle != INVALID_DOUBLE_VALUE) {
1102  while (angle >= 360.) {
1103  angle -= 360.;
1104  }
1105  while (angle < 0.) {
1106  angle += 360.;
1107  }
1108  }
1109 
1110  Position vehPos = veh->getPosition();
1111 #ifdef DEBUG_MOVEXY
1112  std::cout << std::endl << SIMTIME << " moveToXY veh=" << veh->getID() << " vehPos=" << vehPos << " lane=" << Named::getIDSecure(veh->getLane()) << std::endl;
1113  std::cout << " wantedPos=" << pos << " origID=" << origID << " laneIndex=" << laneIndex << " origAngle=" << origAngle << " angle=" << angle << " keepRoute=" << keepRoute << std::endl;
1114 #endif
1115 
1116  ConstMSEdgeVector edges;
1117  MSLane* lane = nullptr;
1118  double lanePos;
1119  double lanePosLat = 0;
1120  double bestDistance = std::numeric_limits<double>::max();
1121  int routeOffset = 0;
1122  bool found;
1123  double maxRouteDistance = 100;
1124  /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
1125  if (doKeepRoute) {
1126  // case a): vehicle is on its earlier route
1127  // we additionally assume it is moving forward (SUMO-limit);
1128  // note that the route ("edges") is not changed in this case
1129 
1130  found = Helper::moveToXYMap_matchingRoutePosition(pos, origID,
1131  veh->getRoute().getEdges(), (int)(veh->getCurrentRouteEdge() - veh->getRoute().begin()),
1132  vClass,
1133  bestDistance, &lane, lanePos, routeOffset);
1134  // @note silenty ignoring mapping failure
1135  } else {
1136  double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
1137  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
1138  speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
1139  vClass,
1140  bestDistance, &lane, lanePos, routeOffset, edges);
1141  }
1142  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1143  // optionally compute lateral offset
1144  pos.setz(veh->getPosition().z());
1145  if (found && (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork)) {
1146  const double perpDist = lane->getShape().distance2D(pos, false);
1147  if (perpDist != GeomHelper::INVALID_OFFSET) {
1148  lanePosLat = perpDist;
1149  if (!mayLeaveNetwork) {
1150  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
1151  }
1152  // figure out whether the offset is to the left or to the right
1153  PositionVector tmp = lane->getShape();
1154  try {
1155  tmp.move2side(-lanePosLat); // moved to left
1156  } catch (ProcessError&) {
1157  WRITE_WARNING("Could not determine position on lane '" + lane->getID() + "' at lateral position " + toString(-lanePosLat) + ".");
1158  }
1159  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
1160  if (tmp.distance2D(pos) > perpDist) {
1161  lanePosLat = -lanePosLat;
1162  }
1163  }
1164  pos.setz(lane->geometryPositionAtOffset(lanePos).z());
1165  }
1166  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
1167  // mapped position may differ from pos
1168  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1169  }
1170  assert((found && lane != 0) || (!found && lane == 0));
1171  if (angle == INVALID_DOUBLE_VALUE) {
1172  if (lane != nullptr) {
1173  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
1174  } else {
1175  // compute angle outside road network from old and new position
1176  angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
1177  }
1178  }
1179  // use the best we have
1180 #ifdef DEBUG_MOVEXY
1181  std::cout << SIMTIME << " veh=" << vehicleID + " moveToXYResult lane='" << Named::getIDSecure(lane) << "' lanePos=" << lanePos << " lanePosLat=" << lanePosLat << "\n";
1182 #endif
1183  Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
1184  if (!veh->isOnRoad()) {
1186  }
1187  } else {
1188  if (lane == nullptr) {
1189  throw TraCIException("Could not map vehicle '" + vehicleID + "', no road found within " + toString(maxRouteDistance) + "m.");
1190  } else {
1191  throw TraCIException("Could not map vehicle '" + vehicleID + "', distance to road is " + toString(bestDistance) + ".");
1192  }
1193  }
1194 }
1195 
1196 void
1197 Vehicle::slowDown(const std::string& vehicleID, double speed, double duration) {
1198  MSVehicle* veh = Helper::getVehicle(vehicleID);
1199  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1200  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1201  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), speed));
1202  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1203 }
1204 
1205 void
1206 Vehicle::openGap(const std::string& vehicleID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
1207  MSVehicle* veh = Helper::getVehicle(vehicleID);
1208  MSVehicle* refVeh = nullptr;
1209  if (referenceVehID != "") {
1210  refVeh = Helper::getVehicle(referenceVehID);
1211  }
1212  const double originalTau = veh->getVehicleType().getCarFollowModel().getHeadwayTime();
1213  if (newTimeHeadway == -1) {
1214  newTimeHeadway = originalTau;
1215  }
1216  if (originalTau > newTimeHeadway) {
1217  WRITE_WARNING("Ignoring openGap(). New time headway must not be smaller than the original.");
1218  return;
1219  }
1220  veh->getInfluencer().activateGapController(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
1221 }
1222 
1223 void
1224 Vehicle::deactivateGapControl(const std::string& vehicleID) {
1225  MSVehicle* veh = Helper::getVehicle(vehicleID);
1226  if (veh->hasInfluencer()) {
1228  }
1229 }
1230 
1231 void
1232 Vehicle::requestToC(const std::string& vehID, double leadTime) {
1233  setParameter(vehID, "device.toc.requestToC", toString(leadTime));
1234 }
1235 
1236 void
1237 Vehicle::setSpeed(const std::string& vehicleID, double speed) {
1238  MSVehicle* veh = Helper::getVehicle(vehicleID);
1239  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1240  if (speed >= 0) {
1241  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), speed));
1242  speedTimeLine.push_back(std::make_pair(SUMOTime_MAX - DELTA_T, speed));
1243  }
1244  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1245 }
1246 
1247 void
1248 Vehicle::setSpeedMode(const std::string& vehicleID, int speedMode) {
1249  Helper::getVehicle(vehicleID)->getInfluencer().setSpeedMode(speedMode);
1250 }
1251 
1252 void
1253 Vehicle::setLaneChangeMode(const std::string& vehicleID, int laneChangeMode) {
1254  Helper::getVehicle(vehicleID)->getInfluencer().setLaneChangeMode(laneChangeMode);
1255 }
1256 
1257 void
1258 Vehicle::setRoutingMode(const std::string& vehicleID, int routingMode) {
1259  Helper::getVehicle(vehicleID)->getInfluencer().setRoutingMode(routingMode);
1260 }
1261 
1262 void
1263 Vehicle::setType(const std::string& vehicleID, const std::string& typeID) {
1264  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1265  if (vehicleType == nullptr) {
1266  throw TraCIException("Vehicle type '" + typeID + "' is not known");
1267  }
1268  Helper::getVehicle(vehicleID)->replaceVehicleType(vehicleType);
1269 }
1270 
1271 void
1272 Vehicle::setRouteID(const std::string& vehicleID, const std::string& routeID) {
1273  MSVehicle* veh = Helper::getVehicle(vehicleID);
1274  const MSRoute* r = MSRoute::dictionary(routeID);
1275  if (r == nullptr) {
1276  throw TraCIException("The route '" + routeID + "' is not known.");
1277  }
1278  std::string msg;
1279  if (!veh->hasValidRoute(msg, r)) {
1280  WRITE_WARNING("Invalid route replacement for vehicle '" + veh->getID() + "'. " + msg);
1282  throw TraCIException("Route replacement failed for " + veh->getID());
1283  }
1284  }
1285 
1286  if (!veh->replaceRoute(r, "traci:setRouteID", veh->getLane() == nullptr)) {
1287  throw TraCIException("Route replacement failed for " + veh->getID());
1288  }
1289 }
1290 
1291 void
1292 Vehicle::setRoute(const std::string& vehicleID, const std::vector<std::string>& edgeIDs) {
1293  MSVehicle* veh = Helper::getVehicle(vehicleID);
1294  ConstMSEdgeVector edges;
1295  try {
1296  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
1297  if (edges.size() > 0 && edges.back()->isInternal()) {
1298  edges.push_back(edges.back()->getLanes()[0]->getNextNormal());
1299  }
1300  } catch (ProcessError& e) {
1301  throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
1302  }
1303  if (!veh->replaceRouteEdges(edges, -1, 0, "traci:setRoute", veh->getLane() == nullptr, true)) {
1304  throw TraCIException("Route replacement failed for " + veh->getID());
1305  }
1306 }
1307 
1308 void
1309 Vehicle::updateBestLanes(const std::string& vehicleID) {
1310  MSVehicle* veh = Helper::getVehicle(vehicleID);
1311  veh->updateBestLanes(true);
1312 }
1313 
1314 
1315 void
1316 Vehicle::setAdaptedTraveltime(const std::string& vehicleID, const std::string& edgeID,
1317  double time, double begSeconds, double endSeconds) {
1318  MSVehicle* veh = Helper::getVehicle(vehicleID);
1319  MSEdge* edge = MSEdge::dictionary(edgeID);
1320  if (edge == nullptr) {
1321  throw TraCIException("Edge '" + edgeID + "' is not known.");
1322  }
1323  if (time != INVALID_DOUBLE_VALUE) {
1324  // add time
1325  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1326  // clean up old values before setting whole range
1327  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
1328  veh->getWeightsStorage().removeTravelTime(edge);
1329  }
1330  }
1331  veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
1332  } else {
1333  // remove time
1334  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
1335  veh->getWeightsStorage().removeTravelTime(edge);
1336  }
1337  }
1338 }
1339 
1340 
1341 void
1342 Vehicle::setEffort(const std::string& vehicleID, const std::string& edgeID,
1343  double effort, double begSeconds, double endSeconds) {
1344  MSVehicle* veh = Helper::getVehicle(vehicleID);
1345  MSEdge* edge = MSEdge::dictionary(edgeID);
1346  if (edge == nullptr) {
1347  throw TraCIException("Edge '" + edgeID + "' is not known.");
1348  }
1349  if (effort != INVALID_DOUBLE_VALUE) {
1350  // add effort
1351  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1352  // clean up old values before setting whole range
1353  while (veh->getWeightsStorage().knowsEffort(edge)) {
1354  veh->getWeightsStorage().removeEffort(edge);
1355  }
1356  }
1357  veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
1358  } else {
1359  // remove effort
1360  while (veh->getWeightsStorage().knowsEffort(edge)) {
1361  veh->getWeightsStorage().removeEffort(edge);
1362  }
1363  }
1364 }
1365 
1366 
1367 void
1368 Vehicle::rerouteTraveltime(const std::string& vehicleID, const bool currentTravelTimes) {
1369  UNUSED_PARAMETER(currentTravelTimes); // !!! see #5943
1370  MSVehicle* veh = Helper::getVehicle(vehicleID);
1371  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteTraveltime",
1372  veh->getInfluencer().getRouterTT(), isOnInit(vehicleID));
1373 }
1374 
1375 
1376 void
1377 Vehicle::rerouteEffort(const std::string& vehicleID) {
1378  MSVehicle* veh = Helper::getVehicle(vehicleID);
1379  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteEffort",
1380  MSNet::getInstance()->getRouterEffort(), isOnInit(vehicleID));
1381 }
1382 
1383 
1384 void
1385 Vehicle::setSignals(const std::string& vehicleID, int signals) {
1386  MSVehicle* veh = Helper::getVehicle(vehicleID);
1387  // set influencer to make the change persistent
1388  veh->getInfluencer().setSignals(signals);
1389  // set them now so that getSignals returns the correct value
1390  veh->switchOffSignal(0x0fffffff);
1391  if (signals >= 0) {
1392  veh->switchOnSignal(signals);
1393  }
1394 }
1395 
1396 
1397 void
1398 Vehicle::moveTo(const std::string& vehicleID, const std::string& laneID, double position) {
1399  MSVehicle* veh = Helper::getVehicle(vehicleID);
1400  MSLane* l = MSLane::dictionary(laneID);
1401  if (l == nullptr) {
1402  throw TraCIException("Unknown lane '" + laneID + "'.");
1403  }
1404  MSEdge* destinationEdge = &l->getEdge();
1405  const MSEdge* destinationRouteEdge = destinationEdge->getNormalBefore();
1406  // find edge in the remaining route
1407  MSRouteIterator it = std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), destinationRouteEdge);
1408  if (it == veh->getRoute().end()) {
1409  // find edge in the edges that were already passed
1410  it = std::find(veh->getRoute().begin(), veh->getRoute().end(), destinationRouteEdge);
1411  }
1412  if (it == veh->getRoute().end() ||
1413  // internal edge must continue the route
1414  (destinationEdge->isInternal() &&
1415  ((it + 1) == veh->getRoute().end()
1416  || l->getNextNormal() != *(it + 1)))) {
1417  throw TraCIException("Lane '" + laneID + "' is not on the route of vehicle '" + vehicleID + "'.");
1418  }
1420  if (veh->getLane() != nullptr) {
1422  } else {
1423  veh->setTentativeLaneAndPosition(l, position);
1424  }
1425  const int newRouteIndex = (int)(it - veh->getRoute().begin());
1426  veh->resetRoutePosition(newRouteIndex, veh->getParameter().departLaneProcedure);
1427  if (!veh->isOnRoad()) {
1429 
1430  }
1431  l->forceVehicleInsertion(veh, position,
1433 }
1434 
1435 
1436 void
1437 Vehicle::setActionStepLength(const std::string& vehicleID, double actionStepLength, bool resetActionOffset) {
1438  if (actionStepLength < 0.0) {
1439  WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
1440  return;
1441  }
1442  MSVehicle* veh = Helper::getVehicle(vehicleID);
1443  if (actionStepLength == 0.) {
1444  veh->resetActionOffset();
1445  } else {
1446  veh->setActionStepLength(actionStepLength, resetActionOffset);
1447  }
1448 }
1449 
1450 
1451 void
1452 Vehicle::remove(const std::string& vehicleID, char reason) {
1453  MSVehicle* veh = Helper::getVehicle(vehicleID);
1455  switch (reason) {
1456  case REMOVE_TELEPORT:
1457  // XXX semantics unclear
1458  // n = MSMoveReminder::NOTIFICATION_TELEPORT;
1460  break;
1461  case REMOVE_PARKING:
1462  // XXX semantics unclear
1463  // n = MSMoveReminder::NOTIFICATION_PARKING;
1465  break;
1466  case REMOVE_ARRIVED:
1468  break;
1469  case REMOVE_VAPORIZED:
1471  break;
1474  break;
1475  default:
1476  throw TraCIException("Unknown removal status.");
1477  }
1478  if (veh->hasDeparted()) {
1479  veh->onRemovalFromNet(n);
1480  if (veh->getLane() != nullptr) {
1481  veh->getLane()->removeVehicle(veh, n);
1482  }
1484  } else {
1487  }
1488 }
1489 
1490 
1491 void
1492 Vehicle::setColor(const std::string& vehicleID, const TraCIColor& col) {
1493  const SUMOVehicleParameter& p = Helper::getVehicle(vehicleID)->getParameter();
1494  p.color.set((unsigned char)col.r, (unsigned char)col.g, (unsigned char)col.b, (unsigned char)col.a);
1496 }
1497 
1498 
1499 void
1500 Vehicle::setSpeedFactor(const std::string& vehicleID, double factor) {
1501  Helper::getVehicle(vehicleID)->setChosenSpeedFactor(factor);
1502 }
1503 
1504 
1505 void
1506 Vehicle::setLine(const std::string& vehicleID, const std::string& line) {
1507  Helper::getVehicle(vehicleID)->getParameter().line = line;
1508 }
1509 
1510 
1511 void
1512 Vehicle::setVia(const std::string& vehicleID, const std::vector<std::string>& via) {
1513  MSVehicle* veh = Helper::getVehicle(vehicleID);
1514  try {
1515  // ensure edges exist
1516  ConstMSEdgeVector edges;
1517  MSEdge::parseEdgesList(via, edges, "<via-edges>");
1518  } catch (ProcessError& e) {
1519  throw TraCIException(e.what());
1520  }
1521  veh->getParameter().via = via;
1522 }
1523 
1524 
1525 void
1526 Vehicle::setLength(const std::string& vehicleID, double length) {
1527  Helper::getVehicle(vehicleID)->getSingularType().setLength(length);
1528 }
1529 
1530 
1531 void
1532 Vehicle::setMaxSpeed(const std::string& vehicleID, double speed) {
1533  Helper::getVehicle(vehicleID)->getSingularType().setMaxSpeed(speed);
1534 }
1535 
1536 
1537 void
1538 Vehicle::setVehicleClass(const std::string& vehicleID, const std::string& clazz) {
1540 }
1541 
1542 
1543 void
1544 Vehicle::setShapeClass(const std::string& vehicleID, const std::string& clazz) {
1546 }
1547 
1548 
1549 void
1550 Vehicle::setEmissionClass(const std::string& vehicleID, const std::string& clazz) {
1552 }
1553 
1554 
1555 void
1556 Vehicle::setWidth(const std::string& vehicleID, double width) {
1557  Helper::getVehicle(vehicleID)->getSingularType().setWidth(width);
1558 }
1559 
1560 
1561 void
1562 Vehicle::setHeight(const std::string& vehicleID, double height) {
1563  Helper::getVehicle(vehicleID)->getSingularType().setHeight(height);
1564 }
1565 
1566 
1567 void
1568 Vehicle::setMinGap(const std::string& vehicleID, double minGap) {
1569  Helper::getVehicle(vehicleID)->getSingularType().setMinGap(minGap);
1570 }
1571 
1572 
1573 void
1574 Vehicle::setAccel(const std::string& vehicleID, double accel) {
1575  Helper::getVehicle(vehicleID)->getSingularType().setAccel(accel);
1576 }
1577 
1578 
1579 void
1580 Vehicle::setDecel(const std::string& vehicleID, double decel) {
1581  VehicleType::setDecel(Helper::getVehicle(vehicleID)->getSingularType().getID(), decel);
1582 }
1583 
1584 
1585 void
1586 Vehicle::setEmergencyDecel(const std::string& vehicleID, double decel) {
1587  VehicleType::setEmergencyDecel(Helper::getVehicle(vehicleID)->getSingularType().getID(), decel);
1588 }
1589 
1590 
1591 void
1592 Vehicle::setApparentDecel(const std::string& vehicleID, double decel) {
1594 }
1595 
1596 
1597 void
1598 Vehicle::setImperfection(const std::string& vehicleID, double imperfection) {
1599  Helper::getVehicle(vehicleID)->getSingularType().setImperfection(imperfection);
1600 }
1601 
1602 
1603 void
1604 Vehicle::setTau(const std::string& vehicleID, double tau) {
1605  Helper::getVehicle(vehicleID)->getSingularType().setTau(tau);
1606 }
1607 
1608 
1609 void
1610 Vehicle::setMinGapLat(const std::string& vehicleID, double minGapLat) {
1611  Helper::getVehicle(vehicleID)->getSingularType().setMinGapLat(minGapLat);
1612 }
1613 
1614 
1615 void
1616 Vehicle::setMaxSpeedLat(const std::string& vehicleID, double speed) {
1617  Helper::getVehicle(vehicleID)->getSingularType().setMaxSpeedLat(speed);
1618 }
1619 
1620 
1621 void
1622 Vehicle::setLateralAlignment(const std::string& vehicleID, const std::string& latAlignment) {
1624 }
1625 
1626 
1627 void
1628 Vehicle::setParameter(const std::string& vehicleID, const std::string& key, const std::string& value) {
1629  MSVehicle* veh = Helper::getVehicle(vehicleID);
1630  if (StringUtils::startsWith(key, "device.")) {
1631  StringTokenizer tok(key, ".");
1632  if (tok.size() < 3) {
1633  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehicleID + "'");
1634  }
1635  try {
1636  veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
1637  } catch (InvalidArgument& e) {
1638  throw TraCIException("Vehicle '" + vehicleID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
1639  }
1640  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
1641  const std::string attrName = key.substr(16);
1642  try {
1643  veh->getLaneChangeModel().setParameter(attrName, value);
1644  } catch (InvalidArgument& e) {
1645  throw TraCIException("Vehicle '" + vehicleID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
1646  }
1647  } else if (StringUtils::startsWith(key, "carFollowModel.")) {
1648  const std::string attrName = key.substr(15);
1649  try {
1650  veh->getCarFollowModel().setParameter(veh, attrName, value);
1651  } catch (InvalidArgument& e) {
1652  throw TraCIException("Vehicle '" + vehicleID + "' does not support carFollowModel parameter '" + key + "' (" + e.what() + ").");
1653  }
1654  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
1655  StringTokenizer tok(key, ".");
1656  if (tok.size() != 3) {
1657  throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
1658  }
1659  const std::string deviceName = tok.get(1);
1660  bool create;
1661  try {
1662  create = StringUtils::toBool(value);
1663  } catch (BoolFormatException&) {
1664  throw TraCIException("Changing device status requires a 'true' or 'false'");
1665  }
1666  if (!create) {
1667  throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
1668  }
1669  try {
1670  veh->createDevice(deviceName);
1671  } catch (InvalidArgument& e) {
1672  throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
1673  }
1674  } else {
1675  ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
1676  }
1677 }
1678 
1679 
1680 void
1681 Vehicle::highlight(const std::string& vehicleID, const TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
1682  // NOTE: Code is duplicated in large parts in POI.cpp
1683  MSVehicle* veh = Helper::getVehicle(vehicleID);
1684 
1685  // Center of the highlight circle
1686  Position center = veh->getPosition();
1687  const double l2 = veh->getLength() * 0.5;
1688  center.sub(cos(veh->getAngle())*l2, sin(veh->getAngle())*l2);
1689  // Size of the highlight circle
1690  if (size <= 0) {
1691  size = veh->getLength() * 0.7;
1692  }
1693  // Make polygon shape
1694  const unsigned int nPoints = 34;
1695  const PositionVector circlePV = GeomHelper::makeRing(size, size + 1., center, nPoints);
1697 
1698 #ifdef DEBUG_DYNAMIC_SHAPES
1699  std::cout << SIMTIME << " Vehicle::highlight() for vehicle '" << vehicleID << "'\n"
1700  << " circle: " << circlePV << std::endl;
1701 #endif
1702 
1703  // Find a free polygon id
1704  int i = 0;
1705  std::string polyID = veh->getID() + "_hl" + toString(i);
1706  while (Polygon::exists(polyID)) {
1707  polyID = veh->getID() + "_hl" + toString(++i);
1708  }
1709  // Line width
1710  double lw = 0.;
1711  // Layer
1712  double lyr = 0.;
1713  if (MSNet::getInstance()->isGUINet()) {
1714  lyr = GLO_VEHICLE + 0.01;
1715  lyr += (type + 1) / 257.;
1716  }
1717  // Make Polygon
1718  Polygon::addHighlightPolygon(vehicleID, type, polyID, circle, col, true, "highlight", (int)lyr, lw);
1719 
1720  // Animation time line
1721  double maxAttack = 1.0; // maximal fade-in time
1722  std::vector<double> timeSpan;
1723  if (duration > 0.) {
1724  timeSpan = {0, MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
1725  }
1726  // Alpha time line
1727  std::vector<double> alphaSpan;
1728  if (alphaMax > 0.) {
1729  alphaSpan = {0., (double) alphaMax, (double)(alphaMax) / 3., 0.};
1730  }
1731  // Attach dynamics
1732  Polygon::addDynamics(polyID, vehicleID, timeSpan, alphaSpan, false, true);
1733 }
1734 
1735 
1737 
1738 
1739 void
1740 Vehicle::subscribeLeader(const std::string& vehicleID, double /* dist */, double beginTime, double endTime) {
1741  // TODO handle dist correctly
1742  Vehicle::subscribe(vehicleID, std::vector<int>({libsumo::VAR_LEADER}), beginTime, endTime);
1743 }
1744 
1745 
1746 void
1747 Vehicle::storeShape(const std::string& id, PositionVector& shape) {
1748  shape.push_back(Helper::getVehicle(id)->getPosition());
1749 }
1750 
1751 
1752 std::shared_ptr<VariableWrapper>
1754  return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
1755 }
1756 
1757 
1758 bool
1759 Vehicle::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper) {
1760  switch (variable) {
1761  case TRACI_ID_LIST:
1762  return wrapper->wrapStringList(objID, variable, getIDList());
1763  case ID_COUNT:
1764  return wrapper->wrapInt(objID, variable, getIDCount());
1765  case VAR_POSITION:
1766  return wrapper->wrapPosition(objID, variable, getPosition(objID));
1767  case VAR_POSITION3D:
1768  return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
1769  case VAR_ANGLE:
1770  return wrapper->wrapDouble(objID, variable, getAngle(objID));
1771  case VAR_SPEED:
1772  return wrapper->wrapDouble(objID, variable, getSpeed(objID));
1773  case VAR_SPEED_LAT:
1774  return wrapper->wrapDouble(objID, variable, getLateralSpeed(objID));
1775  case VAR_ROAD_ID:
1776  return wrapper->wrapString(objID, variable, getRoadID(objID));
1778  return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
1779  case VAR_SLOPE:
1780  return wrapper->wrapDouble(objID, variable, getSlope(objID));
1781  case VAR_LANE_ID:
1782  return wrapper->wrapString(objID, variable, getLaneID(objID));
1783  case VAR_LANE_INDEX:
1784  return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
1785  case VAR_TYPE:
1786  return wrapper->wrapString(objID, variable, getTypeID(objID));
1787  case VAR_ROUTE_ID:
1788  return wrapper->wrapString(objID, variable, getRouteID(objID));
1789  case VAR_ROUTE_INDEX:
1790  return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
1791  case VAR_COLOR:
1792  return wrapper->wrapColor(objID, variable, getColor(objID));
1793  case VAR_LANEPOSITION:
1794  return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
1795  case VAR_LANEPOSITION_LAT:
1796  return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
1797  case VAR_CO2EMISSION:
1798  return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
1799  case VAR_COEMISSION:
1800  return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
1801  case VAR_HCEMISSION:
1802  return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
1803  case VAR_PMXEMISSION:
1804  return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
1805  case VAR_NOXEMISSION:
1806  return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
1807  case VAR_FUELCONSUMPTION:
1808  return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
1809  case VAR_NOISEEMISSION:
1810  return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
1812  return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
1813  case VAR_PERSON_NUMBER:
1814  return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
1815  case VAR_PERSON_CAPACITY:
1816  return wrapper->wrapInt(objID, variable, getPersonCapacity(objID));
1818  return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
1819  case VAR_WAITING_TIME:
1820  return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
1822  return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
1823  case VAR_ROUTE_VALID:
1824  return wrapper->wrapInt(objID, variable, isRouteValid(objID));
1825  case VAR_EDGES:
1826  return wrapper->wrapStringList(objID, variable, getRoute(objID));
1827  case VAR_SIGNALS:
1828  return wrapper->wrapInt(objID, variable, getSignals(objID));
1829  case VAR_STOPSTATE:
1830  return wrapper->wrapInt(objID, variable, getStopState(objID));
1831  case VAR_DISTANCE:
1832  return wrapper->wrapDouble(objID, variable, getDistance(objID));
1833  case VAR_ALLOWED_SPEED:
1834  return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
1835  case VAR_SPEED_FACTOR:
1836  return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
1837  case VAR_SPEEDSETMODE:
1838  return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
1839  case VAR_LANECHANGE_MODE:
1840  return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
1841  case VAR_ROUTING_MODE:
1842  return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
1843  case VAR_LINE:
1844  return wrapper->wrapString(objID, variable, getLine(objID));
1845  case VAR_VIA:
1846  return wrapper->wrapStringList(objID, variable, getVia(objID));
1847  case VAR_ACCELERATION:
1848  return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
1849  case VAR_LASTACTIONTIME:
1850  return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
1851  case VAR_LEADER: {
1852  const auto& lead = getLeader(objID);
1853  TraCIRoadPosition rp;
1854  rp.edgeID = lead.first;
1855  rp.pos = lead.second;
1856  return wrapper->wrapRoadPosition(objID, variable, rp);
1857  }
1858  default:
1859  return false;
1860  }
1861 }
1862 
1863 
1864 }
1865 
1866 /****************************************************************************/
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
int getRoutePosition() const
Definition: MSVehicle.cpp:1180
virtual std::string getParameter(const MSVehicle *veh, const std::string &key) const
try to get the given parameter for this carFollowingModel
Definition: MSCFModel.h:572
static std::string getLaneID(const std::string &vehicleID)
Definition: Vehicle.cpp:166
double getApparentDecel() const
Get the vehicle type&#39;s apparent deceleration [m/s^2] (the one regarded by its followers.
Definition: MSCFModel.h:234
static std::vector< TraCIBestLanesData > getBestLanes(const std::string &vehicleID)
Definition: Vehicle.cpp:348
void setMinGap(const double &minGap)
Set a new value for this type&#39;s minimum gap.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204
static double gLateralResolution
Definition: MSGlobals.h:85
double getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:5130
virtual void setParameter(MSVehicle *veh, const std::string &key, const std::string &value) const
try to set the given parameter for this carFollowingModel
Definition: MSCFModel.h:585
std::string id
The id of the next tls.
Definition: TraCIDefs.h:303
int stopFlags
Stop flags.
Definition: TraCIDefs.h:321
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
Definition: MSVehicle.h:667
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.
SumoXMLTag
Numbers representing SUMO-XML - element names.
double getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:5118
TRACI_CONST int VAR_LANE_ID
static void setStop(const std::string &vehicleID, const std::string &edgeID, double pos=1., int laneIndex=0, double duration=INVALID_DOUBLE_VALUE, int flags=STOP_DEFAULT, double startPos=INVALID_DOUBLE_VALUE, double until=INVALID_DOUBLE_VALUE)
Definition: Vehicle.cpp:831
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
Definition: MSVehicle.cpp:896
RGBColor color
The vehicle&#39;s color, TraCI may change this.
double getLength() const
Returns the vehicle&#39;s length.
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:670
static void setEffort(const std::string &vehicleID, const std::string &edgeID, double effort=INVALID_DOUBLE_VALUE, double begSeconds=0, double endSeconds=std::numeric_limits< double >::max())
Definition: Vehicle.cpp:1342
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
long long int SUMOTime
Definition: SUMOTime.h:35
const int VEHPARS_FORCE_REROUTE
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
Definition: MSVehicle.cpp:5136
TRACI_CONST int VAR_COEMISSION
static void setLine(const std::string &vehicleID, const std::string &line)
Definition: Vehicle.cpp:1506
double dist
The distance to the tls.
Definition: TraCIDefs.h:307
double getAngle() const
Returns the vehicle&#39;s direction in radians.
Definition: MSVehicle.h:681
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:339
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
The time is given.
static void updateBestLanes(const std::string &vehicleID)
Definition: Vehicle.cpp:1309
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:121
TRACI_CONST int VAR_PERSON_NUMBER
double until
The time at which the vehicle may continue its journey.
Definition: TraCIDefs.h:325
const MSEdge * getNextNormal() const
Returns the lane&#39;s follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1827
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: Helper.cpp:247
The vehicle is discarded if emission fails (not fully implemented yet)
An edgeId, position and laneIndex.
Definition: TraCIDefs.h:122
double z() const
Returns the z-position.
Definition: Position.h:67
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:657
static double getSpeedWithoutTraCI(const std::string &vehicleID)
Definition: Vehicle.cpp:122
static std::string getRoadID(const std::string &vehicleID)
Definition: Vehicle.cpp:159
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) ...
TRACI_CONST int VAR_ROUTE_INDEX
static void changeLaneRelative(const std::string &vehicleID, int indexOffset, double duration)
Definition: Vehicle.cpp:961
static void setRoute(const std::string &vehicleID, const std::vector< std::string > &edgeIDs)
Definition: Vehicle.cpp:1292
TRACI_CONST int VAR_VIA
bool hasDeparted() const
Returns whether this vehicle has already departed.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
TRACI_CONST int VAR_COLOR
static int getPersonNumber(const std::string &vehicleID)
Definition: Vehicle.cpp:264
TRACI_CONST int VAR_LEADER
Stop & getNextStop()
Definition: MSVehicle.cpp:5807
TRACI_CONST int VAR_WAITING_TIME
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
bool resumeFromStopping()
Definition: MSVehicle.cpp:5756
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:561
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...
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void setTau(double tau)
Set a new value for this type&#39;s headway.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
Definition: MSVehicle.h:823
void setShape(SUMOVehicleShape shape)
Set a new value for this type&#39;s shape.
static MSEdge * getEdge(const std::string &edgeID)
Definition: Helper.cpp:280
The vehicle is blocked by left follower.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:244
static double getAcceleration(const std::string &vehicleID)
Definition: Vehicle.cpp:115
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:393
TRACI_CONST int VAR_ROAD_ID
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
Definition: MSVehicle.cpp:5059
static void deactivateGapControl(const std::string &vehicleID)
Definition: Vehicle.cpp:1224
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSVehicle.h:937
SUMOTime duration
The stopping duration.
Definition: MSVehicle.h:939
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition: Helper.cpp:264
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static void setParameter(const std::string &vehicleID, const std::string &key, const std::string &value)
Definition: Vehicle.cpp:1628
TRACI_CONST int REMOVE_TELEPORT
virtual double getImperfection() const
Get the driver&#39;s imperfection.
Definition: MSCFModel.h:251
std::list< Stop > getMyStops()
Definition: MSVehicle.cpp:5812
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSVehicle.h:933
static double getSlope(const std::string &vehicleID)
Definition: Vehicle.cpp:152
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSVehicle.h:929
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:397
static PositionVector makeRing(const double radius1, const double radius2, const Position &center, unsigned int nPoints)
Definition: GeomHelper.cpp:255
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
TRACI_CONST int VAR_SIGNALS
static std::string getTypeID(const std::string &vehicleID)
Definition: Vehicle.cpp:180
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
bool reached
Information whether the stop has been reached.
Definition: MSVehicle.h:945
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2169
static void setRoutingMode(const std::string &vehicleID, int routingMode)
Definition: Vehicle.cpp:1258
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
std::string get(int pos) const
returns the item at the given position
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:398
bool addTraciStopAtStoppingPlace(const std::string &stopId, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, const SumoXMLTag stoppingPlaceType, std::string &errorMsg)
Definition: MSVehicle.cpp:5676
double occupation
The traffic density along length.
Definition: TraCIDefs.h:335
TRACI_CONST int VAR_POSITION
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:165
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
Definition: Position.h:254
static double getCOEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:222
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
TRACI_CONST int VAR_ALLOWED_SPEED
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
static void add(const std::string &routeID, const std::vector< std::string > &edgeIDs)
Definition: Route.cpp:85
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:331
static void setSpeedMode(const std::string &vehicleID, int speedMode)
Definition: Vehicle.cpp:1248
std::vector< double > & getParameter()
Returns the parameters of this distribution.
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
TRACI_CONST int VAR_FUELCONSUMPTION
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:541
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:478
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:70
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1983
static std::vector< std::string > getVia(const std::string &vehicleID)
Definition: Vehicle.cpp:593
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key ...
const MSRoute & getRoute() const
Returns the current route.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
The vehicle got vaporized.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:804
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:1280
static void rerouteParkingArea(const std::string &vehicleID, const std::string &parkingAreaID)
Definition: Vehicle.cpp:898
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void setApparentDecel(double apparentDecel)
Set a new value for this type&#39;s apparent deceleration.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:205
TRACI_CONST int VAR_ANGLE
static TraCIPosition getPosition3D(const std::string &vehicleID)
Definition: Vehicle.cpp:139
void setLength(const double &length)
Set a new value for this type&#39;s length.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void subscribeLeader(const std::string &vehicleID, double dist=0., double beginTime=libsumo::INVALID_DOUBLE_VALUE, double endTime=libsumo::INVALID_DOUBLE_VALUE)
Definition: Vehicle.cpp:1740
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
int getSignals() const
Returns the signals.
Definition: MSVehicle.h:1249
static void setRouteID(const std::string &vehicleID, const std::string &routeID)
Definition: Vehicle.cpp:1272
int getLaneChangeMode() const
return the current lane change mode
Definition: MSVehicle.cpp:437
const std::string & getID() const
Returns the id.
Definition: Named.h:77
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
TRACI_CONST int REMOVE_PARKING
static double getAngle(const std::string &vehicleID)
Definition: Vehicle.cpp:145
int getSpeedMode() const
return the current speed mode
Definition: MSVehicle.cpp:427
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Vehicle.cpp:1753
TRACI_CONST int VAR_NOXEMISSION
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type&#39;s maximum speed.
double nextOccupation
As occupation, but without the first lane.
Definition: MSVehicle.h:821
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Vehicle.h:202
double length
The overall length which may be driven when using this lane without a lane change.
Definition: MSVehicle.h:815
void setImperfection(double imperfection)
Set a new value for this type&#39;s imperfection.
static std::string getLine(const std::string &vehicleID)
Definition: Vehicle.cpp:587
int getPersonCapacity() const
Get this vehicle type&#39;s person capacity.
TRACI_CONST int VAR_ROUTE_ID
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
Definition: MSVehicle.cpp:5549
TRACI_CONST int REMOVE_VAPORIZED
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
Definition: Helper.cpp:224
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:557
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:32
static double getDistance(const std::string &vehicleID)
Definition: Vehicle.cpp:492
static double getNoiseEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:252
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
The car-following model and parameter.
Definition: MSVehicleType.h:66
bool triggered
whether an arriving person lets the vehicle continue
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:4609
#define SIMTIME
Definition: SUMOTime.h:64
double getDepartPos() const
Returns this vehicle&#39;s real departure position.
std::string toTaz
The vehicle&#39;s destination zone (district)
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
int getLaneIndex() const
Definition: MSVehicle.cpp:5233
static std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction)
Definition: Vehicle.cpp:599
TRACI_CONST int REMOVE_ARRIVED
static void openGap(const std::string &vehicleID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel=INVALID_DOUBLE_VALUE, const std::string &referenceVehID="")
Definition: Vehicle.cpp:1206
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
Definition: Helper.cpp:1045
static double getNOxEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:240
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter ...
static double getEffort(const std::string &vehicleID, double time, const std::string &edgeID)
Definition: Vehicle.cpp:314
static void requestToC(const std::string &vehID, double leadTime)
Definition: Vehicle.cpp:1232
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Vehicle.cpp:1747
bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
Definition: MSVehicle.cpp:1078
static std::vector< std::string > getPersonIDList(const std::string &vehicleID)
Definition: Vehicle.cpp:274
static double getWaitingTime(const std::string &vehicleID)
Definition: Vehicle.cpp:293
static double getLastActionTime(const std::string &vehicleID)
Definition: Vehicle.cpp:759
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
Definition: Polygon.cpp:295
double getMaxAccel() const
Get the vehicle type&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:210
static SubscriptionResults mySubscriptionResults
Definition: Vehicle.h:201
static double getCO2Emission(const std::string &vehicleID)
Definition: Vehicle.cpp:216
void setMinGapLat(const double &minGapLat)
Set a new value for this type&#39;s minimum lataral gap.
bool isInternal() const
Definition: MSLane.cpp:1999
TRACI_CONST int TRACI_ID_LIST
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:337
double departSpeed
(optional) The initial speed of the vehicle
A road/street connecting two junctions.
Definition: MSEdge.h:76
static void resume(const std::string &vehicleID)
Definition: Vehicle.cpp:908
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:583
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:387
MSLane * lane
The described lane.
Definition: MSVehicle.h:813
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:758
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:194
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:894
The action has not been determined.
TRACI_CONST int VAR_STOPSTATE
double getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:5100
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:564
TRACI_CONST int VAR_NOISEEMISSION
static LIBSUMO_SUBSCRIPTION_API void addHighlightPolygon(const std::string &objectID, const int type, const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &color, bool fill, const std::string &polygonType, int layer, double lineWidth)
Definition: Polygon.cpp:133
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
Definition: MSVehicle.cpp:1186
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
Definition: MSVehicle.cpp:422
TRACI_CONST int INVALID_INT_VALUE
static std::vector< TraCINextTLSData > getNextTLS(const std::string &vehicleID)
Definition: Vehicle.cpp:374
const MSCFModel & getCarFollowModel() const
Returns the vehicle type&#39;s car following model definition (const version)
int size() const
returns the number of existing substrings
TRACI_CONST int ID_COUNT
static int getSpeedMode(const std::string &vehicleID)
Definition: Vehicle.cpp:569
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
void createDevice(const std::string &deviceName)
create device of the given type
static int getRouteIndex(const std::string &vehicleID)
Definition: Vehicle.cpp:192
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, MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
Definition: Helper.cpp:822
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int VAR_ROUTE_VALID
void setAccel(double accel)
Set a new value for this type&#39;s acceleration.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
static void setLaneChangeMode(const std::string &vehicleID, int laneChangeMode)
Definition: Vehicle.cpp:1253
static void setVia(const std::string &vehicleID, const std::vector< std::string > &via)
Definition: Vehicle.cpp:1512
static bool gCheckRoutes
Definition: MSGlobals.h:79
static double getLateralLanePosition(const std::string &vehicleID)
Definition: Vehicle.cpp:210
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static double getHCEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:228
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
MSRouteIterator edge
The edge in the route to stop at.
Definition: MSVehicle.h:925
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 set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition: RGBColor.cpp:80
std::string stoppingPlaceID
Id assigned to the stop.
Definition: TraCIDefs.h:319
A list of positions.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:4627
int getRoutingMode() const
return the current routing mode
Definition: MSVehicle.h:1469
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:4987
static bool isOnInit(const std::string &vehicleID)
Definition: Vehicle.cpp:77
double getEmergencyDecel() const
Get the vehicle type&#39;s maximal phisically possible deceleration [m/s^2].
Definition: MSCFModel.h:226
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
TRACI_CONST int VAR_EDGES
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:337
void setHeight(const double &height)
Set a new value for this type&#39;s height.
static void add(const std::string &vehicleID, const std::string &routeID, const std::string &typeID="DEFAULT_VEHTYPE", const std::string &depart="now", const std::string &departLane="first", const std::string &departPos="base", const std::string &departSpeed="0", const std::string &arrivalLane="current", const std::string &arrivalPos="max", const std::string &arrivalSpeed="current", const std::string &fromTaz="", const std::string &toTaz="", const std::string &line="", int personCapacity=4, int personNumber=0)
Definition: Vehicle.cpp:977
static double getFuelConsumption(const std::string &vehicleID)
Definition: Vehicle.cpp:246
virtual bool wrapRoadPosition(const std::string &objID, const int variable, const TraCIRoadPosition &value)=0
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 move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
TRACI_CONST int VAR_PMXEMISSION
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:58
static double getLanePosition(const std::string &vehicleID)
Definition: Vehicle.cpp:204
static std::vector< std::string > getRoute(const std::string &vehicleID)
Definition: Vehicle.cpp:330
The vehicle arrived at its destination (is deleted)
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
Definition: MSVehicle.h:995
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1013
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
TRACI_CONST int VAR_LANECHANGE_MODE
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...
static void moveTo(const std::string &vehicleID, const std::string &laneID, double position)
Definition: Vehicle.cpp:1398
TRACI_CONST int VAR_LASTACTIONTIME
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: MSEdge.cpp:740
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Definition: MSVehicle.cpp:5142
TRACI_CONST int VAR_LINE
static double getLateralSpeed(const std::string &vehicleID)
Definition: Vehicle.cpp:108
T MIN2(T a, T b)
Definition: StdDefs.h:74
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
Definition: MSVehicle.cpp:2110
TRACI_CONST int VAR_SLOPE
#define POSITION_EPS
Definition: config.h:169
std::string fromTaz
The vehicle&#39;s origin zone (district)
A structure representing the best lanes for continuing the current route starting at &#39;lane&#39;...
Definition: MSVehicle.h:811
static void changeLane(const std::string &vehicleID, int laneIndex, double duration)
Definition: Vehicle.cpp:953
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:1055
static std::vector< std::pair< std::string, double > > getNeighbors(const std::string &vehicleID, const int mode)
Definition: Vehicle.cpp:649
bool hasInfluencer() const
Definition: MSVehicle.h:1680
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
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.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type&#39;s emission class.
static std::vector< std::string > getIDList()
Definition: Vehicle.cpp:84
double getMinGap() const
Get the free space in front of vehicles of this class.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
double getMaxDecel() const
Get the vehicle type&#39;s maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:218
double endPos
The stopping position end.
Definition: TraCIDefs.h:317
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition: Helper.cpp:307
static double getAccumulatedWaitingTime(const std::string &vehicleID)
Definition: Vehicle.cpp:299
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: TraCIDefs.h:51
TRACI_CONST int VAR_POSITION3D
#define DEBUG_COND
Definition: Vehicle.cpp:55
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Vehicle.cpp:1759
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:52
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:233
const int VEHPARS_COLOR_SET
static void setSpeed(const std::string &vehicleID, double speed)
Definition: Vehicle.cpp:1237
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons) ...
static std::string getRouteID(const std::string &vehicleID)
Definition: Vehicle.cpp:186
static TraCIPosition getPosition(const std::string &vehicleID, const bool includeZ=false)
Definition: Vehicle.cpp:129
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
Definition: MSLane.cpp:2050
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
bool allowsContinuation
Whether this lane allows to continue the drive.
Definition: MSVehicle.h:825
static int getLaneChangeMode(const std::string &vehicleID)
Definition: Vehicle.cpp:575
Definition: Edge.cpp:30
static double getAdaptedTraveltime(const std::string &vehicleID, double time, const std::string &edgeID)
Definition: Vehicle.cpp:305
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::string line
The vehicle&#39;s line (mainly for public transport)
double arrivalPos
(optional) The position the vehicle shall arrive on
double getLateralPositionOnLane() const
Get the vehicle&#39;s lateral position on the lane.
Definition: MSVehicle.h:434
void setRoutingMode(int value)
Sets routing behavior.
Definition: MSVehicle.h:1554
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
Definition: MSVehicle.cpp:1433
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
double getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:5106
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static std::string getParameter(const std::string &vehicleID, const std::string &key)
Definition: Vehicle.cpp:610
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
virtual bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)=0
double getMaxSpeedLat() const
Get vehicle&#39;s maximum lateral speed [m/s].
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition: Helper.cpp:786
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
static int getLaneIndex(const std::string &vehicleID)
Definition: Vehicle.cpp:173
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
bool addTraciStop(MSLane *const lane, const double startPos, const double endPos, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, std::string &errorMsg)
Definition: MSVehicle.cpp:5623
static int getIDCount()
Definition: Vehicle.cpp:96
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
TRACI_CONST int VAR_SPEED
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1855
double startPos
The stopping position start.
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
SUMOVehicleClass getVClass() const
Returns the vehicle&#39;s access class.
static void changeTarget(const std::string &vehicleID, const std::string &edgeID)
Definition: Vehicle.cpp:927
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:5817
int getPersonNumber() const
Returns the number of persons.
TRACI_CONST int REMOVE_TELEPORT_ARRIVED
Structure representing possible vehicle parameter.
TRACI_CONST int VAR_SPEED_FACTOR
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
static double getAllowedSpeed(const std::string &vehicleID)
Definition: Vehicle.cpp:552
static double getPMxEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:234
TRACI_CONST int VAR_TYPE
#define SUMOTime_MAX
Definition: SUMOTime.h:36
static void setSignals(const std::string &vehicleID, int signals)
Definition: Vehicle.cpp:1385
static void highlight(const std::string &vehicleID, const TraCIColor &col, double size, const int alphaMax, const double duration, const int type)
Definition: Vehicle.cpp:1681
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
TRACI_CONST int VAR_LANEPOSITION
static bool isRouteValid(const std::string &vehicleID)
Definition: Vehicle.cpp:323
TRACI_CONST int VAR_ACCELERATION
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:5240
bool containerTriggered
whether an arriving container lets the vehicle continue
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:390
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
virtual double getHeadwayTime() const
Get the driver&#39;s desired headway [s].
Definition: MSCFModel.h:259
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:837
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.
static void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int laneIndex, const double x, const double y, double angle=INVALID_DOUBLE_VALUE, const int keepRoute=1)
Definition: Vehicle.cpp:1085
static double getDrivingDistance2D(const std::string &vehicleID, double x, double y)
Definition: Vehicle.cpp:535
TRACI_CONST int VAR_PERSON_CAPACITY
std::vector< MSLane * > bestContinuations
Definition: MSVehicle.h:831
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSVehicle.h:935
char state
The current state of the tls.
Definition: TraCIDefs.h:309
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 getAcceleration() const
Returns the vehicle&#39;s acceleration in m/s (this is computed as the last step&#39;s mean acceleration in c...
Definition: MSVehicle.h:494
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSVehicle.h:931
TRACI_CONST int VAR_LANEPOSITION_LAT
static std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist=0.)
Definition: Vehicle.cpp:279
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
Definition: MSVehicle.cpp:1397
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
double getPMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:5124
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void setWidth(const double &width)
Set a new value for this type&#39;s width.
double getActionStepLengthSecs() const
Returns this type&#39;s default action step length in seconds.
static int getRoutingMode(const std::string &vehicleID)
Definition: Vehicle.cpp:581
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.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
static void slowDown(const std::string &vehicleID, double speed, double duration)
Definition: Vehicle.cpp:1197
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.
double getLength() const
Get vehicle&#39;s length [m].
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void setLaneChangeMode(int value)
Sets lane changing behavior.
Definition: MSVehicle.cpp:768
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type&#39;s vehicle class.
static void rerouteTraveltime(const std::string &vehicleID, const bool currentTravelTimes=true)
Definition: Vehicle.cpp:1368
TRACI_CONST int VAR_ROUTING_MODE
void setSignals(int signals)
Definition: MSVehicle.h:1581
static void setAdaptedTraveltime(const std::string &vehicleID, const std::string &edgeID, double time=INVALID_DOUBLE_VALUE, double begSeconds=0, double endSeconds=std::numeric_limits< double >::max())
Definition: Vehicle.cpp:1316
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:1196
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
Definition: Helper.cpp:353
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
void switchOffSignal(int signal)
Switches the given signal off.
Definition: MSVehicle.h:1241
void switchOnSignal(int signal)
Switches the given signal on.
Definition: MSVehicle.h:1233
double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MSVehicle.cpp:1269
static void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED)
Definition: Vehicle.cpp:1452
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
TRACI_CONST int VAR_CO2EMISSION
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:333
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
const std::shared_ptr< MSLeaderDistanceInfo > getLeaders(const int dir)
Returns the neighboring, lc-relevant leaders for the last step in the requested direction.
static void addDynamics(const std::string &polygonID, const std::string &trackedID="", const std::vector< double > &timeSpan=std::vector< double >(), const std::vector< double > &alphaSpan=std::vector< double >(), bool looped=false, bool rotate=true)
Definition: Polygon.cpp:140
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
Definition: MSVehicle.cpp:408
double getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:5112
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:70
The vehicle was teleported out of the net.
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:1751
The class responsible for building and deletion of vehicles.
TRACI_CONST int VAR_LANE_INDEX
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:72
static double getElectricityConsumption(const std::string &vehicleID)
Definition: Vehicle.cpp:258
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:4621
static MSVehicle * getVehicle(const std::string &id)
Definition: Helper.cpp:339
static void setType(const std::string &vehicleID, const std::string &typeID)
Definition: Vehicle.cpp:1263
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int VAR_HCEMISSION
double getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:477
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
The vehicle is blocked by right leader.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type&#39;s maximum lateral speed.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle&#39;s preferred lateral alignment.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
static double getDrivingDistance(const std::string &vehicleID, const std::string &edgeID, double position, int laneIndex=0)
Definition: Vehicle.cpp:519
TRACI_CONST int VAR_SPEED_LAT
A 3D-position.
Definition: TraCIDefs.h:110
static int getSignals(const std::string &vehicleID)
Definition: Vehicle.cpp:342
TRACI_CONST double INVALID_DOUBLE_VALUE
const std::string & getID() const
Returns the name of the vehicle.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
static void changeSublane(const std::string &vehicleID, double latDist)
Definition: Vehicle.cpp:971
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
void deactivateGapController()
Deactivates the gap control.
Definition: MSVehicle.cpp:401
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:305
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:519
static double getSpeed(const std::string &vehicleID)
Definition: Vehicle.cpp:102
static int getStopState(const std::string &vehicleID)
Definition: Vehicle.cpp:473
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
static bool isVisible(const SUMOVehicle *veh)
Definition: Vehicle.cpp:71
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
A list of positions.
static std::vector< TraCINextStopData > getNextStops(const std::string &vehicleID)
Definition: Vehicle.cpp:433
The vehicle is blocked by right follower.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:76
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:861
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
vehicles ignoring classes
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
double duration
The stopping duration.
Definition: TraCIDefs.h:323
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:341
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
bool parking
whether the vehicle is removed from the net while stopping
std::string id
The vehicle&#39;s id.
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
Definition: MSVehicle.cpp:5832
The vehicle is being teleported.
static void rerouteEffort(const std::string &vehicleID)
Definition: Vehicle.cpp:1377
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:921
std::string lane
The lane to stop at.
Definition: TraCIDefs.h:315
const std::pair< int, int > & getSavedState(const int dir) const
void addEffort(const MSEdge *const e, double begin, double end, double value)
Adds an effort information for an edge and a time span.
void setz(double z)
set position z
Definition: Position.h:82
void sub(double dx, double dy)
Substracts the given position from this one.
Definition: Position.h:147
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:114
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.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
Definition: MSRoute.cpp:277