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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // C++ Vehicle API
18 /****************************************************************************/
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
29 #include <utils/geom/GeomHelper.h>
39 #include <microsim/MSVehicle.h>
41 #include <microsim/MSVehicleType.h>
43 #include <microsim/MSNet.h>
44 #include <microsim/MSEdge.h>
45 #include <microsim/MSLane.h>
46 #include <libsumo/TraCIDefs.h>
48 #include "Helper.h"
49 #include "Vehicle.h"
50 
51 
52 namespace libsumo {
53 // ===========================================================================
54 // member definitions
55 // ===========================================================================
56 MSVehicle*
57 Vehicle::getVehicle(const std::string& id) {
59  if (sumoVehicle == 0) {
60  throw TraCIException("Vehicle '" + id + "' is not known");
61  }
62  MSVehicle* v = dynamic_cast<MSVehicle*>(sumoVehicle);
63  if (v == 0) {
64  throw TraCIException("Vehicle '" + id + "' is not a micro-simulation vehicle");
65  }
66  return v;
67 }
68 
69 
70 bool
72  return veh->isOnRoad() || veh->isParking() || veh->wasRemoteControlled();
73 }
74 
75 
76 bool
77 Vehicle::isOnInit(const std::string& vehicleID) {
78  SUMOVehicle* sumoVehicle = MSNet::getInstance()->getVehicleControl().getVehicle(vehicleID);
79  return sumoVehicle == 0 || sumoVehicle->getLane() == 0;
80 }
81 
82 std::vector<std::string>
84  std::vector<std::string> ids;
86  for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
87  if ((*i).second->isOnRoad() || (*i).second->isParking()) {
88  ids.push_back((*i).first);
89  }
90  }
91  return ids;
92 }
93 
94 int
96  return (int)getIDList().size();
97 }
98 
99 double
100 Vehicle::getSpeed(const std::string& vehicleID) {
101  MSVehicle* veh = getVehicle(vehicleID);
102  return isVisible(veh) ? veh->getSpeed() : INVALID_DOUBLE_VALUE;
103 }
104 
105 
106 double
107 Vehicle::getSpeedWithoutTraCI(const std::string& vehicleID) {
108  MSVehicle* veh = getVehicle(vehicleID);
110 }
111 
112 
114 Vehicle::getPosition(const std::string& vehicleID) {
115  MSVehicle* veh = getVehicle(vehicleID);
116  if (isVisible(veh)) {
117  return Helper::makeTraCIPosition(veh->getPosition());
118  } else {
119  TraCIPosition result;
120  result.x = INVALID_DOUBLE_VALUE;
121  result.y = INVALID_DOUBLE_VALUE;
122  result.z = INVALID_DOUBLE_VALUE;
123  return result;
124  }
125 }
126 
127 
128 double
129 Vehicle::getAngle(const std::string& vehicleID) {
130  MSVehicle* veh = getVehicle(vehicleID);
132 }
133 
134 
135 double
136 Vehicle::getSlope(const std::string& vehicleID) {
137  MSVehicle* veh = getVehicle(vehicleID);
138  return veh->isOnRoad() ? veh->getSlope() : INVALID_DOUBLE_VALUE;
139 }
140 
141 
142 std::string
143 Vehicle::getRoadID(const std::string& vehicleID) {
144  MSVehicle* veh = getVehicle(vehicleID);
145  return isVisible(veh) ? veh->getLane()->getEdge().getID() : "";
146 }
147 
148 
149 std::string
150 Vehicle::getLaneID(const std::string& vehicleID) {
151  MSVehicle* veh = getVehicle(vehicleID);
152  return veh->isOnRoad() ? veh->getLane()->getID() : "";
153 }
154 
155 
156 int
157 Vehicle::getLaneIndex(const std::string& vehicleID) {
158  MSVehicle* veh = getVehicle(vehicleID);
159  return veh->isOnRoad() ? veh->getLane()->getIndex() : INVALID_INT_VALUE;
160 }
161 
162 std::string
163 Vehicle::getTypeID(const std::string& vehicleID) {
164  return getVehicle(vehicleID)->getVehicleType().getID();
165 }
166 
167 std::string
168 Vehicle::getRouteID(const std::string& vehicleID) {
169  return getVehicle(vehicleID)->getRoute().getID();
170 }
171 
172 int
173 Vehicle::getRouteIndex(const std::string& vehicleID) {
174  MSVehicle* veh = getVehicle(vehicleID);
175  return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
176 }
177 
179 Vehicle::getColor(const std::string& vehicleID) {
180  return Helper::makeTraCIColor(getVehicle(vehicleID)->getParameter().color);
181 }
182 
183 double
184 Vehicle::getLanePosition(const std::string& vehicleID) {
185  MSVehicle* veh = getVehicle(vehicleID);
186  return veh->isOnRoad() ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
187 }
188 
189 double
190 Vehicle::getLateralLanePosition(const std::string& vehicleID) {
191  MSVehicle* veh = getVehicle(vehicleID);
192  return veh->isOnRoad() ? veh->getLateralPositionOnLane() : INVALID_DOUBLE_VALUE;
193 }
194 
195 double
196 Vehicle::getCO2Emission(const std::string& vehicleID) {
197  MSVehicle* veh = getVehicle(vehicleID);
198  return isVisible(veh) ? veh->getCO2Emissions() : INVALID_DOUBLE_VALUE;
199 }
200 
201 double
202 Vehicle::getCOEmission(const std::string& vehicleID) {
203  MSVehicle* veh = getVehicle(vehicleID);
204  return isVisible(veh) ? veh->getCOEmissions() : INVALID_DOUBLE_VALUE;
205 }
206 
207 double
208 Vehicle::getHCEmission(const std::string& vehicleID) {
209  MSVehicle* veh = getVehicle(vehicleID);
210  return isVisible(veh) ? veh->getHCEmissions() : INVALID_DOUBLE_VALUE;
211 }
212 
213 double
214 Vehicle::getPMxEmission(const std::string& vehicleID) {
215  MSVehicle* veh = getVehicle(vehicleID);
216  return isVisible(veh) ? veh->getPMxEmissions() : INVALID_DOUBLE_VALUE;
217 }
218 
219 double
220 Vehicle::getNOxEmission(const std::string& vehicleID) {
221  MSVehicle* veh = getVehicle(vehicleID);
222  return isVisible(veh) ? veh->getNOxEmissions() : INVALID_DOUBLE_VALUE;
223 }
224 
225 double
226 Vehicle::getFuelConsumption(const std::string& vehicleID) {
227  MSVehicle* veh = getVehicle(vehicleID);
228  return isVisible(veh) ? veh->getFuelConsumption() : INVALID_DOUBLE_VALUE;
229 }
230 
231 double
232 Vehicle::getNoiseEmission(const std::string& vehicleID) {
233  MSVehicle* veh = getVehicle(vehicleID);
235 }
236 
237 double
238 Vehicle::getElectricityConsumption(const std::string& vehicleID) {
239  MSVehicle* veh = getVehicle(vehicleID);
241 }
242 
243 int
244 Vehicle::getPersonNumber(const std::string& vehicleID) {
245  return getVehicle(vehicleID)->getPersonNumber();
246 }
247 
248 
249 std::pair<std::string, double>
250 Vehicle::getLeader(const std::string& vehicleID, double dist) {
251  MSVehicle* veh = getVehicle(vehicleID);
252  if (veh->isOnRoad()) {
253  std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist);
254  return std::make_pair(
255  leaderInfo.first != 0 ? leaderInfo.first->getID() : "",
256  leaderInfo.second);
257  } else {
258  return std::make_pair("", -1);
259  }
260 }
261 
262 
263 double
264 Vehicle::getWaitingTime(const std::string& vehicleID) {
265  return getVehicle(vehicleID)->getWaitingSeconds();
266 }
267 
268 
269 double
270 Vehicle::getAccumulatedWaitingTime(const std::string& vehicleID) {
271  return getVehicle(vehicleID)->getAccumulatedWaitingSeconds();
272 }
273 
274 
275 double
276 Vehicle::getAdaptedTraveltime(const std::string& vehicleID, const std::string& edgeID, int time) {
277  MSVehicle* veh = getVehicle(vehicleID);
278  MSEdge* edge = Helper::getEdge(edgeID);
279  double value = INVALID_DOUBLE_VALUE;;
280  veh->getWeightsStorage().retrieveExistingTravelTime(edge, time, value);
281  return value;
282 }
283 
284 
285 double
286 Vehicle::getEffort(const std::string& vehicleID, const std::string& edgeID, int time) {
287  MSVehicle* veh = getVehicle(vehicleID);
288  MSEdge* edge = Helper::getEdge(edgeID);
289  double value = INVALID_DOUBLE_VALUE;;
290  veh->getWeightsStorage().retrieveExistingEffort(edge, time, value);
291  return value;
292 }
293 
294 
295 bool
296 Vehicle::isRouteValid(const std::string& vehicleID) {
297  std::string msg;
298  return getVehicle(vehicleID)->hasValidRoute(msg);
299 }
300 
301 std::vector<std::string>
302 Vehicle::getEdges(const std::string& vehicleID) {
303  std::vector<std::string> result;
304  MSVehicle* veh = getVehicle(vehicleID);
305  const MSRoute& r = veh->getRoute();
306  for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
307  result.push_back((*i)->getID());
308  }
309  return result;
310 }
311 
312 
313 int
314 Vehicle::getSignalStates(const std::string& vehicleID) {
315  return getVehicle(vehicleID)->getSignals();
316 }
317 
318 std::vector<TraCIBestLanesData>
319 Vehicle::getBestLanes(const std::string& vehicleID) {
320  std::vector<TraCIBestLanesData> result;
321  MSVehicle* veh = getVehicle(vehicleID);
322  if (veh->isOnRoad()) {
323  const std::vector<MSVehicle::LaneQ>& bestLanes = veh->getBestLanes();
324  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
325  TraCIBestLanesData bld;
326  const MSVehicle::LaneQ& lq = *i;
327  bld.laneID = lq.lane->getID();
328  bld.length = lq.length;
329  bld.occupation = lq.nextOccupation;
332  for (std::vector<MSLane*>::const_iterator j = lq.bestContinuations.begin(); j != lq.bestContinuations.end(); ++j) {
333  if ((*j) != 0) {
334  bld.continuationLanes.push_back((*j)->getID());
335  }
336  }
337  result.push_back(bld);
338  }
339  }
340  return result;
341 }
342 
343 
344 std::vector<TraCINextTLSData>
345 Vehicle::getNextTLS(const std::string& vehicleID) {
346  std::vector<TraCINextTLSData> result;
347  MSVehicle* veh = getVehicle(vehicleID);
348  if (veh->isOnRoad()) {
349  const MSLane* lane = veh->getLane();
350  const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
351  double seen = veh->getLane()->getLength() - veh->getPositionOnLane();
352  int view = 1;
353  MSLinkCont::const_iterator link = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
354  while (!lane->isLinkEnd(link)) {
355  if (!lane->getEdge().isInternal()) {
356  if ((*link)->isTLSControlled()) {
357  TraCINextTLSData ntd;
358  ntd.id = (*link)->getTLLogic()->getID();
359  ntd.tlIndex = (*link)->getTLIndex();
360  ntd.dist = seen;
361  ntd.state = (char)(*link)->getState();
362  result.push_back(ntd);
363  }
364  }
365  lane = (*link)->getViaLaneOrLane();
366  if (!lane->getEdge().isInternal()) {
367  view++;
368  }
369  seen += lane->getLength();
370  link = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
371  }
372  }
373  return result;
374 }
375 
376 int
377 Vehicle::getStopState(const std::string& vehicleID) {
378  MSVehicle* veh = getVehicle(vehicleID);
379  int result = 0;
380  if (veh->isStopped()) {
381  const MSVehicle::Stop& stop = veh->getNextStop();
382  result = (1 + (stop.pars.parking ? 2 : 0) +
383  (stop.pars.triggered ? 4 : 0) +
384  (stop.pars.containerTriggered ? 8 : 0) +
385  (stop.busstop != 0 ? 16 : 0) +
386  (stop.containerstop != 0 ? 32 : 0) +
387  (stop.chargingStation != 0 ? 64 : 0) +
388  (stop.parkingarea != 0 ? 128 : 0));
389  }
390  return result;
391 }
392 
393 double
394 Vehicle::getDistance(const std::string& vehicleID) {
395  MSVehicle* veh = getVehicle(vehicleID);
396  if (veh->isOnRoad()) {
397  double distance;
398  if (veh->getLane()->isInternal()) {
399  // route edge still points to the edge before the intersection
400  const double normalEnd = (*veh->getCurrentRouteEdge())->getLength();
401  distance = (veh->getRoute().getDistanceBetween(veh->getDepartPos(), normalEnd,
402  veh->getRoute().begin(), veh->getCurrentRouteEdge())
403  + veh->getRoute().getDistanceBetween(normalEnd, veh->getPositionOnLane(),
404  *veh->getCurrentRouteEdge(), &veh->getLane()->getEdge()));
405  } else {
406  distance = veh->getRoute().getDistanceBetween(veh->getDepartPos(), veh->getPositionOnLane(),
407  veh->getRoute().begin(), veh->getCurrentRouteEdge());
408  }
409  if (distance == std::numeric_limits<double>::max()) {
410  return INVALID_DOUBLE_VALUE;
411  } else {
412  return distance;
413  }
414  } else {
415  return INVALID_DOUBLE_VALUE;
416  }
417 }
418 
419 
420 double
421 Vehicle::getDrivingDistance(const std::string& vehicleID, const std::string& edgeID, double position, int /* laneIndex */) {
422  MSVehicle* veh = getVehicle(vehicleID);
423  if (veh->isOnRoad()) {
424  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), position,
425  &veh->getLane()->getEdge(), Helper::getEdge(edgeID));
426  if (distance == std::numeric_limits<double>::max()) {
427  return INVALID_DOUBLE_VALUE;
428  }
429  return distance;
430  } else {
431  return INVALID_DOUBLE_VALUE;
432  }
433 }
434 
435 
436 double
437 Vehicle::getDrivingDistance2D(const std::string& vehicleID, double x, double y) {
438  MSVehicle* veh = getVehicle(vehicleID);
439  if (veh->isOnRoad()) {
440  std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y));
441  double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
442  veh->getEdge(), &roadPos.first->getEdge());
443  if (distance == std::numeric_limits<double>::max()) {
444  return INVALID_DOUBLE_VALUE;
445  }
446  return distance;
447  } else {
448  return INVALID_DOUBLE_VALUE;
449  }
450 }
451 
452 
453 
454 double
455 Vehicle::getAllowedSpeed(const std::string& vehicleID) {
456  MSVehicle* veh = getVehicle(vehicleID);
457  if (veh->isOnRoad()) {
458  return veh->getLane()->getVehicleMaxSpeed(veh);
459  } else {
460  return INVALID_DOUBLE_VALUE;
461  }
462 }
463 
464 double
465 Vehicle::getSpeedFactor(const std::string& vehicleID) {
466  return getVehicle(vehicleID)->getChosenSpeedFactor();
467 }
468 
469 
470 int
471 Vehicle::getSpeedMode(const std::string& vehicleID) {
472  return getVehicle(vehicleID)->getInfluencer().getSpeedMode();
473 }
474 
475 int
476 Vehicle::getLanechangeMode(const std::string& vehicleID) {
477  return getVehicle(vehicleID)->getInfluencer().getLanechangeMode();
478 }
479 
480 int
481 Vehicle::getRoutingMode(const std::string& vehicleID) {
482  return getVehicle(vehicleID)->getInfluencer().getRoutingMode();
483 }
484 
485 std::string
486 Vehicle::getLine(const std::string& vehicleID) {
487  return getVehicle(vehicleID)->getParameter().line;
488 }
489 
490 std::vector<std::string>
491 Vehicle::getVia(const std::string& vehicleID) {
492  return getVehicle(vehicleID)->getParameter().via;
493 }
494 
495 
496 std::pair<int, int>
497 Vehicle::getLaneChangeState(const std::string& vehicleID, int direction) {
498  MSVehicle* veh = getVehicle(vehicleID);
499  if (veh->isOnRoad()) {
500  return veh->getLaneChangeModel().getSavedState(direction);
501  } else {
502  return std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
503  }
504 }
505 
506 
507 std::string
508 Vehicle::getParameter(const std::string& vehicleID, const std::string& key) {
509  MSVehicle* veh = getVehicle(vehicleID);
510  if (StringUtils::startsWith(key, "device.")) {
511  StringTokenizer tok(key, ".");
512  if (tok.size() < 3) {
513  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehicleID + "'");
514  }
515  try {
516  return veh->getDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2));
517  } catch (InvalidArgument& e) {
518  throw TraCIException("Vehicle '" + vehicleID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
519  }
520  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
521  const std::string attrName = key.substr(16);
522  try {
523  return veh->getLaneChangeModel().getParameter(attrName);
524  } catch (InvalidArgument& e) {
525  throw TraCIException("Vehicle '" + vehicleID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
526  }
527  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
528  StringTokenizer tok(key, ".");
529  if (tok.size() != 3) {
530  throw TraCIException("Invalid check for device. Expected format is 'has.DEVICENAME.device'");
531  }
532  return veh->hasDevice(tok.get(1)) ? "true" : "false";
533  } else {
534  return veh->getParameter().getParameter(key, "");
535  }
536 }
537 
538 
539 const MSVehicleType&
540 Vehicle::getVehicleType(const std::string& vehicleID) {
541  return getVehicle(vehicleID)->getVehicleType();
542 }
543 
544 
545 std::string
546 Vehicle::getEmissionClass(const std::string& vehicleID) {
548 }
549 
550 std::string
551 Vehicle::getShapeClass(const std::string& vehicleID) {
552  return getVehicleShapeName(getVehicleType(vehicleID).getGuiShape());
553 }
554 
555 
556 double
557 Vehicle::getLength(const std::string& vehicleID) {
558  return getVehicleType(vehicleID).getLength();
559 }
560 
561 
562 double
563 Vehicle::getAccel(const std::string& vehicleID) {
564  return getVehicleType(vehicleID).getLength();
565 }
566 
567 
568 double
569 Vehicle::getDecel(const std::string& vehicleID) {
570  return getVehicleType(vehicleID).getCarFollowModel().getMaxDecel();
571 }
572 
573 
574 double Vehicle::getEmergencyDecel(const std::string& vehicleID) {
575  return getVehicleType(vehicleID).getCarFollowModel().getEmergencyDecel();
576 }
577 double Vehicle::getApparentDecel(const std::string& vehicleID) {
578  return getVehicleType(vehicleID).getCarFollowModel().getApparentDecel();
579 }
580 double Vehicle::getActionStepLength(const std::string& vehicleID) {
581  return getVehicleType(vehicleID).getActionStepLengthSecs();
582 }
583 double Vehicle::getLastActionTime(const std::string& vehicleID) {
584  return STEPS2TIME(getVehicle(vehicleID)->getLastActionTime());
585 }
586 
587 double
588 Vehicle::getTau(const std::string& vehicleID) {
589  return getVehicleType(vehicleID).getCarFollowModel().getHeadwayTime();
590 }
591 
592 
593 double
594 Vehicle::getImperfection(const std::string& vehicleID) {
595  return getVehicleType(vehicleID).getCarFollowModel().getImperfection();
596 }
597 
598 
599 double
600 Vehicle::getSpeedDeviation(const std::string& vehicleID) {
601  return getVehicleType(vehicleID).getSpeedFactor().getParameter()[1];
602 }
603 
604 
605 std::string
606 Vehicle::getVClass(const std::string& vehicleID) {
607  return toString(getVehicleType(vehicleID).getVehicleClass());
608 }
609 
610 
611 double
612 Vehicle::getMinGap(const std::string& vehicleID) {
613  return getVehicleType(vehicleID).getMinGap();
614 }
615 
616 
617 double
618 Vehicle::getMaxSpeed(const std::string& vehicleID) {
619  return getVehicleType(vehicleID).getMaxSpeed();
620 }
621 
622 
623 double
624 Vehicle::getWidth(const std::string& vehicleID) {
625  return getVehicleType(vehicleID).getWidth();
626 }
627 
628 
629 void
630 Vehicle::setStop(const std::string& vehicleID,
631  const std::string& edgeID,
632  double endPos,
633  int laneIndex,
634  SUMOTime duration,
635  int flags,
636  double startPos,
637  SUMOTime until) {
638  MSVehicle* veh = getVehicle(vehicleID);
639  // optional stop flags
640  bool parking = false;
641  bool triggered = false;
642  bool containerTriggered = false;
643  SumoXMLTag stoppingPlaceType = SUMO_TAG_NOTHING;
644 
645  parking = ((flags & 1) != 0);
646  triggered = ((flags & 2) != 0);
647  containerTriggered = ((flags & 4) != 0);
648  if ((flags & 8) != 0) {
649  stoppingPlaceType = SUMO_TAG_BUS_STOP;
650  }
651  if ((flags & 16) != 0) {
652  stoppingPlaceType = SUMO_TAG_CONTAINER_STOP;
653  }
654  if ((flags & 32) != 0) {
655  stoppingPlaceType = SUMO_TAG_CHARGING_STATION;
656  }
657  if ((flags & 64) != 0) {
658  stoppingPlaceType = SUMO_TAG_PARKING_AREA;
659  }
660 
661  std::string error;
662  if (stoppingPlaceType != SUMO_TAG_NOTHING) {
663  // Forward command to vehicle
664  if (!veh->addTraciStopAtStoppingPlace(edgeID, duration, until, parking, triggered, containerTriggered, stoppingPlaceType, error)) {
665  throw TraCIException(error);
666  }
667  } else {
668  // check
669  if (startPos < 0) {
670  throw TraCIException("Position on lane must not be negative.");
671  }
672  if (endPos < startPos) {
673  throw TraCIException("End position on lane must be after start position.");
674  }
675  // get the actual lane that is referenced by laneIndex
676  MSEdge* road = MSEdge::dictionary(edgeID);
677  if (road == 0) {
678  throw TraCIException("Unable to retrieve road with given id.");
679  }
680  const std::vector<MSLane*>& allLanes = road->getLanes();
681  if ((laneIndex < 0) || laneIndex >= (int)(allLanes.size())) {
682  throw TraCIException("No lane with index '" + toString(laneIndex) + "' on road '" + edgeID + "'.");
683  }
684  // Forward command to vehicle
685  if (!veh->addTraciStop(allLanes[laneIndex], startPos, endPos, duration, until, parking, triggered, containerTriggered, error)) {
686  throw TraCIException(error);
687  }
688  }
689 }
690 
691 
692 void
693 Vehicle::resume(const std::string& vehicleID) {
694  MSVehicle* veh = getVehicle(vehicleID);
695  if (!veh->hasStops()) {
696  throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
697  }
698  if (!veh->resumeFromStopping()) {
699  MSVehicle::Stop& sto = veh->getNextStop();
700  std::ostringstream strs;
701  strs << "reached: " << sto.reached;
702  strs << ", duration:" << sto.duration;
703  strs << ", edge:" << (*sto.edge)->getID();
704  strs << ", startPos: " << sto.pars.startPos;
705  std::string posStr = strs.str();
706  throw TraCIException("Failed to resume from stoppingfor vehicle '" + veh->getID() + "', " + posStr);
707  }
708 }
709 
710 
711 void
712 Vehicle::changeTarget(const std::string& vehicleID, const std::string& edgeID) {
713  MSVehicle* veh = getVehicle(vehicleID);
714  const MSEdge* destEdge = MSEdge::dictionary(edgeID);
715  const bool onInit = isOnInit(vehicleID);
716  if (destEdge == 0) {
717  throw TraCIException("Can not retrieve road with ID " + edgeID);
718  }
719  // build a new route between the vehicle's current edge and destination edge
720  ConstMSEdgeVector newRoute;
721  const MSEdge* currentEdge = veh->getRerouteOrigin();
723  currentEdge, destEdge, (const MSVehicle * const)veh, MSNet::getInstance()->getCurrentTimeStep(), newRoute);
724  // replace the vehicle's route by the new one
725  if (!veh->replaceRouteEdges(newRoute, onInit)) {
726  throw TraCIException("Route replacement failed for " + veh->getID());
727  }
728  // route again to ensure usage of via/stops
729  try {
730  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), MSNet::getInstance()->getRouterTT(), onInit);
731  } catch (ProcessError& e) {
732  throw TraCIException(e.what());
733  }
734 }
735 
736 
737 void
738 Vehicle::changeLane(const std::string& vehicleID, int laneIndex, SUMOTime duration) {
739  std::vector<std::pair<SUMOTime, int> > laneTimeLine;
740  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
741  laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + duration, laneIndex));
742  getVehicle(vehicleID)->getInfluencer().setLaneTimeLine(laneTimeLine);
743 }
744 
745 
746 void
747 Vehicle::changeSublane(const std::string& vehicleID, double latDist) {
748  getVehicle(vehicleID)->getInfluencer().setSublaneChange(latDist);
749 }
750 
751 
752 void
753 Vehicle::add(const std::string& vehicleID,
754  const std::string& routeID,
755  const std::string& typeID,
756  int depart,
757  int departLane,
758  double departPos,
759  double departSpeed,
760  int /* arrivalLane */,
761  double /*arrivalPos */,
762  double /* arrivalSpeed */,
763  const std::string& /* fromTaz */,
764  const std::string& /* toTaz */,
765  const std::string& /* line */,
766  int /* personCapacity */,
767  int /* personNumber */) {
769  if (veh != 0) {
770  throw TraCIException("The vehicle " + vehicleID + " to add already exists.");
771  }
772 
773  SUMOVehicleParameter vehicleParams;
774  vehicleParams.id = vehicleID;
775  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
776  if (!vehicleType) {
777  throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehicleID + "'");
778  }
779  const MSRoute* route = MSRoute::dictionary(routeID);
780  if (!route) {
781  throw TraCIException("Invalid route '" + routeID + "' for vehicle: '" + vehicleID + "'");
782  }
783 
784  if (depart < 0) {
785  const int proc = -depart;
786  if (proc >= static_cast<int>(DEPART_DEF_MAX)) {
787  throw TraCIException("Invalid departure time.");
788  }
789  vehicleParams.departProcedure = (DepartDefinition)proc;
790  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
791  } else if (depart < MSNet::getInstance()->getCurrentTimeStep()) {
792  vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
793  WRITE_WARNING("Departure time for vehicle '" + vehicleID + "' is in the past; using current time instead.");
794  } else {
795  vehicleParams.depart = depart;
796  }
797 
798  vehicleParams.departPos = departPos;
799  if (vehicleParams.departPos < 0) {
800  const int proc = static_cast<int>(-vehicleParams.departPos);
801  if (fabs(proc + vehicleParams.departPos) > NUMERICAL_EPS || proc >= static_cast<int>(DEPART_POS_DEF_MAX) || proc == static_cast<int>(DEPART_POS_GIVEN)) {
802  throw TraCIException("Invalid departure position.");
803  }
804  vehicleParams.departPosProcedure = (DepartPosDefinition)proc;
805  } else {
806  vehicleParams.departPosProcedure = DEPART_POS_GIVEN;
807  }
808 
809  vehicleParams.departSpeed = departSpeed;
810  if (vehicleParams.departSpeed < 0) {
811  const int proc = static_cast<int>(-vehicleParams.departSpeed);
812  if (proc >= static_cast<int>(DEPART_SPEED_DEF_MAX)) {
813  throw TraCIException("Invalid departure speed.");
814  }
815  vehicleParams.departSpeedProcedure = (DepartSpeedDefinition)proc;
816  } else {
818  }
819 
820  vehicleParams.departLane = departLane;
821  if (vehicleParams.departLane < 0) {
822  const int proc = static_cast<int>(-vehicleParams.departLane);
823  if (proc >= static_cast<int>(DEPART_LANE_DEF_MAX)) {
824  throw TraCIException("Invalid departure lane.");
825  }
826  vehicleParams.departLaneProcedure = (DepartLaneDefinition)proc;
827  } else {
828  vehicleParams.departLaneProcedure = DEPART_LANE_GIVEN;
829  }
830 
831  SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
832  try {
833  SUMOVehicle* vehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(params, route, vehicleType, true, false);
834  MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
836  } catch (ProcessError& e) {
837  throw TraCIException(e.what());
838  }
839 }
840 
841 
842 void
843 Vehicle::moveToXY(const std::string& vehicleID, const std::string& edgeID, const int laneIndex, const double x, const double y, double angle, const int keepRouteFlag) {
844  MSVehicle* veh = getVehicle(vehicleID);
845  bool keepRoute = (keepRouteFlag == 1) && veh->getID() != "VTD_EGO";
846  bool mayLeaveNetwork = (keepRouteFlag == 2);
847  // process
848  const std::string origID = edgeID + "_" + toString(laneIndex);
849  // @todo add an interpretation layer for OSM derived origID values (without lane index)
850  Position pos(x, y);
851 #ifdef DEBUG_MOVEXY
852  const double origAngle = angle;
853 #endif
854  // angle must be in [0,360] because it will be compared against those returned by naviDegree()
855  // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
856  if (angle != INVALID_DOUBLE_VALUE) {
857  while (angle >= 360.) {
858  angle -= 360.;
859  }
860  while (angle < 0.) {
861  angle += 360.;
862  }
863  }
864 
865  Position vehPos = veh->getPosition();
866 #ifdef DEBUG_MOVEXY
867  std::cout << std::endl << "begin vehicle " << veh->getID() << " vehPos:" << vehPos << " lane:" << Named::getIDSecure(veh->getLane()) << std::endl;
868  std::cout << " want pos:" << pos << " origID:" << origID << " laneIndex:" << laneIndex << " origAngle:" << origAngle << " angle:" << angle << " keepRoute:" << keepRoute << std::endl;
869 #endif
870 
871  ConstMSEdgeVector edges;
872  MSLane* lane = 0;
873  double lanePos;
874  double lanePosLat = 0;
875  double bestDistance = std::numeric_limits<double>::max();
876  int routeOffset = 0;
877  bool found;
878  double maxRouteDistance = 100;
879  /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
880  if (keepRoute) {
881  // case a): vehicle is on its earlier route
882  // we additionally assume it is moving forward (SUMO-limit);
883  // note that the route ("edges") is not changed in this case
884 
885  found = Helper::moveToXYMap_matchingRoutePosition(pos, origID,
886  veh->getRoute().getEdges(), (int)(veh->getCurrentRouteEdge() - veh->getRoute().begin()),
887  bestDistance, &lane, lanePos, routeOffset);
888  // @note silenty ignoring mapping failure
889  } else {
890  double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
891  found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
892  speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
893  bestDistance, &lane, lanePos, routeOffset, edges);
894  }
895  if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
896  // optionally compute lateral offset
897  if (found && (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork)) {
898  const double perpDist = lane->getShape().distance2D(pos, false);
899  if (perpDist != GeomHelper::INVALID_OFFSET) {
900  lanePosLat = perpDist;
901  if (!mayLeaveNetwork) {
902  lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
903  }
904  // figure out whether the offset is to the left or to the right
905  PositionVector tmp = lane->getShape();
906  try {
907  tmp.move2side(-lanePosLat); // moved to left
908  } catch (ProcessError&) {
909  WRITE_WARNING("Could not determine position on lane '" + lane->getID() + " at lateral position " + toString(-lanePosLat) + ".");
910  }
911  //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
912  if (tmp.distance2D(pos) > perpDist) {
913  lanePosLat = -lanePosLat;
914  }
915  }
916  }
917  if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
918  // mapped position may differ from pos
919  pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
920  }
921  assert((found && lane != 0) || (!found && lane == 0));
922  if (angle == INVALID_DOUBLE_VALUE) {
923  if (lane != 0) {
924  angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
925  } else {
926  // compute angle outside road network from old and new position
927  angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
928  }
929  }
930  // use the best we have
931  Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
932  if (!veh->isOnRoad()) {
934 
935  }
936  } else {
937  if (lane == 0) {
938  throw TraCIException("Could not map vehicle '" + vehicleID + "' no road found within " + toString(maxRouteDistance) + "m.");
939  } else {
940  throw TraCIException("Could not map vehicle '" + vehicleID + "' distance to road is " + toString(bestDistance) + ".");
941  }
942  }
943 }
944 
945 void
946 Vehicle::slowDown(const std::string& vehicleID, double speed, SUMOTime duration) {
947  MSVehicle* veh = getVehicle(vehicleID);
948  std::vector<std::pair<SUMOTime, double> > speedTimeLine;
949  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
950  speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + duration, speed));
951  veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
952 }
953 
954 void
955 Vehicle::setSpeed(const std::string& vehicleID, double speed) {
956  getVehicle(vehicleID);
957  UNUSED_PARAMETER(speed);
958 }
959 
960 void
961 Vehicle::setType(const std::string& vehicleID, const std::string& typeID) {
962  MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
963  if (vehicleType == 0) {
964  throw TraCIException("Vehicle type '" + vehicleID + "' is not known");
965  }
966  getVehicle(vehicleID)->replaceVehicleType(vehicleType);
967 }
968 
969 void
970 Vehicle::setRouteID(const std::string& vehicleID, const std::string& routeID) {
971  MSVehicle* veh = getVehicle(vehicleID);
972  const MSRoute* r = MSRoute::dictionary(routeID);
973  if (r == 0) {
974  throw TraCIException("The route '" + routeID + "' is not known.");
975  }
976  std::string msg;
977  if (!veh->hasValidRoute(msg, r)) {
978  WRITE_WARNING("Invalid route replacement for vehicle '" + veh->getID() + "'. " + msg);
980  throw TraCIException("Route replacement failed for " + veh->getID());
981  }
982  }
983 
984  if (!veh->replaceRoute(r, veh->getLane() == 0)) {
985  throw TraCIException("Route replacement failed for " + veh->getID());
986  }
987 }
988 
989 
990 void
991 Vehicle::setRoute(const std::string& vehicleID, const std::vector<std::string>& edgeIDs) {
992  MSVehicle* veh = getVehicle(vehicleID);
993  ConstMSEdgeVector edges;
994  try {
995  MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
996  } catch (ProcessError& e) {
997  throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
998  }
999  if (!veh->replaceRouteEdges(edges, veh->getLane() == 0, true)) {
1000  throw TraCIException("Route replacement failed for " + veh->getID());
1001  }
1002 }
1003 
1004 void
1005 Vehicle::setAdaptedTraveltime(const std::string& vehicleID, const std::string& edgeID,
1006  double time, double begSeconds, double endSeconds) {
1007  MSVehicle* veh = getVehicle(vehicleID);
1008  MSEdge* edge = MSEdge::dictionary(edgeID);
1009  if (edge == 0) {
1010  throw TraCIException("Referended edge '" + edgeID + "' is not known.");
1011  }
1012  if (time != INVALID_DOUBLE_VALUE) {
1013  // add time
1014  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1015  // clean up old values before setting whole range
1016  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
1017  veh->getWeightsStorage().removeTravelTime(edge);
1018  }
1019  }
1020  veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
1021  } else {
1022  // remove time
1023  while (veh->getWeightsStorage().knowsTravelTime(edge)) {
1024  veh->getWeightsStorage().removeTravelTime(edge);
1025  }
1026  }
1027 }
1028 
1029 
1030 void
1031 Vehicle::setEffort(const std::string& vehicleID, const std::string& edgeID,
1032  double effort, double begSeconds, double endSeconds) {
1033  MSVehicle* veh = getVehicle(vehicleID);
1034  MSEdge* edge = MSEdge::dictionary(edgeID);
1035  if (edge == 0) {
1036  throw TraCIException("Referended edge '" + edgeID + "' is not known.");
1037  }
1038  if (effort != INVALID_DOUBLE_VALUE) {
1039  // add effort
1040  if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1041  // clean up old values before setting whole range
1042  while (veh->getWeightsStorage().knowsEffort(edge)) {
1043  veh->getWeightsStorage().removeEffort(edge);
1044  }
1045  }
1046  veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
1047  } else {
1048  // remove effort
1049  while (veh->getWeightsStorage().knowsEffort(edge)) {
1050  veh->getWeightsStorage().removeEffort(edge);
1051  }
1052  }
1053 }
1054 
1055 
1056 void
1057 Vehicle::rerouteTraveltime(const std::string& vehicleID) {
1058  MSVehicle* veh = getVehicle(vehicleID);
1059  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), MSNet::getInstance()->getRouterTT(), isOnInit(vehicleID));
1060 }
1061 
1062 
1063 void
1064 Vehicle::rerouteEffort(const std::string& vehicleID) {
1065  MSVehicle* veh = getVehicle(vehicleID);
1066  veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), MSNet::getInstance()->getRouterEffort(), isOnInit(vehicleID));
1067 }
1068 
1069 
1070 void
1071 Vehicle::setSignals(const std::string& vehicleID, int signals) {
1072  MSVehicle* veh = getVehicle(vehicleID);
1073  // set influencer to make the change persistent
1074  veh->getInfluencer().setSignals(signals);
1075  // set them now so that getSignals returns the correct value
1076  veh->switchOffSignal(0x0fffffff);
1077  if (signals >= 0) {
1078  veh->switchOnSignal(signals);
1079  }
1080 }
1081 
1082 
1083 void
1084 Vehicle::moveTo(const std::string& vehicleID, const std::string& laneID, double position) {
1085  MSVehicle* veh = getVehicle(vehicleID);
1086  MSLane* l = MSLane::dictionary(laneID);
1087  if (l == 0) {
1088  throw TraCIException("Unknown lane '" + laneID + "'.");
1089  }
1090  MSEdge& destinationEdge = l->getEdge();
1091  if (!veh->willPass(&destinationEdge)) {
1092  throw TraCIException("Vehicle '" + laneID + "' may be set onto an edge to pass only.");
1093  }
1095  if (veh->getLane() != 0) {
1097  } else {
1098  veh->setTentativeLaneAndPosition(l, position);
1099  }
1100  while (veh->getEdge() != &destinationEdge) {
1101  const MSEdge* nextEdge = veh->succEdge(1);
1102  // let the vehicle move to the next edge
1103  if (veh->enterLaneAtMove(nextEdge->getLanes()[0], true)) {
1105  continue;
1106  }
1107  }
1108  if (!veh->isOnRoad()) {
1110 
1111  }
1112  l->forceVehicleInsertion(veh, position,
1114 }
1115 
1116 
1117 void
1118 Vehicle::setMaxSpeed(const std::string& vehicleID, double speed) {
1119  getVehicle(vehicleID)->getSingularType().setMaxSpeed(speed);
1120 }
1121 
1122 void
1123 Vehicle::setActionStepLength(const std::string& vehicleID, double actionStepLength, bool resetActionOffset) {
1124  if (actionStepLength < 0.0) {
1125  WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
1126  return;
1127  }
1128  MSVehicle* veh = getVehicle(vehicleID);
1129  if (actionStepLength == 0.) {
1130  veh->resetActionOffset();
1131  return;
1132  }
1133  SUMOTime actionStepLengthMillisecs = SUMOVehicleParserHelper::processActionStepLength(actionStepLength);
1134  SUMOTime previousActionStepLength = veh->getActionStepLength();
1135  veh->getSingularType().setActionStepLength(actionStepLengthMillisecs, resetActionOffset);
1136  if (resetActionOffset) {
1137  veh->resetActionOffset();
1138  } else {
1139  veh->updateActionOffset(previousActionStepLength, actionStepLengthMillisecs);
1140  }
1141 }
1142 
1143 void
1144 Vehicle::remove(const std::string& vehicleID, char reason) {
1145  getVehicle(vehicleID);
1146  UNUSED_PARAMETER(reason);
1147 }
1148 
1149 
1150 void
1151 Vehicle::setColor(const std::string& vehicleID, const TraCIColor& col) {
1152  const SUMOVehicleParameter& p = getVehicle(vehicleID)->getParameter();
1153  p.color.set(col.r, col.g, col.b, col.a);
1155 }
1156 
1157 
1158 void
1159 Vehicle::setLine(const std::string& vehicleID, const std::string& line) {
1160  getVehicle(vehicleID)->getParameter().line = line;
1161 }
1162 
1163 void
1164 Vehicle::setVia(const std::string& vehicleID, const std::vector<std::string>& via) {
1165  getVehicle(vehicleID);
1166  UNUSED_PARAMETER(via);
1167 }
1168 
1169 void
1170 Vehicle::setShapeClass(const std::string& vehicleID, const std::string& clazz) {
1171  getVehicle(vehicleID)->getSingularType().setShape(getVehicleShapeID(clazz));
1172 }
1173 
1174 void
1175 Vehicle::setEmissionClass(const std::string& vehicleID, const std::string& clazz) {
1176  getVehicle(vehicleID);
1177  UNUSED_PARAMETER(clazz);
1178 }
1179 
1180 
1181 void
1182 Vehicle::setParameter(const std::string& vehicleID, const std::string& key, const std::string& value) {
1183  MSVehicle* veh = getVehicle(vehicleID);
1184  if (StringUtils::startsWith(key, "device.")) {
1185  StringTokenizer tok(key, ".");
1186  if (tok.size() < 3) {
1187  throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehicleID + "'");
1188  }
1189  try {
1190  veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
1191  } catch (InvalidArgument& e) {
1192  throw TraCIException("Vehicle '" + vehicleID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
1193  }
1194  } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
1195  const std::string attrName = key.substr(16);
1196  try {
1197  veh->getLaneChangeModel().setParameter(attrName, value);
1198  } catch (InvalidArgument& e) {
1199  throw TraCIException("Vehicle '" + vehicleID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
1200  }
1201  } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
1202  StringTokenizer tok(key, ".");
1203  if (tok.size() != 3) {
1204  throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
1205  }
1206  const std::string deviceName = tok.get(1);
1207  bool create;
1208  try {
1209  create = TplConvert::_2bool(value.c_str());
1210  } catch (BoolFormatException) {
1211  throw TraCIException("Changing device status requires a 'true' or 'false'");
1212  }
1213  if (!create) {
1214  throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
1215  }
1216  try {
1217  veh->createDevice(deviceName);
1218  } catch (InvalidArgument& e) {
1219  throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
1220  }
1221  } else {
1222  ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
1223  }
1224 }
1225 
1226 
1227 
1228 }
1229 
1230 /****************************************************************************/
int getRoutePosition() const
Definition: MSVehicle.cpp:802
static void slowDown(const std::string &vehicleID, double speed, SUMOTime duration)
Definition: Vehicle.cpp:946
unsigned char g
Definition: TraCIDefs.h:79
static std::string getLaneID(const std::string &vehicleID)
Definition: Vehicle.cpp:150
double getApparentDecel() const
Get the vehicle type&#39;s apparent deceleration [m/s^2] (the one regarded by its followers.
Definition: MSCFModel.h:227
static std::vector< TraCIBestLanesData > getBestLanes(const std::string &vehicleID)
Definition: Vehicle.cpp:319
static double gLateralResolution
Definition: MSGlobals.h:91
double getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:4168
std::string id
The id of the next tls.
Definition: TraCIDefs.h:181
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
Definition: MSVehicle.h:670
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:475
SumoXMLTag
Numbers representing SUMO-XML - element names.
double getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:4156
static std::vector< std::string > getEdges(const std::string &vehicleID)
Definition: Vehicle.cpp:302
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Definition: MSVehicle.cpp:3478
RGBColor color
The vehicle&#39;s color, TraCI may change this.
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:607
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:1031
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
static double getEmergencyDecel(const std::string &vehicleID)
Definition: Vehicle.cpp:574
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
static TraCIPosition getPosition(const std::string &vehicleID)
Definition: Vehicle.cpp:114
double getElectricityConsumption() const
Returns electricity consumption of the current state.
Definition: MSVehicle.cpp:4174
static void setLine(const std::string &vehicleID, const std::string &line)
Definition: Vehicle.cpp:1159
double dist
The distance to the tls.
Definition: TraCIDefs.h:185
double getAngle() const
Returns the vehicle&#39;s direction in radians.
Definition: MSVehicle.h:684
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:201
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:127
static int getSignalStates(const std::string &vehicleID)
Definition: Vehicle.cpp:314
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:660
static double getSpeedWithoutTraCI(const std::string &vehicleID)
Definition: Vehicle.cpp:107
static std::string getRoadID(const std::string &vehicleID)
Definition: Vehicle.cpp:143
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) ...
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:991
static double getDrivingDistance(const std::string &vehicleID, const std::string &edgeID, double position, int laneIndex)
Definition: Vehicle.cpp:421
bool hasDeparted() const
Returns whether this vehicle has already departed.
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition: Helper.cpp:283
static int getPersonNumber(const std::string &vehicleID)
Definition: Vehicle.cpp:244
Stop & getNextStop()
Definition: MSVehicle.cpp:4806
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
bool resumeFromStopping()
Definition: MSVehicle.cpp:4755
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:564
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...
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:388
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
Definition: MSVehicle.h:811
void setShape(SUMOVehicleShape shape)
Set a new value for this type&#39;s shape.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:249
static double getWidth(const std::string &vehicleID)
Definition: Vehicle.cpp:624
int getPersonNumber() const
Returns the number of persons.
Definition: MSVehicle.cpp:4247
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:4098
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSVehicle.h:917
SUMOTime duration
The stopping duration.
Definition: MSVehicle.h:919
static std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist)
Definition: Vehicle.cpp:250
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:1182
virtual double getImperfection() const
Get the driver&#39;s imperfection.
Definition: MSCFModel.h:238
std::vector< double > & getParameter()
Returns the parameters of this distribution.
The position is given.
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSVehicle.h:913
static double getSlope(const std::string &vehicleID)
Definition: Vehicle.cpp:136
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSVehicle.h:909
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:402
Tag for the last element in the enum for safe int casting.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
static std::string getTypeID(const std::string &vehicleID)
Definition: Vehicle.cpp:163
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:925
static TraCIPosition makeTraCIPosition(const Position &position)
Definition: Helper.cpp:147
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:280
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1944
static double getTau(const std::string &vehicleID)
Definition: Vehicle.cpp:588
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.
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:4675
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:197
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:167
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:259
static double getCOEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:202
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:193
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:497
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:439
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:58
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1758
static std::vector< std::string > getVia(const std::string &vehicleID)
Definition: Vehicle.cpp:491
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.
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:744
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:901
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
int getSignals() const
Returns the signals.
Definition: MSVehicle.h:1231
static void setRouteID(const std::string &vehicleID, const std::string &routeID)
Definition: Vehicle.cpp:970
const std::string & getID() const
Returns the id.
Definition: Named.h:65
static void setColor(const std::string &vehicleID, const TraCIColor &col)
Definition: Vehicle.cpp:1151
static double getAngle(const std::string &vehicleID)
Definition: Vehicle.cpp:129
int getSpeedMode() const
return the current speed mode
Definition: MSVehicle.cpp:283
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:809
double length
The overall length which may be driven when using this lane without a lane change.
Definition: MSVehicle.h:803
static std::string getLine(const std::string &vehicleID)
Definition: Vehicle.cpp:486
Tag for the last element in the enum for safe int casting.
static double getSpeedFactor(const std::string &vehicleID)
Definition: Vehicle.cpp:465
bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const
Returns the information whether the vehicle is fully controlled via TraCI within the lookBack time...
Definition: MSVehicle.cpp:4862
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:513
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
static double getDistance(const std::string &vehicleID)
Definition: Vehicle.cpp:394
static double getNoiseEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:232
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
The speed is given.
The car-following model and parameter.
Definition: MSVehicleType.h:72
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:3674
double getDepartPos() const
Returns this vehicle&#39;s real departure position.
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...
The lane is given.
static std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction)
Definition: Vehicle.cpp:497
static void add(const std::string &vehicleID, const std::string &routeID, const std::string &typeID="DEFAULT_VEHTYPE", int depart=DEPARTFLAG_NOW, int departLane=DEPARTFLAG_LANE_FIRST_ALLOWED, double departPos=DEPARTFLAG_POS_BASE, double departSpeed=0, int arrivalLane=ARRIVALFLAG_LANE_CURRENT, double arrivalPos=ARRIVALFLAG_POS_MAX, double arrivalSpeed=ARRIVALFLAG_SPEED_CURRENT, const std::string &fromTaz="", const std::string &toTaz="", const std::string &line="", int personCapacity=4, int personNumber=0)
Definition: Vehicle.cpp:753
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:220
static void rerouteTraveltime(const std::string &vehicleID)
Definition: Vehicle.cpp:1057
static double getWaitingTime(const std::string &vehicleID)
Definition: Vehicle.cpp:264
static double getLastActionTime(const std::string &vehicleID)
Definition: Vehicle.cpp:583
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
static double getCO2Emission(const std::string &vehicleID)
Definition: Vehicle.cpp:196
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
Definition: Vehicle.cpp:540
bool isInternal() const
Definition: MSLane.cpp:1774
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:199
unsigned char b
Definition: TraCIDefs.h:79
double departSpeed
(optional) The initial speed of the vehicle
A road/street connecting two junctions.
Definition: MSEdge.h:80
static void resume(const std::string &vehicleID)
Definition: Vehicle.cpp:693
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:586
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Definition: MSVehicle.cpp:266
MSLane * lane
The described lane.
Definition: MSVehicle.h:801
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:186
The action has not been determined.
double getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:4138
static double getDecel(const std::string &vehicleID)
Definition: Vehicle.cpp:569
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:520
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
static double getImperfection(const std::string &vehicleID)
Definition: Vehicle.cpp:594
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
Definition: MSVehicle.cpp:278
DepartLaneDefinition
Possible ways to choose a lane on depart.
static std::vector< TraCINextTLSData > getNextTLS(const std::string &vehicleID)
Definition: Vehicle.cpp:345
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:471
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
void createDevice(const std::string &deviceName)
create device of the given type
static int getRouteIndex(const std::string &vehicleID)
Definition: Vehicle.cpp:173
Representation of a vehicle.
Definition: SUMOVehicle.h:66
static void setVia(const std::string &vehicleID, const std::vector< std::string > &via)
Definition: Vehicle.cpp:1164
static bool gCheckRoutes
Definition: MSGlobals.h:85
double startPos
The stopping position start.
static double getLateralLanePosition(const std::string &vehicleID)
Definition: Vehicle.cpp:190
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static double getHCEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:208
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
SUMOTime getActionStepLength() const
Returns the vehicle&#39;s action step length in millisecs, i.e. the interval between two action points...
Definition: MSVehicle.h:508
MSRouteIterator edge
The edge in the route to stop at.
Definition: MSVehicle.h:905
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:82
A list of positions.
bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
Definition: MSVehicle.cpp:732
int getRoutingMode() const
return the current routing mode
Definition: MSVehicle.h:1362
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:4026
static bool isOnInit(const std::string &vehicleID)
Definition: Vehicle.cpp:77
double getEmergencyDecel() const
Get the vehicle type&#39;s maximal phisically possible deceleration [m/s^2].
Definition: MSCFModel.h:219
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:306
static double getFuelConsumption(const std::string &vehicleID)
Definition: Vehicle.cpp:226
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.
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:64
static double getLanePosition(const std::string &vehicleID)
Definition: Vehicle.cpp:184
unsigned char a
Definition: TraCIDefs.h:79
SUMOTime depart
The vehicle&#39;s departure time.
#define STEPS2TIME(x)
Definition: SUMOTime.h:64
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: Helper.cpp:130
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
Definition: MSVehicle.h:973
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:940
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool isVisible(const MSVehicle *veh)
Definition: Vehicle.cpp:71
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:253
static void changeLane(const std::string &vehicleID, int laneIndex, SUMOTime duration)
Definition: Vehicle.cpp:738
static void moveTo(const std::string &vehicleID, const std::string &laneID, double position)
Definition: Vehicle.cpp:1084
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:4180
T MIN2(T a, T b)
Definition: StdDefs.h:67
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
Definition: MSVehicle.cpp:1613
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
Tag for the last element in the enum for safe int casting.
A structure representing the best lanes for continuing the current route starting at &#39;lane&#39;...
Definition: MSVehicle.h:799
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:709
unsigned char r
Definition: TraCIDefs.h:79
static std::vector< std::string > getIDList()
Definition: Vehicle.cpp:83
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:211
static double getAccumulatedWaitingTime(const std::string &vehicleID)
Definition: Vehicle.cpp:270
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition: GeomHelper.h:58
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:229
const int VEHPARS_COLOR_SET
static void setSpeed(const std::string &vehicleID, double speed)
Definition: Vehicle.cpp:955
static std::string getRouteID(const std::string &vehicleID)
Definition: Vehicle.cpp:168
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:1825
bool allowsContinuation
Whether this lane allows to continue the drive.
Definition: MSVehicle.h:813
Definition: Edge.cpp:31
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
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:439
static std::string getEmissionClass(const std::string &vehicleID)
Definition: Vehicle.cpp:546
DepartSpeedDefinition
Possible ways to choose the departure speed.
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:4144
static void setStop(const std::string &vehicleID, const std::string &edgeID, double endPos=1., int laneIndex=0, SUMOTime duration=4294967295u, int flags=STOP_DEFAULT, double startPos=INVALID_DOUBLE_VALUE, SUMOTime until=-1)
Definition: Vehicle.cpp:630
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:508
static double getActionStepLength(const std::string &vehicleID)
Definition: Vehicle.cpp:580
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
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:319
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:157
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:4626
static int getIDCount()
Definition: Vehicle.cpp:95
static void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int laneIndex, const double x, const double y, double angle, const int keepRouteFlag)
Definition: Vehicle.cpp:843
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:1639
static void setShapeClass(const std::string &vehicleID, const std::string &clazz)
Definition: Vehicle.cpp:1170
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:712
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition: MSVehicle.cpp:4812
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
#define INVALID_INT_VALUE
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:455
static double getPMxEmission(const std::string &vehicleID)
Definition: Vehicle.cpp:214
static void setSignals(const std::string &vehicleID, int signals)
Definition: Vehicle.cpp:1071
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
static bool isRouteValid(const std::string &vehicleID)
Definition: Vehicle.cpp:296
static void setMaxSpeed(const std::string &vehicleID, double speed)
Definition: Vehicle.cpp:1118
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:4321
static TraCIColor getColor(const std::string &vehicleID)
Definition: Vehicle.cpp:179
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:359
virtual double getHeadwayTime() const
Get the driver&#39;s desired headway [s].
Definition: MSCFModel.h:246
static double getDrivingDistance2D(const std::string &vehicleID, double x, double y)
Definition: Vehicle.cpp:437
std::vector< MSLane * > bestContinuations
Definition: MSVehicle.h:819
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSVehicle.h:915
char state
The current state of the tls.
Definition: TraCIDefs.h:187
static double getAccel(const std::string &vehicleID)
Definition: Vehicle.cpp:563
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSVehicle.h:911
int getLanechangeMode() const
return the current lane change mode
Definition: MSVehicle.cpp:293
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
Definition: MSVehicle.cpp:1011
const std::string & getID() const
Returns the name of the vehicle type.
double getPMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:4162
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
double getActionStepLengthSecs() const
Returns this type&#39;s default action step length in seconds.
static int getRoutingMode(const std::string &vehicleID)
Definition: Vehicle.cpp:481
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:461
static std::string getShapeClass(const std::string &vehicleID)
Definition: Vehicle.cpp:551
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:1618
double getLength() const
Get vehicle&#39;s length [m].
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
static double getLength(const std::string &vehicleID)
Definition: Vehicle.cpp:557
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
void setSignals(int signals)
Definition: MSVehicle.h:1451
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:1005
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:817
static double getMaxSpeed(const std::string &vehicleID)
Definition: Vehicle.cpp:618
static MSEdge * getEdge(const std::string &edgeID)
Definition: Helper.cpp:165
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
static int getLanechangeMode(const std::string &vehicleID)
Definition: Vehicle.cpp:476
void switchOffSignal(int signal)
Switches the given signal off.
Definition: MSVehicle.h:1223
void switchOnSignal(int signal)
Switches the given signal on.
Definition: MSVehicle.h:1215
double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MSVehicle.cpp:890
static void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED)
Definition: Vehicle.cpp:1144
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
static MSVehicle * getVehicle(const std::string &id)
Definition: Vehicle.cpp:57
long long int SUMOTime
Definition: TraCIDefs.h:51
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:195
#define NUMERICAL_EPS
Definition: config.h:151
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
Definition: MSVehicle.cpp:273
double getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:4150
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:73
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:897
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:1332
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:796
static double getElectricityConsumption(const std::string &vehicleID)
Definition: Vehicle.cpp:238
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.
static double getEffort(const std::string &vehicleID, const std::string &edgeID, int time)
Definition: Vehicle.cpp:286
static void setEmissionClass(const std::string &vehicleID, const std::string &clazz)
Definition: Vehicle.cpp:1175
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:3686
static void setType(const std::string &vehicleID, const std::string &typeID)
Definition: Vehicle.cpp:961
static double getApparentDecel(const std::string &vehicleID)
Definition: Vehicle.cpp:577
bool isParking() const
Returns whether the vehicle is parking.
Definition: MSVehicle.cpp:1358
double getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:482
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
static double getMinGap(const std::string &vehicleID)
Definition: Vehicle.cpp:612
Tag for the last element in the enum for safe int casting.
A 3D-position.
Definition: TraCIDefs.h:71
static std::string getVClass(const std::string &vehicleID)
Definition: Vehicle.cpp:606
DepartPosDefinition
Possible ways to choose the departure position.
static double getSpeedDeviation(const std::string &vehicleID)
Definition: Vehicle.cpp:600
const std::string & getID() const
Returns the name of the vehicle.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
static std::pair< MSLane *, double > convertCartesianToRoadMap(Position pos)
Definition: Helper.cpp:192
static void changeSublane(const std::string &vehicleID, double latDist)
Definition: Vehicle.cpp:747
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:183
static double getSpeed(const std::string &vehicleID)
Definition: Vehicle.cpp:100
static int getStopState(const std::string &vehicleID)
Definition: Vehicle.cpp:377
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:79
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:801
DepartDefinition
Possible ways to depart.
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:203
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
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:529
std::string id
The vehicle&#39;s id.
static double getAdaptedTraveltime(const std::string &vehicleID, const std::string &edgeID, int time)
Definition: Vehicle.cpp:276
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
Definition: MSVehicle.cpp:4827
The vehicle is being teleported.
static void rerouteEffort(const std::string &vehicleID)
Definition: Vehicle.cpp:1064
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:901
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 dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:117
static void setActionStepLength(const std::string &vehicleID, double actionStepLength, bool resetActionOffset=true)
Definition: Vehicle.cpp:1123