Skip to content

fix: motion planning detours & hysteresis, custom referee rules, and benchmark metrics - #147

Merged
isaac0804 merged 4 commits into
mainfrom
fix/motion-planning-referee-tactics
Oct 19, 2026
Merged

isaac0804 merged 4 commits into
mainfrom
fix/motion-planning-referee-tactics

Conversation

@isaac0804

Copy link
Copy Markdown
Contributor

Summary

Comprehensive audit and stabilization across motion planning, referee overrides, and tactic partitioning:

1. Motion Planning

  • Detour Memory Keying (FastPathPlanner): Keyed detour memory on obstacle identity rather than contact points, eliminating dithering oscillations against static and dynamic obstacles.
  • Speed Modulation & Angular Penalties (TrajSample): Added temporal speed-modulation candidates (0.75x, 0.55x) and Sumatra-style angular deviation penalties. On crossing, completion time dropped from 5.10s -> 3.43s (-1.67s), path ratio dropped from 1.55x -> 1.09x, and brake events dropped from 3.0 -> 0.0.
  • Forward Candidate Pruning (TrajSample): Restricted intermediate candidate generation to the forward/lateral hemisphere (<= 90 deg), removing an erroneous 180-deg backward candidate that caused robots to reverse away from dynamic pinches (pinching_contest time dropped from 4.68s -> 2.57s and path ratio from 1.26x -> 1.06x).
  • Benchmark Metrics: Surfaced excess_distance_m and near_miss_ratio (% of moving ticks where clearance < 0.15m) across results JSON, markdown tables, and terminal reporting.

2. Custom Referee Rules & Actions

  • Keep-Out Clamping: Clamped restart positioning outside the 0.80m keep-out arc to prevent 0.79m boundary precision violations.
  • Penalty Positioning: Positioned defending penalty goalkeepers with +r_robot offset on the defense line and attacking keepers on their own goal line.
  • Crashing Rule: Avoided penalizing separating robots when relative crash speed <= threshold.
  • Double Touch: Fixed attribution of double-touch fouls to the last kicker and registered indirect free kicks in two-stage restarts.

3. Strategy & Tactics Hysteresis

  • Closer-to-Ball Hysteresis: Added margin-based hysteresis to friendly_closer_to_ball to prevent rapid 60Hz role-swapping between equidistant robots.
  • Activation Bounds: Widened spatial thresholds in ClearBallTactic (2.6m -> 3.0m) and PressAndContainTactic (1.4m -> 1.7m) to prevent boundary flickering; added Sticky[int] hysteresis to presser selection.
  • Deadlock Timeout: Added stall recovery timeout to DecoyOverloadTactic.
  • State Cleanliness: Moved hysteresis state to tactic instances with clean reset_applicable() and test teardown hooks.

Test Verification

  • pixi run lint: 100% clean (black, ruff, isort).
  • pixi run test: 12,885 passed, 83 xfailed, 0 failed.
  • Motion planning benchmark: 29/29 scenarios passing for trajsample.
  • Unit regression tests added for all fixed boundary conditions.

…e detours

- FastPathPlanner (C++ and Python): key obstacle detour memory on obstacle ID
  rather than shifting contact points, eliminating dithering oscillations.
- TrajectorySamplingPlanner: add temporal speed-modulation candidates (0.75x,
  0.55x) and Sumatra-style angular deviation penalty, cutting crossing detour
  from 1.55x (5.10s) to 1.09x (3.43s) with zero brake events.
- TrajectorySamplingPlanner: constrain candidate targets to forward/lateral
  hemisphere (<= 90 deg), eliminating the 180-deg backward candidate that caused
  robots to reverse away from dynamic pinches (pinching_contest 4.68s -> 2.57s).
- Update visual comparisons and motion planning documentation.
- Add excess_distance_m (path length minus direct Euclidean distance) and
  near_miss_ratio (% of moving ticks where clearance < 0.15m) to BenchmarkManager.
- Record both metrics in results JSON, aggregate summaries, and Markdown report.
- Include excess distance (+X.XXm) in terminal progress printout.
… and crashing rule

- actions.py: clamp restart positions outside 0.80m keep-out arc (fixing 0.79m
  floating-point precision boundary penalty).
- actions.py: place defending penalty goalkeeper +ROBOT_RADIUS offset on defense line
  and attacking keeper on own goal line.
- crashing_rule.py: do not penalize separating robots when relative crash speed <= threshold.
- double_touch_rule.py: correctly attribute double-touch fouls to the last kicker.
- Add regression tests in test_custom_referee, test_pushing_crashing, and test_referee_unit.
…and tactics

- pickers.py: add margin-based hysteresis to friendly_closer_to_ball to prevent
  rapid 60Hz role-swapping when robots are equidistant to the ball.
- ClearBallTactic: expand activation thresholds (friendly distance 2.6m -> 3.0m,
  enemy distance 1.2m -> 1.5m) to prevent boundary flickering.
- PressAndContainTactic: widen enemy distance threshold (1.4m -> 1.7m) and use
  Sticky[int] hysteresis for presser robot selection.
- DecoyOverloadTactic: add stall/deadlock timeout when no friendly targets are reachable.
- Engine/tactics: store all hysteresis state on tactic instances with reset_applicable()
  and module-level reset hooks for clean test isolation.
- Add comprehensive regression tests in test_strategy, test_friendly_closer_to_ball,
  test_clear_ball_tactic, test_press_and_contain_tactic, and test_decoy_and_overload_tactic.
@isaac0804 isaac0804 added bug Something isn't working release:patch Fixes and small tweaks to main. labels Oct 18, 2026
@isaac0804
isaac0804 merged commit 0ce4e2a into main Oct 19, 2026
4 of 5 checks passed
@isaac0804
isaac0804 deleted the fix/motion-planning-referee-tactics branch October 19, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working release:patch Fixes and small tweaks to main.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant