Skip to content

Commit

Permalink
now ignoring some bidi-sublane conflicts. refs #11642
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Jun 16, 2023
1 parent 62ad809 commit b94736f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/microsim/MSLink.cpp
Expand Up @@ -1512,22 +1512,28 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector<const MSPer
leader->getCarFollowModel().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;
}
// ignore vehicles if not in conflict sublane-wise
const double egoLatOffset = isShadowLink ? ego->getLatOffset(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);
if (gDebugFlag1) {
std::cout << " checkIgnore sublaneFoe lane=" << myInternalLaneBefore->getID()
<< " sameSource=" << sameSource
<< " sameTarget=" << sameTarget
<< " foeLaneIsBidi=" << foeLaneIsBidi
<< " foeLane=" << foeLane->getID()
<< " leader=" << leader->getID()
<< " egoLane=" << ego->getLane()->getID()
Expand Down Expand Up @@ -1557,7 +1563,7 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector<const MSPer
}
continue;
}
} else {
} else if (sameTarget) {
// for lanes from different edges we cannot rely on the
// index due to wrap-around issues
if (myDirection != foeEntryLink->getDirection()) {
Expand All @@ -1580,6 +1586,11 @@ MSLink::getLeaderInfo(const MSVehicle* ego, double dist, std::vector<const MSPer
} else {
// XXX figure out relative direction somehow
}
} else {
if (gDebugFlag1) {
std::cout << " ignored oncoming bidi leader\n";
}
continue;
}
}
}
Expand Down

0 comments on commit b94736f

Please sign in to comment.