Skip to content

Fix A*, route prediction, interval/route operations, and Python submodule bugs & perf in ad_map_access - #265

Open
M-Colley wants to merge 1 commit into
carla-simulator:mainfrom
M-Colley:fix/ad-map-access-routing-and-python
Open

M-Colley wants to merge 1 commit into
carla-simulator:mainfrom
M-Colley:fix/ad-map-access-routing-and-python

Conversation

@M-Colley

@M-Colley M-Colley commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes routing correctness bugs, A* open-set relaxation and asymptotic complexity, RoutePrediction exception safety, RouteOperation / LaneIntervalOperation edge cases, and Python binding sys.modules collisions in ad_map_access.

Note: Part 4 of 5 independent, modular PRs branched directly from main with strictly disjoint file sets (each builds, tests, and merges cleanly in any order).

Bug Fixes

  • A & Route Expansion (RouteAStar, RouteExpander, Planning)*:
    • Update routeDuration alongside routeDistance and cost when relaxing an open-set neighbor in RouteAstar::addNeighbor.
    • Respect explicit destination direction in RouteExpander::expandSameLaneNeighbors without clobbering concrete movement direction.
    • Fix MergingRouteSearch mutating caller prediction hints in place, and fall back to merging search in planRoute when direct A* results are filtered out.
  • Route Prediction (RoutePrediction):
    • Manage RouteTreeElement nodes with an RAII std::deque instead of raw new/delete (fixing memory leaks if expansion throws) and avoid emitting bogus zero-length negative leaf routes on DONT_CARE unidirectional starts.
  • Route & Interval Operations (RouteOperation, LaneIntervalOperation):
    • Fix inverted left/right neighbor assignment in updateLaneSegmentNeighbors and synchronize minLaneOffset/maxLaneOffset in updateLaneConnections.
    • Normalize getRouteParaPointFromParaPoint offset by interval parametric length, guard zero-length segments/lanes in calculateRouteParaPointAtDistance and LaneIntervalOperation, clamp restrictIntervalFromBegin to interval end, avoid ParametricValue unsigned underflow in getMetricRanges, and fix getSpeedLimits(ConnectingRoute), empty RoadSegment sentinels, signed-to-unsigned std::distance UB on RouteIterator, opposing-lane remaining distance, and route counters in calculateBypassingRoute.
  • Python Bindings (AdMapAccessPython.cpp.in, generate_python_lib.py.in):
    • Scope submodules under ad_map_access.map.* so importing ad_map_access alongside ad_physics does not overwrite shared physics/geometry entries in sys.modules.

Performance Improvements

  • Replace $O(V^2)$ linear std::min_element open-set scans in RouteAstar::calculate with an $O((V + E) \log V)$ min-heap (std::priority_queue) and cache mDestPoint once per search instead of recomputing ENU coordinates at every expansion.

Tests

  • Added C++ unit and Python regression tests in LaneIntervalOperationTest.cpp, RoutePlanningTests.cpp, RoutePredictionTest.cpp, and ad_map_access/python/tests/interface_test.py.

This change is Reviewable

- Fix inverted left/right neighbor assignment in updateLaneSegmentNeighbors and sync min/max lane offsets in updateLaneConnections
- Fix RouteExpander::expandSameLaneNeighbors ignoring explicit destination direction and clobbering concrete movement direction
- Fix RouteAstar::addNeighbor leaving routeDuration stale on open-set path relaxation and replace O(V^2) open-set scan with O((V+E) log V) priority queue + cached mDestPoint
- Fix RoutePrediction exception-safety leak via RAII deque<RouteTreeElement> and prevent bogus 0-length negative leaf route on DONT_CARE unidirectional starts
- Normalize getRouteParaPointFromParaPoint offset by interval parametric length and guard zero-length segments in calculateRouteParaPointAtDistance
- Fix getSpeedLimits(ConnectingRoute) copy-paste bug, empty RoadSegment max() sentinels / infinite loop, signed-to-unsigned std::distance UB on RouteIterators, opposing-lane remaining distance, and missing route counters in calculateBypassingRoute
- Clamp restrictIntervalFromBegin to interval end, guard zero-length lanes in LaneIntervalOperation, and avoid ParametricValue subtraction underflow in getMetricRanges
- Fix MergingRouteSearch mutating prediction hints in place and fall back to Merging search when direct A* candidates are filtered out
- Scope ad_map_access Python submodules under ad_map_access.map.* to avoid sys.modules collisions with ad_physics
- Add unit and Python interface regression tests

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant