Skip to content

Fix agent-cap wipe, Town03 map crash, and short HDMap smoothing - #40

Draft
cursor[bot] wants to merge 3 commits into
devfrom
cursor/critical-bug-inspection-17b0
Draft

Fix agent-cap wipe, Town03 map crash, and short HDMap smoothing#40
cursor[bot] wants to merge 3 commits into
devfrom
cursor/critical-bug-inspection-17b0

Conversation

@cursor

@cursor cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Bug and impact

Three high-severity correctness bugs on dev:

  1. Detection / NPC wipe at the agent cap. PerceptionModel.add_agent_vehicle cleared all agents when c11_max_agents (default 12) was reached, then appended the new one. FastBEV rebuilds detections each frame, so a scene with 13+ clusters left only the last obstacle. Spawning a 13th NPC in BasicSim deleted every previously spawned agent. Lattice / velocity planners then planned through traffic that was still present.

  2. Bundled Town03 OpenDRIVE cannot load. _connect_lanes looked up predecessor/successor lanes in the driving-only lane_by_uid map and dereferenced None when the link pointed at a sidewalk or missing lane. After skipping those links, can_laneA_access_laneB still crashed on short CARLA junction centerlines ([:, -3] on a 2-point polyline). Selecting data/Town03_Opt.xodr aborted stack build.

  3. Short HDMap routes crash in Savitzky–Golay. smoothen_path_savgol is always called from HDMapGlobalPlanner.plan. After 0.5 m near-duplicate pruning, a same-lane start/goal a few meters apart can leave 3, 4, or 6 points. The window clamp produced window_length > n or polyorder >= window_length, raising ValueError and killing global replan.

Root cause

  • Cap handler replaced the list instead of evicting the oldest agent.
  • Lane-link resolution assumed every OpenDRIVE predecessor/successor id is a driving lane, and heading checks assumed ≥3 centerline samples.
  • Smoothing adjusted window length to an odd number without also enforcing window_length <= n and polyorder < window_length.

Fix

  • Evict oldest agents (FIFO) until there is room; refuse adds when the cap is ≤0.
  • Skip unresolved lane links; clamp centerline column indices in the access check.
  • Clamp Savitzky–Golay window/polyorder and skip smoothing when the cleaned path is too short.

Validation

  • test_add_agent_evicts_oldest_when_cap_reached — 5 adds with cap 3 keep the last 3.
  • Unresolved-link fixture + bundled Town03_Opt.xodr load without crash.
  • smoothen_path_savgol parametrized for n ∈ {2..8}.
  • pytest test/c10_perception/ test/c20_planning/test_c24_global_hdmap_planners.py — 28 related tests passed; broader perception/planning subset 43 passed.

Not in this PR

Existing open inspection PRs (#22#37) were not re-reported. Toolbar Save Settings still omits planning/control YAML (silent profile data loss); F-key profile cycle still skips reload_stack. Those are noted in the Slack summary.

Open in Web View Automation 

cursoragent and others added 3 commits August 17, 2026 05:09
…olay.

Evict the oldest agent instead of clearing the detection set when
c11_max_agents is reached. Skip unresolved OpenDRIVE lane predecessors
so bundled Town03 loads. Clamp Savitzky–Golay window/polyorder so short
HDMap routes no longer raise.

Co-authored-by: Majid Khonji <majid-khonji@users.noreply.github.com>
Town03 junction stubs have 2-point polylines; indexing [:, -3] crashed
after unresolved links were skipped. Clamp column indices instead.

Co-authored-by: Majid Khonji <majid-khonji@users.noreply.github.com>
Co-authored-by: Majid Khonji <majid-khonji@users.noreply.github.com>
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