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.dev/sumo
3 // Copyright (C) 2001-2024 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>
33 #include <utils/geom/GeomHelper.h>
40 #include <utils/gui/div/GLHelper.h>
44 #include <microsim/MSGlobals.h>
45 #include <microsim/MSVehicle.h>
46 #include <microsim/MSJunction.h>
47 #include <microsim/MSLane.h>
48 #include <microsim/MSLink.h>
49 #include <microsim/MSStop.h>
50 #include <microsim/MSParkingArea.h>
51 #include <microsim/MSTrainHelper.h>
63 #include <gui/GUIGlobals.h>
64 #include "GUIVehicle.h"
65 #include "GUIPerson.h"
66 #include "GUIContainer.h"
67 #include "GUINet.h"
68 #include "GUIEdge.h"
69 #include "GUILane.h"
70 
71 #define SPEEDMODE_DEFAULT 31
72 #define LANECHANGEMODE_DEFAULT 1621
73 
74 //#define DEBUG_FOES
75 
76 // ===========================================================================
77 // FOX callback mapping
78 // ===========================================================================
79 
80 // Object implementation
81 
82 
83 /* -------------------------------------------------------------------------
84  * GUIVehicle - methods
85  * ----------------------------------------------------------------------- */
86 
88  MSVehicleType* type, const double speedFactor) :
89  MSVehicle(pars, route, type, speedFactor),
90  GUIBaseVehicle((MSBaseVehicle&) * this) {
91 }
92 
93 
95 }
96 
97 
101  const bool isElecHybrid = getDevice(typeid(MSDevice_ElecHybrid)) != nullptr ? true : false;
102  const bool hasBattery = getDevice(typeid(MSDevice_Battery)) != nullptr;
103  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
104  // add items
105  ret->mkItem(TL("lane [id]"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLaneID));
106  if (MSGlobals::gSublane) {
107  ret->mkItem(TL("shadow lane [id]"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getShadowLaneID));
108  }
110  ret->mkItem(TL("target lane [id]"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getTargetLaneID));
111  }
112  if (isSelected()) {
113  ret->mkItem(TL("back lanes [id,..]"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getBackLaneIDs));
114  }
115  ret->mkItem(TL("position [m]"), true,
117  ret->mkItem(TL("lateral offset [m]"), true,
119  ret->mkItem(TL("speed [m/s]"), true,
121  ret->mkItem(TL("lateral speed [m/s]"), true,
123  ret->mkItem(TL("acceleration [m/s^2]"), true,
125  ret->mkItem(TL("angle [degree]"), true,
127  ret->mkItem(TL("slope [degree]"), true,
129  ret->mkItem(TL("speed factor"), true,
131  ret->mkItem(TL("time gap on lane [s]"), true,
133  ret->mkItem(TL("waiting time [s]"), true,
135  ret->mkItem(TLF("waiting time (accumulated, % s) [s]", time2string(MSGlobals::gWaitingTimeMemory)).c_str(), true,
137  ret->mkItem(TL("time since startup [s]"), true,
139  ret->mkItem(TL("time loss [s]"), true,
141  ret->mkItem(TL("impatience"), true,
143  ret->mkItem(TL("last lane change [s]"), true,
145  ret->mkItem(TL("desired depart [s]"), false, time2string(getParameter().depart));
146  ret->mkItem(TL("depart delay [s]"), false, time2string(getDepartDelay()));
147  ret->mkItem(TL("odometer [m]"), true,
149  if (getParameter().repetitionNumber < std::numeric_limits<int>::max()) {
150  ret->mkItem(TL("remaining [#]"), false, (int) getParameter().repetitionNumber - getParameter().repetitionsDone);
151  }
152  if (getParameter().repetitionOffset > 0) {
153  ret->mkItem(TL("insertion period [s]"), false, time2string(getParameter().repetitionOffset));
154  }
155  if (getParameter().repetitionProbability > 0) {
156  ret->mkItem(TL("insertion probability"), false, getParameter().repetitionProbability);
157  }
158  if (getParameter().poissonRate > 0) {
159  ret->mkItem(TL("poisson rate"), false, getParameter().poissonRate);
160  }
161  ret->mkItem(TL("stop info"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getStopInfo));
162  ret->mkItem(TL("line"), false, myParameter->line);
163  ret->mkItem(TL("CO2 [mg/s]"), true,
164  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::CO2>));
165  ret->mkItem(TL("CO [mg/s]"), true,
166  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::CO>));
167  ret->mkItem(TL("HC [mg/s]"), true,
168  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::HC>));
169  ret->mkItem(TL("NOx [mg/s]"), true,
170  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::NO_X>));
171  ret->mkItem(TL("PMx [mg/s]"), true,
172  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::PM_X>));
173  ret->mkItem(TL("fuel [mg/s]"), true,
174  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::FUEL>));
175  ret->mkItem(TL("electricity [Wh/s]"), true,
176  new FunctionBinding<GUIVehicle, double>(this, &MSVehicle::getEmissions<PollutantsInterface::ELEC>));
177  ret->mkItem(TL("noise (Harmonoise) [dB]"), true,
179  ret->mkItem(TL("devices"), false, getDeviceDescription());
180  ret->mkItem(TL("persons"), true,
182  ret->mkItem(TL("containers"), true,
184  ret->mkItem(TL("lcState right"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateRight));
185  ret->mkItem(TL("lcState left"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateLeft));
186  ret->mkItem(TL("parking badges"), false, joinToString(getParkingBadges(), " "));
187  // close building
189  ret->mkItem(TL("lcState center"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLCStateCenter));
190  ret->mkItem(TL("right side on edge [m]"), true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getRightSideOnEdge2));
191  ret->mkItem(TL("left side on edge [m]"), true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getLeftSideOnEdge));
192  ret->mkItem(TL("rightmost edge sublane [#]"), true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getRightSublaneOnEdge));
193  ret->mkItem(TL("leftmost edge sublane [#]"), true, new FunctionBinding<GUIVehicle, int>(this, &GUIVehicle::getLeftSublaneOnEdge));
194  ret->mkItem(TL("lane change maneuver distance [m]"), true, new FunctionBinding<GUIVehicle, double>(this, &GUIVehicle::getManeuverDist));
195  }
196  if (hasBattery || isElecHybrid) {
197  ret->mkItem(TL("present state of charge [Wh]"), true,
199  }
200  if (hasBattery) {
201  ret->mkItem(TL("relative state of charge (SoC) [-]"), true,
203  ret->mkItem(TL("currently charging [Wh]"), true,
205  ret->mkItem(TL("maximum charge rate [W]"), true,
207  }
208  if (isElecHybrid) {
209  ret->mkItem(TL("present electric current [A]"), true,
211  }
212  if (hasInfluencer()) {
214  ret->mkItem(TL("speed mode"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getSpeedMode));
215  }
217  ret->mkItem(TL("lane change mode"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getLaneChangeMode));
218  }
219  }
220  ret->closeBuilding(&getParameter());
221  return ret;
222 }
223 
224 
227  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, "vType:" + myType->getID());
228  ret->mkItem(TL("length [m]"), false, myType->getLength());
229  ret->mkItem(TL("width [m]"), false, myType->getWidth());
230  ret->mkItem(TL("height [m]"), false, myType->getHeight());
231  ret->mkItem(TL("minGap [m]"), false, myType->getMinGap());
232  ret->mkItem(TL("vehicle class"), false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
233  ret->mkItem(TL("emission class"), false, PollutantsInterface::getName(myType->getEmissionClass()));
234  ret->mkItem(TL("mass [kg]"), false, myType->getMass());
235  ret->mkItem(TL("car-following model"), false, SUMOXMLDefinitions::CarFollowModels.getString((SumoXMLTag)getCarFollowModel().getModelID()));
236  ret->mkItem(TL("lane-change model"), false, SUMOXMLDefinitions::LaneChangeModels.getString(getLaneChangeModel().getModelID()));
237  ret->mkItem(TL("guiShape"), false, getVehicleShapeName(myType->getGuiShape()));
238  ret->mkItem(TL("maximum speed [m/s]"), false, getVehicleType().getMaxSpeed());
239  ret->mkItem(TL("desired maximum speed [m/s]"), false, getVehicleType().getDesiredMaxSpeed());
240  ret->mkItem(TL("maximum acceleration [m/s^2]"), false, getCarFollowModel().getMaxAccel());
241  ret->mkItem(TL("maximum deceleration [m/s^2]"), false, getCarFollowModel().getMaxDecel());
242  ret->mkItem(TL("emergency deceleration [m/s^2]"), false, getCarFollowModel().getEmergencyDecel());
243  ret->mkItem(TL("apparent deceleration [m/s^2]"), false, getCarFollowModel().getApparentDecel());
244  ret->mkItem(TL("imperfection (sigma)"), false, getCarFollowModel().getImperfection());
245  ret->mkItem(TL("desired headway (tau) [s]"), false, getCarFollowModel().getHeadwayTime());
246  ret->mkItem(TL("speedfactor"), false, myType->getParameter().speedFactor.toStr(gPrecision));
248  ret->mkItem(TL("action step length [s]"), false, myType->getActionStepLengthSecs());
249  }
250  ret->mkItem(TL("person capacity"), false, myType->getPersonCapacity());
251  ret->mkItem(TL("boarding time [s]"), false, STEPS2TIME(myType->getLoadingDuration(true)));
252  ret->mkItem(TL("container capacity"), false, myType->getContainerCapacity());
253  ret->mkItem(TL("loading time [s]"), false, STEPS2TIME(myType->getLoadingDuration(false)));
255  ret->mkItem(TL("minGapLat [m]"), false, myType->getMinGapLat());
256  ret->mkItem(TL("maxSpeedLat [m/s]"), false, myType->getMaxSpeedLat());
257  ret->mkItem(TL("latAlignment"), true, new FunctionBindingString<GUIVehicle>(this, &GUIVehicle::getDynamicAlignment));
258  } else if (MSGlobals::gLaneChangeDuration > 0) {
259  ret->mkItem(TL("maxSpeedLat [m/s]"), false, myType->getMaxSpeedLat());
260  }
261  for (auto item : myType->getParameter().lcParameter) {
262  ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
263  }
264  for (auto item : myType->getParameter().jmParameter) {
265  ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
266  }
268  ret->mkItem(TL("manoeuver Angle vs Times"), false, myType->getParameter().getManoeuverAngleTimesS());
269  }
270  ret->closeBuilding(&(myType->getParameter()));
271  return ret;
272 }
273 
274 
275 std::string
280  std::string align2 = toString(getLaneChangeModel().getDesiredAlignment());
281  if (align2 != align) {
282  align = align2 + " (default: " + align + ")";
283  }
284  return align;
285 }
286 
287 void
289  glTranslated(0, 0, getType() + .2); // draw on top of cars
290  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
291  if ((*i).myLink == nullptr) {
292  continue;
293  }
294  MSLink* link = (*i).myLink;
295  MSLane* via = link->getViaLaneOrLane();
296  if (via != nullptr) {
297  Position p = via->getShape()[0];
298  if ((*i).mySetRequest) {
299  glColor3d(0, .8, 0);
300  } else {
301  glColor3d(.8, 0, 0);
302  }
303  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
304  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLength());
305  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleName.size / s.scale);
306  // the time slot that ego vehicle uses when checking opened may
307  // differ from the one it requests in setApproaching
308  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
309  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
310  UNUSED_PARAMETER(avi); // only used for assertion
311  }
312  }
313  glTranslated(0, 0, getType() - .2); // draw on top of cars
314 }
315 
316 
317 void
319  RGBColor current = GLHelper::getColor();
320  RGBColor darker = current.changedBrightness(-51);
321  const double exaggeration = (s.vehicleSize.getExaggeration(s, this)
323  if (exaggeration == 0) {
324  return;
325  }
326  // bool reversed =
327  MSTrainHelper trainHelper(this, isReversed() && s.drawReversed, s.secondaryShape, exaggeration, s.vehicleQuality);
328  const int numCarriages = trainHelper.getNumCarriages();
329  const int firstPassengerCarriage = trainHelper.getFirstPassengerCarriage();
330  const int noPersonsBackCarriages = (getVehicleType().getGuiShape() == SUMOVehicleShape::TRUCK_SEMITRAILER || getVehicleType().getGuiShape() == SUMOVehicleShape::TRUCK_1TRAILER) && numCarriages > 1 ? 1 : 0;
331  const int firstContainerCarriage = numCarriages == 1 || getVehicleType().getGuiShape() == SUMOVehicleShape::TRUCK_1TRAILER ? 0 : 1;
332  const int seatsPerCarriage = (int)ceil(getVType().getPersonCapacity() / (numCarriages - firstPassengerCarriage - noPersonsBackCarriages));
333  const int containersPerCarriage = (int)ceil(getVType().getContainerCapacity() / (numCarriages - firstContainerCarriage));
334  // Handle seats.
335  int requiredSeats = getNumPassengers();
336  int requiredPositions = getNumContainers();
337  if (requiredSeats > 0) {
338  mySeatPositions.clear();
339  }
340  if (requiredPositions > 0) {
341  myContainerPositions.clear();
342  }
343  GLHelper::popMatrix(); // undo initial translation and rotation
344  const double xCornerCut = 0.3 * exaggeration;
345  const double yCornerCut = 0.4 * trainHelper.getUpscaleLength();
346  Position front, back;
347  double angle = 0.0;
348  double curCLength = trainHelper.getFirstCarriageLength();
349  const std::vector<MSTrainHelper::Carriage*>& carriages = trainHelper.getCarriages();
350  for (int i = 0; i < numCarriages; ++i) {
351  front = carriages[i]->front;
352  back = carriages[i]->back;
353  if (front == back) {
354  // No place for drawing available.
355  continue;
356  }
357  const double drawnCarriageLength = front.distanceTo2D(back);
358  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (double) 180.0 / (double) M_PI;
359  // if we are in reverse 'first' carriages are drawn last so the >= test doesn't work
360  const bool reversed = trainHelper.isReversed();
361  if (reversed) {
362  if (i <= numCarriages - firstPassengerCarriage) {
363  computeSeats(back, front, SUMO_const_waitingPersonWidth, seatsPerCarriage, exaggeration, requiredSeats, mySeatPositions);
364  }
365  if (i <= numCarriages - firstContainerCarriage) {
366  computeSeats(front, back, SUMO_const_waitingContainerWidth, containersPerCarriage, exaggeration, requiredPositions, myContainerPositions);
367  }
368  } else {
369  if (i >= firstPassengerCarriage) {
370  computeSeats(front, back, SUMO_const_waitingPersonWidth, seatsPerCarriage, exaggeration, requiredSeats, mySeatPositions);
371  }
372  if (i >= firstContainerCarriage) {
373  computeSeats(front, back, SUMO_const_waitingContainerWidth, containersPerCarriage, exaggeration, requiredPositions, myContainerPositions);
374  }
375  }
376  curCLength = (i == trainHelper.getFirstCarriageNo() ? trainHelper.getFirstCarriageLength() : trainHelper.getCarriageLength());
378  if (s.trueZ) {
379  glTranslated(front.x(), front.y(), front.z() + 1);
380  } else {
381  glTranslated(front.x(), front.y(), getType());
382  }
383  glRotated(angle, 0, 0, 1);
384  double halfWidth = trainHelper.getHalfWidth();
385  std::string imgFile = getVType().getImgFile();
386  if (asImage && i != trainHelper.getFirstCarriageNo()) {
387  if (getVType().getParameter().hasParameter("carriageImages")) {
388  std::vector<std::string> imgFiles = StringTokenizer(getVType().getParameter().getParameter("carriageImages", ""), ",").getVector();
389  if (imgFiles.size() > 0) {
390  const int carIndex = trainHelper.isReversed() ? numCarriages - i : i;
391  imgFile = imgFiles[MIN2((int)imgFiles.size() - 1, carIndex - 1)];
392  }
393  }
394  }
395  if (!asImage || !GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(s, imgFile, this, getVType().getWidth() * exaggeration, curCLength)) {
396  switch (getVType().getGuiShape()) {
399  if (i == trainHelper.getFirstCarriageNo()) { // at the moment amReversed is only ever set for rail - so has no impact in this call
400  GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth() * exaggeration, curCLength, 0, false, reversed);
401  } else {
402  GLHelper::setColor(current);
403  GLHelper::drawBoxLine(Position(0, 0), 180, curCLength, halfWidth);
404  }
405  break;
406  default: {
407  if (i == trainHelper.getFirstCarriageNo()) {
408  GLHelper::setColor(darker);
409  } else {
410  GLHelper::setColor(current);
411  }
412  // generic rail carriage
413  glBegin(GL_TRIANGLE_FAN);
414  glVertex2d(-halfWidth + xCornerCut, 0);
415  glVertex2d(-halfWidth, yCornerCut);
416  glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
417  glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
418  glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
419  glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
420  glVertex2d(halfWidth, yCornerCut);
421  glVertex2d(halfWidth - xCornerCut, 0);
422  glEnd();
423  // indicate front of the head of the train
424  if (i == trainHelper.getFirstCarriageNo()) {
425  glTranslated(0, 0, 0.1);
426  glColor3d(0, 0, 0);
427  glBegin(GL_TRIANGLE_FAN);
428  if (reversed) { // not quite correct as its drawing at the wrong end of the locomotive - however useful as visual indicator of reverse?
429  glVertex2d(-halfWidth + xCornerCut, yCornerCut);
430  glVertex2d(-halfWidth + 2 * xCornerCut, 3 * yCornerCut);
431  glVertex2d(halfWidth - 2 * xCornerCut, 3 * yCornerCut);
432  glVertex2d(halfWidth - xCornerCut, yCornerCut);
433  } else {
434  glVertex2d(-halfWidth + 2 * xCornerCut, yCornerCut);
435  glVertex2d(-halfWidth + xCornerCut, 3 * yCornerCut);
436  glVertex2d(halfWidth - xCornerCut, 3 * yCornerCut);
437  glVertex2d(halfWidth - 2 * xCornerCut, yCornerCut);
438  }
439  glEnd();
440  glTranslated(0, 0, -0.1);
441  }
442  }
443  }
444  }
446  }
447  if (getVType().getGuiShape() == SUMOVehicleShape::RAIL_CAR) {
449  if (s.trueZ) {
450  glTranslated(front.x(), front.y(), front.z() + 1);
451  } else {
452  glTranslated(front.x(), front.y(), getType());
453  }
454  glRotated(angle, 0, 0, 1);
455  drawAction_drawVehicleBlinker(curCLength);
458  }
459  // restore matrix
461  front = getPosition();
462  glTranslated(front.x(), front.y(), getType());
463  const double degAngle = RAD2DEG(getAngle() + M_PI / 2.);
464  glRotated(degAngle, 0, 0, 1);
465  glScaled(exaggeration, trainHelper.getUpscaleLength(), 1);
466  if (mySeatPositions.size() == 0) {
467  mySeatPositions.push_back(Seat(back, DEG2RAD(angle)));
468  }
469  if (myContainerPositions.size() == 0) {
470  myContainerPositions.push_back(Seat(back, DEG2RAD(angle)));
471  }
472 }
473 
474 #define BLINKER_POS_FRONT .5
475 #define BLINKER_POS_BACK .5
476 
477 inline void
478 drawAction_drawBlinker(double dir, double length) {
479  glColor3d(1.f, .8f, 0);
481  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
485  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
488 }
489 
490 
491 void
494  return;
495  }
496  const double offset = MAX2(.5 * getVehicleType().getWidth(), .4);
498  drawAction_drawBlinker(-offset, length);
499  }
501  drawAction_drawBlinker(offset, length);
502  }
504  drawAction_drawBlinker(-offset, length);
505  drawAction_drawBlinker(offset, length);
506  }
507 }
508 
509 
510 inline void
511 GUIVehicle::drawAction_drawVehicleBrakeLight(double length, bool onlyOne) const {
513  return;
514  }
515  glColor3f(1.f, .2f, 0);
517  if (onlyOne) {
518  glTranslated(0, length, -0.1);
520  } else {
521  glTranslated(-getVehicleType().getWidth() * 0.5, length, -0.1);
525  glTranslated(getVehicleType().getWidth() * 0.5, length, -0.1);
527  }
529 }
530 
531 inline void
535  glTranslated(0, 2.5, .5);
536  glColor3f(0, 0, 1);
539  }
540 }
541 
542 
543 double
544 GUIVehicle::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
545  switch (activeScheme) {
546  case 8:
547  if (isStopped()) {
548  return isParking() ? -2 : -1;
549  }
550  return getSpeed();
551  case 9:
552  // color by action step
553  if (isActionStep(SIMSTEP)) {
554  // Upcoming simstep is actionstep (t was already increased before drawing)
555  return 1.;
556  } else if (isActive()) {
557  // Completed simstep was actionstep
558  return 2.;
559  } else {
560  // not active
561  return 0.;
562  }
563  case 10:
564  return getWaitingSeconds();
565  case 11:
567  case 12:
568  return getLastLaneChangeOffset();
569  case 13:
570  return getLane()->getVehicleMaxSpeed(this);
571  case 14:
572  return getEmissions<PollutantsInterface::CO2>();
573  case 15:
574  return getEmissions<PollutantsInterface::CO>();
575  case 16:
576  return getEmissions<PollutantsInterface::PM_X>();
577  case 17:
578  return getEmissions<PollutantsInterface::NO_X>();
579  case 18:
580  return getEmissions<PollutantsInterface::HC>();
581  case 19:
582  return getEmissions<PollutantsInterface::FUEL>();
583  case 20:
585  case 21:
586  return getNumberReroutes();
587  case 22:
589  case 23:
590  return getLaneChangeModel().isOpposite() ? -100 : getBestLaneOffset();
591  case 24:
592  return getAcceleration();
593  case 25:
594  return getTimeGapOnLane();
595  case 26:
596  return STEPS2TIME(getDepartDelay());
597  case 27:
598  return getEmissions<PollutantsInterface::ELEC>();
599  case 28:
600  return getRelativeStateOfCharge();
601  case 29:
602  return getChargedEnergy();
603  case 30:
604  return getTimeLossSeconds();
605  case 31:
606  return getStopDelay();
607  case 32:
608  return getStopArrivalDelay();
609  case 33:
610  return getLaneChangeModel().getSpeedLat();
611  case 34: // by numerical param value
612  std::string error;
613  std::string val = getPrefixedParameter(s.vehicleParam, error);
614  try {
615  if (val == "") {
617  } else {
618  return StringUtils::toDouble(val);
619  }
620  } catch (NumberFormatException&) {
621  try {
622  return StringUtils::toBool(val);
623  } catch (BoolFormatException&) {
624  WRITE_WARNINGF(TL("Vehicle parameter '%' key '%' is not a number for vehicle '%'."),
627  }
628  }
629  }
630  return 0;
631 }
632 
633 
634 void
636  myLock.lock();
637  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
638  myLock.unlock();
639  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
640  std::vector<MSVehicle::LaneQ>& lanes = *j;
641  double gmax = -1;
642  double rmax = -1;
643  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
644  gmax = MAX2((*i).length, gmax);
645  rmax = MAX2((*i).occupation, rmax);
646  }
647  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
648  const PositionVector& shape = (*i).lane->getShape();
649  double g = (*i).length / gmax;
650  double r = (*i).occupation / rmax;
651  glColor3d(r, g, 0);
652  double width = 0.5 / (1 + abs((*i).bestLaneOffset));
653  GLHelper::drawBoxLines(shape, width);
654 
655  PositionVector s1 = shape;
656  s1.move2side((double) .1);
657  glColor3d(r, 0, 0);
658  GLHelper::drawLine(s1);
659  s1.move2side((double) - .2);
660  glColor3d(0, g, 0);
661  GLHelper::drawLine(s1);
662 
663  glColor3d(r, g, 0);
664  }
665  }
666 }
667 
668 
669 void
670 GUIVehicle::drawRouteHelper(const GUIVisualizationSettings& s, ConstMSRoutePtr r, bool future, bool noLoop, const RGBColor& col) const {
671  const double exaggeration = s.vehicleSize.getExaggeration(s, this) * (s.gaming ? 0.5 : 1);
672  MSRouteIterator start = future ? myCurrEdge : r->begin();
673  MSRouteIterator i = start;
674  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
675  // draw continuation lanes when drawing the current route where available
676  int bestLaneIndex = (r == myRoute ? 0 : (int)bestLaneConts.size());
677  std::map<const MSLane*, int> repeatLane; // count repeated occurrences of the same edge
678  const double textSize = s.vehicleName.size / s.scale;
679  const GUILane* prevLane = nullptr;
680  int reversalIndex = 0;
681  const int indexDigits = (int)toString(r->size()).size();
682  if (!isOnRoad() && !isParking()) {
683  // simulation time has already advanced so isRemoteControlled is always false
684  const std::string offRoadLabel = hasInfluencer() && getInfluencer()->isRemoteAffected(SIMSTEP) ? "offRoad" : "teleporting";
685  GLHelper::drawTextSettings(s.vehicleValue, offRoadLabel, getPosition(), s.scale, s.angle, 1.0);
686  } else if (myLane->isInternal()) {
687  bestLaneIndex++;
688  }
689  const bool s2 = s.secondaryShape;
690  for (; i != r->end(); ++i) {
691  const GUILane* lane;
692  if (bestLaneIndex < (int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
693  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
694  ++bestLaneIndex;
695  } else {
696  const std::vector<MSLane*>* allowed = (*i)->allowedLanes(getVClass());
697  if (allowed != nullptr && allowed->size() != 0) {
698  lane = static_cast<GUILane*>((*allowed)[0]);
699  } else {
700  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
701  }
702  }
703  GLHelper::setColor(col);
704  GLHelper::drawBoxLines(lane->getShape(s2), lane->getShapeRotations(s2), lane->getShapeLengths(s2), exaggeration);
705  if (prevLane != nullptr && lane->getBidiLane() == prevLane) {
706  // indicate train reversal
707  std::string label = "reverse:" + toString(reversalIndex++);
708  if (s.showRouteIndex) {
709  label += "@r" + toString((int)(i - myCurrEdge));
710  }
711  Position pos = lane->geometryPositionAtOffset(lane->getLength() / 2) - Position(0, textSize * repeatLane[lane]);
712  GLHelper::drawTextSettings(s.vehicleValue, label, pos, s.scale, s.angle, 1.0);
713  }
714  if (s.showRouteIndex) {
715  std::string label = toString((int)(i - myCurrEdge));
716  const double laneAngle = lane->getShape(s2).angleAt2D(0);
717  Position pos = lane->getShape(s2).front() - Position(0, textSize * repeatLane[lane]) + Position(
718  (laneAngle >= -0.25 * M_PI && laneAngle < 0.75 * M_PI ? 1 : -1) * 0.4 * indexDigits * textSize, 0);
719  //GLHelper::drawText(label, pos, 1.0, textSize, s.vehicleName.color);
720  GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
721  }
722  repeatLane[lane]++;
723  prevLane = lane;
724  if (noLoop && i != start && (*i) == (*start)) {
725  break;
726  }
727  }
728  drawStopLabels(s, noLoop, col);
729  drawParkingInfo(s);
730  drawChargingInfo(s);
731 }
732 
733 
734 double
737 }
738 
739 
740 std::string
742  std::string result = "";
743  if (isParking()) {
744  result += "parking";
745  } else if (isStopped()) {
746  result += "stopped";
747  } else if (hasStops()) {
748  return "next: " + myStops.front().getDescription();
749  } else {
750  return "";
751  }
752  if (myStops.front().pars.triggered) {
753  result += ", triggered";
754  }
755  if (myStops.front().pars.containerTriggered) {
756  result += ", containerTriggered";
757  }
758  if (myStops.front().pars.collision) {
759  result += ", collision";
760  }
761  if (myStops.front().pars.arrival != -1) {
762  result += ", arrival=" + time2string(myStops.front().pars.arrival);
763  }
764  if (myStops.front().pars.started != -1) {
765  result += ", started=" + time2string(myStops.front().pars.started);
766  }
767  if (myStops.front().pars.until != -1) {
768  result += ", until=" + time2string(myStops.front().pars.until);
769  }
770  if (myStops.front().pars.extension != -1) {
771  result += ", extension=" + time2string(myStops.front().pars.extension);
772  }
773  if (!myStops.front().pars.permitted.empty()) {
774  result += ", permitted=" + toString(myStops.front().pars.permitted);
775  }
776  if (myStops.front().pars.actType != "") {
777  result += ", actType=" + myStops.front().pars.actType;
778  }
779  result += ", duration=" + time2string(myStops.front().duration);
780  return StringUtils::wrapText(result, 60);
781 }
782 
783 
784 void
786  double dist = myLane->getLength() - getPositionOnLane();
787 #ifdef DEBUG_FOES
788  gDebugFlag1 = true;
789  std::cout << SIMTIME << " selectBlockingFoes veh=" << getID() << " dist=" << dist << " numLinks=" << myLFLinkLanes.size() << "\n";
790 #endif
791  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
792  const DriveProcessItem& dpi = *i;
793  if (dpi.myLink == nullptr) {
795  continue;
796  }
797  MSLink::BlockingFoes blockingFoes;
798  std::vector<const MSPerson*> blockingPersons;
799 #ifdef DEBUG_FOES
800  std::cout << " foeLink=" << dpi.myLink->getViaLaneOrLane()->getID() << "\n";
801  const bool isOpen =
802 #endif
804  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), getLateralPositionOnLane(), &blockingFoes, false, this, dpi.myDistance);
805 #ifdef DEBUG_FOES
806  if (!isOpen) {
807  std::cout << " closed due to:\n";
808  for (const auto& item : blockingFoes) {
809  std::cout << " " << item->getID() << "\n";
810  }
811  }
812 #endif
813  if (getLaneChangeModel().getShadowLane() != nullptr) {
814  MSLink* parallelLink = dpi.myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
815  if (parallelLink != nullptr) {
816  const double shadowLatPos = getLateralPositionOnLane() - getLaneChangeModel().getShadowDirection() * 0.5 * (
818 #ifdef DEBUG_FOES
819  const bool isShadowOpen =
820 #endif
821  parallelLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
824  getWaitingTime(), shadowLatPos, &blockingFoes, false, this, dpi.myDistance);
825 #ifdef DEBUG_FOES
826  if (!isShadowOpen) {
827  std::cout << " foes at shadow link=" << parallelLink->getViaLaneOrLane()->getID() << ":\n";
828  for (const auto& item : blockingFoes) {
829  std::cout << " " << item->getID() << "\n";
830  }
831  }
832 #endif
833  }
834  }
835  for (const auto& item : blockingFoes) {
836  if (item->isVehicle()) {
837  gSelected.select(static_cast<const GUIVehicle*>(item)->getGlID());
838  } else {
839  gSelected.select(static_cast<const GUIPerson*>(item)->getGlID());
840  }
841  }
842  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(this, dist, &blockingPersons);
843 #ifdef DEBUG_FOES
844  gDebugFlag1 = false;
845 #endif
846  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
847  // the vehicle to enter the junction first has priority
848  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
849  if (leader != nullptr) {
850  if (isLeader(dpi.myLink, leader, it->vehAndGap.second) || it->inTheWay()) {
851  gSelected.select(leader->getGlID());
852 #ifdef DEBUG_FOES
853  std::cout << " linkLeader=" << leader->getID() << "\n";
854 #endif
855  }
856  } else {
857  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
858  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
859  if (foe != nullptr) {
860  gSelected.select(foe->getGlID());
861  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
862  }
863  }
864  }
865  }
866  dist += dpi.myLink->getViaLaneOrLane()->getLength();
867  }
868 }
869 
870 
871 void
874  GUISUMOAbstractView* view = mw->getActiveView();
875  if (view != nullptr) {
876  if (add) {
879  view->addAdditionalGLVisualisation(this);
880  }
881  } else {
884  }
885  }
886 }
887 
888 bool
891 }
892 
893 int
895  const double rightSide = getRightSideOnEdge();
896  const std::vector<double>& sublaneSides = myLane->getEdge().getSubLaneSides();
897  for (int i = 0; i < (int)sublaneSides.size(); ++i) {
898  if (sublaneSides[i] > rightSide) {
899  return MAX2(i - 1, 0);
900  }
901  }
902  return (int)sublaneSides.size() - 1;
903 }
904 
905 int
907  const double leftSide = getLeftSideOnEdge();
908  const std::vector<double>& sublaneSides = myLane->getEdge().getSubLaneSides();
909  for (int i = (int)sublaneSides.size() - 1; i >= 0; --i) {
910  if (sublaneSides[i] < leftSide) {
911  return i;
912  }
913  }
914  return -1;
915 }
916 
917 
918 std::string
920  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(-1).second);
921 }
922 
923 std::string
925  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(1).second);
926 }
927 
928 std::string
930  return toString((LaneChangeAction)getLaneChangeModel().getSavedState(0).second);
931 }
932 
933 std::string
935  return Named::getIDSecure(myLane, "n/a");
936 }
937 
938 std::string
940  return toString(myFurtherLanes);
941 }
942 
943 std::string
945  return Named::getIDSecure(getLaneChangeModel().getShadowLane(), "");
946 }
947 
948 std::string
950  return Named::getIDSecure(getLaneChangeModel().getTargetLane(), "");
951 }
952 
953 double
956 }
957 
958 std::string
960  return std::bitset<6>(getInfluencer()->getSpeedMode()).to_string();
961 }
962 
963 std::string
965  return std::bitset<12>(getInfluencer()->getLaneChangeMode()).to_string();
966 }
967 
968 void
970  SUMOTime intermediateDuration = TIME2STEPS(20);
971  SUMOTime finalDuration = SUMOTime_MAX;
972  if (myParameter->stops.size() >= 2) {
973  // copy durations from the original stops
974  intermediateDuration = myParameter->stops.front().duration;
975  finalDuration = myParameter->stops.back().duration;
976  }
977  // if the stop is already in the list of stops, cancel all stops that come
978  // after it and set the stop duration
979  std::string line = "";
980  int destinations = 0;
981  bool add = true;
982  for (auto it = myStops.begin(); it != myStops.end(); it++) {
983  if (!it->reached && destinations < 2 && it->busstop != nullptr) {
984  line += it->busstop->getID();
985  destinations++;
986  }
987  if (it->busstop == busStop) {
988  it->duration = finalDuration;
989  myStops.erase(++it, myStops.end());
990  add = false;
991  break;
992  } else {
993  it->duration = MIN2(it->duration, intermediateDuration);
994  }
995  }
996  if (destinations < 2) {
997  line += busStop->getID();
998  }
999  if (add) {
1000  // create new stop
1002  stopPar.busstop = busStop->getID();
1003  stopPar.lane = busStop->getLane().getID();
1004  stopPar.startPos = busStop->getBeginLanePosition();
1005  stopPar.endPos = busStop->getEndLanePosition();
1006  stopPar.duration = finalDuration;
1007  stopPar.until = -1;
1008  stopPar.triggered = false;
1009  stopPar.containerTriggered = false;
1010  stopPar.parking = ParkingType::ONROAD;
1011  stopPar.index = STOP_INDEX_FIT;
1013  // clean up prior route to improve visualisation, ensure that the stop can be added immediately
1014  ConstMSEdgeVector edges = myRoute->getEdges();
1015  edges.erase(edges.begin(), edges.begin() + getRoutePosition());
1016  edges.push_back(&busStop->getLane().getEdge());
1017  replaceRouteEdges(edges, -1, 0, "DRT.tmp", false, false, false);
1018  std::string errorMsg;
1019  // add stop
1020  addStop(stopPar, errorMsg);
1021  }
1022  const bool hasReroutingDevice = getDevice(typeid(MSDevice_Routing)) != nullptr;
1023  SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = hasReroutingDevice
1026  // reroute to ensure the new stop is reached
1027  reroute(MSNet::getInstance()->getCurrentTimeStep(), "DRT", router);
1028  myParameter->line = line;
1029  assert(haveValidStopEdges());
1030 }
1031 
1032 Position
1033 GUIVehicle::getVisualPosition(bool s2, const double offset) const {
1034  if (s2) {
1035  // see MSVehicle::getPosition
1036  if (myLane == nullptr) {
1037  return Position::INVALID;
1038  }
1039  if (isParking()) {
1040  if (myStops.begin()->parkingarea != nullptr) {
1041  return myStops.begin()->parkingarea->getVehiclePosition(*this);
1042  } else {
1043  // position beside the road
1044  PositionVector shp = myLane->getEdge().getLanes()[0]->getShape(s2);
1046  return shp.positionAtOffset((getPositionOnLane() + offset) * myLane->getLengthGeometryFactor(s2));
1047  }
1048  }
1049  const PositionVector& shape = myLane->getShape(s2);
1050  const double posLat = (MSGlobals::gLefthand ? 1 : -1) * getLateralPositionOnLane();
1051  return shape.positionAtOffset((getPositionOnLane() + offset) * myLane->getLengthGeometryFactor(s2), posLat);
1052  } else {
1053  return getPosition(offset);
1054  }
1055 }
1056 
1057 
1058 double
1060  if (s2) {
1061  // see MSVehicle::computeAngle
1062  const PositionVector& shape = myLane->getShape(s2);
1063  if (isParking()) {
1064  if (myStops.begin()->parkingarea != nullptr) {
1065  return myStops.begin()->parkingarea->getVehicleAngle(*this);
1066  } else {
1068  }
1069  }
1070  // if (myLaneChangeModel->isChangingLanes()) {
1071  const double lefthandSign = (MSGlobals::gLefthand ? -1 : 1);
1072  Position p1 = getVisualPosition(s2);
1073  Position p2 = getVisualPosition(s2, MAX2(0.0, -myType->getLength()));
1074  double result = (p1 != p2 ? p2.angleTo2D(p1) :
1077  result += lefthandSign * DEG2RAD(myLaneChangeModel->getAngleOffset());
1078  }
1079  return result;
1080  } else {
1081  return getAngle();
1082  }
1083 }
1084 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
@ GLO_VEHICLE
a vehicle
GUISelectedStorage gSelected
A global holder of selected objects.
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:474
#define LANECHANGEMODE_DEFAULT
Definition: GUIVehicle.cpp:72
#define SPEEDMODE_DEFAULT
Definition: GUIVehicle.cpp:71
void drawAction_drawBlinker(double dir, double length)
Definition: GUIVehicle.cpp:478
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:475
#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:56
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:31
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition: SUMOTime.cpp:69
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
#define SIMSTEP
Definition: SUMOTime.h:61
#define SUMOTime_MAX
Definition: SUMOTime.h:34
#define SIMTIME
Definition: SUMOTime.h:62
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
const long long int VTYPEPARS_ACTIONSTEPLENGTH_SET
@ GIVEN
The alignment as offset is given.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
@ 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:26
bool gDebugFlag1
global utility flags for debugging
Definition: StdDefs.cpp:37
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:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
const double SUMO_const_waitingContainerWidth
Definition: StdDefs.h:54
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:52
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:283
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:438
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:654
static void drawFilledCircle(const double widradiusth, const int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:569
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
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:347
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:660
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:295
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
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:787
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 successful
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
A MSVehicle extended by some values for usage within the gui.
int getNumContainers() const
return the number of passengers
void drawParkingInfo(const GUIVisualizationSettings &s) const
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 drawChargingInfo(const GUIVisualizationSettings &s) const
@ 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
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into, double extraOffset=0) const
add seats to mySeatPositions and update requiredSeats
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.
Definition: GUIGlObject.h:156
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:104
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:60
const std::vector< double > & getShapeRotations(bool secondary) const
Definition: GUILane.cpp:1097
const PositionVector & getShape(bool secondary) const override
Definition: GUILane.cpp:1091
const std::vector< double > & getShapeLengths(bool secondary) const
Definition: GUILane.cpp:1103
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.
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:889
int getLeftSublaneOnEdge() const
Definition: GUIVehicle.cpp:906
double getAngle() const
Return current angle.
Definition: GUIVehicle.h:81
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:544
std::string getDynamicAlignment() const
return the current lateral alignment as string
Definition: GUIVehicle.cpp:276
double getVisualAngle(bool s2) const
Returns the vehicle's direction in radians taking into account secondary shape.
void selectBlockingFoes() const
adds the blocking foes to the current selection
Definition: GUIVehicle.cpp:785
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIVehicle.cpp:226
void drawBestLanes() const
Draws the vehicle's best lanes.
Definition: GUIVehicle.cpp:635
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
Definition: GUIVehicle.cpp:872
int getRightSublaneOnEdge() const
return the righmost sublane on the edge occupied by the vehicle
Definition: GUIVehicle.cpp:894
void drawRouteHelper(const GUIVisualizationSettings &s, ConstMSRoutePtr r, bool future, bool noLoop, const RGBColor &col) const
Draws the route.
Definition: GUIVehicle.cpp:670
std::string getStopInfo() const
retrieve information about the current stop state
Definition: GUIVehicle.cpp:741
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:99
std::string getBackLaneIDs() const
Definition: GUIVehicle.cpp:939
double getLeftSideOnEdge() const
return left vehicle side on current edge
Definition: GUIVehicle.h:144
void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const
draws the given guiShape with distinct carriages/modules
Definition: GUIVehicle.cpp:318
std::string getShadowLaneID() const
Definition: GUIVehicle.cpp:944
double getManeuverDist() const
return the lane-change maneuver distance
Definition: GUIVehicle.cpp:954
double getRightSideOnEdge2() const
return right vehicle side on current edge (without argument)
Definition: GUIVehicle.h:140
std::string getSpeedMode() const
return the speed mode as bit string
Definition: GUIVehicle.cpp:959
GUIVehicle(SUMOVehicleParameter *pars, ConstMSRoutePtr route, MSVehicleType *type, const double speedFactor)
Constructor.
Definition: GUIVehicle.cpp:87
void drawAction_drawVehicleBlinker(double length) const
Definition: GUIVehicle.cpp:492
void rerouteDRTStop(MSStoppingPlace *busStop)
handle route to accomodate to given stop
Definition: GUIVehicle.cpp:969
std::string getLCStateRight() const
return the lanechange state
Definition: GUIVehicle.cpp:919
void drawAction_drawVehicleBlueLight() const
Definition: GUIVehicle.cpp:532
double getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
Definition: GUIVehicle.cpp:735
std::string getLaneID() const
return vehicle lane id
Definition: GUIVehicle.cpp:934
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:288
std::string getTargetLaneID() const
Definition: GUIVehicle.cpp:949
std::string getLCStateLeft() const
Definition: GUIVehicle.cpp:924
Position getVisualPosition(bool s2, const double offset=0) const
Return current position taking into account secondary shape.
void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
Definition: GUIVehicle.cpp:511
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:94
std::string getLCStateCenter() const
Definition: GUIVehicle.cpp:929
std::string getLaneChangeMode() const
return the lane change mode as bit string
Definition: GUIVehicle.cpp:964
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
bool trueZ
drawl all objects according to their z data
GUIVisualizationTextSettings vehicleValue
int vehicleQuality
The quality of vehicle drawing.
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 secondaryShape
whether secondary lane shape shall be drawn
bool drawReversed
Whether to draw reversed vehicles in their reversed state.
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
double getAngleOffset() const
return the angle offset resulting from lane change and sigma
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:57
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
bool haveValidStopEdges(bool silent=false) const
check whether all stop.edge MSRouteIterators are valid and in order
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 getMaxChargeRate() const
Returns the maximum charge rate allowed by the battery in the current time step (W)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
bool isReversed() const
Returns whether the logical state of the vehicle is reversed - for drawing.
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 getRelativeStateOfCharge() const
Returns actual relative state of charge of battery (-)
MSRouteIterator myCurrEdge
Iterator to current route-edge.
const std::vector< std::string > & getParkingBadges() const
get the valid parking access rights (vehicle settings override vehicle type settings)
ConstMSRoutePtr myRoute
This vehicle's route.
double getWidth() const
Returns the vehicle's width.
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 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, MSRouteIterator *searchStart=nullptr)
Adds a stop.
double getChargedEnergy() const
Returns the energy charged to the battery in the current time step (Wh)
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.
bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)
Performs a rerouting using the given router.
int getRNGIndex() const
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
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:264
Battery device for electric vehicles.
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.
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:646
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
Definition: MSGlobals.h:159
static double gLateralResolution
Definition: MSGlobals.h:97
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:171
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
Definition: MSGlobals.h:162
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:94
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
Definition: MSGlobals.h:112
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
virtual double getLengthGeometryFactor(bool) const
Definition: MSLane.h:290
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:566
bool isInternal() const
Definition: MSLane.cpp:2526
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:756
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:4545
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:627
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:552
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:294
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:184
MSVehicleRouter & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1487
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the vehicle 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.
A class that helps computing positions of a train's carriages and additional structures.
Definition: MSTrainHelper.h:42
const std::vector< Carriage * > & getCarriages() const
Definition: MSTrainHelper.h:99
int getFirstCarriageNo() const
Definition: MSTrainHelper.h:87
double getFirstCarriageLength() const
Definition: MSTrainHelper.h:79
bool isReversed() const
Definition: MSTrainHelper.h:95
double getCarriageLength() const
Definition: MSTrainHelper.h:75
int getNumCarriages() const
Definition: MSTrainHelper.h:71
double getUpscaleLength() const
Definition: MSTrainHelper.h:63
int getFirstPassengerCarriage() const
Definition: MSTrainHelper.h:91
double getHalfWidth() const
Definition: MSTrainHelper.h:67
bool isRemoteAffected(SUMOTime t) const
Definition: MSVehicle.cpp:821
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:6706
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
Definition: MSVehicle.cpp:6564
double getStopDelay() const
Returns the public transport stop delay in seconds.
Definition: MSVehicle.cpp:7992
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MSVehicle.h:608
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
Definition: MSVehicle.h:631
double getTimeLossSeconds() const
Returns the time loss in seconds.
Definition: MSVehicle.h:719
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
Definition: MSVehicle.h:713
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:673
double getTimeSinceStartupSeconds() const
Definition: MSVehicle.h:690
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5774
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle.
Definition: MSVehicle.h:638
MSAbstractLaneChangeModel * myLaneChangeModel
Definition: MSVehicle.h:1887
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1914
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:1194
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:517
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:6290
int getBestLaneOffset() const
Definition: MSVehicle.cpp:6461
double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
Definition: MSVehicle.cpp:8014
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
Definition: MSVehicle.h:1116
@ VEH_SIGNAL_BRAKELIGHT
The brake lights are on.
Definition: MSVehicle.h:1122
@ VEH_SIGNAL_EMERGENCY_BLUE
A blue emergency light is on.
Definition: MSVehicle.h:1138
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
Definition: MSVehicle.h:1118
@ VEH_SIGNAL_BLINKER_EMERGENCY
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:1120
bool isLeader(const MSLink *link, const MSVehicle *veh, const double gap) const
whether the given vehicle must be followed at the given junction
Definition: MSVehicle.cpp:7406
Influencer & getInfluencer()
Definition: MSVehicle.cpp:7251
std::vector< std::vector< LaneQ > > myBestLanes
Definition: MSVehicle.h:1897
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:416
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
Definition: MSVehicle.cpp:1217
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:493
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:377
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:584
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:977
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1885
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition: MSVehicle.h:1685
DriveItemVector myLFLinkLanes
container for the planned speeds in the current step
Definition: MSVehicle.h:2014
The car-following model and parameter.
Definition: MSVehicleType.h:63
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.
SUMOTime getLoadingDuration(const bool isPerson) const
Get this vehicle type's loading duration.
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].
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:91
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
double getMass() const
Get this vehicle type's mass.
std::string getImgFile() const
Get this vehicle type's raster model file name.
const SUMOVTypeParameter & getParameter() const
double getPreferredLateralAlignmentOffset() const
Get vehicle's preferred lateral alignment offset (in m from center line)
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
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:322
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:276
double x() const
Returns the x-position.
Definition: Position.h:55
double z() const
Returns the z-position.
Definition: Position.h:65
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition: Position.h:286
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
double length() const
Returns the length.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
double angleAt2D(int pos) const
get angle in certain position of position vector (in radians between -M_PI and M_PI)
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
bool wasSet(long long 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)
ParkingType parking
whether the vehicle is removed from the net while stopping
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.
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
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static std::string wrapText(const std::string s, int width)
remove leading and trailing whitespace
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:45
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:1953
double getLeaveSpeed() const
Definition: MSVehicle.h:2004