Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSAbstractLaneChangeModel.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/****************************************************************************/
23// Interface for lane-change models
24/****************************************************************************/
25
26// ===========================================================================
27// DEBUG
28// ===========================================================================
29//#define DEBUG_TARGET_LANE
30//#define DEBUG_SHADOWLANE
31//#define DEBUG_OPPOSITE
32//#define DEBUG_MANEUVER
33#define DEBUG_COND (myVehicle.isSelected())
34
35#include <config.h>
36
40#include <microsim/MSNet.h>
41#include <microsim/MSEdge.h>
42#include <microsim/MSLane.h>
43#include <microsim/MSLink.h>
44#include <microsim/MSStop.h>
46#include <microsim/MSGlobals.h>
48#include "MSLCM_DK2008.h"
49#include "MSLCM_LC2013.h"
50#include "MSLCM_LC2013_CC.h"
51#include "MSLCM_SL2015.h"
53
54/* -------------------------------------------------------------------------
55 * static members
56 * ----------------------------------------------------------------------- */
62const double MSAbstractLaneChangeModel::NO_NEIGHBOR(std::numeric_limits<double>::max());
64
65#define LC_ASSUMED_DECEL 1.0 // the minimal constant deceleration assumed to estimate the duration of a continuous lane-change at its initiation.
66
67/* -------------------------------------------------------------------------
68 * MSAbstractLaneChangeModel-methods
69 * ----------------------------------------------------------------------- */
70
71void
73 myAllowOvertakingRight = oc.getBool("lanechange.overtake-right");
74 myLCOutput = oc.isSet("lanechange-output");
75 myLCStartedOutput = oc.getBool("lanechange-output.started");
76 myLCEndedOutput = oc.getBool("lanechange-output.ended");
77 myLCXYOutput = oc.getBool("lanechange-output.xy");
78}
79
80
84 throw ProcessError(TLF("Lane change model '%' is not compatible with sublane simulation", toString(lcm)));
85 }
86 switch (lcm) {
88 return new MSLCM_DK2008(v);
90 return new MSLCM_LC2013(v);
92 return new MSLCM_LC2013_CC(v);
94 return new MSLCM_SL2015(v);
97 return new MSLCM_LC2013(v);
98 } else {
99 return new MSLCM_SL2015(v);
100 }
101 default:
102 throw ProcessError(TLF("Lane change model '%' not implemented", toString(lcm)));
103 }
104}
105
106
108 myVehicle(v),
109 myOwnState(0),
110 myPreviousState(0),
111 myPreviousState2(0),
112 myCanceledStateRight(LCA_NONE),
113 myCanceledStateCenter(LCA_NONE),
114 myCanceledStateLeft(LCA_NONE),
115 mySpeedLat(0),
116 myAccelerationLat(0),
117 myAngleOffset(0),
118 myPreviousAngleOffset(0),
119 myCommittedSpeed(0),
120 myLaneChangeCompletion(1.0),
121 myLaneChangeDirection(0),
122 myAlreadyChanged(false),
123 myShadowLane(nullptr),
124 myTargetLane(nullptr),
125 myModel(model),
126 myLastLateralGapLeft(0.),
127 myLastLateralGapRight(0.),
128 myLastLeaderGap(0.),
129 myLastFollowerGap(0.),
130 myLastLeaderSecureGap(0.),
131 myLastFollowerSecureGap(0.),
132 myLastOrigLeaderGap(0.),
133 myLastOrigLeaderSecureGap(0.),
134 myLastLeaderSpeed(0),
135 myLastFollowerSpeed(0),
136 myLastOrigLeaderSpeed(0),
137 myDontResetLCGaps(false),
138 myStrategicLookahead(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_STRATEGIC_LOOKAHEAD, UNDEFINED_LOOKAHEAD)),
139 myMaxSpeedLatStanding(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING, v.getVehicleType().getMaxSpeedLat())),
140 myMaxSpeedLatFactor(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR, 1)),
141 myMaxDistLatStanding(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_MAXDISTLATSTANDING,
142 // prevent lateral sliding for cars but permit for two-wheelers due to better maneuverability
143 (v.getVClass() & (SVC_BICYCLE | SVC_MOTORCYCLE | SVC_MOPED)) != 0 ? std::numeric_limits<double>::max() : 1.6)),
144 mySigma(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_SIGMA, 0.0)),
145 myOvertakeRightParam(v.getVehicleType().getParameter().getLCParam(SUMO_ATTR_LCA_OVERTAKE_RIGHT, 0)),
146 myHaveBlueLight(v.getDevice(typeid(MSDevice_Bluelight)) != nullptr), // see MSVehicle::initDevices
147 myLastLaneChangeOffset(0),
148 myAmOpposite(false),
149 myManeuverDist(0.),
150 myPreviousManeuverDist(0.) {
154}
155
156
159
160void
163 myOwnState = state;
164 myPreviousState = state; // myOwnState is modified in prepareStep so we make a backup
165}
166
167void
168MSAbstractLaneChangeModel::updateSafeLatDist(const double travelledLatDist) {
169 UNUSED_PARAMETER(travelledLatDist);
170}
171
172
173void
175#ifdef DEBUG_MANEUVER
176 if (DEBUG_COND) {
177 std::cout << SIMTIME
178 << " veh=" << myVehicle.getID()
179 << " setManeuverDist() old=" << myManeuverDist << " new=" << dist
180 << std::endl;
181 }
182#endif
183 myManeuverDist = fabs(dist) < NUMERICAL_EPS ? 0. : dist;
184 // store value which may be modified by the model during the next step
186}
187
188
189double
193
194double
198
199void
201 if (dir == -1) {
202 myLeftFollowers = std::make_shared<MSLeaderDistanceInfo>(followers);
203 myLeftLeaders = std::make_shared<MSLeaderDistanceInfo>(leaders);
204 } else if (dir == 1) {
205 myRightFollowers = std::make_shared<MSLeaderDistanceInfo>(followers);
206 myRightLeaders = std::make_shared<MSLeaderDistanceInfo>(leaders);
207 } else {
208 // dir \in {-1,1} !
209 assert(false);
210 }
211}
212
213
214void
215MSAbstractLaneChangeModel::saveNeighbors(const int dir, const std::pair<MSVehicle* const, double>& follower, const std::pair<MSVehicle* const, double>& leader) {
216 if (dir == -1) {
217 myLeftFollowers = std::make_shared<MSLeaderDistanceInfo>(follower, myVehicle.getLane()->getWidth());
218 myLeftLeaders = std::make_shared<MSLeaderDistanceInfo>(leader, myVehicle.getLane()->getWidth());
219 } else if (dir == 1) {
220 myRightFollowers = std::make_shared<MSLeaderDistanceInfo>(follower, myVehicle.getLane()->getWidth());
221 myRightLeaders = std::make_shared<MSLeaderDistanceInfo>(leader, myVehicle.getLane()->getWidth());
222 } else {
223 // dir \in {-1,1} !
224 assert(false);
225 }
226}
227
228
229void
231 myLeftFollowers = nullptr;
232 myLeftLeaders = nullptr;
233 myRightFollowers = nullptr;
234 myRightLeaders = nullptr;
235}
236
237
238const std::shared_ptr<MSLeaderDistanceInfo>
240 if (dir == -1) {
241 return myLeftFollowers;
242 } else if (dir == 1) {
243 return myRightFollowers;
244 } else {
245 // dir \in {-1,1} !
246 assert(false);
247 }
248 return nullptr;
249}
250
251const std::shared_ptr<MSLeaderDistanceInfo>
253 if (dir == -1) {
254 return myLeftLeaders;
255 } else if (dir == 1) {
256 return myRightLeaders;
257 } else {
258 // dir \in {-1,1} !
259 assert(false);
260 }
261 return nullptr;
262}
263
264
265bool
267 if (neighLeader == nullptr) {
268 return false;
269 }
270 // Congested situation are relevant only on highways (maxSpeed > 70km/h)
271 // and congested on German Highways means that the vehicles have speeds
272 // below 60km/h. Overtaking on the right is allowed then.
273 if ((myVehicle.getLane()->getSpeedLimit() <= 70.0 / 3.6) || (neighLeader->getLane()->getSpeedLimit() <= 70.0 / 3.6)) {
274
275 return false;
276 }
277 if (myVehicle.congested() && neighLeader->congested()) {
278 return true;
279 }
280 return false;
281}
282
283
284bool
291
292bool
293MSAbstractLaneChangeModel::predInteraction(const std::pair<MSVehicle*, double>& leader) {
294 if (leader.first == 0) {
295 return false;
296 }
297 // let's check it on highways only
298 if (leader.first->getSpeed() < (80.0 / 3.6)) {
299 return false;
300 }
301 return leader.second < getCarFollowModel().interactionGap(&myVehicle, leader.first->getSpeed());
302}
303
304
305bool
309 myLaneChangeDirection = direction;
310 setManeuverDist((target->getWidth() + source->getWidth()) * 0.5 * direction);
313 if (myLCOutput) {
315 }
316 return true;
317 } else {
318 primaryLaneChanged(source, target, direction);
319 return false;
320 }
321}
322
323void
327
328void
332
333void
335 initLastLaneChangeOffset(direction);
337 source->leftByLaneChange(&myVehicle);
338 laneChangeOutput("change", source, target, direction); // record position on the source edge in case of opposite change
339 if (&source->getEdge() != &target->getEdge()) {
341#ifdef DEBUG_OPPOSITE
342 if (debugVehicle()) {
343 std::cout << SIMTIME << " veh=" << myVehicle.getID() << " primaryLaneChanged source=" << source->getID() << " target=" << target->getID() << " nowOpposite=" << myAmOpposite << "\n";
344 }
345#endif
348 } else if (myAmOpposite) {
349#ifdef DEBUG_OPPOSITE
350 if (debugVehicle()) {
351 std::cout << SIMTIME << " veh=" << myVehicle.getID() << " primaryLaneChanged source=" << source->getID() << " target=" << target->getID() << " stayOpposite\n";
352 }
353#endif
354 myAlreadyChanged = true;
356 if (!MSGlobals::gSublane) {
357 // in the continous case, the vehicle is added to the target lane via MSLaneChanger::continueChange / registerHop
358 // in the sublane case, the vehicle is added to the target lane via MSLaneChangerSublane::checkChangeOppositeSublane / MSLane::myTmpVehicles
360 }
361 } else {
364 }
365 // Assure that the drive items are up to date (even if the following step is no actionstep for the vehicle).
366 // This is necessary because the lane advance uses the target lane from the corresponding drive item.
368 changed();
369}
370
371void
372MSAbstractLaneChangeModel::laneChangeOutput(const std::string& tag, MSLane* source, MSLane* target, int direction, double maneuverDist) {
373 if (myLCOutput) {
374 OutputDevice& of = OutputDevice::getDeviceByOption("lanechange-output");
375 of.openTag(tag);
378 of.writeAttr(SUMO_ATTR_TIME, time2string(MSNet::getInstance()->getCurrentTimeStep()));
379 of.writeAttr(SUMO_ATTR_FROM, source->getID());
380 of.writeAttr(SUMO_ATTR_TO, target->getID());
381 of.writeAttr(SUMO_ATTR_DIR, direction);
389 of.writeAttr("leaderGap", myLastLeaderGap == NO_NEIGHBOR ? "None" : toString(myLastLeaderGap));
390 of.writeAttr("leaderSecureGap", myLastLeaderSecureGap == NO_NEIGHBOR ? "None" : toString(myLastLeaderSecureGap));
391 of.writeAttr("leaderSpeed", myLastLeaderSpeed == NO_NEIGHBOR ? "None" : toString(myLastLeaderSpeed));
392 of.writeAttr("followerGap", myLastFollowerGap == NO_NEIGHBOR ? "None" : toString(myLastFollowerGap));
393 of.writeAttr("followerSecureGap", myLastFollowerSecureGap == NO_NEIGHBOR ? "None" : toString(myLastFollowerSecureGap));
394 of.writeAttr("followerSpeed", myLastFollowerSpeed == NO_NEIGHBOR ? "None" : toString(myLastFollowerSpeed));
395 of.writeAttr("origLeaderGap", myLastOrigLeaderGap == NO_NEIGHBOR ? "None" : toString(myLastOrigLeaderGap));
396 of.writeAttr("origLeaderSecureGap", myLastOrigLeaderSecureGap == NO_NEIGHBOR ? "None" : toString(myLastOrigLeaderSecureGap));
397 of.writeAttr("origLeaderSpeed", myLastOrigLeaderSpeed == NO_NEIGHBOR ? "None" : toString(myLastOrigLeaderSpeed));
399 const double latGap = direction < 0 ? myLastLateralGapRight : myLastLateralGapLeft;
400 of.writeAttr("latGap", latGap == NO_NEIGHBOR ? "None" : toString(latGap));
401 if (maneuverDist != 0) {
402 of.writeAttr("maneuverDistance", toString(maneuverDist));
403 }
404 }
405 if (myLCXYOutput) {
408 }
409 of.closeTag();
412 }
413 }
414}
415
416
417double
418MSAbstractLaneChangeModel::computeSpeedLat(double /*latDist*/, double& maneuverDist, bool /*urgent*/) const {
420 int stepsToChange = (int)ceil(fabs(maneuverDist) / SPEED2DIST(myVehicle.getVehicleType().getMaxSpeedLat()));
421 return DIST2SPEED(maneuverDist / stepsToChange);
422 } else {
423 return maneuverDist / STEPS2TIME(MSGlobals::gLaneChangeDuration);
424 }
425}
426
427
428double
432
433void
436 mySpeedLat = speedLat;
437}
438
439
440void
446
447
448bool
450 const bool pastBefore = pastMidpoint();
451 // maneuverDist is not updated in the context of continuous lane changing but represents the full LC distance
452 double maneuverDist = getManeuverDist();
453 setSpeedLat(computeSpeedLat(0, maneuverDist, (myOwnState & LCA_URGENT) != 0));
455 return !pastBefore && pastMidpoint();
456}
457
458
459void
461 UNUSED_PARAMETER(reason);
470 // opposite driving continues after parking
471 } else {
472 // aborted maneuver
473#ifdef DEBUG_OPPOSITE
474 if (debugVehicle()) {
475 std::cout << SIMTIME << " veh=" << myVehicle.getID() << " aborted maneuver (no longer opposite)\n";
476 }
477#endif
479 }
480 }
481}
482
483
484MSLane*
485MSAbstractLaneChangeModel::getShadowLane(const MSLane* lane, double posLat) const {
487 // initialize shadow lane
488 const double overlap = myVehicle.getLateralOverlap(posLat, lane);
489#ifdef DEBUG_SHADOWLANE
490 if (debugVehicle()) {
491 std::cout << SIMTIME << " veh=" << myVehicle.getID() << " posLat=" << posLat << " overlap=" << overlap << "\n";
492 }
493#endif
494 if (myAmOpposite) {
495 // return the neigh-lane in forward direction
496 return lane->getParallelLane(1);
497 } else if (overlap > NUMERICAL_EPS) {
498 const int shadowDirection = posLat < 0 ? -1 : 1;
499 return lane->getParallelLane(shadowDirection);
500 } else if (isChangingLanes() && myLaneChangeCompletion < 0.5) {
501 // "reserve" target lane even when there is no overlap yet
503 } else {
504 return nullptr;
505 }
506 } else {
507 return nullptr;
508 }
509}
510
511
512MSLane*
516
517
518void
520 if (myShadowLane != nullptr) {
521 if (debugVehicle()) {
522 std::cout << SIMTIME << " cleanupShadowLane\n";
523 }
525 myShadowLane = nullptr;
526 }
527 for (std::vector<MSLane*>::const_iterator it = myShadowFurtherLanes.begin(); it != myShadowFurtherLanes.end(); ++it) {
528 if (debugVehicle()) {
529 std::cout << SIMTIME << " cleanupShadowLane2\n";
530 }
532 }
533 myShadowFurtherLanes.clear();
535}
536
537void
539 if (myTargetLane != nullptr) {
540 if (debugVehicle()) {
541 std::cout << SIMTIME << " cleanupTargetLane\n";
542 }
544 myTargetLane = nullptr;
545 }
546 for (std::vector<MSLane*>::const_iterator it = myFurtherTargetLanes.begin(); it != myFurtherTargetLanes.end(); ++it) {
547 if (debugVehicle()) {
548 std::cout << SIMTIME << " cleanupTargetLane\n";
549 }
550 if (*it != nullptr) {
552 }
553 }
554 myFurtherTargetLanes.clear();
555// myNoPartiallyOccupatedByShadow.clear();
556}
557
558
559bool
561 // store request before canceling
562 getCanceledState(laneOffset) |= state;
563 int ret = myVehicle.influenceChangeDecision(state);
564 return ret != state;
565}
566
567double
571
572void
574 if (dir > 0) {
576 } else if (dir < 0) {
578 }
579}
580
581void
583 if (!MSGlobals::gSublane) {
584 // assume each vehicle drives at the center of its lane and act as if it fits
585 return;
586 }
587 if (myShadowLane != nullptr) {
588#ifdef DEBUG_SHADOWLANE
589 if (debugVehicle()) {
590 std::cout << SIMTIME << " updateShadowLane()\n";
591 }
592#endif
594 }
596 std::vector<MSLane*> passed;
597 if (myShadowLane != nullptr) {
599 const std::vector<MSLane*>& further = myVehicle.getFurtherLanes();
600 if (myAmOpposite) {
601 assert(further.size() == 0);
602 } else {
603 const std::vector<double>& furtherPosLat = myVehicle.getFurtherLanesPosLat();
604 assert(further.size() == furtherPosLat.size());
605 passed.push_back(myShadowLane);
606 for (int i = 0; i < (int)further.size(); ++i) {
607 MSLane* shadowFurther = getShadowLane(further[i], furtherPosLat[i]);
608#ifdef DEBUG_SHADOWLANE
609 if (debugVehicle()) {
610 std::cout << SIMTIME << " further=" << further[i]->getID() << " (posLat=" << furtherPosLat[i] << ") shadowFurther=" << Named::getIDSecure(shadowFurther) << "\n";
611 }
612#endif
613 if (shadowFurther != nullptr && shadowFurther->getLinkTo(passed.back()) != nullptr) {
614 passed.push_back(shadowFurther);
615 }
616 }
617 std::reverse(passed.begin(), passed.end());
618 }
619 } else {
620 if (isChangingLanes() && myVehicle.getLateralOverlap() > NUMERICAL_EPS) {
621 WRITE_WARNING("Vehicle '" + myVehicle.getID() + "' could not finish continuous lane change (lane disappeared) time=" +
622 time2string(MSNet::getInstance()->getCurrentTimeStep()) + ".");
624 }
625 }
626#ifdef DEBUG_SHADOWLANE
627 if (debugVehicle()) {
628 std::cout << SIMTIME << " updateShadowLane() veh=" << myVehicle.getID()
629 << " newShadowLane=" << Named::getIDSecure(myShadowLane)
630 << "\n before:" << " myShadowFurtherLanes=" << toString(myShadowFurtherLanes) << " further=" << toString(myVehicle.getFurtherLanes()) << " passed=" << toString(passed);
631 std::cout << std::endl;
632 }
633#endif
635#ifdef DEBUG_SHADOWLANE
636 if (debugVehicle()) std::cout
637 << "\n after:" << " myShadowFurtherLanes=" << toString(myShadowFurtherLanes) << "\n";
638#endif
639}
640
641
642int
644 if (isChangingLanes()) {
645 if (pastMidpoint()) {
646 return -myLaneChangeDirection;
647 } else {
649 }
650 } else if (myShadowLane == nullptr) {
651 return 0;
652 } else if (myAmOpposite) {
653 // return neigh-lane in forward direction
654 return 1;
655 } else if (&myShadowLane->getEdge() == &myVehicle.getLane()->getEdge()) {
657 } else {
658 // overlap with opposite direction lane
659 return 1;
660 }
661}
662
663
664MSLane*
666#ifdef DEBUG_TARGET_LANE
667 MSLane* oldTarget = myTargetLane;
668 std::vector<MSLane*> oldFurtherTargets = myFurtherTargetLanes;
669 if (debugVehicle()) {
670 std::cout << SIMTIME << " veh '" << myVehicle.getID() << "' (lane=" << myVehicle.getLane()->getID() << ") updateTargetLane()"
671 << "\n oldTarget: " << (oldTarget == nullptr ? "NULL" : oldTarget->getID())
672 << " oldFurtherTargets: " << toString(oldFurtherTargets);
673 }
674#endif
675 if (myTargetLane != nullptr) {
677 }
678 // Clear old further target lanes
679 for (MSLane* oldTargetLane : myFurtherTargetLanes) {
680 if (oldTargetLane != nullptr) {
681 oldTargetLane->resetManeuverReservation(&myVehicle);
682 }
683 }
684 myFurtherTargetLanes.clear();
685
686 // Get new target lanes and issue a maneuver reservation.
687 int targetDir;
689 if (myTargetLane != nullptr) {
691 // further targets are just the target lanes corresponding to the vehicle's further lanes
692 // @note In a neglectable amount of situations we might add a reservation for a shadow further lane.
693 for (MSLane* furtherLane : myVehicle.getFurtherLanes()) {
694 MSLane* furtherTargetLane = furtherLane->getParallelLane(targetDir);
695 myFurtherTargetLanes.push_back(furtherTargetLane);
696 if (furtherTargetLane != nullptr) {
697 furtherTargetLane->setManeuverReservation(&myVehicle);
698 }
699 }
700 }
701#ifdef DEBUG_TARGET_LANE
702 if (debugVehicle()) {
703 std::cout << "\n newTarget (maneuverDist=" << myManeuverDist << " offset=" << targetDir << "): " << (myTargetLane == nullptr ? "NULL" : myTargetLane->getID())
704 << " newFurtherTargets: " << toString(myFurtherTargetLanes)
705 << std::endl;
706 }
707#endif
708 return myTargetLane;
709}
710
711
712MSLane*
714 targetDir = 0;
715 if (myManeuverDist == 0) {
716 return nullptr;
717 }
718 // Current lateral boundaries of the vehicle
719 const double vehRight = myVehicle.getLateralPositionOnLane() - 0.5 * myVehicle.getWidth();
720 const double vehLeft = myVehicle.getLateralPositionOnLane() + 0.5 * myVehicle.getWidth();
721 const double halfLaneWidth = 0.5 * myVehicle.getLane()->getWidth();
722
723 if (vehRight + myManeuverDist < -halfLaneWidth) {
724 // Vehicle intends to traverse the right lane boundary
725 targetDir = -1;
726 } else if (vehLeft + myManeuverDist > halfLaneWidth) {
727 // Vehicle intends to traverse the left lane boundary
728 targetDir = 1;
729 }
730 if (targetDir == 0) {
731 // Presently, no maneuvering into another lane is begun.
732 return nullptr;
733 }
734 MSLane* target = myVehicle.getLane()->getParallelLane(targetDir);
735 if (target == nullptr || target == myShadowLane) {
736 return nullptr;
737 } else {
738 return target;
739 }
740}
741
742
743
744double
746 double result = 0.;
747 if (!(fabs(mySpeedLat) < NUMERICAL_EPS && fabs(myPreviousAngleOffset * 180 / M_PI) < NUMERICAL_EPS)) {
749 result = atan2(mySpeedLat, myVehicle.getSpeed());
750 } else {
752 }
753 }
754
755 myAngleOffset = result;
756 return result;
757}
758
759
760double
761MSAbstractLaneChangeModel::estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel, bool urgent) const {
762
764 if (lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING) == lcParams.end() && lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR) == lcParams.end()) {
766 // no dependency of lateral speed on longitudinal speed. (Only called prior to LC initialization to determine whether it could be completed)
768 } else {
769 return remainingManeuverDist / myVehicle.getVehicleType().getMaxSpeedLat();
770 }
771 }
772
773 if (remainingManeuverDist == 0) {
774 return 0;
775 }
776
777 // Check argument assumptions
778 assert(speed >= 0);
779 assert(remainingManeuverDist >= 0);
780 assert(decel > 0);
783 assert(myMaxSpeedLatStanding >= 0);
784
785 // for brevity
786 const double v0 = speed;
787 const double D = remainingManeuverDist;
788 const double b = decel;
789 const double wmin = myMaxSpeedLatStanding;
790 const double f = myMaxSpeedLatFactor;
791 const double wmax = myVehicle.getVehicleType().getMaxSpeedLat();
792
793 /* Here's the approach for the calculation of the required time for the LC:
794 * To obtain the maximal LC-duration, for v(t) we assume that v(t)=max(0, v0-b*t),
795 * Where v(t)=0 <=> t >= ts:=v0/b
796 * For the lateral speed w(t) this gives:
797 * w(t) = min(wmax, wmin + f*v(t))
798 * The lateral distance covered until t is
799 * d(t) = int_0^t w(s) ds
800 * We distinguish three possibilities for the solution d(T)=D, where T is the time of the LC completion.
801 * 1) w(T) = wmax, i.e. v(T)>(wmax-wmin)/f
802 * 2) wmin < w(T) < wmax, i.e. (wmax-wmin)/f > v(T) > 0
803 * 3) w(T) = wmin, i.e., v(T)=0
804 */
805 const double vm = (wmax - wmin) / f;
806 double distSoFar = 0.;
807 double timeSoFar = 0.;
808 double v = v0;
809 if (v > vm) {
810 const double wmaxTime = (v0 - vm) / b;
811 const double d1 = wmax * wmaxTime;
812 if (d1 >= D) {
813 return D / wmax;
814 } else {
815 distSoFar += d1;
816 timeSoFar += wmaxTime;
817 v = vm;
818 }
819 }
820 if (v > 0) {
821 /* Here, w(t1+t) = wmin + f*v(t1+t) = wmin + f*(v - b*t)
822 * Thus, the additional lateral distance covered after time t is:
823 * d2 = (wmin + f*v)*t - 0.5*f*b*t^2
824 * and the additional lateral distance covered until v=0 at t=v/b is:
825 * d2 = (wmin + 0.5*f*v)*t
826 */
827 const double t = v / b; // stop time
828 const double d2 = (wmin + 0.5 * f * v) * t; // lateral distance covered until stop
829 assert(d2 > 0);
830 if (distSoFar + d2 >= D) {
831 // LC is completed during this phase
832 const double x = 0.5 * f * b;
833 const double y = wmin + f * v;
834 /* Solve D - distSoFar = y*t - x*t^2.
835 * 0 = x*t^2 - y*t/x + (D - distSoFar)/x
836 */
837 const double p = 0.5 * y / x;
838 const double q = (D - distSoFar) / x;
839 assert(p * p - q > 0);
840 const double t2 = p + sqrt(p * p - q);
841 return timeSoFar + t2;
842 } else {
843 distSoFar += d2;
844 timeSoFar += t;
845 //v = 0;
846 }
847 }
848 // If we didn't return yet this means the LC was not completed until the vehicle stops (if braking with rate b)
849 if (wmin == 0) {
850 // LC won't be completed if vehicle stands
851 double maneuverDist = remainingManeuverDist;
852 const double vModel = computeSpeedLat(maneuverDist, maneuverDist, urgent);
853 double result = D / vModel;
854 // make sure that the vehicle isn't braking to a stop during the manuever
855 if (vModel > SUMO_const_haltingSpeed && (vModel + myVehicle.getAcceleration() * result) > SUMO_const_haltingSpeed) {
856 // unless the model tells us something different
857 return result;
858 } else {
859 return -1;
860 }
861 } else {
862 // complete LC with lateral speed wmin
863 return timeSoFar + (D - distSoFar) / wmin;
864 }
865}
866
869 assert(isChangingLanes()); // Only to be called during ongoing lane change
871 if (lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING) == lcParams.end() && lcParams.find(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR) == lcParams.end()) {
874 } else {
876 }
877 }
878 // Using maxSpeedLat(Factor/Standing)
879 const bool urgent = (myOwnState & LCA_URGENT) != 0;
883}
884
885
886void
888 //std::cout << SIMTIME << " veh=" << myVehicle.getID() << " @=" << &myVehicle << " set shadow approaching=" << link->getViaLaneOrLane()->getID() << "\n";
889 myApproachedByShadow.push_back(link);
890}
891
892void
894 for (std::vector<MSLink*>::iterator it = myApproachedByShadow.begin(); it != myApproachedByShadow.end(); ++it) {
895 //std::cout << SIMTIME << " veh=" << myVehicle.getID() << " @=" << &myVehicle << " remove shadow approaching=" << (*it)->getViaLaneOrLane()->getID() << "\n";
896 (*it)->removeApproaching(&myVehicle);
897 }
898 myApproachedByShadow.clear();
899}
900
901
902
903void
906 int oldstate = myVehicle.getLaneChangeModel().getOwnState();
907 if (myOwnState != newstate) {
909 // Calculate and set the lateral maneuver distance corresponding to the change request
910 // to induce a corresponding sublane change.
911 const int dir = (newstate & LCA_RIGHT) != 0 ? -1 : ((newstate & LCA_LEFT) != 0 ? 1 : 0);
912 // minimum distance to move the vehicle fully onto the lane at offset dir
913 const double latLaneDist = myVehicle.lateralDistanceToLane(dir);
914 if ((newstate & LCA_TRACI) != 0) {
915 if ((newstate & LCA_STAY) != 0) {
916 setManeuverDist(0.);
917 } else if (((newstate & LCA_RIGHT) != 0 && dir < 0)
918 || ((newstate & LCA_LEFT) != 0 && dir > 0)) {
919 setManeuverDist(latLaneDist);
920 }
921 }
922 if (myVehicle.hasInfluencer()) {
923 // lane change requests override sublane change requests
925 }
926
927 }
928 setOwnState(newstate);
929 } else {
930 // Check for sublane change requests
932 const double maneuverDist = myVehicle.getInfluencer().getLatDist();
935 newstate |= LCA_TRACI;
936 if (myOwnState != newstate) {
937 setOwnState(newstate);
938 }
939 if (gDebugFlag2) {
940 std::cout << " traci influenced maneuverDist=" << maneuverDist << "\n";
941 }
942 }
943 }
944 if (gDebugFlag2) {
945 std::cout << SIMTIME << " veh=" << myVehicle.getID() << " stateAfterTraCI=" << toString((LaneChangeAction)newstate) << " original=" << toString((LaneChangeAction)oldstate) << "\n";
946 }
947}
948
949void
954
955void
957 if (follower.first != 0) {
958 myLastFollowerGap = follower.second + follower.first->getVehicleType().getMinGap();
960 myLastFollowerSpeed = follower.first->getSpeed();
961 }
962}
963
964void
966 if (leader.first != 0) {
968 myLastLeaderSecureGap = secGap;
969 myLastLeaderSpeed = leader.first->getSpeed();
970 }
971}
972
973void
975 if (leader.first != 0) {
978 myLastOrigLeaderSpeed = leader.first->getSpeed();
979 }
980}
981
982void
1005
1006void
1008 int rightmost;
1009 int leftmost;
1010 vehicles.getSubLanes(&myVehicle, 0, rightmost, leftmost);
1011 for (int i = rightmost; i <= leftmost; ++i) {
1012 CLeaderDist vehDist = vehicles[i];
1013 if (vehDist.first != 0) {
1014 const MSVehicle* leader = &myVehicle;
1015 const MSVehicle* follower = vehDist.first;
1016 const double netGap = vehDist.second + follower->getVehicleType().getMinGap();
1017 if (netGap < myLastFollowerGap && netGap >= 0) {
1018 myLastFollowerGap = netGap;
1019 myLastFollowerSecureGap = follower->getCarFollowModel().getSecureGap(follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel());
1020 myLastFollowerSpeed = follower->getSpeed();
1021 }
1022 }
1023 }
1024}
1025
1026void
1028 int rightmost;
1029 int leftmost;
1030 vehicles.getSubLanes(&myVehicle, 0, rightmost, leftmost);
1031 for (int i = rightmost; i <= leftmost; ++i) {
1032 CLeaderDist vehDist = vehicles[i];
1033 if (vehDist.first != 0) {
1034 const MSVehicle* leader = vehDist.first;
1035 const MSVehicle* follower = &myVehicle;
1036 const double netGap = vehDist.second + follower->getVehicleType().getMinGap();
1037 if (netGap < myLastLeaderGap && netGap >= 0) {
1038 myLastLeaderGap = netGap;
1039 myLastLeaderSecureGap = follower->getCarFollowModel().getSecureGap(follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel());
1040 myLastLeaderSpeed = leader->getSpeed();
1041 }
1042 }
1043 }
1044}
1045
1046void
1048 int rightmost;
1049 int leftmost;
1050 vehicles.getSubLanes(&myVehicle, 0, rightmost, leftmost);
1051 for (int i = rightmost; i <= leftmost; ++i) {
1052 CLeaderDist vehDist = vehicles[i];
1053 if (vehDist.first != 0) {
1054 const MSVehicle* leader = vehDist.first;
1055 const MSVehicle* follower = &myVehicle;
1056 const double netGap = vehDist.second + follower->getVehicleType().getMinGap();
1057 if (netGap < myLastOrigLeaderGap && netGap >= 0) {
1058 myLastOrigLeaderGap = netGap;
1059 myLastOrigLeaderSecureGap = follower->getCarFollowModel().getSecureGap(follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel());
1060 myLastOrigLeaderSpeed = leader->getSpeed();
1061 }
1062 }
1063 }
1064}
1065
1066
1067bool
1069 const int stateRight = mySavedStateRight.second;
1070 if (
1071 (stateRight & LCA_STRATEGIC) != 0
1072 && (stateRight & LCA_RIGHT) != 0
1073 && (stateRight & LCA_BLOCKED) != 0) {
1074 return true;
1075 }
1076 const int stateLeft = mySavedStateLeft.second;
1077 if (
1078 (stateLeft & LCA_STRATEGIC) != 0
1079 && (stateLeft & LCA_LEFT) != 0
1080 && (stateLeft & LCA_BLOCKED) != 0) {
1081 return true;
1082 }
1083 return false;
1084}
1085
1086double
1090
1091
1092int
1094 const int i = myVehicle.getLane()->getIndex();
1095 if (myAmOpposite) {
1097 } else {
1098 return i;
1099 }
1100}
1101
1102void
1103MSAbstractLaneChangeModel::addLCSpeedAdvice(const double vSafe, bool ownAdvice) {
1104 const double accel = SPEED2ACCEL(vSafe - myVehicle.getSpeed());
1105 myLCAccelerationAdvices.push_back({accel, ownAdvice});
1106}
1107
1108
1109void
1111 std::vector<std::string> lcState;
1113 lcState.push_back(toString(mySpeedLat));
1114 lcState.push_back(toString(myLaneChangeCompletion));
1115 lcState.push_back(toString(myLaneChangeDirection));
1116 }
1117 if (lcState.size() > 0) {
1118 out.writeAttr(SUMO_ATTR_LCSTATE, lcState);
1119 }
1120}
1121
1122void
1124 if (attrs.hasAttribute(SUMO_ATTR_LCSTATE)) {
1125 std::istringstream bis(attrs.getString(SUMO_ATTR_LCSTATE));
1126 bis >> mySpeedLat;
1128 bis >> myLaneChangeDirection;
1129 }
1130}
long long int SUMOTime
Definition GUI.h:36
#define LC_ASSUMED_DECEL
std::pair< const MSVehicle *, double > CLeaderDist
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TLF(string,...)
Definition MsgHandler.h:317
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
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 SPEED2DIST(x)
Definition SUMOTime.h:45
#define SIMTIME
Definition SUMOTime.h:62
#define TIME2STEPS(x)
Definition SUMOTime.h:57
#define DIST2SPEED(x)
Definition SUMOTime.h:47
#define SPEED2ACCEL(x)
Definition SUMOTime.h:53
const long long int VTYPEPARS_MAXSPEED_LAT_SET
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_MOTORCYCLE
vehicle is a motorcycle
@ SVC_EMERGENCY
public emergency vehicles
@ SVC_MOPED
vehicle is a moped
LaneChangeAction
The state of a vehicle's lane-change behavior.
@ LCA_UNKNOWN
The action has not been determined.
@ LCA_BLOCKED
blocked in all directions
@ LCA_URGENT
The action is urgent (to be defined by lc-model)
@ LCA_STAY
Needs to stay on the current lane.
@ LCA_AMBACKBLOCKER
@ LCA_AMBLOCKINGLEADER
@ LCA_LEFT
Wants go to the left.
@ LCA_STRATEGIC
The action is needed to follow the route (navigational lc)
@ LCA_AMBACKBLOCKER_STANDING
@ LCA_TRACI
The action is due to a TraCI request.
@ LCA_RIGHT
Wants go to the right.
@ LCA_AMBLOCKINGFOLLOWER
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_Y
@ SUMO_ATTR_X
@ SUMO_ATTR_LCA_MAXDISTLATSTANDING
@ SUMO_ATTR_LCA_MAXSPEEDLATFACTOR
@ SUMO_ATTR_LCA_MAXSPEEDLATSTANDING
@ SUMO_ATTR_LCA_STRATEGIC_LOOKAHEAD
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_LCA_SIGMA
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_ID
@ SUMO_ATTR_LCSTATE
The state of the lanechange model.
@ SUMO_ATTR_LCA_OVERTAKE_RIGHT
@ SUMO_ATTR_DIR
The abstract direction of a link.
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_TIME
trigger: the time of the step
bool gDebugFlag2
Definition StdDefs.cpp:38
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition StdDefs.h:58
T MAX2(T a, T b)
Definition StdDefs.h:82
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
Interface for lane-change models.
double getForwardPos() const
get vehicle position relative to the forward direction lane
double myAccelerationLat
the current lateral acceleration
void setFollowerGaps(CLeaderDist follower, double secGap)
std::vector< MSLane * > myFurtherTargetLanes
bool myAlreadyChanged
whether the vehicle has already moved this step
bool myAmOpposite
whether the vehicle is driving in the opposite direction
std::shared_ptr< MSLeaderDistanceInfo > myRightFollowers
std::shared_ptr< MSLeaderDistanceInfo > myRightLeaders
virtual void setOwnState(const int state)
bool pastMidpoint() const
return whether the vehicle passed the midpoint of a continuous lane change maneuver
double myPreviousAngleOffset
the angle offset of the previous time step resulting from lane change and sigma
virtual double getAssumedDecelForLaneChangeDuration() const
Returns a deceleration value which is used for the estimation of the duration of a lane change.
virtual double computeSpeedLat(double latDist, double &maneuverDist, bool urgent) const
decides the next lateral speed depending on the remaining lane change distance to be covered and upda...
virtual double estimateLCDuration(const double speed, const double remainingManeuverDist, const double decel, bool urgent) const
Calculates the maximal time needed to complete a lane change maneuver if lcMaxSpeedLatFactor and lcMa...
std::shared_ptr< MSLeaderDistanceInfo > myLeftLeaders
int myPreviousState
lane changing state from the previous simulation step
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
int myOwnState
The current state of the vehicle.
double myLastOrigLeaderGap
acutal and secure distance to closest leader vehicle on the original when performing lane change
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
void laneChangeOutput(const std::string &tag, MSLane *source, MSLane *target, int direction, double maneuverDist=0)
called once the vehicle ends a lane change manoeuvre (non-instant)
bool myDontResetLCGaps
Flag to prevent resetting the memorized values for LC relevant gaps until the LC output is triggered ...
int myPreviousState2
lane changing state from step before the previous simulation step
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
const std::shared_ptr< MSLeaderDistanceInfo > getFollowers(const int dir)
Returns the neighboring, lc-relevant followers for the last step in the requested direction.
double myCommittedSpeed
the speed when committing to a change maneuver
std::shared_ptr< MSLeaderDistanceInfo > myLeftFollowers
Cached info on lc-relevant neighboring vehicles.
static bool myLCOutput
whether to record lane-changing
bool startLaneChangeManeuver(MSLane *source, MSLane *target, int direction)
start the lane change maneuver and return whether it continues
virtual void saveState(OutputDevice &out) const
Save the state of the laneChangeModel.
std::pair< int, int > mySavedStateRight
double myLastLeaderSecureGap
the minimum longitudinal distances to vehicles on the target lane that would be necessary for stringe...
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
void saveLCState(const int dir, int stateWithoutTraCI, const int state)
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
std::vector< MSLink * > myApproachedByShadow
links which are approached by the shadow vehicle
void addLCSpeedAdvice(const double vSafe, bool ownAdvice=true)
Takes a vSafe (speed advice for speed in the next simulation step), converts it into an acceleration ...
void setLeaderGaps(CLeaderDist, double secGap)
const std::shared_ptr< MSLeaderDistanceInfo > getLeaders(const int dir)
Returns the neighboring, lc-relevant leaders for the last step in the requested direction.
std::vector< MSLane * > myNoPartiallyOccupatedByShadow
bool cancelRequest(int state, int laneOffset)
whether the influencer cancels the given request
double myLastLeaderGap
the actual minimum longitudinal distances to vehicles on the target lane
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
void setOrigLeaderGaps(CLeaderDist, double secGap)
void setManeuverDist(const double dist)
Updates the remaining distance for the current maneuver while it is continued within non-action steps...
std::vector< std::pair< double, bool > > myLCAccelerationAdvices
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
int getNormalizedLaneIndex()
brief return lane index that treats opposite lanes like normal lanes to the left of the forward lanes
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
void setSpeedLat(double speedLat)
set the lateral speed and update lateral acceleraton
MSLane * myTargetLane
The target lane for the vehicle's current maneuver.
MSLane * determineTargetLane(int &targetDir) const
double myPreviousManeuverDist
Maneuver distance from the previous simulation step.
double getMaxSpeedLat2() const
return the max of maxSpeedLat and lcMaxSpeedLatStanding
std::vector< double > myShadowFurtherLanesPosLat
const MSCFModel & getCarFollowModel() const
The vehicle's car following model.
MSLane * myShadowLane
A lane that is partially occupied by the front of the vehicle but that is not the primary lane.
double mySpeedLat
the current lateral speed
virtual void updateSafeLatDist(const double travelledLatDist)
Updates the value of safe lateral distances (in SL2015) during maneuver continuation in non-action st...
void checkTraCICommands()
Check for commands issued for the vehicle via TraCI and apply the appropriate state changes For the s...
double myManeuverDist
The complete lateral distance the vehicle wants to travel to finish its maneuver Only used by sublane...
int myLaneChangeDirection
direction of the lane change maneuver -1 means right, 1 means left
void primaryLaneChanged(MSLane *source, MSLane *target, int direction)
called once when the vehicles primary lane changes
int getShadowDirection() const
return the direction in which the current shadow lane lies
double myLastLeaderSpeed
speeds of surrounding vehicles at the time of lane change
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the laneChangeModel from the given attributes.
MSAbstractLaneChangeModel(MSVehicle &v, const LaneChangeModel model)
Constructor.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
double calcAngleOffset()
return the angle offset during a continuous change maneuver
double myAngleOffset
the current angle offset resulting from lane change and sigma
double myLastLateralGapLeft
the minimum lateral gaps to other vehicles that were found when last changing to the left and right
virtual ~MSAbstractLaneChangeModel()
Destructor.
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
void memorizeGapsAtLCInit()
Control for resetting the memorized values for LC relevant gaps until the LC output is triggered in t...
double myLaneChangeCompletion
progress of the lane change maneuver 0:started, 1:complete
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
virtual void changed()=0
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
std::vector< MSLane * > myShadowFurtherLanes
virtual bool congested(const MSVehicle *const neighLeader)
void clearNeighbors()
Clear info on neighboring vehicle from previous step.
void saveNeighbors(const int dir, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &leaders)
Saves the lane change relevant vehicles, which are currently on neighboring lanes in the given direct...
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getLength() const
Returns the vehicle's length.
MSStop & getNextStop()
double getWidth() const
Returns the vehicle's width.
SumoRNG * getRNG() const
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual double interactionGap(const MSVehicle *const veh, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition MSCFModel.h:264
A device which collects info on the vehicle trip (mainly on departure and arrival)
int getNumLanes() const
Definition MSEdge.h:172
static double gLateralResolution
Definition MSGlobals.h:100
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition MSGlobals.h:174
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
Definition MSGlobals.h:165
static SUMOTime gLaneChangeDuration
Definition MSGlobals.h:97
A lane change model developed by D. Krajzewicz between 2004 and 2010.
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013,...
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013.
A lane change model developed by J. Erdmann.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition MSLane.cpp:2774
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition MSLane.cpp:427
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition MSLane.cpp:2669
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition MSLane.cpp:1349
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition MSLane.h:592
void enteredByLaneChange(MSVehicle *v)
Definition MSLane.cpp:3279
double getLength() const
Returns the lane's length.
Definition MSLane.h:606
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition MSLane.cpp:374
int getIndex() const
Returns the lane's index.
Definition MSLane.h:642
void leftByLaneChange(MSVehicle *v)
Definition MSLane.cpp:3272
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition MSLane.cpp:4312
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition MSLane.cpp:393
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition MSLane.cpp:416
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
Definition MSLane.cpp:4306
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:764
double getWidth() const
Returns the lane's width.
Definition MSLane.h:635
saves leader/follower vehicles and their distances relative to an ego vehicle
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
Notification
Definition of a vehicle state.
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
bool isOpposite
whether this an opposite-direction stop
Definition MSStop.h:87
double getLatDist() const
Definition MSVehicle.h:1584
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
const std::vector< double > & getFurtherLanesPosLat() const
Definition MSVehicle.h:839
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
MSAbstractLaneChangeModel & getLaneChangeModel()
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
void fixPosition()
repair errors in vehicle position after changing between internal edges
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:514
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
void switchOffSignal(int signal)
Switches the given signal off.
Definition MSVehicle.h:1169
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
Definition MSVehicle.h:1108
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
Definition MSVehicle.h:1110
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MSVehicle.h:581
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
Influencer & getInfluencer()
double updateFurtherLanes(std::vector< MSLane * > &furtherLanes, std::vector< double > &furtherLanesPosLat, const std::vector< MSLane * > &passedLanes)
update a vector of further lanes and return the new backPos
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition MSVehicle.h:413
bool congested() const
double getSpeed() const
Returns the vehicle's current speed.
Definition MSVehicle.h:490
const std::vector< MSLane * > & getFurtherLanes() const
Definition MSVehicle.h:835
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition MSVehicle.h:969
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MSVehicle.h:374
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition MSVehicle.h:1680
void switchOnSignal(int signal)
Switches the given signal on.
Definition MSVehicle.h:1161
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
const std::string & getID() const
Returns the name of the vehicle type.
double getMinGap() const
Get the free space in front of vehicles of this class.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
const SUMOVTypeParameter & getParameter() const
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
A storage for options typed value containers)
Definition OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
const SubParams & getLCParams() const
Returns the LC parameter.
#define DEBUG_COND
Definition json.hpp:4471
#define M_PI
Definition odrSpiral.cpp:45