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-2018 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 <libsumo/TraCIDefs.h>
42 #include "Helper.h"
43 #include "Route.h"
44 #include "Vehicle.h"
45 
46 
47 namespace libsumo {
48 // ===========================================================================
49 // static member initializations
50 // ===========================================================================
53 
54 
55 // ===========================================================================
56 // static member definitions
57 // ===========================================================================
58 MSVehicle*
59 Vehicle::getVehicle(const std::string& id) {
61  if (sumoVehicle == 0) {
62  throw TraCIException("Vehicle '" + id + "' is not known");
63  }
64  MSVehicle* v = dynamic_cast<MSVehicle*>(sumoVehicle);
65  if (v == 0) {
66  throw TraCIException("Vehicle '" + id + "' is not a micro-simulation vehicle");
67  }
68  return v;
69 }
70 
71 
72 bool
74  return veh->isOnRoad() || veh->isParking() || veh->wasRemoteControlled();
75 }
76 
77 
78 bool
79 Vehicle::isOnInit(const std::string& vehicleID) {
80  SUMOVehicle* sumoVehicle = MSNet::getInstance()->getVehicleControl().getVehicle(vehicleID);
81  return sumoVehicle == 0 || sumoVehicle->getLane() == 0;
82 }
83 
84 std::vector<std::string>
86  std::vector<std::string> ids;
88  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
89  if (isVisible((*i).second)) {
90  ids.push_back((*i).first);
91  }
92  }
93  return ids;
94 }
95 
96 int
98  return (int)getIDList().size();
99 }
100 
101 
102 double
103 Vehicle::getSpeed(const std::string& vehicleID) {
104  MSVehicle* veh = getVehicle(vehicleID);
105  return isVisible(veh) ? veh->getSpeed() : INVALID_DOUBLE_VALUE;
106 }
107 
108 
109 double
110 Vehicle::getAcceleration(const std::string& vehicleID) {
111  MSVehicle* veh = getVehicle(vehicleID);
112  return isVisible(veh) ? veh->getAcceleration() : INVALID_DOUBLE_VALUE;
113 }
114 
115 
116 double
117 Vehicle::getSpeedWithoutTraCI(const std::string& vehicleID) {
118  MSVehicle* veh = getVehicle(vehicleID);
120 }
121 
122 
124 Vehicle::getPosition(const std::string& vehicleID, const bool includeZ) {
125  MSVehicle* veh = getVehicle(vehicleID);
126  if (isVisible(veh)) {
127  return Helper::makeTraCIPosition(veh->getPosition(), includeZ);
128  }
129  TraCIPosition pos;
130  pos.x = INVALID_DOUBLE_VALUE;
131  pos.y = INVALID_DOUBLE_VALUE;
132  pos.z = INVALID_DOUBLE_VALUE;
133  return pos;
134 }
135 
136 
138 Vehicle::getPosition3D(const std::string& vehicleID) {
139  return getPosition(vehicleID, true);
140 }
141 
142 
143 double
144 Vehicle::getAngle(const std::string& vehicleID) {
145  MSVehicle* veh = getVehicle(vehicleID);
147 }
148 
149 
150 double
151 Vehicle::getSlope(const std::string& vehicleID) {
152  MSVehicle* veh = getVehicle(vehicleID);
153  return veh->isOnRoad() ? veh->getSlope() : INVALID_DOUBLE_VALUE;
154 }
155 
156 
157 std::string
158 Vehicle::getRoadID(const std::string& vehicleID) {
159  MSVehicle* veh = getVehicle(vehicleID);
160  return isVisible(veh) ? veh->getLane()->getEdge().getID() : "";
161 }
162 
163 
164 std::string
165 Vehicle::getLaneID(const std::string& vehicleID) {
166  MSVehicle* veh = getVehicle(vehicleID);
167  return veh->isOnRoad() ? veh->getLane()->getID() : "";
168 }
169 
170 
171 int
172 Vehicle::getLaneIndex(const std::string& vehicleID) {
173  MSVehicle* veh = getVehicle(vehicleID);
174  return veh->isOnRoad() ? veh->getLane()->getIndex() : INVALID_INT_VALUE;
175 }
176 
177 
178 std::string
179 Vehicle::getTypeID(const std::string& vehicleID) {
180  return getVehicle(vehicleID)->getVehicleType().getID();
181 }
182 
183 
184 std::string
185 Vehicle::getRouteID(const std::string& vehicleID) {
186  return getVehicle(vehicleID)->getRoute().getID();
187 }
188 
189 
190 int
191 Vehicle::getRouteIndex(const std::string& vehicleID) {
192  MSVehicle* veh = getVehicle(vehicleID);
193  return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
194 }
195 
196 
198 Vehicle::getColor(const std::string& vehicleID) {
199  return Helper::makeTraCIColor(getVehicle(vehicleID)->getParameter().color);
200 }
201 
202 double
203 Vehicle::getLanePosition(const std::string& vehicleID) {
204  MSVehicle* veh = getVehicle(vehicleID);
205  return veh->isOnRoad() ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
206 }
207 
208 double
209 Vehicle::getLateralLanePosition(const std::string& vehicleID) {
210  MSVehicle* veh = getVehicle(vehicleID);
211  return veh->isOnRoad() ? veh->getLateralPositionOnLane() : INVALID_DOUBLE_VALUE;
212 }
213 
214 double
215 Vehicle::getCO2Emission(const std::string& vehicleID) {
216  MSVehicle* veh = getVehicle(vehicleID);
217  return isVisible(veh) ? veh->getCO2Emissions() : INVALID_DOUBLE_VALUE;
218 }
219 
220 double
221 Vehicle::getCOEmission(const std::string& vehicleID) {
222  MSVehicle* veh = getVehicle(vehicleID);
223  return isVisible(veh) ? veh->getCOEmissions() : INVALID_DOUBLE_VALUE;
224 }
225 
226 double
227 Vehicle::getHCEmission(const std::string& vehicleID) {
228  MSVehicle* veh = getVehicle(vehicleID);
229  return isVisible(veh) ? veh->getHCEmissions() : INVALID_DOUBLE_VALUE;
230 }
231 
232 double
233 Vehicle::getPMxEmission(const std::string& vehicleID) {
234  MSVehicle* veh = getVehicle(vehicleID);
235  return isVisible(veh) ? veh->getPMxEmissions() : INVALID_DOUBLE_VALUE;
236 }
237 
238 double
239 Vehicle::getNOxEmission(const std::string& vehicleID) {
240  MSVehicle* veh = getVehicle(vehicleID);
241  return isVisible(veh) ? veh->getNOxEmissions() : INVALID_DOUBLE_VALUE;
242 }
243 
244 double
245 Vehicle::getFuelConsumption(const std::string& vehicleID) {
246  MSVehicle* veh = getVehicle(vehicleID);
247  return isVisible(veh) ? veh->getFuelConsumption() : INVALID_DOUBLE_VALUE;
248 }
249 
250 double
251 Vehicle::getNoiseEmission(const std::string& vehicleID) {
252  MSVehicle* veh = getVehicle(vehicleID);
254 }
255 
256 double
257 Vehicle::getElectricityConsumption(const std::string& vehicleID) {
258  MSVehicle* veh = getVehicle(vehicleID);
260 }
261 
262 int
263 Vehicle::getPersonNumber(const std::string& vehicleID) {
264  return getVehicle(vehicleID)->getPersonNumber();
265 }
266 
267 std::vector<std::string>
268 Vehicle::getPersonIDList(const std::string& vehicleID) {
269  return getVehicle(vehicleID)->getPersonIDList();
270 }
271 
272 std::pair<std::string, double>
273 Vehicle::getLeader(const std::string& vehicleID, double dist) {
274  MSVehicle* veh = getVehicle(vehicleID);
275  if (veh->isOnRoad()) {
276  std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist);
277  return std::make_pair(
278  leaderInfo.first != 0 ? leaderInfo.first->getID() : "",
279  leaderInfo.second);
280  } else {
281  return std::make_pair("", -1);
282  }
283 }
284 
285 
286 double
287 Vehicle::getWaitingTime(const std::string& vehicleID) {
288  return getVehicle(vehicleID)->getWaitingSeconds();
289 }
290 
291 
292 double
293 Vehicle::getAccumulatedWaitingTime(const std::string& vehicleID) {
294  return getVehicle(vehicleID)->getAccumulatedWaitingSeconds();
295 }
296 
297 
298 double
299 Vehicle::getAdaptedTraveltime(const std::string& vehicleID, double time, const std::string& edgeID) {
300  MSEdge* edge = Helper::getEdge(edgeID);
301  double value = INVALID_DOUBLE_VALUE;
302  getVehicle(vehicleID)->getWeightsStorage().retrieveExistingTravelTime(edge, time, value);
303  return value;
304 }
305 
306 
307 double
308 Vehicle::getEffort(const std::string& vehicleID, double time, const std::string& edgeID) {
309  MSEdge* edge = Helper::getEdge(edgeID);
310  double value = INVALID_DOUBLE_VALUE;
311  getVehicle(vehicleID)->getWeightsStorage().retrieveExistingEffort(edge, time, value);
312  return value;
313 }
314 
315 
316 bool
317 Vehicle::isRouteValid(const std::string& vehicleID) {
318  std::string msg;
319  return getVehicle(vehicleID)->hasValidRoute(msg);
320 }
321 
322 
323 std::vector<std::string>
324 Vehicle::getRoute(const std::string& vehicleID) {
325  std::vector<std::string> result;
326  MSVehicle* veh = getVehicle(vehicleID);
327  const MSRoute& r = veh->getRoute();
328  for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
329  result.push_back((*i)->getID());
330  }
331  return result;
332 }
333 
334 
335 int
336 Vehicle::getSignals(const std::string& vehicleID) {
337  return getVehicle(vehicleID)->getSignals();
338 }
339 
340 
341 std::vector<TraCIBestLanesData>
342 Vehicle::getBestLanes(const std::string& vehicleID) {
343  std::vector<TraCIBestLanesData> result;
344  MSVehicle* veh = getVehicle(vehicleID);
345  if (veh->isOnRoad()) {
346  const std::vector<MSVehicle::LaneQ>& bestLanes = veh->getBestLanes();
347  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
348  TraCIBestLanesData bld;
349  const MSVehicle::LaneQ& lq = *i;
350  bld.laneID = lq.lane->getID();
351  bld.length = lq.length;
352  bld.occupation = lq.nextOccupation;
355  for (std::vector<MSLane*>::const_iterator j = lq.bestContinuations.begin(); j != lq.bestContinuations.end(); ++j) {
356  if ((*j) != 0) {
357  bld.continuationLanes.push_back((*j)->getID());
358  }
359  }
360  result.push_back(bld);
361  }
362  }
363  return result;
364 }
365 
366 
367 std::vector<TraCINextTLSData>
368 Vehicle::getNextTLS(const std::string& vehicleID) {
369  std::vector<TraCINextTLSData> result;
370  MSVehicle* veh = getVehicle(vehicleID);
371  if (veh->isOnRoad()) {
372  const MSLane* lane = veh->getLane();
373  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
374  double seen = veh->getLane()->getLength() - veh->getPositionOnLane();
375  int view = 1;
376  MSLinkCont::const_iterator link = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
377  while (!lane->isLinkEnd(link)) {
378  if (!lane->getEdge().isInternal()) {
379  if ((*link)->isTLSControlled()) {
380  TraCINextTLSData ntd;
381  ntd.id = (*link)->getTLLogic()->getID();
382  ntd.tlIndex = (*link)->getTLIndex();
383  ntd.dist = seen;
384  ntd.state = (char)(*link)->getState();
385  result.push_back(ntd);
386  }
387  }
388  lane = (*link)->getViaLaneOrLane();
389  if (!lane->getEdge().isInternal()) {
390  view++;
391  }
392  seen += lane->getLength();
393  link = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
394  }
395  }
396  return result;
397 }
398 
399 
400 std::vector<TraCINextStopData>
401 Vehicle::getNextStops(const std::string& vehicleID) {
402  std::vector<TraCINextStopData> result;
403  MSVehicle* veh = getVehicle(vehicleID);
404  std::list<MSVehicle::Stop> stops = veh->getMyStops();
405  for (std::list<MSVehicle::Stop>::iterator it = stops.begin(); it != stops.end(); ++it) {
406  if (!it->reached && !it->collision) {
407  TraCINextStopData nsd;
408  nsd.lane = it->lane->getID();
409  nsd.endPos = it->getEndPos(*veh);
410  // all optionals, only one can be set
411  if (it->busstop != 0) {
412  nsd.stoppingPlaceID = it->busstop->getID();
413  }
414  if (it->containerstop != 0) {
415  nsd.stoppingPlaceID = it->containerstop->getID();
416  }
417  if (it->parkingarea != 0) {
418  nsd.stoppingPlaceID = it->parkingarea->getID();
419  }
420  if (it->chargingStation != 0) {
421  nsd.stoppingPlaceID = it->chargingStation->getID();
422  }
423  nsd.stopFlags = (1 +
424  (it->pars.parking ? 2 : 0) +
425  (it->pars.triggered ? 4 : 0) +
426  (it->pars.containerTriggered ? 8 : 0) +
427  (it->busstop != 0 ? 16 : 0) +
428  (it->containerstop != 0 ? 32 : 0) +
429  (it->chargingStation != 0 ? 64 : 0) +
430  (it->parkingarea != 0 ? 128 : 0));
431  nsd.duration = STEPS2TIME(it->pars.duration);
432  nsd.until = STEPS2TIME(it->pars.until);
433  result.push_back(nsd);
434  }
435  }
436  return result;
437 }
438 
439 
440 int
441 Vehicle::getStopState(const std::string& vehicleID) {
442  MSVehicle* veh = getVehicle(vehicleID);
443  int result = 0;
444  if (veh->isStopped()) {
445  const MSVehicle::Stop& stop = veh->getNextStop();
446  result = (1 + (stop.pars.parking ? 2 : 0) +
447  (stop.pars.triggered ? 4 : 0) +
448  (stop.pars.containerTriggered ? 8 : 0) +
449  (stop.busstop != 0 ? 16 : 0) +
450  (stop.containerstop != 0 ? 32 : 0) +
451  (stop.chargingStation != 0 ? 64 : 0) +
452  (stop.parkingarea != 0 ? 128 : 0));
453  }
454  return result;
455 }
456 
457 double
458 Vehicle::getDistance(const std::string& vehicleID) {
459  MSVehicle* veh = getVehicle(vehicleID);
460  if (veh->isOnRoad()) {
461  double distance;
462  if (veh->getLane()->isInternal()) {
463  // route edge still points to the edge before the intersection
464  const double normalEnd = (*veh->getCurrentRouteEdge())->getLength();
465  distance = (veh->getRoute().getDistanceBetween(veh->getDepartPos(), normalEnd,
466  veh->getRoute().begin(), veh->getCurrentRouteEdge())
467  + veh->getRoute().getDistanceBetween(normalEnd, veh->getPositionOnLane(),
468  *veh->getCurrentRouteEdge(), &veh->getLane()->getEdge()));
469  } else {
470  distance = veh->getRoute().getDistanceBetween(veh->getDepartPos(), veh->getPositionOnLane(),
471  veh->getRoute().begin(), veh->getCurrentRouteEdge());
472  }
473  if (distance == std::numeric_limits<double>::max()) {
474  return INVALID_DOUBLE_VALUE;
475  } else {
476  return distance;
477  }
478  } else {
479  return INVALID_DOUBLE_VALUE;
480  }
481 }
482 
483 
484 double
485 Vehicle::getDrivingDistance(const std::string& vehicleID, const std::string& edgeID, double position, int /* laneIndex */) {
486  MSVehicle* veh = getVehicle(vehicleID);
487  if (veh->isOnRoad()) {
488  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), position,
489  &veh->getLane()->getEdge(), Helper::getEdge(edgeID));
490  if (distance == std::numeric_limits<double>::max()) {
491  return INVALID_DOUBLE_VALUE;
492  }
493  return distance;
494  } else {
495  return INVALID_DOUBLE_VALUE;
496  }
497 }
498 
499 
500 double
501 Vehicle::getDrivingDistance2D(const std::string& vehicleID, double x, double y) {
502  MSVehicle* veh = getVehicle(vehicleID);
503  if (veh->isOnRoad()) {
504  std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y));
505  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
506  veh->getEdge(), &roadPos.first->getEdge());
507  if (distance == std::numeric_limits<double>::max()) {
508  return INVALID_DOUBLE_VALUE;
509  }
510  return distance;
511  } else {
512  return INVALID_DOUBLE_VALUE;
513  }
514 }
515 
516 
517 
518 double
519 Vehicle::getAllowedSpeed(const std::string& vehicleID) {
520  MSVehicle* veh = getVehicle(vehicleID);
521  if (veh->isOnRoad()) {
522  return veh->getLane()->getVehicleMaxSpeed(veh);
523  } else {
524  return INVALID_DOUBLE_VALUE;
525  }
526 }
527 
528 
529 double
530 Vehicle::getSpeedFactor(const std::string& vehicleID) {
531  return getVehicle(vehicleID)->getChosenSpeedFactor();
532 }
533 
534 
535 int
536 Vehicle::getSpeedMode(const std::string& vehicleID) {
537  return getVehicle(vehicleID)->getInfluencer().getSpeedMode();
538 }
539 
540 int
541 Vehicle::getLaneChangeMode(const std::string& vehicleID) {
542  return getVehicle(vehicleID)->getInfluencer().getLaneChangeMode();
543 }
544 
545 int
546 Vehicle::getRoutingMode(const std::string& vehicleID) {
547  return getVehicle(vehicleID)->getInfluencer().getRoutingMode();
548 }
549 
550 std::string
551 Vehicle::getLine(const std::string& vehicleID) {
552  return getVehicle(vehicleID)->getParameter().line;
553 }
554 
555 std::vector<std::string>
556 Vehicle::getVia(const std::string& vehicleID) {
557  return getVehicle(vehicleID)->getParameter().via;
558 }
559 
560 
561 std::pair<int, int>
562 Vehicle::getLaneChangeState(const std::string& vehicleID, int direction) {
563  MSVehicle* veh = getVehicle(vehicleID);
564  if (veh->isOnRoad() && veh->getLaneChangeModel().hasSavedState(direction)) {
565  return veh->getLaneChangeModel().getSavedState(direction);
566  } else {
567  return std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
568  }
569 }
570 
571 
572 std::string
573 Vehicle::getParameter(const std::string& vehicleID, const std::string& key) {
574  MSVehicle* veh = getVehicle(vehicleID);
575  if (StringUtils::startsWith(key, "device.")) {
576  StringTokenizer tok(key, ".");
577  if (tok.size() < 3) {
578  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehicleID + "'");
579  }
580  try {
581  return veh->getDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2));
582  } catch (InvalidArgument& e) {
583  throw TraCIException("Vehicle '" + vehicleID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
584  }
585  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
586  const std::string attrName = key.substr(16);
587  try {
588  return veh->getLaneChangeModel().getParameter(attrName);
589  } catch (InvalidArgument& e) {
590  throw TraCIException("Vehicle '" + vehicleID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
591  }
592  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
593  StringTokenizer tok(key, ".");
594  if (tok.size() != 3) {
595  throw TraCIException("Invalid check for device. Expected format is 'has.DEVICENAME.device'");
596  }
597  return veh->hasDevice(tok.get(1)) ? "true" : "false";
598  } else {
599  return veh->getParameter().getParameter(key, "");
600  }
601 }
602 
603 
604 const MSVehicleType&
605 Vehicle::getVehicleType(const std::string& vehicleID) {
606  return getVehicle(vehicleID)->getVehicleType();
607 }
608 
609 
610 std::string
611 Vehicle::getEmissionClass(const std::string& vehicleID) {
612  return PollutantsInterface::getName(getVehicleType(vehicleID).getEmissionClass());
613 }
614 
615 std::string
616 Vehicle::getShapeClass(const std::string& vehicleID) {
617  return getVehicleShapeName(getVehicleType(vehicleID).getGuiShape());
618 }
619 
620 
621 double
622 Vehicle::getLength(const std::string& vehicleID) {
623  return getVehicleType(vehicleID).getLength();
624 }
625 
626 
627 double
628 Vehicle::getAccel(const std::string& vehicleID) {
629  return getVehicleType(vehicleID).getCarFollowModel().getMaxAccel();
630 }
631 
632 
633 double
634 Vehicle::getDecel(const std::string& vehicleID) {
635  return getVehicleType(vehicleID).getCarFollowModel().getMaxDecel();
636 }
637 
638 
639 double Vehicle::getEmergencyDecel(const std::string& vehicleID) {
640  return getVehicleType(vehicleID).getCarFollowModel().getEmergencyDecel();
641 }
642 
643 
644 double Vehicle::getApparentDecel(const std::string& vehicleID) {
645  return getVehicleType(vehicleID).getCarFollowModel().getApparentDecel();
646 }
647 
648 
649 double Vehicle::getActionStepLength(const std::string& vehicleID) {
650  return getVehicleType(vehicleID).getActionStepLengthSecs();
651 }
652 
653 
654 double Vehicle::getLastActionTime(const std::string& vehicleID) {
655  return STEPS2TIME(getVehicle(vehicleID)->getLastActionTime());
656 }
657 
658 
659 double
660 Vehicle::getTau(const std::string& vehicleID) {
661  return getVehicleType(vehicleID).getCarFollowModel().getHeadwayTime();
662 }
663 
664 
665 double
666 Vehicle::getImperfection(const std::string& vehicleID) {
667  return getVehicleType(vehicleID).getCarFollowModel().getImperfection();
668 }
669 
670 
671 double
672 Vehicle::getSpeedDeviation(const std::string& vehicleID) {
673  return getVehicleType(vehicleID).getSpeedFactor().getParameter()[1];
674 }
675 
676 
677 std::string
678 Vehicle::getVehicleClass(const std::string& vehicleID) {
679  return toString(getVehicleType(vehicleID).getVehicleClass());
680 }
681 
682 
683 double
684 Vehicle::getMinGap(const std::string& vehicleID) {
685  return getVehicleType(vehicleID).getMinGap();
686 }
687 
688 
689 double
690 Vehicle::getMinGapLat(const std::string& vehicleID) {
691  return getVehicleType(vehicleID).getMinGapLat();
692 }
693 
694 
695 double
696 Vehicle::getMaxSpeed(const std::string& vehicleID) {
697  return getVehicleType(vehicleID).getMaxSpeed();
698 }
699 
700 
701 double
702 Vehicle::getMaxSpeedLat(const std::string& vehicleID) {
703  return getVehicleType(vehicleID).getMaxSpeedLat();
704 }
705 
706 
707 std::string
708 Vehicle::getLateralAlignment(const std::string& vehicleID) {
709  return toString(getVehicleType(vehicleID).getPreferredLateralAlignment());
710 }
711 
712 
713 double
714 Vehicle::getWidth(const std::string& vehicleID) {
715  return getVehicleType(vehicleID).getWidth();
716 }
717 
718 
719 double
720 Vehicle::getHeight(const std::string& vehicleID) {
721  return getVehicleType(vehicleID).getHeight();
722 }
723 
724 
725 void
726 Vehicle::setStop(const std::string& vehicleID,
727  const std::string& edgeID,
728  double pos,
729  int laneIndex,
730  double duration,
731  int flags,
732  double startPos,
733  double until) {
734  MSVehicle* veh = getVehicle(vehicleID);
735  // optional stop flags
736  bool parking = false;
737  bool triggered = false;
738  bool containerTriggered = false;
739  SumoXMLTag stoppingPlaceType = SUMO_TAG_NOTHING;
740 
741  parking = ((flags & 1) != 0);
742  triggered = ((flags & 2) != 0);
743  containerTriggered = ((flags & 4) != 0);
744  if ((flags & 8) != 0) {
745  stoppingPlaceType = SUMO_TAG_BUS_STOP;
746  }
747  if ((flags & 16) != 0) {
748  stoppingPlaceType = SUMO_TAG_CONTAINER_STOP;
749  }
750  if ((flags & 32) != 0) {
751  stoppingPlaceType = SUMO_TAG_CHARGING_STATION;
752  }
753  if ((flags & 64) != 0) {
754  stoppingPlaceType = SUMO_TAG_PARKING_AREA;
755  }
756  const SUMOTime durationSteps = duration == INVALID_DOUBLE_VALUE ? SUMOTime_MAX : TIME2STEPS(duration);
757  const SUMOTime untilStep = until == INVALID_DOUBLE_VALUE ? -1 : TIME2STEPS(until);
758 
759  std::string error;
760  if (stoppingPlaceType != SUMO_TAG_NOTHING) {
761  // Forward command to vehicle
762  if (!veh->addTraciStopAtStoppingPlace(edgeID, durationSteps, untilStep, parking, triggered, containerTriggered, stoppingPlaceType, error)) {
763  throw TraCIException(error);
764  }
765  } else {
766  // check
767  if (startPos == INVALID_DOUBLE_VALUE) {
768  startPos = pos - POSITION_EPS;
769  }
770  if (startPos < 0.) {
771  throw TraCIException("Position on lane must not be negative.");
772  }
773  if (pos < startPos) {
774  throw TraCIException("End position on lane must be after start position.");
775  }
776  // get the actual lane that is referenced by laneIndex
777  MSEdge* road = MSEdge::dictionary(edgeID);
778  if (road == 0) {
779  throw TraCIException("Unable to retrieve road with given id.");
780  }
781  const std::vector<MSLane*>& allLanes = road->getLanes();
782  if ((laneIndex < 0) || laneIndex >= (int)(allLanes.size())) {
783  throw TraCIException("No lane with index '" + toString(laneIndex) + "' on road '" + edgeID + "'.");
784  }
785  // Forward command to vehicle
786  if (!veh->addTraciStop(allLanes[laneIndex], startPos, pos, durationSteps, untilStep, parking, triggered, containerTriggered, error)) {
787  throw TraCIException(error);
788  }
789  }
790 }
791 
792 void
793 Vehicle::rerouteParkingArea(const std::string& vehicleID, const std::string& parkingAreaID) {
794  MSVehicle* veh = getVehicle(vehicleID);
795  std::string error;
796  // Forward command to vehicle
797  if (!veh->rerouteParkingArea(parkingAreaID, error)) {
798  throw TraCIException(error);
799  }
800 }
801 
802 void
803 Vehicle::resume(const std::string& vehicleID) {
804  MSVehicle* veh = getVehicle(vehicleID);
805  if (!veh->hasStops()) {
806  throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
807  }
808  if (!veh->resumeFromStopping()) {
809  MSVehicle::Stop& sto = veh->getNextStop();
810  std::ostringstream strs;
811  strs << "reached: " << sto.reached;
812  strs << ", duration:" << sto.duration;
813  strs << ", edge:" << (*sto.edge)->getID();
814  strs << ", startPos: " << sto.pars.startPos;
815  std::string posStr = strs.str();
816  throw TraCIException("Failed to resume from stoppingfor vehicle '" + veh->getID() + "', " + posStr);
817  }
818 }
819 
820 
821 void
822 Vehicle::changeTarget(const std::string& vehicleID, const std::string& edgeID) {
823  MSVehicle* veh = getVehicle(vehicleID);
824  const MSEdge* destEdge = MSEdge::dictionary(edgeID);
825  const bool onInit = isOnInit(vehicleID);
826  if (destEdge == 0) {
827  throw TraCIException("Can not retrieve road with ID " + edgeID);
828  }
829  // build a new route between the vehicle's current edge and destination edge
830  ConstMSEdgeVector newRoute;
831  const MSEdge* currentEdge = veh->getRerouteOrigin();
833  currentEdge, destEdge, (const MSVehicle * const)veh, MSNet::getInstance()->getCurrentTimeStep(), newRoute);
834  // replace the vehicle's route by the new one
835  if (!veh->replaceRouteEdges(newRoute, "traci:changeTarget", onInit)) {
836  throw TraCIException("Route replacement failed for " + veh->getID());
837  }
838  // route again to ensure usage of via/stops
839  try {
840  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget", veh->getInfluencer().getRouterTT(), onInit);
841  } catch (ProcessError& e) {
842  throw TraCIException(e.what());
843  }
844 }
845 
846 
847 void
848 Vehicle::changeLane(const std::string& vehicleID, int laneIndex, double duration) {
849  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
850  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
851  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
852  getVehicle(vehicleID)->getInfluencer().setLaneTimeLine(laneTimeLine);
853 }
854 
855 void
856 Vehicle::changeLaneRelative(const std::string& vehicleID, int laneChange, double duration) {
857  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
858  int laneIndex;
859  // Check in which direction the lane change should be performed 0: for right, >0 to left
860  if (laneChange > 0) {
861  laneIndex = getVehicle(vehicleID)->getLaneIndex() + laneChange;
862  } else {
863  laneIndex = getVehicle(vehicleID)->getLaneIndex() - 1;
864  }
865  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
866  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
867  getVehicle(vehicleID)->getInfluencer().setLaneTimeLine(laneTimeLine);
868 }
869 
870 
871 void
872 Vehicle::changeSublane(const std::string& vehicleID, double latDist) {
873  getVehicle(vehicleID)->getInfluencer().setSublaneChange(latDist);
874 }
875 
876 
877 void
878 Vehicle::add(const std::string& vehicleID,
879  const std::string& routeID,
880  const std::string& typeID,
881  const std::string& depart,
882  const std::string& departLane,
883  const std::string& departPos,
884  const std::string& departSpeed,
885  const std::string& arrivalLane,
886  const std::string& arrivalPos,
887  const std::string& arrivalSpeed,
888  const std::string& fromTaz,
889  const std::string& toTaz,
890  const std::string& line,
891  int /*personCapacity*/,
892  int personNumber) {
894  if (veh != 0) {
895  throw TraCIException("The vehicle " + vehicleID + " to add already exists.");
896  }
897 
898  SUMOVehicleParameter vehicleParams;
899  vehicleParams.id = vehicleID;
900  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
901  if (!vehicleType) {
902  throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehicleID + "'");
903  }
904  const MSRoute* route = MSRoute::dictionary(routeID);
905  if (!route) {
906  if (routeID == "") {
907  // assume, route was intentionally left blank because the caller
908  // intends to control the vehicle remotely
909  SUMOVehicleClass vclass = vehicleType->getVehicleClass();
910  const std::string dummyRouteID = "DUMMY_ROUTE_" + SumoVehicleClassStrings.getString(vclass);
911  route = MSRoute::dictionary(dummyRouteID);
912  if (route == 0) {
913  for (MSEdge* e : MSEdge::getAllEdges()) {
914  if (e->getFunction() == EDGEFUNC_NORMAL && (e->getPermissions() & vclass) == vclass) {
915  std::vector<std::string> edges;
916  edges.push_back(e->getID());
917  libsumo::Route::add(dummyRouteID, edges);
918  break;
919  }
920  }
921  }
922  route = MSRoute::dictionary(dummyRouteID);
923  if (!route) {
924  throw TraCIException("Could not build dummy route for vehicle class: '" + SumoVehicleClassStrings.getString(vehicleType->getVehicleClass()) + "'");
925  }
926  } else {
927  throw TraCIException("Invalid route '" + routeID + "' for vehicle: '" + vehicleID + "'");
928  }
929  }
930  // check if the route implies a trip
931  if (route->getEdges().size() == 2) {
932  const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
933  if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
934  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
935  }
936  }
937  if (fromTaz != "" || toTaz != "") {
938  vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
939  }
940  std::string error;
941  if (!SUMOVehicleParameter::parseDepart(depart, "vehicle", vehicleID, vehicleParams.depart, vehicleParams.departProcedure, error)) {
942  throw TraCIException(error);
943  }
944  if (vehicleParams.departProcedure == DEPART_GIVEN && vehicleParams.depart < MSNet::getInstance()->getCurrentTimeStep()) {
945  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
946  WRITE_WARNING("Departure time for vehicle '" + vehicleID + "' is in the past; using current time instead.");
947  } else if (vehicleParams.departProcedure == DEPART_NOW) {
948  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
949  }
950  if (!SUMOVehicleParameter::parseDepartLane(departLane, "vehicle", vehicleID, vehicleParams.departLane, vehicleParams.departLaneProcedure, error)) {
951  throw TraCIException(error);
952  }
953  if (!SUMOVehicleParameter::parseDepartPos(departPos, "vehicle", vehicleID, vehicleParams.departPos, vehicleParams.departPosProcedure, error)) {
954  throw TraCIException(error);
955  }
956  if (!SUMOVehicleParameter::parseDepartSpeed(departSpeed, "vehicle", vehicleID, vehicleParams.departSpeed, vehicleParams.departSpeedProcedure, error)) {
957  throw TraCIException(error);
958  }
959  if (!SUMOVehicleParameter::parseArrivalLane(arrivalLane, "vehicle", vehicleID, vehicleParams.arrivalLane, vehicleParams.arrivalLaneProcedure, error)) {
960  throw TraCIException(error);
961  }
962  if (!SUMOVehicleParameter::parseArrivalPos(arrivalPos, "vehicle", vehicleID, vehicleParams.arrivalPos, vehicleParams.arrivalPosProcedure, error)) {
963  throw TraCIException(error);
964  }
965  if (!SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeed, "vehicle", vehicleID, vehicleParams.arrivalSpeed, vehicleParams.arrivalSpeedProcedure, error)) {
966  throw TraCIException(error);
967  }
968  vehicleParams.fromTaz = fromTaz;
969  vehicleParams.toTaz = toTaz;
970  vehicleParams.line = line;
971  //vehicleParams.personCapacity = personCapacity;
972  vehicleParams.personNumber = personNumber;
973 
974  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
975  try {
976  SUMOVehicle* vehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(params, route, vehicleType, true, false);
977  MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
979  } catch (ProcessError& e) {
980  throw TraCIException(e.what());
981  }
982 }
983 
984 
985 void
986 Vehicle::moveToXY(const std::string& vehicleID, const std::string& edgeID, const int laneIndex, const double x, const double y, double angle, const int keepRoute) {
987  MSVehicle* veh = getVehicle(vehicleID);
988  const bool doKeepRoute = (keepRoute == 1) && veh->getID() != "VTD_EGO";
989  const bool mayLeaveNetwork = (keepRoute == 2);
990  // process
991  const std::string origID = edgeID + "_" + toString(laneIndex);
992  // @todo add an interpretation layer for OSM derived origID values (without lane index)
993  Position pos(x, y);
994 #ifdef DEBUG_MOVEXY
995  const double origAngle = angle;
996 #endif
997  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
998  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
999  if (angle != INVALID_DOUBLE_VALUE) {
1000  while (angle >= 360.) {
1001  angle -= 360.;
1002  }
1003  while (angle < 0.) {
1004  angle += 360.;
1005  }
1006  }
1007 
1008  Position vehPos = veh->getPosition();
1009 #ifdef DEBUG_MOVEXY
1010  std::cout << std::endl << "begin vehicle " << veh->getID() << " vehPos:" << vehPos << " lane:" << Named::getIDSecure(veh->getLane()) << std::endl;
1011  std::cout << " want pos:" << pos << " origID:" << origID << " laneIndex:" << laneIndex << " origAngle:" << origAngle << " angle:" << angle << " keepRoute:" << keepRoute << std::endl;
1012 #endif
1013 
1014  ConstMSEdgeVector edges;
1015  MSLane* lane = 0;
1016  double lanePos;
1017  double lanePosLat = 0;
1018  double bestDistance = std::numeric_limits<double>::max();
1019  int routeOffset = 0;
1020  bool found;
1021  double maxRouteDistance = 100;
1022  /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
1023  if (doKeepRoute) {
1024  // case a): vehicle is on its earlier route
1025  // we additionally assume it is moving forward (SUMO-limit);
1026  // note that the route ("edges") is not changed in this case
1027 
1028  found = Helper::moveToXYMap_matchingRoutePosition(pos, origID,
1029  veh->getRoute().getEdges(), (int)(veh->getCurrentRouteEdge() - veh->getRoute().begin()),
1030  bestDistance, &lane, lanePos, routeOffset);
1031  // @note silenty ignoring mapping failure
1032  } else {
1033  double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
1034  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
1035  speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
1036  bestDistance, &lane, lanePos, routeOffset, edges);
1037  }
1038  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1039  // optionally compute lateral offset
1040  if (found && (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork)) {
1041  const double perpDist = lane->getShape().distance2D(pos, false);
1042  if (perpDist != GeomHelper::INVALID_OFFSET) {
1043  lanePosLat = perpDist;
1044  if (!mayLeaveNetwork) {
1045  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
1046  }
1047  // figure out whether the offset is to the left or to the right
1048  PositionVector tmp = lane->getShape();
1049  try {
1050  tmp.move2side(-lanePosLat); // moved to left
1051  } catch (ProcessError&) {
1052  WRITE_WARNING("Could not determine position on lane '" + lane->getID() + " at lateral position " + toString(-lanePosLat) + ".");
1053  }
1054  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
1055  if (tmp.distance2D(pos) > perpDist) {
1056  lanePosLat = -lanePosLat;
1057  }
1058  }
1059  }
1060  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
1061  // mapped position may differ from pos
1062  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1063  }
1064  assert((found && lane != 0) || (!found && lane == 0));
1065  if (angle == INVALID_DOUBLE_VALUE) {
1066  if (lane != 0) {
1067  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
1068  } else {
1069  // compute angle outside road network from old and new position
1070  angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
1071  }
1072  }
1073  // use the best we have
1074  Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
1075  if (!veh->isOnRoad()) {
1077  }
1078  } else {
1079  if (lane == 0) {
1080  throw TraCIException("Could not map vehicle '" + vehicleID + "' no road found within " + toString(maxRouteDistance) + "m.");
1081  } else {
1082  throw TraCIException("Could not map vehicle '" + vehicleID + "' distance to road is " + toString(bestDistance) + ".");
1083  }
1084  }
1085 }
1086 
1087 void
1088 Vehicle::slowDown(const std::string& vehicleID, double speed, double duration) {
1089  MSVehicle* veh = getVehicle(vehicleID);
1090  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1091  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1092  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), speed));
1093  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1094 }
1095 
1096 void
1097 Vehicle::setSpeed(const std::string& vehicleID, double speed) {
1098  MSVehicle* veh = getVehicle(vehicleID);
1099  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1100  if (speed >= 0) {
1101  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), speed));
1102  speedTimeLine.push_back(std::make_pair(SUMOTime_MAX - DELTA_T, speed));
1103  }
1104  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1105 }
1106 
1107 void
1108 Vehicle::setSpeedMode(const std::string& vehicleID, int speedMode) {
1109  getVehicle(vehicleID)->getInfluencer().setSpeedMode(speedMode);
1110 }
1111 
1112 void
1113 Vehicle::setLaneChangeMode(const std::string& vehicleID, int laneChangeMode) {
1114  getVehicle(vehicleID)->getInfluencer().setLaneChangeMode(laneChangeMode);
1115 }
1116 
1117 void
1118 Vehicle::setRoutingMode(const std::string& vehicleID, int routingMode) {
1119  getVehicle(vehicleID)->getInfluencer().setRoutingMode(routingMode);
1120 }
1121 
1122 void
1123 Vehicle::setType(const std::string& vehicleID, const std::string& typeID) {
1124  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1125  if (vehicleType == 0) {
1126  throw TraCIException("Vehicle type '" + typeID + "' is not known");
1127  }
1128  getVehicle(vehicleID)->replaceVehicleType(vehicleType);
1129 }
1130 
1131 void
1132 Vehicle::setRouteID(const std::string& vehicleID, const std::string& routeID) {
1133  MSVehicle* veh = getVehicle(vehicleID);
1134  const MSRoute* r = MSRoute::dictionary(routeID);
1135  if (r == 0) {
1136  throw TraCIException("The route '" + routeID + "' is not known.");
1137  }
1138  std::string msg;
1139  if (!veh->hasValidRoute(msg, r)) {
1140  WRITE_WARNING("Invalid route replacement for vehicle '" + veh->getID() + "'. " + msg);
1142  throw TraCIException("Route replacement failed for " + veh->getID());
1143  }
1144  }
1145 
1146  if (!veh->replaceRoute(r, "traci:setRouteID", veh->getLane() == 0)) {
1147  throw TraCIException("Route replacement failed for " + veh->getID());
1148  }
1149 }
1150 
1151 void
1152 Vehicle::setRoute(const std::string& vehicleID, const std::vector<std::string>& edgeIDs) {
1153  MSVehicle* veh = getVehicle(vehicleID);
1154  ConstMSEdgeVector edges;
1155  try {
1156  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
1157  } catch (ProcessError& e) {
1158  throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
1159  }
1160  if (!veh->replaceRouteEdges(edges, "traci:setRoute", veh->getLane() == 0, true)) {
1161  throw TraCIException("Route replacement failed for " + veh->getID());
1162  }
1163 }
1164 
1165 void
1166 Vehicle::updateBestLanes(const std::string& vehicleID) {
1167  MSVehicle* veh = getVehicle(vehicleID);
1168  veh->updateBestLanes(true);
1169 }
1170 
1171 
1172 void
1173 Vehicle::setAdaptedTraveltime(const std::string& vehicleID, const std::string& edgeID,
1174  double time, double begSeconds, double endSeconds) {
1175  MSVehicle* veh = getVehicle(vehicleID);
1176  MSEdge* edge = MSEdge::dictionary(edgeID);
1177  if (edge == 0) {
1178  throw TraCIException("Referended edge '" + edgeID + "' is not known.");
1179  }
1180  if (time != INVALID_DOUBLE_VALUE) {
1181  // add time
1182  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1183  // clean up old values before setting whole range
1184  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
1185  veh->getWeightsStorage().removeTravelTime(edge);
1186  }
1187  }
1188  veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
1189  } else {
1190  // remove time
1191  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
1192  veh->getWeightsStorage().removeTravelTime(edge);
1193  }
1194  }
1195 }
1196 
1197 
1198 void
1199 Vehicle::setEffort(const std::string& vehicleID, const std::string& edgeID,
1200  double effort, double begSeconds, double endSeconds) {
1201  MSVehicle* veh = getVehicle(vehicleID);
1202  MSEdge* edge = MSEdge::dictionary(edgeID);
1203  if (edge == 0) {
1204  throw TraCIException("Referended edge '" + edgeID + "' is not known.");
1205  }
1206  if (effort != INVALID_DOUBLE_VALUE) {
1207  // add effort
1208  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1209  // clean up old values before setting whole range
1210  while (veh->getWeightsStorage().knowsEffort(edge)) {
1211  veh->getWeightsStorage().removeEffort(edge);
1212  }
1213  }
1214  veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
1215  } else {
1216  // remove effort
1217  while (veh->getWeightsStorage().knowsEffort(edge)) {
1218  veh->getWeightsStorage().removeEffort(edge);
1219  }
1220  }
1221 }
1222 
1223 
1224 void
1225 Vehicle::rerouteTraveltime(const std::string& vehicleID) {
1226  MSVehicle* veh = getVehicle(vehicleID);
1227  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteTraveltime",
1228  veh->getInfluencer().getRouterTT(), isOnInit(vehicleID));
1229 }
1230 
1231 
1232 void
1233 Vehicle::rerouteEffort(const std::string& vehicleID) {
1234  MSVehicle* veh = getVehicle(vehicleID);
1235  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteEffort", MSNet::getInstance()->getRouterEffort(), isOnInit(vehicleID));
1236 }
1237 
1238 
1239 void
1240 Vehicle::setSignals(const std::string& vehicleID, int signals) {
1241  MSVehicle* veh = getVehicle(vehicleID);
1242  // set influencer to make the change persistent
1243  veh->getInfluencer().setSignals(signals);
1244  // set them now so that getSignals returns the correct value
1245  veh->switchOffSignal(0x0fffffff);
1246  if (signals >= 0) {
1247  veh->switchOnSignal(signals);
1248  }
1249 }
1250 
1251 
1252 void
1253 Vehicle::moveTo(const std::string& vehicleID, const std::string& laneID, double position) {
1254  MSVehicle* veh = getVehicle(vehicleID);
1255  MSLane* l = MSLane::dictionary(laneID);
1256  if (l == 0) {
1257  throw TraCIException("Unknown lane '" + laneID + "'.");
1258  }
1259  MSEdge& destinationEdge = l->getEdge();
1260  if (!veh->willPass(&destinationEdge)) {
1261  throw TraCIException("Vehicle '" + laneID + "' may be set onto an edge to pass only.");
1262  }
1264  if (veh->getLane() != 0) {
1266  } else {
1267  veh->setTentativeLaneAndPosition(l, position);
1268  }
1269  while (veh->getEdge() != &destinationEdge) {
1270  const MSEdge* nextEdge = veh->succEdge(1);
1271  // let the vehicle move to the next edge
1272  if (veh->enterLaneAtMove(nextEdge->getLanes()[0], true)) {
1274  continue;
1275  }
1276  }
1277  if (!veh->isOnRoad()) {
1279 
1280  }
1281  l->forceVehicleInsertion(veh, position,
1283 }
1284 
1285 
1286 void
1287 Vehicle::setActionStepLength(const std::string& vehicleID, double actionStepLength, bool resetActionOffset) {
1288  if (actionStepLength < 0.0) {
1289  WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
1290  return;
1291  }
1292  MSVehicle* veh = getVehicle(vehicleID);
1293  if (actionStepLength == 0.) {
1294  veh->resetActionOffset();
1295  return;
1296  }
1297  SUMOTime actionStepLengthMillisecs = SUMOVehicleParserHelper::processActionStepLength(actionStepLength);
1298  SUMOTime previousActionStepLength = veh->getActionStepLength();
1299  veh->getSingularType().setActionStepLength(actionStepLengthMillisecs, resetActionOffset);
1300  if (resetActionOffset) {
1301  veh->resetActionOffset();
1302  } else {
1303  veh->updateActionOffset(previousActionStepLength, actionStepLengthMillisecs);
1304  }
1305 }
1306 
1307 
1308 void
1309 Vehicle::remove(const std::string& vehicleID, char reason) {
1310  MSVehicle* veh = getVehicle(vehicleID);
1312  switch (reason) {
1313  case REMOVE_TELEPORT:
1314  // XXX semantics unclear
1315  // n = MSMoveReminder::NOTIFICATION_TELEPORT;
1317  break;
1318  case REMOVE_PARKING:
1319  // XXX semantics unclear
1320  // n = MSMoveReminder::NOTIFICATION_PARKING;
1322  break;
1323  case REMOVE_ARRIVED:
1325  break;
1326  case REMOVE_VAPORIZED:
1328  break;
1331  break;
1332  default:
1333  throw TraCIException("Unknown removal status.");
1334  }
1335  if (veh->hasDeparted()) {
1336  veh->onRemovalFromNet(n);
1337  if (veh->getLane() != 0) {
1338  veh->getLane()->removeVehicle(veh, n);
1339  }
1341  } else {
1344  }
1345 }
1346 
1347 
1348 void
1349 Vehicle::setColor(const std::string& vehicleID, const TraCIColor& col) {
1350  const SUMOVehicleParameter& p = getVehicle(vehicleID)->getParameter();
1351  p.color.set(col.r, col.g, col.b, col.a);
1353 }
1354 
1355 
1356 void
1357 Vehicle::setSpeedFactor(const std::string& vehicleID, double factor) {
1358  getVehicle(vehicleID)->setChosenSpeedFactor(factor);
1359 }
1360 
1361 
1362 void
1363 Vehicle::setLine(const std::string& vehicleID, const std::string& line) {
1364  getVehicle(vehicleID)->getParameter().line = line;
1365 }
1366 
1367 
1368 void
1369 Vehicle::setVia(const std::string& vehicleID, const std::vector<std::string>& via) {
1370  MSVehicle* veh = getVehicle(vehicleID);
1371  try {
1372  // ensure edges exist
1373  ConstMSEdgeVector edges;
1374  MSEdge::parseEdgesList(via, edges, "<via-edges>");
1375  } catch (ProcessError& e) {
1376  throw TraCIException(e.what());
1377  }
1378  veh->getParameter().via = via;
1379 }
1380 
1381 
1382 void
1383 Vehicle::setLength(const std::string& vehicleID, double length) {
1384  getVehicle(vehicleID)->getSingularType().setLength(length);
1385 }
1386 
1387 
1388 void
1389 Vehicle::setMaxSpeed(const std::string& vehicleID, double speed) {
1390  getVehicle(vehicleID)->getSingularType().setMaxSpeed(speed);
1391 }
1392 
1393 
1394 void
1395 Vehicle::setVehicleClass(const std::string& vehicleID, const std::string& clazz) {
1396  getVehicle(vehicleID)->getSingularType().setVClass(getVehicleClassID(clazz));
1397 }
1398 
1399 
1400 void
1401 Vehicle::setShapeClass(const std::string& vehicleID, const std::string& clazz) {
1402  getVehicle(vehicleID)->getSingularType().setShape(getVehicleShapeID(clazz));
1403 }
1404 
1405 
1406 void
1407 Vehicle::setEmissionClass(const std::string& vehicleID, const std::string& clazz) {
1409 }
1410 
1411 
1412 void
1413 Vehicle::setWidth(const std::string& vehicleID, double width) {
1414  getVehicle(vehicleID)->getSingularType().setWidth(width);
1415 }
1416 
1417 
1418 void
1419 Vehicle::setHeight(const std::string& vehicleID, double height) {
1420  getVehicle(vehicleID)->getSingularType().setHeight(height);
1421 }
1422 
1423 
1424 void
1425 Vehicle::setMinGap(const std::string& vehicleID, double minGap) {
1426  getVehicle(vehicleID)->getSingularType().setMinGap(minGap);
1427 }
1428 
1429 
1430 void
1431 Vehicle::setAccel(const std::string& vehicleID, double accel) {
1432  getVehicle(vehicleID)->getSingularType().setAccel(accel);
1433 }
1434 
1435 
1436 void
1437 Vehicle::setDecel(const std::string& vehicleID, double decel) {
1438  VehicleType::setDecel(getVehicle(vehicleID)->getSingularType().getID(), decel);
1439 }
1440 
1441 
1442 void
1443 Vehicle::setEmergencyDecel(const std::string& vehicleID, double decel) {
1444  VehicleType::setEmergencyDecel(getVehicle(vehicleID)->getSingularType().getID(), decel);
1445 }
1446 
1447 
1448 void
1449 Vehicle::setApparentDecel(const std::string& vehicleID, double decel) {
1450  getVehicle(vehicleID)->getSingularType().setApparentDecel(decel);
1451 }
1452 
1453 
1454 void
1455 Vehicle::setImperfection(const std::string& vehicleID, double imperfection) {
1456  getVehicle(vehicleID)->getSingularType().setImperfection(imperfection);
1457 }
1458 
1459 
1460 void
1461 Vehicle::setTau(const std::string& vehicleID, double tau) {
1462  getVehicle(vehicleID)->getSingularType().setTau(tau);
1463 }
1464 
1465 
1466 void
1467 Vehicle::setMinGapLat(const std::string& vehicleID, double minGapLat) {
1468  getVehicle(vehicleID)->getSingularType().setMinGapLat(minGapLat);
1469 }
1470 
1471 
1472 void
1473 Vehicle::setMaxSpeedLat(const std::string& vehicleID, double speed) {
1474  getVehicle(vehicleID)->getSingularType().setMaxSpeedLat(speed);
1475 }
1476 
1477 
1478 void
1479 Vehicle::setLateralAlignment(const std::string& vehicleID, const std::string& latAlignment) {
1481 }
1482 
1483 
1484 void
1485 Vehicle::setParameter(const std::string& vehicleID, const std::string& key, const std::string& value) {
1486  MSVehicle* veh = getVehicle(vehicleID);
1487  if (StringUtils::startsWith(key, "device.")) {
1488  StringTokenizer tok(key, ".");
1489  if (tok.size() < 3) {
1490  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehicleID + "'");
1491  }
1492  try {
1493  veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
1494  } catch (InvalidArgument& e) {
1495  throw TraCIException("Vehicle '" + vehicleID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
1496  }
1497  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
1498  const std::string attrName = key.substr(16);
1499  try {
1500  veh->getLaneChangeModel().setParameter(attrName, value);
1501  } catch (InvalidArgument& e) {
1502  throw TraCIException("Vehicle '" + vehicleID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
1503  }
1504  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
1505  StringTokenizer tok(key, ".");
1506  if (tok.size() != 3) {
1507  throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
1508  }
1509  const std::string deviceName = tok.get(1);
1510  bool create;
1511  try {
1512  create = TplConvert::_2bool(value.c_str());
1513  } catch (BoolFormatException&) {
1514  throw TraCIException("Changing device status requires a 'true' or 'false'");
1515  }
1516  if (!create) {
1517  throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
1518  }
1519  try {
1520  veh->createDevice(deviceName);
1521  } catch (InvalidArgument& e) {
1522  throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
1523  }
1524  } else {
1525  ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
1526  }
1527 }
1528 
1529 
1531 
1532 
1533 void
1534 Vehicle::storeShape(const std::string& id, PositionVector& shape) {
1535  shape.push_back(getVehicle(id)->getPosition());
1536 }
1537 
1538 
1539 std::shared_ptr<VariableWrapper>
1541  return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
1542 }
1543 
1544 
1545 bool
1546 Vehicle::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper) {
1547  switch (variable) {
1548  case ID_LIST:
1549  return wrapper->wrapStringList(objID, variable, getIDList());
1550  case ID_COUNT:
1551  return wrapper->wrapInt(objID, variable, getIDCount());
1552  case VAR_POSITION:
1553  return wrapper->wrapPosition(objID, variable, getPosition(objID));
1554  case VAR_POSITION3D:
1555  return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
1556  case VAR_ANGLE:
1557  return wrapper->wrapDouble(objID, variable, getAngle(objID));
1558  case VAR_SPEED:
1559  return wrapper->wrapDouble(objID, variable, getSpeed(objID));
1560  case VAR_ROAD_ID:
1561  return wrapper->wrapString(objID, variable, getRoadID(objID));
1563  return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
1564  case VAR_SLOPE:
1565  return wrapper->wrapDouble(objID, variable, getSlope(objID));
1566  case VAR_LANE_ID:
1567  return wrapper->wrapString(objID, variable, getLaneID(objID));
1568  case VAR_LANE_INDEX:
1569  return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
1570  case VAR_TYPE:
1571  return wrapper->wrapString(objID, variable, getTypeID(objID));
1572  case VAR_ROUTE_ID:
1573  return wrapper->wrapString(objID, variable, getRouteID(objID));
1574  case VAR_ROUTE_INDEX:
1575  return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
1576  case VAR_COLOR:
1577  return wrapper->wrapColor(objID, variable, getColor(objID));
1578  case VAR_LANEPOSITION:
1579  return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
1580  case VAR_LANEPOSITION_LAT:
1581  return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
1582  case VAR_CO2EMISSION:
1583  return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
1584  case VAR_COEMISSION:
1585  return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
1586  case VAR_HCEMISSION:
1587  return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
1588  case VAR_PMXEMISSION:
1589  return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
1590  case VAR_NOXEMISSION:
1591  return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
1592  case VAR_FUELCONSUMPTION:
1593  return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
1594  case VAR_NOISEEMISSION:
1595  return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
1597  return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
1598  case VAR_PERSON_NUMBER:
1599  return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
1601  return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
1602  case VAR_WAITING_TIME:
1603  return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
1605  return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
1606  case VAR_ROUTE_VALID:
1607  return wrapper->wrapInt(objID, variable, isRouteValid(objID));
1608  case VAR_EDGES:
1609  return wrapper->wrapStringList(objID, variable, getRoute(objID));
1610  case VAR_SIGNALS:
1611  return wrapper->wrapInt(objID, variable, getSignals(objID));
1612  case VAR_STOPSTATE:
1613  return wrapper->wrapInt(objID, variable, getStopState(objID));
1614  case VAR_DISTANCE:
1615  return wrapper->wrapDouble(objID, variable, getDistance(objID));
1616  case VAR_ALLOWED_SPEED:
1617  return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
1618  case VAR_SPEED_FACTOR:
1619  return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
1620  case VAR_SPEEDSETMODE:
1621  return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
1622  case VAR_LANECHANGE_MODE:
1623  return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
1624  case VAR_ROUTING_MODE:
1625  return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
1626  case VAR_LINE:
1627  return wrapper->wrapString(objID, variable, getLine(objID));
1628  case VAR_VIA:
1629  return wrapper->wrapStringList(objID, variable, getVia(objID));
1630  case VAR_ACCELERATION:
1631  return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
1632  case VAR_LASTACTIONTIME:
1633  return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
1634  default:
1635  return false;
1636  }
1637 }
1638 
1639 
1640 }
1641 
1642 /****************************************************************************/
#define VAR_ROAD_ID
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
int getRoutePosition() const
Definition: MSVehicle.cpp:833
unsigned char g
Definition: TraCIDefs.h:139
static std::string getLaneID(const std::string &vehicleID)
Definition: Vehicle.cpp:165
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:342
#define REMOVE_PARKING
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:199
static double gLateralResolution
Definition: MSGlobals.h:85
double getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:4523
std::string id
The id of the next tls.
Definition: TraCIDefs.h:279
int stopFlags
Stop flags.
Definition: TraCIDefs.h:297
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
Definition: MSVehicle.h:667
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:485
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool hasSavedState(const int dir) const
double getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:4511
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Definition: MSVehicle.cpp:3819
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:726
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
Definition: MSVehicle.cpp:582
RGBColor color
The vehicle&#39;s color, TraCI may change this.
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:617
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:1199
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
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:36
const int VEHPARS_FORCE_REROUTE
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
#define VAR_VIA
#define VAR_CO2EMISSION
double getElectricityConsumption() const
Returns electricity consumption of the current state.
Definition: MSVehicle.cpp:4529
#define VAR_ACCELERATION
static void setLine(const std::string &vehicleID, const std::string &line)
Definition: Vehicle.cpp:1363
double dist
The distance to the tls.
Definition: TraCIDefs.h:283
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:315
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
The time is given.
static std::pair< MSLane *, double > convertCartesianToRoadMap(Position pos)
Definition: Helper.cpp:268
static void updateBestLanes(const std::string &vehicleID)
Definition: Vehicle.cpp:1166
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:121
double until
The time at which the vehicle may continue its journey.
Definition: TraCIDefs.h:301
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: Helper.cpp:208
The vehicle is discarded if emission fails (not fully implemented yet)
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:117
static std::string getRoadID(const std::string &vehicleID)
Definition: Vehicle.cpp:158
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) ...
#define VAR_ACCUMULATED_WAITING_TIME
bool parking
whether the vehicle is removed from the net while stopping
static void setRoute(const std::string &vehicleID, const std::vector< std::string > &edgeIDs)
Definition: Vehicle.cpp:1152
bool hasDeparted() const
Returns whether this vehicle has already departed.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static int getPersonNumber(const std::string &vehicleID)
Definition: Vehicle.cpp:263
Stop & getNextStop()
Definition: MSVehicle.cpp:5187
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
#define VAR_POSITION
bool resumeFromStopping()
Definition: MSVehicle.cpp:5136
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.
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
Definition: TplConvert.h:382
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
Definition: MSVehicle.h:816
void setShape(SUMOVehicleShape shape)
Set a new value for this type&#39;s shape.
static MSEdge * getEdge(const std::string &edgeID)
Definition: Helper.cpp:241
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:243
#define VAR_SPEEDSETMODE
static double getAcceleration(const std::string &vehicleID)
Definition: Vehicle.cpp:110
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:4452
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSVehicle.h:931
SUMOTime duration
The stopping duration.
Definition: MSVehicle.h:933
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition: Helper.cpp:225
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:1485
virtual double getImperfection() const
Get the driver&#39;s imperfection.
Definition: MSCFModel.h:251
std::list< Stop > getMyStops()
Definition: MSVehicle.cpp:5192
#define VAR_ALLOWED_SPEED
std::vector< double > & getParameter()
Returns the parameters of this distribution.
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSVehicle.h:927
static double getSlope(const std::string &vehicleID)
Definition: Vehicle.cpp:151
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSVehicle.h:923
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:399
#define VAR_WAITING_TIME
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
#define VAR_SIGNALS
#define VAR_TYPE
static std::string getTypeID(const std::string &vehicleID)
Definition: Vehicle.cpp:179
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:939
#define VAR_ROUTE_ID
Notification
Definition of a vehicle state.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
Definition: MSRoute.cpp:274
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2022
static void setRoutingMode(const std::string &vehicleID, int routingMode)
Definition: Vehicle.cpp:1118
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
#define VAR_SPEED_FACTOR
#define VAR_COLOR
std::string get(int pos) const
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
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:5056
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
double occupation
The traffic density along length.
Definition: TraCIDefs.h:311
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
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:253
static double getCOEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:221
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:160
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:307
static void setSpeedMode(const std::string &vehicleID, int speedMode)
Definition: Vehicle.cpp:1108
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:507
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:449
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:62
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1836
#define VAR_ROUTING_MODE
static std::vector< std::string > getVia(const std::string &vehicleID)
Definition: Vehicle.cpp:556
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:742
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:932
static void rerouteParkingArea(const std::string &vehicleID, const std::string &parkingAreaID)
Definition: Vehicle.cpp:793
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:200
static TraCIPosition getPosition3D(const std::string &vehicleID)
Definition: Vehicle.cpp:138
void setLength(const double &length)
Set a new value for this type&#39;s length.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
int getSignals() const
Returns the signals.
Definition: MSVehicle.h:1242
static void setRouteID(const std::string &vehicleID, const std::string &routeID)
Definition: Vehicle.cpp:1132
int getLaneChangeMode() const
return the current lane change mode
Definition: MSVehicle.cpp:292
const std::string & getID() const
Returns the id.
Definition: Named.h:69
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
#define TIME2STEPS(x)
Definition: SUMOTime.h:60
static double getAngle(const std::string &vehicleID)
Definition: Vehicle.cpp:144
int getSpeedMode() const
return the current speed mode
Definition: MSVehicle.cpp:282
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Vehicle.cpp:1540
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:814
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Vehicle.h:198
double length
The overall length which may be driven when using this lane without a lane change.
Definition: MSVehicle.h:808
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:551
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
Definition: MSVehicle.cpp:4936
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
#define VAR_NOISEEMISSION
#define VAR_FUELCONSUMPTION
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:523
static double getDistance(const std::string &vehicleID)
Definition: Vehicle.cpp:458
static double getNoiseEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:251
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
#define VAR_POSITION3D
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:4028
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:4626
static std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction)
Definition: Vehicle.cpp:562
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
static double getNOxEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:239
static void rerouteTraveltime(const std::string &vehicleID)
Definition: Vehicle.cpp:1225
static double getEffort(const std::string &vehicleID, double time, const std::string &edgeID)
Definition: Vehicle.cpp:308
#define VAR_NOXEMISSION
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Vehicle.cpp:1534
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:763
static std::vector< std::string > getPersonIDList(const std::string &vehicleID)
Definition: Vehicle.cpp:268
static double getWaitingTime(const std::string &vehicleID)
Definition: Vehicle.cpp:287
bool replaceRouteEdges(ConstMSEdgeVector &edges, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
static double getLastActionTime(const std::string &vehicleID)
Definition: Vehicle.cpp:654
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
double getMaxAccel() const
Get the vehicle type&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:210
static SubscriptionResults mySubscriptionResults
Definition: Vehicle.h:197
static double getCO2Emission(const std::string &vehicleID)
Definition: Vehicle.cpp:215
void setMinGapLat(const double &minGapLat)
Set a new value for this type&#39;s minimum lataral gap.
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
Definition: Vehicle.cpp:605
bool isInternal() const
Definition: MSLane.cpp:1852
#define VAR_ANGLE
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:313
unsigned char b
Definition: TraCIDefs.h:139
double departSpeed
(optional) The initial speed of the vehicle
A road/street connecting two junctions.
Definition: MSEdge.h:75
static void resume(const std::string &vehicleID)
Definition: Vehicle.cpp:803
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:265
MSLane * lane
The described lane.
Definition: MSVehicle.h:806
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
Definition: MSVehicle.cpp:452
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:180
#define VAR_PERSON_NUMBER
The action has not been determined.
double getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:4493
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:530
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
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.
#define REMOVE_ARRIVED
void setSublaneChange(double latDist)
Sets a new sublane-change request.
Definition: MSVehicle.cpp:277
static std::vector< TraCINextTLSData > getNextTLS(const std::string &vehicleID)
Definition: Vehicle.cpp:368
const MSCFModel & getCarFollowModel() const
Returns the vehicle type&#39;s car following model definition (const version)
static int getSpeedMode(const std::string &vehicleID)
Definition: Vehicle.cpp:536
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
void createDevice(const std::string &deviceName)
create device of the given type
static int getRouteIndex(const std::string &vehicleID)
Definition: Vehicle.cpp:191
void setAccel(double accel)
Set a new value for this type&#39;s acceleration.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
static void setLaneChangeMode(const std::string &vehicleID, int laneChangeMode)
Definition: Vehicle.cpp:1113
static void setVia(const std::string &vehicleID, const std::vector< std::string > &via)
Definition: Vehicle.cpp:1369
static bool gCheckRoutes
Definition: MSGlobals.h:79
double startPos
The stopping position start.
static double getLateralLanePosition(const std::string &vehicleID)
Definition: Vehicle.cpp:209
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
#define REMOVE_TELEPORT_ARRIVED
static double getHCEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:227
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
SUMOTime getActionStepLength() const
Returns the vehicle&#39;s action step length in millisecs, i.e. the interval between two action points...
Definition: MSVehicle.h:505
MSRouteIterator edge
The edge in the route to stop at.
Definition: MSVehicle.h:919
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:76
#define VAR_LANEPOSITION
std::string stoppingPlaceID
Id assigned to the stop.
Definition: TraCIDefs.h:295
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:4046
int getRoutingMode() const
return the current routing mode
Definition: MSVehicle.h:1384
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:4380
static bool isOnInit(const std::string &vehicleID)
Definition: Vehicle.cpp:79
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.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:309
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:878
static double getFuelConsumption(const std::string &vehicleID)
Definition: Vehicle.cpp:245
#define REMOVE_TELEPORT
bool triggered
whether an arriving person lets the vehicle continue
void addTravelTime(const MSEdge *const e, double begin, double end, double value)
Adds a travel time information for an edge and a time span.
#define VAR_LASTACTIONTIME
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:58
static double getLanePosition(const std::string &vehicleID)
Definition: Vehicle.cpp:203
static std::vector< std::string > getRoute(const std::string &vehicleID)
Definition: Vehicle.cpp:324
The vehicle arrived at its destination (is deleted)
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
unsigned char a
Definition: TraCIDefs.h:139
SUMOTime depart
The vehicle&#39;s departure time.
#define VAR_PMXEMISSION
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
Definition: MSVehicle.h:990
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:951
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:256
static void moveTo(const std::string &vehicleID, const std::string &laneID, double position)
Definition: Vehicle.cpp:1253
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:4535
T MIN2(T a, T b)
Definition: StdDefs.h:70
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
Definition: MSVehicle.cpp:1699
#define POSITION_EPS
Definition: config.h:172
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:804
static void changeLane(const std::string &vehicleID, int laneIndex, double duration)
Definition: Vehicle.cpp:848
#define VAR_EDGES
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:740
unsigned char r
Definition: TraCIDefs.h:139
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:85
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:293
static double getAccumulatedWaitingTime(const std::string &vehicleID)
Definition: Vehicle.cpp:293
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: TraCIDefs.h:52
#define VAR_STOPSTATE
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Vehicle.cpp:1546
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
#define VAR_SLOPE
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:224
const int VEHPARS_COLOR_SET
static void setSpeed(const std::string &vehicleID, double speed)
Definition: Vehicle.cpp:1097
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:185
static TraCIPosition getPosition(const std::string &vehicleID, const bool includeZ=false)
Definition: Vehicle.cpp:124
bool containerTriggered
whether an arriving container lets the vehicle continue
void move2side(double amount)
move position vector to side using certain ammount
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
Definition: MSLane.cpp:1903
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
bool allowsContinuation
Whether this lane allows to continue the drive.
Definition: MSVehicle.h:818
static int getLaneChangeMode(const std::string &vehicleID)
Definition: Vehicle.cpp:541
Definition: Edge.cpp:30
static double getAdaptedTraveltime(const std::string &vehicleID, double time, const std::string &edgeID)
Definition: Vehicle.cpp:299
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)
#define INVALID_DOUBLE_VALUE
double arrivalPos
(optional) The position the vehicle shall arrive on
#define VAR_SPEED
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type&#39;s action step length.
double getLateralPositionOnLane() const
Get the vehicle&#39;s lateral position on the lane.
Definition: MSVehicle.h:436
void setRoutingMode(int value)
Sets routing behavior.
Definition: MSVehicle.h:1453
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)
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
double getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:4499
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:573
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:248
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:413
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:172
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:5008
static int getIDCount()
Definition: Vehicle.cpp:97
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
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:1708
#define VAR_COEMISSION
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
static void changeTarget(const std::string &vehicleID, const std::string &edgeID)
Definition: Vehicle.cpp:822
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:5197
int getPersonNumber() const
Returns the number of persons.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
#define INVALID_INT_VALUE
#define VAR_LANEPOSITION_LAT
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:519
static double getPMxEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:233
#define SUMOTime_MAX
Definition: SUMOTime.h:37
static void setSignals(const std::string &vehicleID, int signals)
Definition: Vehicle.cpp:1240
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.
static bool isRouteValid(const std::string &vehicleID)
Definition: Vehicle.cpp:317
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:4633
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:362
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:775
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:986
static double getDrivingDistance2D(const std::string &vehicleID, double x, double y)
Definition: Vehicle.cpp:501
std::vector< MSLane * > bestContinuations
Definition: MSVehicle.h:824
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSVehicle.h:929
char state
The current state of the tls.
Definition: TraCIDefs.h:285
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.
#define VAR_ELECTRICITYCONSUMPTION
#define VAR_ROUTE_INDEX
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:496
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSVehicle.h:925
static std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist=0.)
Definition: Vehicle.cpp:273
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
Definition: MSVehicle.cpp:1048
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:4517
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:546
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:471
static void slowDown(const std::string &vehicleID, double speed, double duration)
Definition: Vehicle.cpp:1088
void updateActionOffset(const SUMOTime oldActionStepLength, const SUMOTime newActionStepLength)
Process an updated action step length value (only affects the vehicle&#39;s action offset, The actionStepLength is stored in the (singular) vtype)
Definition: MSVehicle.cpp:1704
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:462
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type&#39;s vehicle class.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
#define REMOVE_VAPORIZED
void setSignals(int signals)
Definition: MSVehicle.h:1480
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:1173
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:848
static void changeLaneRelative(const std::string &vehicleID, int laneChange, double duration)
Definition: Vehicle.cpp:856
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:1234
void switchOnSignal(int signal)
Switches the given signal on.
Definition: MSVehicle.h:1226
double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MSVehicle.cpp:921
#define LAST_STEP_PERSON_ID_LIST
static void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED)
Definition: Vehicle.cpp:1309
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
#define VAR_SPEED_WITHOUT_TRACI
static MSVehicle * getVehicle(const std::string &id)
Definition: Vehicle.cpp:59
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:309
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
#define VAR_LANECHANGE_MODE
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
Definition: MSVehicle.cpp:272
double getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:4505
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:67
The vehicle was teleported out of the net.
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:1386
void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
#define VAR_ROUTE_VALID
The class responsible for building and deletion of vehicles.
bool willPass(const MSEdge *const edge) const
Returns whether the vehicle wil pass the given edge.
Definition: MSVehicle.cpp:827
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:71
static double getElectricityConsumption(const std::string &vehicleID)
Definition: Vehicle.cpp:257
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.
#define ID_COUNT
#define VAR_LANE_INDEX
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:4040
static void setType(const std::string &vehicleID, const std::string &typeID)
Definition: Vehicle.cpp:1123
#define VAR_LANE_ID
#define VAR_LINE
double getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:479
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
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:485
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
Definition: Helper.cpp:660
A 3D-position.
Definition: TraCIDefs.h:107
static int getSignals(const std::string &vehicleID)
Definition: Vehicle.cpp:336
#define ID_LIST
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:872
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:281
static double getSpeed(const std::string &vehicleID)
Definition: Vehicle.cpp:103
static int getStopState(const std::string &vehicleID)
Definition: Vehicle.cpp:441
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
static bool isVisible(const SUMOVehicle *veh)
Definition: Vehicle.cpp:73
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
static std::vector< TraCINextStopData > getNextStops(const std::string &vehicleID)
Definition: Vehicle.cpp:401
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:73
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:799
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.
#define VAR_DISTANCE
double duration
The stopping duration.
Definition: TraCIDefs.h:299
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:317
#define VAR_HCEMISSION
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.
std::string id
The vehicle&#39;s id.
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
Definition: MSVehicle.cpp:5212
The vehicle is being teleported.
static void rerouteEffort(const std::string &vehicleID)
Definition: Vehicle.cpp:1233
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:915
std::string lane
The lane to stop at.
Definition: TraCIDefs.h:291
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.
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, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
Definition: Helper.cpp:449
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:111
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.