Eclipse SUMO - Simulation of Urban MObility
GUIVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A MSVehicle extended by some values for usage within the gui
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include <cmath>
25 #include <vector>
26 #include <string>
27 #include <bitset>
31 #include <utils/geom/GeomHelper.h>
38 #include <utils/gui/div/GLHelper.h>
42 #include <microsim/MSGlobals.h>
43 #include <microsim/MSVehicle.h>
44 #include <microsim/MSJunction.h>
45 #include <microsim/MSLane.h>
46 #include <microsim/MSLink.h>
47 #include <microsim/MSStop.h>
58 #include <gui/GUIGlobals.h>
59 
60 #include "GUIVehicle.h"
61 #include "GUIPerson.h"
62 #include "GUIContainer.h"
63 #include "GUINet.h"
64 #include "GUIEdge.h"
65 #include "GUILane.h"
66 
67 #define SPEEDMODE_DEFAULT 31
68 #define LANECHANGEMODE_DEFAULT 1621
69 
70 //#define DEBUG_FOES
71 
72 // ===========================================================================
73 // FOX callback mapping
74 // ===========================================================================
75 
76 // Object implementation
77 
78 
79 /* -------------------------------------------------------------------------
80  * GUIVehicle - methods
81  * ----------------------------------------------------------------------- */
82 #ifdef _MSC_VER
83 #pragma warning(push)
84 #pragma warning(disable: 4355)
85 #endif
87  MSVehicleType* type, const double speedFactor) :
88  MSVehicle(pars, route, type, speedFactor),
89  GUIBaseVehicle((MSBaseVehicle&) * this) {
90 }
91 #ifdef _MSC_VER
92 #pragma warning(pop)
93 #endif
94 
95 
97 }
98 
99 
103  const bool isElecHybrid = getDevice(typeid(MSDevice_ElecHybrid)) != nullptr ? true : false;
104  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
105  // add items
106  ret->mkItem("lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLaneID));
107  if (MSGlobals::gSublane) {
108  ret->mkItem("shadow lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getShadowLaneID));
109  }
111  ret->mkItem("target lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getTargetLaneID));
112  }
113  if (isSelected()) {
114  ret->mkItem("back lanes [id,..]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getBackLaneIDs));
115  }
116  ret->mkItem("position [m]", true,
118  ret->mkItem("lateral offset [m]", true,
120  ret->mkItem("speed [m/s]", true,
122  ret->mkItem("lateral speed [m/s]", true,
124  ret->mkItem("acceleration [m/s^2]", true,
126  ret->mkItem("angle [degree]", true,
128  ret->mkItem("slope [degree]", true,
130  ret->mkItem("speed factor", true,
132  ret->mkItem("time gap on lane [s]", true,
134  ret->mkItem("waiting time [s]", true,
136  ret->mkItem(("waiting time (accumulated, " + time2string(MSGlobals::gWaitingTimeMemory) + "s) [s]").c_str(), true,
138  ret->mkItem("time loss [s]", true,
140  ret->mkItem("impatience", true,
142  ret->mkItem("last lane change [s]", true,
144  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
145  ret->mkItem("depart delay [s]", false, time2string(getDepartDelay()));
146  ret->mkItem("odometer [m]", true,
148  if (getParameter().repetitionNumber < std::numeric_limits<int>::max()) {
149  ret->mkItem("remaining [#]", false, (int) getParameter().repetitionNumber - getParameter().repetitionsDone);
150  }
151  if (getParameter().repetitionOffset > 0) {
152  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
153  }
154  if (getParameter().repetitionProbability > 0) {
155  ret->mkItem("insertion probability", false, getParameter().repetitionProbability);
156  }
157  ret->mkItem("stop info", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getStopInfo));
158  ret->mkItem("line", false, myParameter->line);
159  ret->mkItem("CO2 [mg/s]", true,
161  ret->mkItem("CO [mg/s]", true,
163  ret->mkItem("HC [mg/s]", true,
165  ret->mkItem("NOx [mg/s]", true,
167  ret->mkItem("PMx [mg/s]", true,
169  ret->mkItem("fuel [ml/s]", true,
171  ret->mkItem("electricity [Wh/s]", true,
173  ret->mkItem("noise (Harmonoise) [dB]", true,
175  ret->mkItem("devices", false, getDeviceDescription());
176  ret->mkItem("persons", true,
178  ret->mkItem("containers", true,
180  ret->mkItem("lcState right", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateRight));
181  ret->mkItem("lcState left", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateLeft));
182  // close building
184  ret->mkItem("lcState center", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateCenter));
185  ret->mkItem("right side on edge [m]", true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getRightSideOnEdge2));
186  ret->mkItem("left side on edge [m]", true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getLeftSideOnEdge));
187  ret->mkItem("rightmost edge sublane [#]", true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getRightSublaneOnEdge));
188  ret->mkItem("leftmost edge sublane [#]", true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getLeftSublaneOnEdge));
189  ret->mkItem("lane change maneuver distance [m]", true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getManeuverDist));
190  }
191  if (isElecHybrid) {
192  ret->mkItem("actual state of charge [Wh]", true,
194  ret->mkItem("actual electric current [A]", true,
196  }
197  if (hasInfluencer()) {
199  ret->mkItem("speed mode", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getSpeedMode));
200  }
202  ret->mkItem("lane change mode", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLaneChangeMode));
203  }
204  }
205  ret->closeBuilding(&getParameter());
206  return ret;
207 }
208 
209 
213  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
214  // add items
215  ret->mkItem("Type Information:", false, "");
216  ret->mkItem("type [id]", false, myType->getID());
217  ret->mkItem("length", false, myType->getLength());
218  ret->mkItem("width", false, myType->getWidth());
219  ret->mkItem("height", false, myType->getHeight());
220  ret->mkItem("minGap", false, myType->getMinGap());
221  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
222  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
223  ret->mkItem("carFollowModel", false, SUMOXMLDefinitions::CarFollowModels.getString((SumoXMLTag)getCarFollowModel().getModelID()));
224  ret->mkItem("LaneChangeModel", false, SUMOXMLDefinitions::LaneChangeModels.getString(getLaneChangeModel().getModelID()));
225  ret->mkItem("guiShape", false, getVehicleShapeName(myType->getGuiShape()));
226  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
227  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
228  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
229  ret->mkItem("emergency deceleration [m/s^2]", false, getCarFollowModel().getEmergencyDecel());
230  ret->mkItem("apparent deceleration [m/s^2]", false, getCarFollowModel().getApparentDecel());
231  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
232  ret->mkItem("desired headway (tau)", false, getCarFollowModel().getHeadwayTime());
233  ret->mkItem("speedFactor", false, myType->getParameter().speedFactor.toStr(gPrecision));
235  ret->mkItem("action step length [s]", false, myType->getActionStepLengthSecs());
236  }
237  ret->mkItem("person capacity", false, myType->getPersonCapacity());
238  ret->mkItem("boarding time", false, STEPS2TIME(myType->getBoardingDuration()));
239  ret->mkItem("container capacity", false, myType->getContainerCapacity());
240  ret->mkItem("loading time", false, STEPS2TIME(myType->getLoadingDuration()));
242  ret->mkItem("minGapLat", false, myType->getMinGapLat());
243  ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
244  ret->mkItem("latAlignment", false, toString(myType->getPreferredLateralAlignment()));
245  } else if (MSGlobals::gLaneChangeDuration > 0) {
246  ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
247  }
248  for (auto item : myType->getParameter().lcParameter) {
249  ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
250  }
251  for (auto item : myType->getParameter().jmParameter) {
252  ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
253  }
255  ret->mkItem("manoeuver Angle vs Times", false, myType->getParameter().getManoeuverAngleTimesS());
256  }
257 
258  // close building
259  ret->closeBuilding(&(myType->getParameter()));
260  return ret;
261 }
262 
263 
264 
265 void
267  glTranslated(0, 0, getType() + .2); // draw on top of cars
268  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
269  if ((*i).myLink == nullptr) {
270  continue;
271  }
272  MSLink* link = (*i).myLink;
273  MSLane* via = link->getViaLaneOrLane();
274  if (via != nullptr) {
275  Position p = via->getShape()[0];
276  if ((*i).mySetRequest) {
277  glColor3d(0, .8, 0);
278  } else {
279  glColor3d(.8, 0, 0);
280  }
281  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
282  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLength());
283  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleName.size / s.scale);
284  // the time slot that ego vehicle uses when checking opened may
285  // differ from the one it requests in setApproaching
286  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
287  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
288  UNUSED_PARAMETER(avi); // only used for assertion
289  }
290  }
291  glTranslated(0, 0, getType() - .2); // draw on top of cars
292 }
293 
294 
295 void
297  RGBColor current = GLHelper::getColor();
298  RGBColor darker = current.changedBrightness(-51);
299  const double exaggeration = (s.vehicleSize.getExaggeration(s, this)
301  const double totalLength = getVType().getLength();
302  double upscaleLength = exaggeration;
303  if (exaggeration > 1 && totalLength > 5) {
304  // reduce the length/width ratio because this is not usefull at high zoom
305  const double widthLengthFactor = totalLength / getVType().getWidth();
306  const double shrinkFactor = MIN2(widthLengthFactor, sqrt(upscaleLength));
307  upscaleLength /= shrinkFactor;
308  }
309  const double locomotiveLength = getVehicleType().getParameter().locomotiveLength * upscaleLength;
310  if (exaggeration == 0) {
311  return;
312  }
313  const double defaultLength = getVehicleType().getParameter().carriageLength * upscaleLength;
314  const double carriageGap = getVehicleType().getParameter().carriageGap * upscaleLength;
315  const double length = totalLength * upscaleLength;
316  const double halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
317  GLHelper::popMatrix(); // undo initial translation and rotation
318  const double xCornerCut = 0.3 * exaggeration;
319  const double yCornerCut = 0.4 * exaggeration;
320  // round to closest integer
321  const int numCarriages = MAX2(1, 1 + (int)((length - locomotiveLength) / (defaultLength + carriageGap) + 0.5));
322  assert(numCarriages > 0);
323  double carriageLengthWithGap = length / numCarriages;
324  double carriageLength = carriageLengthWithGap - carriageGap;
325  double firstCarriageLength = carriageLength;
326  if (defaultLength != locomotiveLength && numCarriages > 1) {
327  firstCarriageLength = locomotiveLength;
328  carriageLengthWithGap = (length - locomotiveLength) / (numCarriages - 1);
329  carriageLength = carriageLengthWithGap - carriageGap;
330  }
331  const int firstPassengerCarriage = defaultLength == locomotiveLength || numCarriages == 1 || (getVClass() & SVC_RAIL_CLASSES) == 0 ? 0 : 1;
332  const int noPersonsBackCarriages = (getVehicleType().getGuiShape() == SUMOVehicleShape::TRUCK_SEMITRAILER || getVehicleType().getGuiShape() == SUMOVehicleShape::TRUCK_1TRAILER) && numCarriages > 1 ? 1 : 0;
333  const int firstContainerCarriage = numCarriages == 1 || getVehicleType().getGuiShape() == SUMOVehicleShape::TRUCK_1TRAILER ? 0 : 1;
334  const int seatsPerCarriage = (int)ceil(getVType().getPersonCapacity() / (numCarriages - firstPassengerCarriage - noPersonsBackCarriages));
335  const int containersPerCarriage = (int)ceil(getVType().getContainerCapacity() / (numCarriages - firstContainerCarriage));
336  // lane on which the carriage front is situated
337  MSLane* lane = myLane;
338  int furtherIndex = 0;
339  // lane on which the carriage back is situated
340  MSLane* backLane = myLane;
341  int backFurtherIndex = furtherIndex;
342  // offsets of front and back
343  double carriageOffset = myState.pos();
344  double carriageBackOffset = myState.pos() - firstCarriageLength;
345  // handle seats
346  int requiredSeats = getNumPassengers();
347  int requiredPositions = getNumContainers();
348  if (requiredSeats > 0) {
349  mySeatPositions.clear();
350  }
351  if (requiredPositions > 0) {
352  myContainerPositions.clear();
353  }
354  Position front, back;
355  double angle = 0.;
356  // position parking vehicle beside the road or track
357  const double lateralOffset = isParking() ? (SUMO_const_laneWidth * (MSGlobals::gLefthand ? -1 : 1)) : 0;
358 
359  // draw individual carriages
360  double curCLength = firstCarriageLength;
361  //std::cout << SIMTIME << " veh=" << getID() << " curCLength=" << curCLength << " loc=" << locomotiveLength << " car=" << carriageLength << " tlen=" << totalLength << " len=" << length << "\n";
362  for (int i = 0; i < numCarriages; ++i) {
363  if (i > 0) {
364  curCLength = carriageLength;
365  }
366  while (carriageOffset < 0) {
367  MSLane* prev = getPreviousLane(lane, furtherIndex);
368  if (prev != lane) {
369  carriageOffset += prev->getLength();
370  } else {
371  // no lane available for drawing.
372  carriageOffset = 0;
373  }
374  lane = prev;
375  }
376  while (carriageBackOffset < 0) {
377  MSLane* prev = getPreviousLane(backLane, backFurtherIndex);
378  if (prev != backLane) {
379  carriageBackOffset += prev->getLength();
380  } else {
381  // no lane available for drawing.
382  carriageBackOffset = 0;
383  }
384  backLane = prev;
385  }
386  front = lane->geometryPositionAtOffset(carriageOffset, lateralOffset);
387  back = backLane->geometryPositionAtOffset(carriageBackOffset, lateralOffset);
388  if (front == back) {
389  // no place for drawing available
390  continue;
391  }
392  const double drawnCarriageLength = front.distanceTo2D(back);
393  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (double) 180.0 / (double) M_PI;
394  if (i >= firstPassengerCarriage) {
395  computeSeats(front, back, SUMO_const_waitingPersonWidth, seatsPerCarriage, exaggeration, requiredSeats, mySeatPositions);
396  }
397  if (i >= firstContainerCarriage) {
398  computeSeats(front, back, SUMO_const_waitingContainerWidth, containersPerCarriage, exaggeration, requiredPositions, myContainerPositions);
399  }
401  glTranslated(front.x(), front.y(), getType());
402  glRotated(angle, 0, 0, 1);
403  if (!asImage || !GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(s, getVType().getImgFile(), this, getVType().getWidth(), curCLength / exaggeration)) {
404  switch (getVType().getGuiShape()) {
407  if (i == 0) {
408  GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth() * exaggeration, curCLength, i);
409  } else {
410  GLHelper::setColor(current);
411  GLHelper::drawBoxLine(Position(0, 0), 180, curCLength, halfWidth);
412  }
413  break;
414  default: {
415  if (i == 0) {
416  GLHelper::setColor(darker);
417  } else {
418  GLHelper::setColor(current);
419  }
420  // generic rail carriage
421  glBegin(GL_TRIANGLE_FAN);
422  glVertex2d(-halfWidth + xCornerCut, 0);
423  glVertex2d(-halfWidth, yCornerCut);
424  glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
425  glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
426  glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
427  glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
428  glVertex2d(halfWidth, yCornerCut);
429  glVertex2d(halfWidth - xCornerCut, 0);
430  glEnd();
431  }
432  }
433  }
435  carriageOffset -= (curCLength + carriageGap);
436  carriageBackOffset -= carriageLengthWithGap;
437  }
440  glTranslated(front.x(), front.y(), getType());
441  glRotated(angle, 0, 0, 1);
442  drawAction_drawVehicleBlinker(curCLength);
445  }
446  // restore matrix
448  front = getPosition();
449  glTranslated(front.x(), front.y(), getType());
450  const double degAngle = RAD2DEG(getAngle() + M_PI / 2.);
451  glRotated(degAngle, 0, 0, 1);
452  glScaled(exaggeration, upscaleLength, 1);
453  if (mySeatPositions.size() == 0) {
454  mySeatPositions.push_back(Seat(back, DEG2RAD(angle)));
455  }
456  if (myContainerPositions.size() == 0) {
457  myContainerPositions.push_back(Seat(back, DEG2RAD(angle)));
458  }
459 }
460 
461 #define BLINKER_POS_FRONT .5
462 #define BLINKER_POS_BACK .5
463 
464 inline void
465 drawAction_drawBlinker(double dir, double length) {
466  glColor3d(1.f, .8f, 0);
468  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
472  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
475 }
476 
477 
478 void
481  return;
482  }
483  const double offset = MAX2(.5 * getVehicleType().getWidth(), .4);
485  drawAction_drawBlinker(-offset, length);
486  }
488  drawAction_drawBlinker(offset, length);
489  }
491  drawAction_drawBlinker(-offset, length);
492  drawAction_drawBlinker(offset, length);
493  }
494 }
495 
496 
497 inline void
498 GUIVehicle::drawAction_drawVehicleBrakeLight(double length, bool onlyOne) const {
500  return;
501  }
502  glColor3f(1.f, .2f, 0);
504  if (onlyOne) {
505  glTranslated(0, length, -0.1);
507  } else {
508  glTranslated(-getVehicleType().getWidth() * 0.5, length, -0.1);
512  glTranslated(getVehicleType().getWidth() * 0.5, length, -0.1);
514  }
516 }
517 
518 inline void
522  glTranslated(0, 2.5, .5);
523  glColor3f(0, 0, 1);
526  }
527 }
528 
529 
530 double
531 GUIVehicle::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
532  switch (activeScheme) {
533  case 8:
534  if (isStopped()) {
535  return isParking() ? -2 : -1;
536  }
537  return getSpeed();
538  case 9:
539  // color by action step
540  if (isActionStep(SIMSTEP)) {
541  // Upcoming simstep is actionstep (t was already increased before drawing)
542  return 1.;
543  } else if (isActive()) {
544  // Completed simstep was actionstep
545  return 2.;
546  } else {
547  // not active
548  return 0.;
549  }
550  case 10:
551  return getWaitingSeconds();
552  case 11:
554  case 12:
555  return getLastLaneChangeOffset();
556  case 13:
557  return getLane()->getVehicleMaxSpeed(this);
558  case 14:
559  return getCO2Emissions();
560  case 15:
561  return getCOEmissions();
562  case 16:
563  return getPMxEmissions();
564  case 17:
565  return getNOxEmissions();
566  case 18:
567  return getHCEmissions();
568  case 19:
569  return getFuelConsumption();
570  case 20:
572  case 21:
573  return getNumberReroutes();
574  case 22:
576  case 23:
577  return getLaneChangeModel().isOpposite() ? -100 : getBestLaneOffset();
578  case 24:
579  return getAcceleration();
580  case 25:
581  return getTimeGapOnLane();
582  case 26:
583  return STEPS2TIME(getDepartDelay());
584  case 27:
585  return getElectricityConsumption();
586  case 28:
587  return getTimeLossSeconds();
588  case 29:
589  return getStopDelay();
590  case 30:
591  return getStopArrivalDelay();
592  case 31:
593  return getLaneChangeModel().getSpeedLat();
594  case 32: // by numerical param value
595  std::string error;
596  std::string val = getPrefixedParameter(s.vehicleParam, error);
597  try {
598  if (val == "") {
599  return 0;
600  } else {
601  return StringUtils::toDouble(val);
602  }
603  } catch (NumberFormatException&) {
604  try {
605  return StringUtils::toBool(val);
606  } catch (BoolFormatException&) {
607  WRITE_WARNING("Vehicle parameter '" + myParameter->getParameter(s.vehicleParam, "0") + "' key '" + s.vehicleParam + "' is not a number for vehicle '" + getID() + "'");
608  return -1;
609  }
610  }
611  }
612  return 0;
613 }
614 
615 
616 void
618  myLock.lock();
619  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
620  myLock.unlock();
621  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
622  std::vector<MSVehicle::LaneQ>& lanes = *j;
623  double gmax = -1;
624  double rmax = -1;
625  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
626  gmax = MAX2((*i).length, gmax);
627  rmax = MAX2((*i).occupation, rmax);
628  }
629  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
630  const PositionVector& shape = (*i).lane->getShape();
631  double g = (*i).length / gmax;
632  double r = (*i).occupation / rmax;
633  glColor3d(r, g, 0);
634  double width = 0.5 / (1 + abs((*i).bestLaneOffset));
635  GLHelper::drawBoxLines(shape, width);
636 
637  PositionVector s1 = shape;
638  s1.move2side((double) .1);
639  glColor3d(r, 0, 0);
640  GLHelper::drawLine(s1);
641  s1.move2side((double) - .2);
642  glColor3d(0, g, 0);
643  GLHelper::drawLine(s1);
644 
645  glColor3d(r, g, 0);
646  }
647  }
648 }
649 
650 
651 void
652 GUIVehicle::drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r, bool future, bool noLoop, const RGBColor& col) const {
653  const double exaggeration = s.vehicleSize.getExaggeration(s, this) * (s.gaming ? 0.5 : 1);
654  MSRouteIterator start = future ? myCurrEdge : r.begin();
655  MSRouteIterator i = start;
656  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
657  // draw continuation lanes when drawing the current route where available
658  int bestLaneIndex = (&r == myRoute ? 0 : (int)bestLaneConts.size());
659  std::map<const MSLane*, int> repeatLane; // count repeated occurrences of the same edge
660  const double textSize = s.vehicleName.size / s.scale;
661  const GUILane* prevLane = nullptr;
662  int reversalIndex = 0;
663  const int indexDigits = (int)toString(r.size()).size();
664  if (!isOnRoad() && !isParking()) {
665  // simulation time has already advanced so isRemoteControlled is always false
666  const std::string offRoadLabel = hasInfluencer() && getInfluencer()->isRemoteAffected(SIMSTEP) ? "offRoad" : "teleporting";
667  GLHelper::drawTextSettings(s.vehicleValue, offRoadLabel, getPosition(), s.scale, s.angle, 1.0);
668  }
669  for (; i != r.end(); ++i) {
670  const GUILane* lane;
671  if (bestLaneIndex < (int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
672  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
673  ++bestLaneIndex;
674  } else {
675  const std::vector<MSLane*>* allowed = (*i)->allowedLanes(getVClass());
676  if (allowed != nullptr && allowed->size() != 0) {
677  lane = static_cast<GUILane*>((*allowed)[0]);
678  } else {
679  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
680  }
681  }
682  GLHelper::setColor(col);
683  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
684  if (prevLane != nullptr && lane->getBidiLane() == prevLane) {
685  // indicate train reversal
686  std::string label = "reverse:" + toString(reversalIndex++);
687  if (s.showRouteIndex) {
688  label += "@r" + toString((int)(i - myCurrEdge));
689  }
690  Position pos = lane->geometryPositionAtOffset(lane->getLength() / 2) - Position(0, textSize * repeatLane[lane]);
691  GLHelper::drawTextSettings(s.vehicleValue, label, pos, s.scale, s.angle, 1.0);
692  }
693  if (s.showRouteIndex) {
694  std::string label = toString((int)(i - myCurrEdge));
695  const double laneAngle = lane->getShape().angleAt2D(0);
696  Position pos = lane->getShape().front() - Position(0, textSize * repeatLane[lane]) + Position(
697  (laneAngle >= -0.25 * M_PI && laneAngle < 0.75 * M_PI ? 1 : -1) * 0.4 * indexDigits * textSize, 0);
698  //GLHelper::drawText(label, pos, 1.0, textSize, s.vehicleName.color);
699  GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
700  }
701  repeatLane[lane]++;
702  prevLane = lane;
703  if (noLoop && i != start && (*i) == (*start)) {
704  break;
705  }
706  }
707  drawStopLabels(s, noLoop, col);
708  drawParkingInfo(s, col);
709 }
710 
711 
712 MSLane*
713 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
714  if (furtherIndex < (int)myFurtherLanes.size()) {
715  return myFurtherLanes[furtherIndex++];
716  } else {
717  // try to use route information
718  int routeIndex = getRoutePosition();
719  bool resultInternal;
720  if (MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks()) {
721  if (myLane->isInternal()) {
722  if (furtherIndex % 2 == 0) {
723  routeIndex -= (furtherIndex + 0) / 2;
724  resultInternal = false;
725  } else {
726  routeIndex -= (furtherIndex + 1) / 2;
727  resultInternal = false;
728  }
729  } else {
730  if (furtherIndex % 2 != 0) {
731  routeIndex -= (furtherIndex + 1) / 2;
732  resultInternal = false;
733  } else {
734  routeIndex -= (furtherIndex + 2) / 2;
735  resultInternal = true;
736  }
737  }
738  } else {
739  routeIndex -= furtherIndex;
740  resultInternal = false;
741  }
742  furtherIndex++;
743  if (routeIndex >= 0) {
744  if (resultInternal) {
745  const MSEdge* prevNormal = myRoute->getEdges()[routeIndex];
746  for (MSLane* cand : prevNormal->getLanes()) {
747  for (MSLink* link : cand->getLinkCont()) {
748  if (link->getLane() == current) {
749  if (link->getViaLane() != nullptr) {
750  return link->getViaLane();
751  } else {
752  return const_cast<MSLane*>(link->getLaneBefore());
753  }
754  }
755  }
756  }
757  } else {
758  return myRoute->getEdges()[routeIndex]->getLanes()[0];
759  }
760  }
761  }
762  return current;
763 }
764 
765 
766 double
769 }
770 
771 
772 std::string
774  std::string result = "";
775  if (isParking()) {
776  result += "parking";
777  } else if (isStopped()) {
778  result += "stopped";
779  } else if (hasStops()) {
780  return "next: " + myStops.front().getDescription();
781  } else {
782  return "";
783  }
784  if (myStops.front().pars.triggered) {
785  result += ", triggered";
786  } else if (myStops.front().pars.containerTriggered) {
787  result += ", containerTriggered";
788  } else if (myStops.front().collision) {
789  result += ", collision";
790  } else if (myStops.front().pars.until != -1) {
791  result += ", until=" + time2string(myStops.front().pars.until);
792  } else {
793  result += ", duration=" + time2string(myStops.front().duration);
794  }
795  if (myStops.front().pars.actType != "") {
796  result += ", actType=" + myStops.front().pars.actType;
797  }
798  return result;
799 }
800 
801 
802 void
804  double dist = myLane->getLength() - getPositionOnLane();
805 #ifdef DEBUG_FOES
806  std::cout << SIMTIME << " selectBlockingFoes veh=" << getID() << " dist=" << dist << " numLinks=" << myLFLinkLanes.size() << "\n";
807 #endif
808  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
809  const DriveProcessItem& dpi = *i;
810  if (dpi.myLink == nullptr) {
812  continue;
813  }
814  MSLink::BlockingFoes blockingFoes;
815  std::vector<const MSPerson*> blockingPersons;
816 #ifdef DEBUG_FOES
817  std::cout << " foeLink=" << dpi.myLink->getViaLaneOrLane()->getID() << "\n";
818  const bool isOpen =
819 #endif
821  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), getLateralPositionOnLane(), &blockingFoes, false, this);
822 #ifdef DEBUG_FOES
823  if (!isOpen) {
824  std::cout << " closed due to:\n";
825  for (const auto& item : blockingFoes) {
826  std::cout << " " << item->getID() << "\n";
827  }
828  }
829 #endif
830  if (getLaneChangeModel().getShadowLane() != nullptr) {
831  MSLink* parallelLink = dpi.myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
832  if (parallelLink != nullptr) {
833  const double shadowLatPos = getLateralPositionOnLane() - getLaneChangeModel().getShadowDirection() * 0.5 * (
835 #ifdef DEBUG_FOES
836  const bool isShadowOpen =
837 #endif
838  parallelLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
841  getWaitingTime(), shadowLatPos, &blockingFoes, false, this);
842 #ifdef DEBUG_FOES
843  if (!isShadowOpen) {
844  std::cout << " foes at shadow link=" << parallelLink->getViaLaneOrLane()->getID() << ":\n";
845  for (const auto& item : blockingFoes) {
846  std::cout << " " << item->getID() << "\n";
847  }
848  }
849 #endif
850  }
851  }
852  for (const auto& item : blockingFoes) {
853  gSelected.select(static_cast<const GUIVehicle*>(item)->getGlID());
854  }
855 #ifdef DEBUG_FOES
856  gDebugFlag1 = true;
857 #endif
858  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(this, dist, &blockingPersons);
859 #ifdef DEBUG_FOES
860  gDebugFlag1 = false;
861 #endif
862  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
863  // the vehicle to enter the junction first has priority
864  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
865  if (leader != nullptr) {
866  if (isLeader(dpi.myLink, leader)) {
867  gSelected.select(leader->getGlID());
868 #ifdef DEBUG_FOES
869  std::cout << " linkLeader=" << leader->getID() << "\n";
870 #endif
871  }
872  } else {
873  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
874  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
875  if (foe != nullptr) {
876  gSelected.select(foe->getGlID());
877  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
878  }
879  }
880  }
881  }
882  dist += dpi.myLink->getViaLaneOrLane()->getLength();
883  }
884 }
885 
886 
887 void
890  GUISUMOAbstractView* view = mw->getActiveView();
891  if (view != nullptr) {
892  if (add) {
895  view->addAdditionalGLVisualisation(this);
896  }
897  } else {
900  }
901  }
902 }
903 
904 bool
907 }
908 
909 int
911  const double rightSide = getRightSideOnEdge();
912  const std::vector<double>& sublaneSides = myLane->getEdge().getSubLaneSides();
913  for (int i = 0; i < (int)sublaneSides.size(); ++i) {
914  if (sublaneSides[i] > rightSide) {
915  return MAX2(i - 1, 0);
916  }
917  }
918  return (int)sublaneSides.size() - 1;
919 }
920 
921 int
923  const double leftSide = getLeftSideOnEdge();
924  const std::vector<double>& sublaneSides = myLane->getEdge().getSubLaneSides();
925  for (int i = (int)sublaneSides.size() - 1; i >= 0; --i) {
926  if (sublaneSides[i] < leftSide) {
927  return i;
928  }
929  }
930  return -1;
931 }
932 
933 
934 std::string
936  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(-1).second);
937 }
938 
939 std::string
941  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(1).second);
942 }
943 
944 std::string
946  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(0).second);
947 }
948 
949 std::string
951  return Named::getIDSecure(myLane, "n/a");
952 }
953 
954 std::string
956  return toString(myFurtherLanes);
957 }
958 
959 std::string
961  return Named::getIDSecure(getLaneChangeModel().getShadowLane(), "");
962 }
963 
964 std::string
966  return Named::getIDSecure(getLaneChangeModel().getTargetLane(), "");
967 }
968 
969 double
972 }
973 
974 std::string
976  return std::bitset<6>(getInfluencer()->getSpeedMode()).to_string();
977 }
978 
979 std::string
981  return std::bitset<12>(getInfluencer()->getLaneChangeMode()).to_string();
982 }
983 
984 void
986  SUMOTime intermediateDuration = TIME2STEPS(20);
987  SUMOTime finalDuration = SUMOTime_MAX;
988  if (myParameter->stops.size() >= 2) {
989  // copy durations from the original stops
990  intermediateDuration = myParameter->stops.front().duration;
991  finalDuration = myParameter->stops.back().duration;
992  }
993  // if the stop is already in the list of stops, cancel all stops that come
994  // after it and set the stop duration
995  std::string line = "";
996  int destinations = 0;
997  bool add = true;
998  for (auto it = myStops.begin(); it != myStops.end(); it++) {
999  if (!it->reached && destinations < 2 && it->busstop != nullptr) {
1000  line += it->busstop->getID();
1001  destinations++;
1002  }
1003  if (it->busstop == busStop) {
1004  it->duration = finalDuration;
1005  myStops.erase(++it, myStops.end());
1006  add = false;
1007  break;
1008  } else {
1009  it->duration = MIN2(it->duration, intermediateDuration);
1010  }
1011  }
1012  if (destinations < 2) {
1013  line += busStop->getID();
1014  }
1015  if (add) {
1016  // create new stop
1018  stopPar.busstop = busStop->getID();
1019  stopPar.lane = busStop->getLane().getID();
1020  stopPar.startPos = busStop->getBeginLanePosition();
1021  stopPar.endPos = busStop->getEndLanePosition();
1022  stopPar.duration = finalDuration;
1023  stopPar.until = -1;
1024  stopPar.triggered = false;
1025  stopPar.containerTriggered = false;
1026  stopPar.parking = false;
1027  stopPar.index = STOP_INDEX_FIT;
1029  // clean up prior route to improve visualisation, ensure that the stop can be added immediately
1030  ConstMSEdgeVector edges = myRoute->getEdges();
1031  edges.erase(edges.begin(), edges.begin() + getRoutePosition());
1032  edges.push_back(&busStop->getLane().getEdge());
1033  replaceRouteEdges(edges, -1, 0, "DRT.tmp", false, false, false);
1034  std::string errorMsg;
1035  // add stop
1036  addStop(stopPar, errorMsg);
1037  }
1038  const bool hasReroutingDevice = getDevice(typeid(MSDevice_Routing)) != nullptr;
1039  SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = hasReroutingDevice
1042  // reroute to ensure the new stop is reached
1043  reroute(MSNet::getInstance()->getCurrentTimeStep(), "DRT", router);
1044  myParameter->line = line;
1045  assert(haveValidStopEdges());
1046 }
1047 
1048 
1049 /****************************************************************************/
@ GLO_VEHICLE
a vehicle
GUISelectedStorage gSelected
A global holder of selected objects.
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:461
#define LANECHANGEMODE_DEFAULT
Definition: GUIVehicle.cpp:68
#define SPEEDMODE_DEFAULT
Definition: GUIVehicle.cpp:67
void drawAction_drawBlinker(double dir, double length)
Definition: GUIVehicle.cpp:465
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:462
#define DEG2RAD(x)
Definition: GeomHelper.h:35
#define RAD2DEG(x)
Definition: GeomHelper.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:54
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SIMSTEP
Definition: SUMOTime.h:59
#define SUMOTime_MAX
Definition: SUMOTime.h:33
#define SIMTIME
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
const int VTYPEPARS_ACTIONSTEPLENGTH_SET
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ RAIL_CAR
render as a (city) rail without locomotive
@ TRUCK_1TRAILER
render as a transport vehicle with one trailer
@ TRUCK_SEMITRAILER
render as a semi-trailer transport vehicle ("Sattelschlepper")
const int STOP_START_SET
const int STOP_INDEX_FIT
const int STOP_END_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
LaneChangeAction
The state of a vehicle's lane-change behavior.
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:25
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:32
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MIN2(T a, T b)
Definition: StdDefs.h:74
T MAX2(T a, T b)
Definition: StdDefs.h:80
const double SUMO_const_waitingContainerWidth
Definition: StdDefs.h:57
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:55
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
std::string toStr(std::streamsize accuracy) const
Returns the string representation of this distribution.
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:369
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:431
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:277
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:513
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:231
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:640
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1)
draw vehicle as a polygon
static bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, const std::string &file, const GUIGlObject *o, const double width, double length)
try to draw vehicle as raster image and return true if sucessful
A MSVehicle extended by some values for usage within the gui.
void drawParkingInfo(const GUIVisualizationSettings &s, const RGBColor &col) const
int getNumContainers() const
return the number of passengers
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the size multiplier value according to the current scheme index
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into) const
add seats to mySeatPositions and update requiredSeats
@ VO_DRAW_OUTSIDE_NETWORK
draw vehicle outside the road network
Seats myContainerPositions
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
double getNaviDegree() const
return the current angle in navigational degrees
int getNumPassengers() const
return the number of passengers
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
void drawStopLabels(const GUIVisualizationSettings &s, bool noLoop, const RGBColor &col) const
Seats mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
std::string getDeviceDescription()
lists equipped device (types) for the current vehicle
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:59
const PositionVector & getShape() const
Definition: GUILane.cpp:987
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:999
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:993
GUISUMOAbstractView * getActiveView() const
get the active view or 0
static GUIMainWindow * getInstance()
get instance
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
const T getColor(const double value) const
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:51
bool isSelected() const
whether this vehicle is selected in the GUI
Definition: GUIVehicle.cpp:905
int getLeftSublaneOnEdge() const
Definition: GUIVehicle.cpp:922
double getAngle() const
Return current angle.
Definition: GUIVehicle.h:79
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: GUIVehicle.h:71
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIVehicle.cpp:531
void selectBlockingFoes() const
adds the blocking foes to the current selection
Definition: GUIVehicle.cpp:803
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIVehicle.cpp:211
void drawBestLanes() const
Draws the vehicle's best lanes.
Definition: GUIVehicle.cpp:617
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
Definition: GUIVehicle.cpp:888
int getRightSublaneOnEdge() const
return the righmost sublane on the edge occupied by the vehicle
Definition: GUIVehicle.cpp:910
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
Definition: GUIVehicle.cpp:713
std::string getStopInfo() const
retrieve information about the current stop state
Definition: GUIVehicle.cpp:773
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:101
std::string getBackLaneIDs() const
Definition: GUIVehicle.cpp:955
double getLeftSideOnEdge() const
return left vehicle side on current edge
Definition: GUIVehicle.h:136
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
Definition: GUIVehicle.cpp:86
void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const
draws the given guiShape with distinct carriages/modules
Definition: GUIVehicle.cpp:296
std::string getShadowLaneID() const
Definition: GUIVehicle.cpp:960
double getManeuverDist() const
return the lane-change maneuver distance
Definition: GUIVehicle.cpp:970
double getRightSideOnEdge2() const
return right vehicle side on current edge (without argument)
Definition: GUIVehicle.h:132
std::string getSpeedMode() const
return the speed mode as bit string
Definition: GUIVehicle.cpp:975
void drawAction_drawVehicleBlinker(double length) const
Definition: GUIVehicle.cpp:479
void rerouteDRTStop(MSStoppingPlace *busStop)
handle route to accomodate to given stop
Definition: GUIVehicle.cpp:985
std::string getLCStateRight() const
return the lanechange state
Definition: GUIVehicle.cpp:935
void drawAction_drawVehicleBlueLight() const
Definition: GUIVehicle.cpp:519
double getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
Definition: GUIVehicle.cpp:767
std::string getLaneID() const
return vehicle lane id
Definition: GUIVehicle.cpp:950
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:266
std::string getTargetLaneID() const
Definition: GUIVehicle.cpp:965
std::string getLCStateLeft() const
Definition: GUIVehicle.cpp:940
void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
Definition: GUIVehicle.cpp:498
void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future, bool noLoop, const RGBColor &col) const
Draws the route.
Definition: GUIVehicle.cpp:652
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:96
std::string getLCStateCenter() const
Definition: GUIVehicle.cpp:945
std::string getLaneChangeMode() const
return the lane change mode as bit string
Definition: GUIVehicle.cpp:980
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIVisualizationTextSettings vehicleValue
bool gaming
whether the application is in gaming mode or not
std::string vehicleParam
key for coloring by vehicle parameter
GUIScaler vehicleScaler
The size scaling settings for vehicles.
double scale
information about a lane's width (temporary, used for a single view)
bool showRouteIndex
Information whether the route index should be shown.
double angle
The current view rotation angle.
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
int getShadowDirection() const
return the direction in which the current shadow lane lies
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
double getMaxSpeed() const
Returns the maximum speed.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
std::list< MSStop > myStops
The vehicle's list of stops.
double getImpatience() const
Returns this vehicles impatience.
MSVehicleType * myType
This vehicle's type.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getFuelConsumption() const
Returns fuel consumption of the current state.
double getCO2Emissions() const
Returns CO2 emission of the current state.
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
double getOdometer() const
Returns the distance that was already driven by this vehicle.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
int getPersonNumber() const
Returns the number of persons.
double getNOxEmissions() const
Returns NOx emission of the current state.
double getPMxEmissions() const
Returns PMx emission of the current state.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
double getWidth() const
Returns the vehicle's width.
double getCOEmissions() const
Returns CO emission of the current state.
double getStateOfCharge() const
Returns actual state of charge of battery (Wh) RICE_CHECK: This may be a misnomer,...
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
const MSRoute * myRoute
This vehicle's route.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=nullptr)
Adds a stop.
double getHCEmissions() const
Returns HC emission of the current state.
bool haveValidStopEdges() const
check whether all stop.edge MSRouteIterators are valid and in order
int getRoutePosition() const
return index of edge within route
SUMOTime getDepartDelay() const
Returns the depart delay.
double getElecHybridCurrent() const
Returns actual current (A) of ElecHybrid device RICE_CHECK: Is this the current consumed from the ove...
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)
Performs a rerouting using the given router.
int getRNGIndex() const
bool isStopped() const
Returns whether the vehicle is at a stop.
int getContainerNumber() const
Returns the number of containers.
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given edges.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:239
A device which collects info on the vehicle trip (mainly on departure and arrival)
A device that performs vehicle rerouting based on current edge speeds.
A road/street connecting two junctions.
Definition: MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const std::vector< double > getSubLaneSides() const
Returns the right side offsets of this edge's sublanes.
Definition: MSEdge.h:617
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
Definition: MSGlobals.h:145
static double gLateralResolution
Definition: MSGlobals.h:88
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:157
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
Definition: MSGlobals.h:148
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:85
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
Definition: MSGlobals.h:103
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:72
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:519
bool isInternal() const
Definition: MSLane.cpp:2122
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:4051
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:556
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1352
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:81
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:75
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:69
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:120
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
bool isRemoteAffected(SUMOTime t) const
Definition: MSVehicle.cpp:808
double pos() const
Position of this state.
Definition: MSVehicle.h:105
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
Definition: MSVehicle.cpp:5894
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
Definition: MSVehicle.cpp:5769
double getStopDelay() const
Returns the public transport stop delay in seconds.
Definition: MSVehicle.cpp:7052
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:574
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:631
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
Definition: MSVehicle.h:597
double getTimeLossSeconds() const
Returns the time loss in seconds.
Definition: MSVehicle.h:668
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
Definition: MSVehicle.h:662
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5051
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle.
Definition: MSVehicle.h:604
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1852
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:1146
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
Definition: MSVehicle.h:485
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:5497
int getBestLaneOffset() const
Definition: MSVehicle.cpp:5668
double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
Definition: MSVehicle.cpp:7073
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
Definition: MSVehicle.h:1068
@ VEH_SIGNAL_BRAKELIGHT
The brake lights are on.
Definition: MSVehicle.h:1074
@ VEH_SIGNAL_EMERGENCY_BLUE
A blue emergency light is on.
Definition: MSVehicle.h:1090
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
Definition: MSVehicle.h:1070
@ VEH_SIGNAL_BLINKER_EMERGENCY
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:1072
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
Definition: MSVehicle.cpp:6527
Influencer & getInfluencer()
Definition: MSVehicle.cpp:6389
std::vector< std::vector< LaneQ > > myBestLanes
Definition: MSVehicle.h:1835
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:411
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
Definition: MSVehicle.cpp:1128
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:462
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:372
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:552
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:917
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1823
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSVehicle.h:1633
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1809
DriveItemVector myLFLinkLanes
container for the planned speeds in the current step
Definition: MSVehicle.h:1951
The car-following model and parameter.
Definition: MSVehicleType.h:62
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
int getPersonCapacity() const
Get this vehicle type's person capacity.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
SUMOTime getLoadingDuration() const
Get this vehicle type's loading duration.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
const SUMOVTypeParameter & getParameter() const
int getContainerCapacity() const
Get this vehicle type's container capacity.
const LatAlignmentDefinition & getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment procedure.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:67
const std::string & getID() const
Returns the id.
Definition: Named.h:74
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
double length() const
Returns the length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
double angleAt2D(int pos) const
get angle in certain position of position vector
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:197
double carriageLength
the length of train carriages and locomotive
bool wasSet(int what) const
Returns whether the given parameter was set.
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
SubParams lcParameter
Lane-changing parameter.
SubParams jmParameter
Junction-model parameter.
std::string getManoeuverAngleTimesS() const
Returns myManoeuverAngleTimes as a string for xml output.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
int parametersSet
Information for the output which parameter were set.
int index
at which position in the stops list
SUMOTime until
The time at which the vehicle may continue its journey.
bool triggered
whether an arriving person lets the vehicle continue
double endPos
The stopping position end.
bool parking
whether the vehicle is removed from the net while stopping
std::string busstop
(Optional) bus stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
std::string line
The vehicle's line (mainly for public transport)
static StringBijection< SumoXMLTag > CarFollowModels
car following models
static StringBijection< LaneChangeModel > LaneChangeModels
lane change models
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
#define M_PI
Definition: odrSpiral.cpp:40
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Drive process items represent bounds on the safe velocity corresponding to the upcoming links.
Definition: MSVehicle.h:1894
double getLeaveSpeed() const
Definition: MSVehicle.h:1941