Fix neighbour_vehicles not detecting vehicles on connected lanes#667
Open
Lidang-Jiang wants to merge 1 commit intoFarama-Foundation:masterfrom
Open
Fix neighbour_vehicles not detecting vehicles on connected lanes#667Lidang-Jiang wants to merge 1 commit intoFarama-Foundation:masterfrom
Lidang-Jiang wants to merge 1 commit intoFarama-Foundation:masterfrom
Conversation
Road.neighbour_vehicles() only searched the current lane segment for front/rear neighbours. Vehicles that had crossed into a connected next/previous segment were invisible, causing incorrect behaviour in multi-segment environments (Racetrack, Roundabout, Intersection). Extend the search to downstream and upstream connected lanes via the road network graph, mapping longitudinal coordinates with appropriate offsets. All 61 existing tests pass unchanged. Fixes Farama-Foundation#626 Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Road.neighbour_vehicles()only searched the current lane segment for front/rear neighbours. Vehicles that had crossed into a connected next or previous lane segment were invisible, causing incorrect behaviour in multi-segment environments like Racetrack, Roundabout, and Intersection.This PR extends the search to connected lanes:
graph[_to]using the current lane's endpoint as the new start node, with longitudinal offset+= current_lane.length-= prev_lane.lengthAll 61 existing tests pass unchanged. 14 new tests added covering same-segment regression, connected-lane detection, curve segments, multi-lane filtering, and edge cases.
Fixes #626
Before (bug reproduction)
After (bug fixed)
Full test output (after)
Test plan