diff --git a/src/microsim/MSLink.cpp b/src/microsim/MSLink.cpp index e652ecdcdab..7c958a7f24f 100644 --- a/src/microsim/MSLink.cpp +++ b/src/microsim/MSLink.cpp @@ -1512,7 +1512,8 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vectorgetCarFollowModel().brakeGap(leader->getSpeed()) <= foeLane->getLength() - leaderBack); const bool sameInternalEdge = &myInternalLaneBefore->getEdge() == &foeExitLink->getInternalLaneBefore()->getEdge(); - if (MSGlobals::gSublane && ego != nullptr && (sameSource || sameTarget) + const bool foeLaneIsBidi = myInternalLaneBefore->getBidiLane() == foeLane; + if (MSGlobals::gSublane && ego != nullptr && (sameSource || sameTarget || foeLaneIsBidi) && (!foeStrategicBlocked || sameInternalEdge)) { if (ego->getLane() == leader->getLane()) { continue; @@ -1520,7 +1521,11 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vectorgetLatOffset(ego->getLaneChangeModel().getShadowLane()) : 0; const double posLat = ego->getLateralPositionOnLane() + egoLatOffset; - const double posLatLeader = leader->getLateralPositionOnLane() + leader->getLatOffset(foeLane); + double posLatLeader = leader->getLateralPositionOnLane() + leader->getLatOffset(foeLane); + if (foeLaneIsBidi) { + // leader is oncoming + posLatLeader = foeLane->getWidth() - posLatLeader; + } const double latGap = (fabs(posLat - posLatLeader) - 0.5 * (ego->getVehicleType().getWidth() + leader->getVehicleType().getWidth())); const double maneuverDist = leader->getLaneChangeModel().getManeuverDist() * (posLat < posLatLeader ? -1 : 1); @@ -1528,6 +1533,7 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector