Skip to content

Fix async Control/Plan toggle orphans and before-start waypoint index - #28

Draft
cursor[bot] wants to merge 1 commit into
devfrom
cursor/critical-bug-inspection-7906
Draft

Fix async Control/Plan toggle orphans and before-start waypoint index#28
cursor[bot] wants to merge 1 commit into
devfrom
cursor/critical-bug-inspection-7906

Conversation

@cursor

@cursor cursor Bot commented Aug 3, 2026

Copy link
Copy Markdown

Summary

Two high-severity correctness bugs found in recent async / trajectory paths:

  1. Async Control/Plan toggle orphans and duplicates workers — Unchecking Control (or Planning) while AsyncThreadedExecuter was running treated the cooperative worker exit as a crash. step() cleared self.threads without stopping live peers, then vacuous all([]) restarted workers and left multiple Planner threads (Control could not come back cleanly).
  2. update_waypoint_by_xy left a stale current_wp before path start — After driving far along a path and teleporting/resetting slightly upstream of the first waypoint (closest_wp==0, projected s < path_s[0]), neither update branch ran. Stanley used the far-path heading (often π/2 after an L-corner) → max steer; Pure Pursuit used the wrong target speed.

Root cause

  • Stage flags were compared with is_alive() (call_control != alive), so intentional disable while the worker was still draining looked like a death; recreate wiped the join list without stop().
  • Before-start Frenet s had no waypoint-update branch when the nearest index was already 0.

Fix

  • Prune finished workers from the join list and _ensure_enabled_workers to start only stages that are enabled again (no peer teardown).
  • create_threads keeps still-alive peers in the join list.
  • update_waypoint_by_xy resets to current_wp=0 / next_wp=1 when ego is before path start.

Validation

PYTHONPATH=/workspace python3 -m pytest \
  test/c40_execution/test_c45_async_stage_toggle.py \
  test/c40_execution/test_c45_async_stop.py \
  test/c50_common/test_c54_trajectory_waypoint_update.py -v

11 passed.

Not re-reported (still open)

Open in Web View Automation 

… index.

AsyncThreadedExecuter treated Control/Plan checkbox off as a dead worker,
cleared the join list without stopping peers, then vacuous all([]) duplicated
Planner threads. Prune finished workers and restart only enabled stages.

update_waypoint_by_xy now resets to wp 0 when ego is upstream of path start
so Stanley/PP do not keep a far-path heading after teleport/reset.

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