Skip to content

domino_real: fold perceived roll modulo pi - #106

Merged
amburger66 merged 5 commits into
masterfrom
fix-domino-roll-symmetry
Jul 31, 2026
Merged

domino_real: fold perceived roll modulo pi#106
amburger66 merged 5 commits into
masterfrom
fix-domino-roll-symmetry

Conversation

@amburger66

@amburger66 amburger66 commented Jul 30, 2026

Copy link
Copy Markdown

A bug found while running the oracle approach on the real-scene domino env against a real capture.

Symptom

Every domino on the table was standing, but the run reported success without moving:

Task init atoms: [... Toppled(domino_0:domino), Toppled(domino_2:domino)]
Found Plan of length 0 in 0.00s
Task 1 / 1: SOLVED

The goal {Toppled(domino_0)} was already true in the task's own initial state, so the planner returned an empty plan and the run scored 1.0. A vacuous pass.

The state dump showed two of four dominoes at roll = 3.14159 and the other two at roll = 0. Not noise: exactly π.

Cause

A domino is a box, so turning it 180° about its own width axis leaves it exactly where it was. Both orientations describe the same physical domino, and a marker-based pose estimate returns either one arbitrarily — within a single capture, some dominoes come back at roll 0 and others at roll ±π.

_Toppled_holds is |roll| >= 10°, so an unfolded roll = π reads as knocked over.

This is a regression from the toppled-domino support in plan PR 6 (#95). Before it, state_from_observation and _init_state_from_perceived hard-coded roll = 0.0, so a flipped estimate could not surface. My offline check against scenes 0000/0001 missed it because every domino in those two captures happened to come back near roll 0 — the flip is capture-dependent.

Fix

Fold roll into [-π/2, π/2):

  • standing (0 or ±π) → ≈ 0 → Upright
  • knocked over (±π/2) → magnitude preserved, which is all Toppled/Upright read

Yaw is untouched, so the push direction is unaffected. The fold lives in the domino env rather than in domino_env_euler, so the geometry helper stays a faithful decomposition and the "a domino is a box" fact sits with the domain that knows it.

Verification

Against the capture that exposed this — all four dominoes now read 0.00°, Upright, and the goal is no longer satisfied at init:

obj        capture id  roll(deg)   Upright  Toppled
domino_0            5       0.00      True    False
domino_1            1       0.00      True    False
domino_2            2       0.00      True    False
domino_3            6       0.00      True    False
goal already true at init: False

Note the earlier SOLVED should not be read as the scene being solvable — that question is still open, and re-running is the way to answer it.

Tests

Three additions to tests/envs/test_pybullet_domino_real.py:

  • the invariant: a capture whose records are 180°-flipped still builds a task with every domino upright, and the goal not already satisfied by its own initial state;
  • the same for a mid-episode observation, so the fold applies to state_from_observation too;
  • the fold itself over eight angles, including that ±90° keeps its magnitude.

Removing the fold fails 6 tests, including both regression tests.

Gates: 39 in this file (was 29), tests/envs + tests/pybullet_helpers = 297 passed / 15 skipped; mypy clean over 709 files; pylint 88/88; isort/yapf/docformatter verified by exit code.

Every domino in a captured scene was standing, but two of the four came
back with roll = pi and read as Toppled before anything moved. A task
whose goal is Toppled(target) was then satisfied in its own initial
state: the planner returned a length-0 plan and the run reported SOLVED.

A domino is a box, so turning it 180 degrees about its own width axis
leaves it exactly where it was. Both orientations describe the same
physical domino and a marker-based pose estimate returns either one
arbitrarily -- in a single capture, some dominoes come back at roll 0 and
others at roll +-pi. Roll is only meaningful modulo pi, so it is now
folded into [-pi/2, pi/2): standing (0 or +-pi) folds to ~0, and knocked
over (+-pi/2) keeps the magnitude that Toppled and Upright are defined
on. Yaw is untouched, so the push direction is unaffected.

This is a regression from the toppled-domino support in plan PR 6. Before
it, both conversions hard-coded roll = 0, so a flipped estimate could not
surface. The offline check against scenes 0000/0001 missed it because
every domino in those two captures happened to come back near roll 0.

The fold lives in the domino env rather than in domino_env_euler, so the
geometry helper stays a faithful decomposition and the "a domino is a
box" fact sits with the domain that knows it.

Tests: the invariant that no domino starts toppled when built from a
capture whose records are flipped, the same for a mid-episode
observation, and the fold itself over eight angles. Verified against the
real capture that exposed this -- all four dominoes now read 0.00 deg and
the goal is no longer true at init.
There was no command that ran the oracle arm on this env: oracle.yaml
un-skips fan, and launch_simp.py takes only -c, so running Stage 1 meant
editing a shared config that fan runs also use. This is a thin launcher of
the kind the repo already uses -- it only un-skips the env and arm it runs.

It also documents the trap that sent Stage 1 off the rails: a bare
`python predicators/main.py --env pybullet_domino_real --approach oracle`
inherits none of the env's flags from envs/all.yaml, and this env does not
work on the settings.py defaults. Most sharply,
domino_use_domino_blocks_as_target defaults False, which sizes the domino
component with the target held as a separate object -- so a 4-domino scene
allocates 3 slots and task construction dies with "perceived 4 dominoes but
only 3 slots".

The scene path is set here rather than in settings.py because envs/all.yaml
already sets it, and a config value beats the settings.py default -- so
editing settings.py has no effect on a launcher run.

Lands with the roll fold so that one branch both runs Stage 1 and answers
it truthfully.
@amburger66 amburger66 changed the title domino_real: fold perceived roll modulo pi (a domino is a box) domino_real: fold perceived roll modulo pi, and a Stage 1 launcher Jul 31, 2026
Narrows this PR to the roll fold alone. The launcher is preserved verbatim
on the oracle-domino-real-launcher branch.
@amburger66 amburger66 changed the title domino_real: fold perceived roll modulo pi, and a Stage 1 launcher domino_real: fold perceived roll modulo pi Jul 31, 2026
@amburger66
amburger66 marked this pull request as ready for review July 31, 2026 19:02
@amburger66 amburger66 self-assigned this Jul 31, 2026

@yichao-liang yichao-liang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@amburger66
amburger66 merged commit 5b04483 into master Jul 31, 2026
14 checks passed
@amburger66
amburger66 deleted the fix-domino-roll-symmetry branch July 31, 2026 19:19
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.

2 participants