Skip to content

Commit

Permalink
ensure even more foes are found. refs #13313
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed May 30, 2023
1 parent f864656 commit f50c37c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/microsim/MSLaneChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ MSLaneChanger::getRealLeader(const ChangerIt& target) const {
//if (vehicle->getID() == "flow.21") std::cout << SIMTIME << " neighLead=" << Named::getIDSecure(neighLead) << " (422)\n";
}
}
if (neighLead == nullptr) {
// extra check for shared lane
const bool checkBidi = target->lane->getBidiLane() != nullptr && target->lane->getBidiLane()->getVehicleNumberWithPartials() > 0;
if (neighLead == nullptr || checkBidi) {
#ifdef DEBUG_SURROUNDING_VEHICLES
if (DEBUG_COND) {
std::cout << "Looking for leader on consecutive lanes." << std::endl;
Expand All @@ -564,12 +566,20 @@ MSLaneChanger::getRealLeader(const ChangerIt& target) const {
MSLane* targetLane = target->lane;
const double egoBack = vehicle->getBackPositionOnLane();
double leaderBack = targetLane->getLength();
if (neighLead != nullptr) {
leaderBack = neighLead->getBackPositionOnLane(targetLane);
}
for (MSVehicle* pl : targetLane->myPartialVehicles) {
double plBack = pl->getBackPositionOnLane(targetLane);
if (pl->getLane() == targetLane->getBidiLane()) {
plBack -= pl->getVehicleType().getLengthWithGap();
}
const double plPos = plBack + pl->getVehicleType().getLength();
#ifdef DEBUG_SURROUNDING_VEHICLES
if (DEBUG_COND) {
std::cout << " partial=" << pl->getID() << " plBack=" << plBack << " plPos=" << plPos << " leaderBack=" << leaderBack << " egoBack=" << egoBack << "\n";
}
#endif
if (plBack < leaderBack && plPos + pl->getVehicleType().getMinGap() >= egoBack) {
neighLead = pl;
leaderBack = plBack;
Expand Down

0 comments on commit f50c37c

Please sign in to comment.