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