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-2020 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/MSStop.h>
57 #include <gui/GUIGlobals.h>
58 
59 #include "GUIVehicle.h"
60 #include "GUIPerson.h"
61 #include "GUIContainer.h"
62 #include "GUINet.h"
63 #include "GUIEdge.h"
64 #include "GUILane.h"
65 
66 #define SPEEDMODE_DEFAULT 31
67 #define LANECHANGEMODE_DEFAULT 1621
68 
69 //#define DEBUG_FOES
70 
71 // ===========================================================================
72 // FOX callback mapping
73 // ===========================================================================
74 
75 // Object implementation
76 
77 
78 /* -------------------------------------------------------------------------
79  * GUIVehicle - methods
80  * ----------------------------------------------------------------------- */
81 #ifdef _MSC_VER
82 #pragma warning(push)
83 #pragma warning(disable: 4355)
84 #endif
86  MSVehicleType* type, const double speedFactor) :
87  MSVehicle(pars, route, type, speedFactor),
88  GUIBaseVehicle((MSBaseVehicle&) * this) {
89 }
90 #ifdef _MSC_VER
91 #pragma warning(pop)
92 #endif
93 
94 
96 }
97 
98 
102  const bool isElecHybrid = getDevice(typeid(MSDevice_ElecHybrid)) != nullptr ? true : false;
103  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
104  // add items
105  ret->mkItem("lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLaneID));
107  ret->mkItem("shadow lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getShadowLaneID));
108  }
110  ret->mkItem("target lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getTargetLaneID));
111  }
112  if (isSelected()) {
113  ret->mkItem("back lane [id]", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getBackLaneID));
114  }
115  ret->mkItem("position [m]", true,
117  ret->mkItem("lateral offset [m]", true,
119  ret->mkItem("speed [m/s]", true,
121  ret->mkItem("lateral speed [m/s]", true,
123  ret->mkItem("acceleration [m/s^2]", true,
125  ret->mkItem("angle [degree]", true,
127  ret->mkItem("slope [degree]", true,
129  ret->mkItem("speed factor", false, getChosenSpeedFactor());
130  ret->mkItem("time gap on lane [s]", true,
132  ret->mkItem("waiting time [s]", true,
134  ret->mkItem(("waiting time (accumulated, " + time2string(MSGlobals::gWaitingTimeMemory) + "s) [s]").c_str(), true,
136  ret->mkItem("time loss [s]", true,
138  ret->mkItem("impatience", true,
140  ret->mkItem("last lane change [s]", true,
142  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
143  ret->mkItem("depart delay [s]", false, time2string(getDepartDelay()));
144  ret->mkItem("odometer [m]", true,
146  if (getParameter().repetitionNumber < std::numeric_limits<int>::max()) {
147  ret->mkItem("remaining [#]", false, (int) getParameter().repetitionNumber - getParameter().repetitionsDone);
148  }
149  if (getParameter().repetitionOffset > 0) {
150  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
151  }
152  if (getParameter().repetitionProbability > 0) {
153  ret->mkItem("insertion probability", false, getParameter().repetitionProbability);
154  }
155  ret->mkItem("stop info", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getStopInfo));
156  ret->mkItem("line", false, myParameter->line);
157  ret->mkItem("CO2 [mg/s]", true,
159  ret->mkItem("CO [mg/s]", true,
161  ret->mkItem("HC [mg/s]", true,
163  ret->mkItem("NOx [mg/s]", true,
165  ret->mkItem("PMx [mg/s]", true,
167  ret->mkItem("fuel [ml/s]", true,
169  ret->mkItem("electricity [Wh/s]", true,
171  ret->mkItem("noise (Harmonoise) [dB]", true,
173  ret->mkItem("devices", false, getDeviceDescription());
174  ret->mkItem("persons", true,
176  ret->mkItem("containers", true,
178  ret->mkItem("lcState right", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateRight));
179  ret->mkItem("lcState left", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateLeft));
180  // close building
182  ret->mkItem("lcState center", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateCenter));
183  ret->mkItem("right side on edge [m]", true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getRightSideOnEdge2));
184  ret->mkItem("left side on edge [m]", true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getLeftSideOnEdge));
185  ret->mkItem("rightmost edge sublane [#]", true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getRightSublaneOnEdge));
186  ret->mkItem("leftmost edge sublane [#]", true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getLeftSublaneOnEdge));
187  ret->mkItem("lane change maneuver distance [m]", true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getManeuverDist));
188  }
189  if (isElecHybrid) {
190  ret->mkItem("actual state of charge [Wh]", true,
192  ret->mkItem("actual electric current [A]", true,
194  }
195  if (hasInfluencer()) {
197  ret->mkItem("speed mode", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getSpeedMode));
198  }
200  ret->mkItem("lane change mode", true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLaneChangeMode));
201  }
202  }
203  ret->closeBuilding(&getParameter());
204  return ret;
205 }
206 
207 
211  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
212  // add items
213  ret->mkItem("Type Information:", false, "");
214  ret->mkItem("type [id]", false, myType->getID());
215  ret->mkItem("length", false, myType->getLength());
216  ret->mkItem("width", false, myType->getWidth());
217  ret->mkItem("height", false, myType->getHeight());
218  ret->mkItem("minGap", false, myType->getMinGap());
219  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
220  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
221  ret->mkItem("carFollowModel", false, SUMOXMLDefinitions::CarFollowModels.getString((SumoXMLTag)getCarFollowModel().getModelID()));
222  ret->mkItem("LaneChangeModel", false, SUMOXMLDefinitions::LaneChangeModels.getString(getLaneChangeModel().getModelID()));
223  ret->mkItem("guiShape", false, getVehicleShapeName(myType->getGuiShape()));
224  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
225  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
226  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
227  ret->mkItem("emergency deceleration [m/s^2]", false, getCarFollowModel().getEmergencyDecel());
228  ret->mkItem("apparent deceleration [m/s^2]", false, getCarFollowModel().getApparentDecel());
229  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
230  ret->mkItem("desired headway (tau)", false, getCarFollowModel().getHeadwayTime());
232  ret->mkItem("action step length [s]", false, myType->getActionStepLengthSecs());
233  }
234  ret->mkItem("person capacity", false, myType->getPersonCapacity());
235  ret->mkItem("boarding time", false, STEPS2TIME(myType->getBoardingDuration()));
236  ret->mkItem("container capacity", false, myType->getContainerCapacity());
237  ret->mkItem("loading time", false, STEPS2TIME(myType->getLoadingDuration()));
239  ret->mkItem("minGapLat", false, myType->getMinGapLat());
240  ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
241  ret->mkItem("latAlignment", false, toString(myType->getPreferredLateralAlignment()));
242  } else if (MSGlobals::gLaneChangeDuration > 0) {
243  ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
244  }
245  for (auto item : myType->getParameter().lcParameter) {
246  ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
247  }
248  for (auto item : myType->getParameter().jmParameter) {
249  ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
250  }
252  ret->mkItem("manoeuver Angle vs Times", false, myType->getParameter().getManoeuverAngleTimesS());
253  }
254 
255  // close building
256  ret->closeBuilding(&(myType->getParameter()));
257  return ret;
258 }
259 
260 
261 
262 void
264  glTranslated(0, 0, getType() + .2); // draw on top of cars
265  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
266  if ((*i).myLink == nullptr) {
267  continue;
268  }
269  MSLink* link = (*i).myLink;
270  MSLane* via = link->getViaLaneOrLane();
271  if (via != nullptr) {
272  Position p = via->getShape()[0];
273  if ((*i).mySetRequest) {
274  glColor3d(0, .8, 0);
275  } else {
276  glColor3d(.8, 0, 0);
277  }
278  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
279  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLength());
280  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleName.size / s.scale);
281  // the time slot that ego vehicle uses when checking opened may
282  // differ from the one it requests in setApproaching
283  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
284  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
285  UNUSED_PARAMETER(avi); // only used for assertion
286  }
287  }
288  glTranslated(0, 0, getType() - .2); // draw on top of cars
289 }
290 
291 
292 void
294  RGBColor current = GLHelper::getColor();
295  RGBColor darker = current.changedBrightness(-51);
296  const double exaggeration = s.vehicleSize.getExaggeration(s, this);
297  const double totalLength = getVType().getLength();
298  double upscaleLength = exaggeration;
299  if (exaggeration > 1 && totalLength > 5) {
300  // reduce the length/width ratio because this is not usefull at high zoom
301  const double widthLengthFactor = totalLength / getVType().getWidth();
302  const double shrinkFactor = MIN2(widthLengthFactor, sqrt(upscaleLength));
303  upscaleLength /= shrinkFactor;
304  }
305  const double locomotiveLength = getVehicleType().getParameter().locomotiveLength * upscaleLength;
306  if (exaggeration == 0) {
307  return;
308  }
309  const double defaultLength = getVehicleType().getParameter().carriageLength * upscaleLength;
310  const double carriageGap = getVehicleType().getParameter().carriageGap * upscaleLength;
311  const double length = totalLength * upscaleLength;
312  const double halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
313  glPopMatrix(); // undo initial translation and rotation
314  const double xCornerCut = 0.3 * exaggeration;
315  const double yCornerCut = 0.4 * exaggeration;
316  // round to closest integer
317  const int numCarriages = MAX2(1, 1 + (int)((length - locomotiveLength) / (defaultLength + carriageGap) + 0.5));
318  assert(numCarriages > 0);
319  double carriageLengthWithGap = length / numCarriages;
320  double carriageLength = carriageLengthWithGap - carriageGap;
321  double firstCarriageLength = carriageLength;
322  if (defaultLength != locomotiveLength && numCarriages > 1) {
323  firstCarriageLength = locomotiveLength;
324  carriageLengthWithGap = (length - locomotiveLength) / (numCarriages - 1);
325  carriageLength = carriageLengthWithGap - carriageGap;
326  }
327  const int firstPassengerCarriage = defaultLength == locomotiveLength || numCarriages == 1 || (getVClass() & SVC_RAIL_CLASSES) == 0 ? 0 : 1;
328  const int firstContainerCarriage = numCarriages == 1 || getVehicleType().getGuiShape() == SVS_TRUCK_1TRAILER ? 0 : 1;
329  const int seatsPerCarriage = (int)ceil(getVType().getPersonCapacity() / (numCarriages - firstPassengerCarriage));
330  const int containersPerCarriage = (int)ceil(getVType().getContainerCapacity() / (numCarriages - firstContainerCarriage));
331  // lane on which the carriage front is situated
332  MSLane* lane = myLane;
333  int furtherIndex = 0;
334  // lane on which the carriage back is situated
335  MSLane* backLane = myLane;
336  int backFurtherIndex = furtherIndex;
337  // offsets of front and back
338  double carriageOffset = myState.pos();
339  double carriageBackOffset = myState.pos() - firstCarriageLength;
340  // handle seats
341  int requiredSeats = getNumPassengers();
342  int requiredPositions = getNumContainers();
343  if (requiredSeats > 0) {
344  mySeatPositions.clear();
345  }
346  if (requiredPositions > 0) {
347  myContainerPositions.clear();
348  }
349  Position front, back;
350  double angle = 0.;
351  // position parking vehicle beside the road or track
352  const double lateralOffset = isParking() ? (SUMO_const_laneWidth * (MSGlobals::gLefthand ? -1 : 1)) : 0;
353 
354  // draw individual carriages
355  double curCLength = firstCarriageLength;
356  //std::cout << SIMTIME << " veh=" << getID() << " curCLength=" << curCLength << " loc=" << locomotiveLength << " car=" << carriageLength << " tlen=" << totalLength << " len=" << length << "\n";
357  for (int i = 0; i < numCarriages; ++i) {
358  if (i > 0) {
359  curCLength = carriageLength;
360  }
361  while (carriageOffset < 0) {
362  MSLane* prev = getPreviousLane(lane, furtherIndex);
363  if (prev != lane) {
364  carriageOffset += prev->getLength();
365  } else {
366  // no lane available for drawing.
367  carriageOffset = 0;
368  }
369  lane = prev;
370  }
371  while (carriageBackOffset < 0) {
372  MSLane* prev = getPreviousLane(backLane, backFurtherIndex);
373  if (prev != backLane) {
374  carriageBackOffset += prev->getLength();
375  } else {
376  // no lane available for drawing.
377  carriageBackOffset = 0;
378  }
379  backLane = prev;
380  }
381  front = lane->geometryPositionAtOffset(carriageOffset, lateralOffset);
382  back = backLane->geometryPositionAtOffset(carriageBackOffset, lateralOffset);
383  if (front == back) {
384  // no place for drawing available
385  continue;
386  }
387  const double drawnCarriageLength = front.distanceTo2D(back);
388  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (double) 180.0 / (double) M_PI;
389  if (i >= firstPassengerCarriage) {
390  computeSeats(front, back, SUMO_const_waitingPersonWidth, seatsPerCarriage, exaggeration, requiredSeats, mySeatPositions);
391  }
392  if (i >= firstContainerCarriage) {
393  computeSeats(front, back, SUMO_const_waitingContainerWidth, containersPerCarriage, exaggeration, requiredPositions, myContainerPositions);
394  }
395  glPushMatrix();
396  glTranslated(front.x(), front.y(), getType());
397  glRotated(angle, 0, 0, 1);
398  if (!asImage || !GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(s, getVType().getImgFile(), this, getVType().getWidth(), curCLength / exaggeration)) {
399  switch (getVType().getGuiShape()) {
401  case SVS_TRUCK_1TRAILER:
402  if (i == 0) {
403  GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth() * exaggeration, curCLength, i);
404  } else {
405  GLHelper::setColor(current);
406  GLHelper::drawBoxLine(Position(0, 0), 180, curCLength, halfWidth);
407  }
408  break;
409  default: {
410  if (i == 0) {
411  GLHelper::setColor(darker);
412  } else {
413  GLHelper::setColor(current);
414  }
415  // generic rail carriage
416  glBegin(GL_TRIANGLE_FAN);
417  glVertex2d(-halfWidth + xCornerCut, 0);
418  glVertex2d(-halfWidth, yCornerCut);
419  glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
420  glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
421  glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
422  glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
423  glVertex2d(halfWidth, yCornerCut);
424  glVertex2d(halfWidth - xCornerCut, 0);
425  glEnd();
426  }
427  }
428  }
429  glPopMatrix();
430  carriageOffset -= (curCLength + carriageGap);
431  carriageBackOffset -= carriageLengthWithGap;
432  }
433  if (getVType().getGuiShape() == SVS_RAIL_CAR) {
434  glPushMatrix();
435  glTranslated(front.x(), front.y(), getType());
436  glRotated(angle, 0, 0, 1);
437  drawAction_drawVehicleBlinker(curCLength);
439  glPopMatrix();
440  }
441  // restore matrix
442  glPushMatrix();
443  front = getPosition();
444  glTranslated(front.x(), front.y(), getType());
445  const double degAngle = RAD2DEG(getAngle() + M_PI / 2.);
446  glRotated(degAngle, 0, 0, 1);
447  glScaled(exaggeration, upscaleLength, 1);
448  if (mySeatPositions.size() == 0) {
449  mySeatPositions.push_back(Seat(back, DEG2RAD(angle)));
450  }
451  if (myContainerPositions.size() == 0) {
452  myContainerPositions.push_back(Seat(back, DEG2RAD(angle)));
453  }
454 }
455 
456 #define BLINKER_POS_FRONT .5
457 #define BLINKER_POS_BACK .5
458 
459 inline void
460 drawAction_drawBlinker(double dir, double length) {
461  glColor3d(1.f, .8f, 0);
462  glPushMatrix();
463  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
465  glPopMatrix();
466  glPushMatrix();
467  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
469  glPopMatrix();
470 }
471 
472 
473 void
476  return;
477  }
478  const double offset = MAX2(.5 * getVehicleType().getWidth(), .4);
480  drawAction_drawBlinker(-offset, length);
481  }
483  drawAction_drawBlinker(offset, length);
484  }
486  drawAction_drawBlinker(-offset, length);
487  drawAction_drawBlinker(offset, length);
488  }
489 }
490 
491 
492 inline void
493 GUIVehicle::drawAction_drawVehicleBrakeLight(double length, bool onlyOne) const {
495  return;
496  }
497  glColor3f(1.f, .2f, 0);
498  glPushMatrix();
499  if (onlyOne) {
500  glTranslated(0, length, -0.1);
502  } else {
503  glTranslated(-getVehicleType().getWidth() * 0.5, length, -0.1);
505  glPopMatrix();
506  glPushMatrix();
507  glTranslated(getVehicleType().getWidth() * 0.5, length, -0.1);
509  }
510  glPopMatrix();
511 }
512 
513 inline void
516  glPushMatrix();
517  glTranslated(0, 2.5, .5);
518  glColor3f(0, 0, 1);
520  glPopMatrix();
521  }
522 }
523 
524 
525 double
526 GUIVehicle::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
527  switch (activeScheme) {
528  case 8:
529  return getSpeed();
530  case 9:
531  // color by action step
532  if (isActionStep(SIMSTEP)) {
533  // Upcoming simstep is actionstep (t was already increased before drawing)
534  return 1.;
535  } else if (isActive()) {
536  // Completed simstep was actionstep
537  return 2.;
538  } else {
539  // not active
540  return 0.;
541  }
542  case 10:
543  return getWaitingSeconds();
544  case 11:
546  case 12:
547  return getLastLaneChangeOffset();
548  case 13:
549  return getLane()->getVehicleMaxSpeed(this);
550  case 14:
551  return getCO2Emissions();
552  case 15:
553  return getCOEmissions();
554  case 16:
555  return getPMxEmissions();
556  case 17:
557  return getNOxEmissions();
558  case 18:
559  return getHCEmissions();
560  case 19:
561  return getFuelConsumption();
562  case 20:
564  case 21:
565  return getNumberReroutes();
566  case 22:
568  case 23:
569  return getLaneChangeModel().isOpposite() ? -100 : getBestLaneOffset();
570  case 24:
571  return getAcceleration();
572  case 25:
573  return getTimeGapOnLane();
574  case 26:
575  return STEPS2TIME(getDepartDelay());
576  case 27:
577  return getElectricityConsumption();
578  case 28:
579  return getTimeLossSeconds();
580  case 29:
581  return getStopDelay();
582  case 30:
583  return getStopArrivalDelay();
584  case 31:
585  return getLaneChangeModel().getSpeedLat();
586  case 32: // by numerical param value
587  std::string error;
588  std::string val = getPrefixedParameter(s.vehicleParam, error);
589  try {
590  if (val == "") {
591  return 0;
592  } else {
593  return StringUtils::toDouble(val);
594  }
595  } catch (NumberFormatException&) {
596  try {
597  return StringUtils::toBool(val);
598  } catch (BoolFormatException&) {
599  WRITE_WARNING("Vehicle parameter '" + myParameter->getParameter(s.vehicleParam, "0") + "' key '" + s.vehicleParam + "' is not a number for vehicle '" + getID() + "'");
600  return -1;
601  }
602  }
603  }
604  return 0;
605 }
606 
607 
608 void
610  myLock.lock();
611  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
612  myLock.unlock();
613  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
614  std::vector<MSVehicle::LaneQ>& lanes = *j;
615  double gmax = -1;
616  double rmax = -1;
617  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
618  gmax = MAX2((*i).length, gmax);
619  rmax = MAX2((*i).occupation, rmax);
620  }
621  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
622  const PositionVector& shape = (*i).lane->getShape();
623  double g = (*i).length / gmax;
624  double r = (*i).occupation / rmax;
625  glColor3d(r, g, 0);
626  double width = 0.5 / (1 + abs((*i).bestLaneOffset));
627  GLHelper::drawBoxLines(shape, width);
628 
629  PositionVector s1 = shape;
630  s1.move2side((double) .1);
631  glColor3d(r, 0, 0);
632  GLHelper::drawLine(s1);
633  s1.move2side((double) - .2);
634  glColor3d(0, g, 0);
635  GLHelper::drawLine(s1);
636 
637  glColor3d(r, g, 0);
638  }
639  }
640 }
641 
642 
643 void
644 GUIVehicle::drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r, bool future, bool noLoop, const RGBColor& col) const {
645  const double exaggeration = s.vehicleSize.getExaggeration(s, this) * (s.gaming ? 0.5 : 1);
646  MSRouteIterator start = future ? myCurrEdge : r.begin();
647  MSRouteIterator i = start;
648  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
649  // draw continuation lanes when drawing the current route where available
650  int bestLaneIndex = (&r == myRoute ? 0 : (int)bestLaneConts.size());
651  std::map<const MSLane*, int> repeatLane; // count repeated occurrences of the same edge
652  const double textSize = s.vehicleName.size / s.scale;
653  const GUILane* prevLane = nullptr;
654  int reversalIndex = 0;
655  const int indexDigits = (int)toString(r.size()).size();
656  for (; i != r.end(); ++i) {
657  const GUILane* lane;
658  if (bestLaneIndex < (int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
659  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
660  ++bestLaneIndex;
661  } else {
662  const std::vector<MSLane*>* allowed = (*i)->allowedLanes(getVClass());
663  if (allowed != nullptr && allowed->size() != 0) {
664  lane = static_cast<GUILane*>((*allowed)[0]);
665  } else {
666  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
667  }
668  }
669  GLHelper::setColor(col);
670  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
671  if (prevLane != nullptr && lane->getBidiLane() == prevLane) {
672  // indicate train reversal
673  std::string label = "reverse:" + toString(reversalIndex++);
674  Position pos = lane->geometryPositionAtOffset(lane->getLength() / 2) - Position(0, textSize * repeatLane[lane]);
675  GLHelper::drawTextSettings(s.vehicleValue, label, pos, s.scale, s.angle, 1.0);
676  }
677  if (s.showRouteIndex) {
678  std::string label = toString((int)(i - myCurrEdge));
679  const double laneAngle = lane->getShape().angleAt2D(0);
680  Position pos = lane->getShape().front() - Position(0, textSize * repeatLane[lane]) + Position(
681  (laneAngle >= -0.25 * M_PI && laneAngle < 0.75 * M_PI ? 1 : -1) * 0.4 * indexDigits * textSize, 0);
682  //GLHelper::drawText(label, pos, 1.0, textSize, s.vehicleName.color);
683  GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
684  }
685  repeatLane[lane]++;
686  prevLane = lane;
687  if (noLoop && i != start && (*i) == (*start)) {
688  break;
689  }
690  }
691  // draw stop labels
692  // (vertical shift for repeated stops at the same position
693  std::map<std::pair<const MSLane*, double>, int> repeat; // count repeated occurrences of the same position
694  int stopIndex = 0;
695  for (const MSStop& stop : myStops) {
696  double stopLanePos;
697  if (stop.pars.speed > 0) {
698  stopLanePos = stop.reached ? stop.pars.endPos : stop.pars.startPos;
699  } else {
700  stopLanePos = stop.reached ? getPositionOnLane() : MAX2(0.0, stop.getEndPos(*this));
701  }
702  Position pos = stop.lane->geometryPositionAtOffset(stopLanePos);
703  GLHelper::setColor(col);
704  GLHelper::drawBoxLines(stop.lane->getShape().getOrthogonal(pos, 10, true, stop.lane->getWidth()), 0.1);
705  std::string label = stop.pars.speed > 0 ? "waypoint" : (stop.reached ? "stopped" : "stop " + toString(stopIndex));
706 #ifdef _DEBUG
707  label += " (" + toString(stop.edge - myCurrEdge) + "e)";
708 #endif
709  if (isStoppedTriggered()) {
710  label += " triggered:";
711  if (stop.triggered) {
712  label += "person";
713  if (stop.numExpectedPerson > 0) {
714  label += "(" + toString(stop.numExpectedPerson) + ")";
715  }
716  }
717  if (stop.containerTriggered) {
718  label += "container";
719  if (stop.numExpectedContainer > 0) {
720  label += "(" + toString(stop.numExpectedContainer) + ")";
721  }
722  }
723  if (stop.joinTriggered) {
724  label += "join";
725  if (stop.pars.join != "") {
726  label += "(" + stop.pars.join + ")";
727  }
728  }
729  }
730  if (stop.pars.until >= 0) {
731  label += " until:" + time2string(stop.pars.until);
732  }
733  if (stop.duration >= 0 || stop.pars.duration > 0) {
734  if (STEPS2TIME(stop.duration) > 3600 * 24) {
735  label += " duration:1day+";
736  } else {
737  label += " duration:" + time2string(stop.duration);
738  }
739  }
740  if (stop.pars.speed > 0) {
741  label += " speed:" + toString(stop.pars.speed);
742  }
743  std::pair<const MSLane*, double> stopPos = std::make_pair(stop.lane, stopLanePos);
744  const double nameSize = s.vehicleName.size / s.scale;
745  Position pos2 = pos - Position(0, nameSize * repeat[stopPos]);
746  if (noLoop && repeat[stopPos] > 0) {
747  break;
748  }
749  GLHelper::drawTextSettings(s.vehicleText, label, pos2, s.scale, s.angle, 1.0);
750  repeat[stopPos]++;
751  stopIndex++;
752  }
753 }
754 
755 
756 
757 MSLane*
758 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
759  if (furtherIndex < (int)myFurtherLanes.size()) {
760  return myFurtherLanes[furtherIndex++];
761  } else {
762  // try to use route information
763  int routeIndex = getRoutePosition();
764  bool resultInternal;
765  if (MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks()) {
766  if (myLane->isInternal()) {
767  if (furtherIndex % 2 == 0) {
768  routeIndex -= (furtherIndex + 0) / 2;
769  resultInternal = false;
770  } else {
771  routeIndex -= (furtherIndex + 1) / 2;
772  resultInternal = false;
773  }
774  } else {
775  if (furtherIndex % 2 != 0) {
776  routeIndex -= (furtherIndex + 1) / 2;
777  resultInternal = false;
778  } else {
779  routeIndex -= (furtherIndex + 2) / 2;
780  resultInternal = true;
781  }
782  }
783  } else {
784  routeIndex -= furtherIndex;
785  resultInternal = false;
786  }
787  furtherIndex++;
788  if (routeIndex >= 0) {
789  if (resultInternal) {
790  const MSEdge* prevNormal = myRoute->getEdges()[routeIndex];
791  for (MSLane* cand : prevNormal->getLanes()) {
792  for (MSLink* link : cand->getLinkCont()) {
793  if (link->getLane() == current) {
794  if (link->getViaLane() != nullptr) {
795  return link->getViaLane();
796  } else {
797  return const_cast<MSLane*>(link->getLaneBefore());
798  }
799  }
800  }
801  }
802  } else {
803  return myRoute->getEdges()[routeIndex]->getLanes()[0];
804  }
805  }
806  }
807  return current;
808 }
809 
810 
811 double
814 }
815 
816 
817 std::string
819  std::string result = "";
820  if (isParking()) {
821  result += "parking";
822  } else if (isStopped()) {
823  result += "stopped";
824  } else if (hasStops()) {
825  return "next: " + myStops.front().getDescription();
826  } else {
827  return "";
828  }
829  if (myStops.front().pars.triggered) {
830  result += ", triggered";
831  } else if (myStops.front().pars.containerTriggered) {
832  result += ", containerTriggered";
833  } else if (myStops.front().collision) {
834  result += ", collision";
835  } else if (myStops.front().pars.until != -1) {
836  result += ", until=" + time2string(myStops.front().pars.until);
837  } else {
838  result += ", duration=" + time2string(myStops.front().duration);
839  }
840  return result;
841 }
842 
843 
844 void
846  double dist = myLane->getLength() - getPositionOnLane();
847 #ifdef DEBUG_FOES
848  std::cout << SIMTIME << " selectBlockingFoes veh=" << getID() << " dist=" << dist << " numLinks=" << myLFLinkLanes.size() << "\n";
849 #endif
850  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
851  const DriveProcessItem& dpi = *i;
852  if (dpi.myLink == nullptr) {
854  continue;
855  }
856  MSLink::BlockingFoes blockingFoes;
857  std::vector<const MSPerson*> blockingPersons;
858 #ifdef DEBUG_FOES
859  std::cout << " foeLink=" << dpi.myLink->getViaLaneOrLane()->getID() << "\n";
860  const bool isOpen =
861 #endif
863  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), getLateralPositionOnLane(), &blockingFoes);
864 #ifdef DEBUG_FOES
865  if (!isOpen) {
866  std::cout << " closed due to:\n";
867  for (const auto& item : blockingFoes) {
868  std::cout << " " << item->getID() << "\n";
869  }
870  }
871 #endif
872  if (getLaneChangeModel().getShadowLane() != nullptr) {
873  MSLink* parallelLink = dpi.myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
874  if (parallelLink != nullptr) {
875  const double shadowLatPos = getLateralPositionOnLane() - getLaneChangeModel().getShadowDirection() * 0.5 * (
877 #ifdef DEBUG_FOES
878  const bool isShadowOpen =
879 #endif
880  parallelLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
883  getWaitingTime(), shadowLatPos, &blockingFoes);
884 #ifdef DEBUG_FOES
885  if (!isShadowOpen) {
886  std::cout << " foes at shadow link=" << parallelLink->getViaLaneOrLane()->getID() << ":\n";
887  for (const auto& item : blockingFoes) {
888  std::cout << " " << item->getID() << "\n";
889  }
890  }
891 #endif
892  }
893  }
894  for (const auto& item : blockingFoes) {
895  gSelected.select(static_cast<const GUIVehicle*>(item)->getGlID());
896  }
897 #ifdef DEBUG_FOES
898  gDebugFlag1 = true;
899 #endif
900  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(this, dist, &blockingPersons);
901 #ifdef DEBUG_FOES
902  gDebugFlag1 = false;
903 #endif
904  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
905  // the vehicle to enter the junction first has priority
906  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
907  if (leader != nullptr) {
908  if (isLeader(dpi.myLink, leader)) {
909  gSelected.select(leader->getGlID());
910 #ifdef DEBUG_FOES
911  std::cout << " linkLeader=" << leader->getID() << "\n";
912 #endif
913  }
914  } else {
915  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
916  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
917  if (foe != nullptr) {
918  gSelected.select(foe->getGlID());
919  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
920  }
921  }
922  }
923  }
924  dist += dpi.myLink->getViaLaneOrLane()->getLength();
925  }
926 }
927 
928 
929 void
932  GUISUMOAbstractView* view = mw->getActiveView();
933  if (view != nullptr) {
934  if (add) {
937  view->addAdditionalGLVisualisation(this);
938  }
939  } else {
942  }
943  }
944 }
945 
946 bool
949 }
950 
951 int
953  const double rightSide = getRightSideOnEdge();
954  const std::vector<double>& sublaneSides = myLane->getEdge().getSubLaneSides();
955  for (int i = 0; i < (int)sublaneSides.size(); ++i) {
956  if (sublaneSides[i] > rightSide) {
957  return MAX2(i - 1, 0);
958  }
959  }
960  return (int)sublaneSides.size() - 1;
961 }
962 
963 int
965  const double leftSide = getLeftSideOnEdge();
966  const std::vector<double>& sublaneSides = myLane->getEdge().getSubLaneSides();
967  for (int i = (int)sublaneSides.size() - 1; i >= 0; --i) {
968  if (sublaneSides[i] < leftSide) {
969  return i;
970  }
971  }
972  return -1;
973 }
974 
975 
976 std::string
978  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(-1).second);
979 }
980 
981 std::string
983  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(1).second);
984 }
985 
986 std::string
988  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(0).second);
989 }
990 
991 std::string
993  return Named::getIDSecure(myLane, "n/a");
994 }
995 
996 std::string
998  return myFurtherLanes.size() > 0 ? myFurtherLanes.back()->getID() : getLaneID();
999 }
1000 
1001 std::string
1003  return Named::getIDSecure(getLaneChangeModel().getShadowLane(), "");
1004 }
1005 
1006 std::string
1008  return Named::getIDSecure(getLaneChangeModel().getTargetLane(), "");
1009 }
1010 
1011 double
1014 }
1015 
1016 std::string
1018  return std::bitset<5>(getInfluencer()->getSpeedMode()).to_string();
1019 }
1020 
1021 std::string
1023  return std::bitset<12>(getInfluencer()->getLaneChangeMode()).to_string();
1024 }
1025 
1026 void
1028  SUMOTime intermediateDuration = TIME2STEPS(20);
1029  SUMOTime finalDuration = SUMOTime_MAX;
1030  if (myParameter->stops.size() >= 2) {
1031  // copy durations from the original stops
1032  intermediateDuration = myParameter->stops.front().duration;
1033  finalDuration = myParameter->stops.back().duration;
1034  }
1035  // if the stop is already in the list of stops, cancel all stops that come
1036  // after it and set the stop duration
1037  std::string line = "";
1038  int destinations = 0;
1039  bool add = true;
1040  for (auto it = myStops.begin(); it != myStops.end(); it++) {
1041  if (!it->reached && destinations < 2 && it->busstop != nullptr) {
1042  line += it->busstop->getID();
1043  destinations++;
1044  }
1045  if (it->busstop == busStop) {
1046  it->duration = finalDuration;
1047  myStops.erase(++it, myStops.end());
1048  add = false;
1049  break;
1050  } else {
1051  it->duration = MIN2(it->duration, intermediateDuration);
1052  }
1053  }
1054  if (destinations < 2) {
1055  line += busStop->getID();
1056  }
1057  if (add) {
1058  // create new stop
1060  stopPar.busstop = busStop->getID();
1061  stopPar.lane = busStop->getLane().getID();
1062  stopPar.startPos = busStop->getBeginLanePosition();
1063  stopPar.endPos = busStop->getEndLanePosition();
1064  stopPar.duration = finalDuration;
1065  stopPar.until = -1;
1066  stopPar.triggered = false;
1067  stopPar.containerTriggered = false;
1068  stopPar.parking = false;
1069  stopPar.index = STOP_INDEX_FIT;
1071  // clean up prior route to improve visualisation, ensure that the stop can be added immediately
1072  ConstMSEdgeVector edges = myRoute->getEdges();
1073  edges.erase(edges.begin(), edges.begin() + getRoutePosition());
1074  edges.push_back(&busStop->getLane().getEdge());
1075  replaceRouteEdges(edges, -1, 0, "DRT.tmp", false, false, false);
1076  std::string errorMsg;
1077  // add stop
1078  addStop(stopPar, errorMsg);
1079  }
1080  const bool hasReroutingDevice = getDevice(typeid(MSDevice_Routing)) != nullptr;
1081  SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = hasReroutingDevice
1084  // reroute to ensure the new stop is reached
1085  reroute(MSNet::getInstance()->getCurrentTimeStep(), "DRT", router);
1086  myParameter->line = line;
1087  assert(haveValidStopEdges());
1088 }
1089 
1090 
1091 /****************************************************************************/
@ GLO_VEHICLE
a vehicle
GUISelectedStorage gSelected
A global holder of selected objects.
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:456
#define LANECHANGEMODE_DEFAULT
Definition: GUIVehicle.cpp:67
#define SPEEDMODE_DEFAULT
Definition: GUIVehicle.cpp:66
void drawAction_drawBlinker(double dir, double length)
Definition: GUIVehicle.cpp:460
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:457
#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:276
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:32
#define SIMTIME
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:31
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
@ SVS_TRUCK_SEMITRAILER
render as a semi-trailer transport vehicle ("Sattelschlepper")
@ SVS_RAIL_CAR
render as a (city) rail without locomotive
@ SVS_TRUCK_1TRAILER
render as a transport vehicle with one trailer
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.
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:31
const double SUMO_const_laneWidth
Definition: StdDefs.h:47
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
const double SUMO_const_waitingContainerWidth
Definition: StdDefs.h:56
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:54
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:273
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:347
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:181
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:452
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:135
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:529
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.
int getNumContainers() const
return the number of passengers
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
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.
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:919
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:931
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:925
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.
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:947
int getLeftSublaneOnEdge() const
Definition: GUIVehicle.cpp:964
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:526
void selectBlockingFoes() const
adds the blocking foes to the current selection
Definition: GUIVehicle.cpp:845
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIVehicle.cpp:209
void drawBestLanes() const
Draws the vehicle's best lanes.
Definition: GUIVehicle.cpp:609
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
Definition: GUIVehicle.cpp:930
int getRightSublaneOnEdge() const
return the righmost sublane on the edge occupied by the vehicle
Definition: GUIVehicle.cpp:952
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
Definition: GUIVehicle.cpp:758
std::string getStopInfo() const
retrieve information about the current stop state
Definition: GUIVehicle.cpp:818
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:100
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:85
void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const
draws the given guiShape with distinct carriages/modules
Definition: GUIVehicle.cpp:293
std::string getShadowLaneID() const
double getManeuverDist() const
return the lane-change maneuver distance
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
std::string getBackLaneID() const
Definition: GUIVehicle.cpp:997
void drawAction_drawVehicleBlinker(double length) const
Definition: GUIVehicle.cpp:474
void rerouteDRTStop(MSStoppingPlace *busStop)
handle route to accomodate to given stop
std::string getLCStateRight() const
return the lanechange state
Definition: GUIVehicle.cpp:977
void drawAction_drawVehicleBlueLight() const
Definition: GUIVehicle.cpp:514
double getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
Definition: GUIVehicle.cpp:812
std::string getLaneID() const
return vehicle lane id
Definition: GUIVehicle.cpp:992
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:263
std::string getTargetLaneID() const
std::string getLCStateLeft() const
Definition: GUIVehicle.cpp:982
void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
Definition: GUIVehicle.cpp:493
void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future, bool noLoop, const RGBColor &col) const
Draws the route.
Definition: GUIVehicle.cpp:644
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:95
std::string getLCStateCenter() const
Definition: GUIVehicle.cpp:987
std::string getLaneChangeMode() const
return the lane change mode as bit string
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
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings vehicleText
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)
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
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)
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
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,...
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 isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
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.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:216
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:166
const std::vector< double > getSubLaneSides() const
Returns the right side offsets of this edge's sublanes.
Definition: MSEdge.h:606
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
Definition: MSGlobals.h:127
static double gLateralResolution
Definition: MSGlobals.h:82
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:136
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:79
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
Definition: MSGlobals.h:97
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:66
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
double getLength() const
Returns the lane's length.
Definition: MSLane.h:539
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:517
bool isInternal() const
Definition: MSLane.cpp:2036
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:476
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:3835
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:555
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:503
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1199
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
Definition: MSStop.h:44
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.
double pos() const
Position of this state.
Definition: MSVehicle.h:107
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
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:5479
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
Definition: MSVehicle.cpp:5353
double getStopDelay() const
Returns the public transport stop delay in seconds.
Definition: MSVehicle.cpp:6693
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:637
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
Definition: MSVehicle.h:603
double getTimeLossSeconds() const
Returns the time loss in seconds.
Definition: MSVehicle.h:685
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
Definition: MSVehicle.h:679
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:4699
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle.
Definition: MSVehicle.h:610
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1863
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:1159
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:483
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:5106
int getBestLaneOffset() const
Definition: MSVehicle.cpp:5252
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:669
double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
Definition: MSVehicle.cpp:6714
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
Definition: MSVehicle.h:1081
@ VEH_SIGNAL_BRAKELIGHT
The brake lights are on.
Definition: MSVehicle.h:1087
@ VEH_SIGNAL_EMERGENCY_BLUE
A blue emergency light is on.
Definition: MSVehicle.h:1103
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
Definition: MSVehicle.h:1083
@ VEH_SIGNAL_BLINKER_EMERGENCY
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:1085
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
Definition: MSVehicle.cpp:6196
Influencer & getInfluencer()
Definition: MSVehicle.cpp:6059
std::vector< std::vector< LaneQ > > myBestLanes
Definition: MSVehicle.h:1846
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:1111
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:458
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:374
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:550
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:930
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1834
bool hasInfluencer() const
Definition: MSVehicle.h:1651
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1820
DriveItemVector myLFLinkLanes
container for the planned speeds in the current step
Definition: MSVehicle.h:1962
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.
LateralAlignment getPreferredLateralAlignment() const
Get vehicle's preferred lateral alignment.
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
const SUMOVTypeParameter & getParameter() const
int getContainerCapacity() const
Get this vehicle type's container capacity.
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:66
const std::string & getID() const
Returns the id.
Definition: Named.h:73
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:36
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:241
double x() const
Returns the x-position.
Definition: Position.h:54
double y() const
Returns the y-position.
Definition: Position.h:59
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:145
double carriageLength
the length of train carriages and locomotive
bool wasSet(int what) const
Returns whether the given parameter was set.
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:1905
double getLeaveSpeed() const
Definition: MSVehicle.h:1952