Skip to content

Planner and sim speed-ups, trajsample overhaul, motion metrics - #144

Merged
isaac0804 merged 7 commits into
mainfrom
perf/planner-and-sim-speedup
Oct 14, 2026
Merged

isaac0804 merged 7 commits into
mainfrom
perf/planner-and-sim-speedup

Conversation

@isaac0804

Copy link
Copy Markdown
Contributor

Speed-ups for the planner and simulator, a trajectory-sampling overhaul, motion and collision metrics, and a per-strategy preferred control scheme.

What's in it

Simulator and startup

  • rSim (vendor/rSim): a raw step buffer (step_fast, get_state_array) and a Release -O3 -march=native build. pybind11 is bumped to 2.13.6, with its hash pinned. robosim_wrapper falls back to the old calls when the extension doesn't have them, so CI's rc-robosim is unaffected.
  • The robosim subprocess launches .pixi/envs/robosim/bin/python directly instead of through pixi run, cutting startup from about 469 ms to 19 ms. The sim is reused across matches within a tournament.
  • Frame generation avoids redundant dict copies.

FastPathPlanner

  • Optional C++ extension (fastpathplanning/cpp, built with pixi run build-planner). It's used when present; the numba kernels are used otherwise. Exact-math mode stays bit-identical (fastpathplanner_equivalence_test.py). The C++ fast path matches numba to 1e-9 (test_fastpathplanner_cpp.py), and that module skips when the extension isn't built (it isn't built in CI).

Trajectory sampling

  • Fixes over-inflation of the transverse reachability tube in collision_numba.
  • Picks the candidate with the shortest arrival time, with 0.15 s hysteresis.
  • A symmetric fan of intermediate targets whose radius scales with distance to the target.
  • Sumatra-style fallback ranking, and role-aware priority (the ball carrier outranks off-ball teammates).
  • The motion planning benchmark grows to 29 scenarios; trajsample passes all of them.

Metrics and control scheme

  • motion_stats and MatchStats: robot and teammate overlap ticks, near-miss ticks, worst clearance, and discrete collision incidents, reported in the round-robin summary.
  • Strategies can declare a preferred control scheme (AbstractStrategy.control_scheme). round_robin's default (fpp) is unchanged, and no strategy declares one yet.

Caveats

  • Trajsample is not ready to be the default. The 2026-10-14 trajsample round-robin (tournament_20261014_105956) had 10 of 66 matches stall and 248 goals. The 2026-10-10 fpp run on the same 66 pairings had no stalls and 471 goals.
  • The C++ FPP fast path can change match results. Whether the extension is built affects results within the 1e-9 tolerance, and the match cache doesn't record it. Round-robins meant to be compared should be run with the same build.
  • The sim and planner changes alter the round-robin fingerprint, so every cached match reruns. A new fpp baseline will be run after this and Real SSL logs as replays, goal ledger, situation bench, and referee fixes #143 are merged.

Tests

  • origin/main + this branch + Real SSL logs as replays, goal ledger, situation bench, and referee fixes #143 merged: lint passes, and pytest utama_core/tests/ --headless --level quick --ignore-glob "**/*grsim*" gives 12680 passed, 87 xfailed, 0 failed.
  • Without the extension, utama_core/tests/motion_planning/ gives 1612 passed, 1 skipped (the C++ module), 87 xfailed. With it built, test_fastpathplanner_cpp.py passes 9 of 9.

🤖 Generated with Claude Code

isaac0804 and others added 7 commits October 14, 2026 11:51
- Add fast raw step buffer to robosim C++ extension and wrapper
- Optimize Frame generation and avoid redundant dict copies
- Add C++ FastPathPlanner implementation and exact equivalence tests
…uite

- Fix transverse tube reachability expansion in collision_numba (remove 1.34m over-inflation)
- Implement global duration-optimal candidate selection with 0.15s hysteresis
- Add symmetric intermediate target fan with compact radius scaling (0.6m to 1.0m)
- Implement Sumatra-aligned fallback progress ranking towards target
- Implement role-aware priority ordering (ball-carrier outranks off-ball teammates)
- Expand motion planning benchmark to 29 scenarios (all passing 100%)
- Add unit test test_has_priority_role_aware_ball_carrier_and_fallback
- Motion planning metrics: Added robot_overlap_ticks, teammate_overlap_ticks,
  near_miss_ticks, and worst_clearance_m to MatchStats and round-robin
  summary reporting, with a fast vectorized motion_stats analysis tool.
- 25x faster robosim subprocess startup: Launch .pixi/envs/robosim/bin/python
  directly with PATH and LD_LIBRARY_PATH instead of invoking 'pixi run',
  slashing startup time from 469ms to 18.7ms.
- Simulator process reuse: Enabled sim reuse across matches in tournament
  evaluations to avoid repeated ODE world instantiation.
- Trajectory sampling collision optimizations: Returned obstacle kind directly
  from Numba to eliminate redundant second collision scans on static obstacles.
- Clearance and allocations: Replaced multi-pass loops with single-pass scans,
  added slots=True to core trajectory and plan dataclasses.
CI doesn't run `pixi run build-planner`, so importing `_fastpathplanner`
failed test collection there. The planner already falls back to the numba
kernels; the test module now skips the same way.

Restore the pybind11 URL_HASH dropped with the 2.13.6 bump, in both the
rSim and FastPathPlanner CMake files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@isaac0804 isaac0804 added the release:minor Minor changes to main label Oct 14, 2026
@isaac0804
isaac0804 merged commit a1b8bdd into main Oct 14, 2026
4 of 5 checks passed
@isaac0804
isaac0804 deleted the perf/planner-and-sim-speedup branch October 14, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:minor Minor changes to main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant