Skip to content

feat: add Python checker parity (BodyContact/PositionDelta/OrderedStep) - #6

Open
keyneszeng wants to merge 1 commit into
AxisAIOrg:mainfrom
keyneszeng:feat/python-checker-parity
Open

feat: add Python checker parity (BodyContact/PositionDelta/OrderedStep)#6
keyneszeng wants to merge 1 commit into
AxisAIOrg:mainfrom
keyneszeng:feat/python-checker-parity

Conversation

@keyneszeng

Copy link
Copy Markdown

Summary

Adds the Python counterparts of the 3 new JS checkers (companion PRs to AxisWebInfra), wires them into run_checker(), and ships 27 unit tests.

Changes

  • New util/check_body_contact.py — AABB intersection + inflation
  • New util/check_position_delta.py — per-axis delta vs baseline
  • New util/check_ordered_step.py — walks a trajectory with a step cursor
  • New tests/test_body_contact.py (7 cases), tests/test_position_delta.py (11 cases), tests/test_ordered_step.py (9 cases)
  • Modified util/validate_offline_trajectory.py — imports the 3 modules and dispatches them in run_checker based on type

Cross-repo contract

JS and Python are documented to use the same task-config field names and the same semantic outcome for each checker. The Python side is the source of truth for offline trajectory validation; the JS side is the source of truth for in-browser teleoperation. Any change to the algorithm must update both.

Implementation notes

  • BodyContact: AABB intersection (no live MuJoCo needed offline). Considers objects in state.object_positions and optional state.object_extents; default half-extent 2.5 cm.
  • PositionDelta: requires an explicit initialPosition (or state["initial_position"]) as the baseline. Without a baseline it conservatively returns False (matching the JS side's first-call behavior where captureRuntimeInitial: true means delta = 0 until movement is observed).
  • OrderedStep: walks a trajectory once with a cursor. The caller must pass the full trajectory under state["_trajectory"] (a list of state dicts); without it, the check returns False rather than guessing.

Verification

  • 27/27 unit tests pass
  • run_checker dispatch verified: existing 10 types still work + 3 new types correctly routed

Run with::

python -m pytest tests/ -v

Adds the Python counterparts of the 3 new JS checkers (see companion
PRs to AxisWebInfra), wires them into run_checker(), and ships 27
unit tests (7 + 11 + 9) covering overlap/far/missing/same/snake
cases, multi-axis OR semantics, ordered multi-step pass/fail, etc.

Cross-repo contract:
- JS and Python are documented to use the same task-config field
  names and the same semantic outcome for each checker.
- The Python side is the source of truth for offline trajectory
  validation; the JS side is the source of truth for in-browser
  teleoperation. Any change to the algorithm must update both.

Implementation notes:
- BodyContact uses AABB intersection (no live MuJoCo needed offline).
- PositionDelta requires an explicit initialPosition (the baseline)
  because Python is stateless per call; the JS side captures this
  implicitly via captureRuntimeInitial.
- OrderedStep walks a trajectory once with a cursor, since the JS
  side keeps state across check() calls.
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