Skip to content

Keep each PyBullet world's body ids on its own Objects - #202

Open
yichao-liang wants to merge 1 commit into
masterfrom
fix-coffee-own-object-ids
Open

yichao-liang wants to merge 1 commit into
masterfrom
fix-coffee-own-object-ids

Conversation

@yichao-liang

Copy link
Copy Markdown
Collaborator

Summary

The bug.
Both oracle approaches failed on pybullet_coffee with RuntimeError: Failed to get pose for object cup0 (id=12).
Body ids live on Object instances.
The planner's world (the option model's env) simulates states whose Objects belong to the executing env, so PyBulletEnv.simulate and _set_state moved bodies through the executing world's ids.
That works only while both worlds number their bodies alike, which holds for bodies built at start-up.
Coffee recreates its cups for every state: in the executing world they ended up as bodies 12 and 11, and the planner moved cup0 by id 12, a body its own world did not have.
Coffee also wrote each world's new cup ids onto whichever Objects the state carried, so the worlds overwrote each other's ids.

The fix.
simulate and _set_state now swap a state's Objects for this world's own Objects of the same name and type (PyBulletEnv._keyed_by_own_objects), which they already did for public recordings.
Each world now reads and writes only its own bodies, including the held object's id that _set_state builds the grasp constraint from.
The states a world returns are keyed by its own Objects, which compare equal to the caller's.

tests/envs/test_pybullet_coffee.py simulates one Coffee world's task in a second world, as the planner does, and checks the task's cup ids, the cup poses, and that the first world still resets and steps.
Coffee now runs with both oracles but does not solve the test task, as the envs README now says.

Test plan

  • The README command on pybullet_coffee with both oracle approaches: both run to completion (0/1 solved); both crashed before.
  • The new test fails on the old code (GetBasePositionAndOrientation failed.) and passes here.
  • This changes the state path every PyBullet env shares, so the README command with both oracle approaches ran on all 22 environments: the same environments solve as before this stack (Ants, Balance, Blocks, Circuit, Cover, Crane, Launcher and Magnets with oracle, Grow with oracle_process_planning) and none crashes.
  • yapf 0.32.0, isort 5.10.1, docformatter 1.4, mypy 1.8.0 and pylint on the whole repo.
  • The full test suite on this branch, in CI's Ubuntu 24.04 container.

Stacked on #201.

🤖 Generated with Claude Code

Both oracle approaches failed on Coffee with "Failed to get pose for
object cup0 (id=12)". Body ids live on Object instances, and the
planner's world (the option model's env) simulates states whose Objects
belong to the executing env, so PyBulletEnv.simulate and _set_state
moved bodies through the executing world's ids. That works only while
both worlds number their bodies alike, which holds for bodies built at
start-up. Coffee recreates its cups for every state, so the planner
moved cup0 by an id its own world did not have, and each world wrote
its new cup ids onto the other world's Objects.

simulate and _set_state now swap a state's Objects for this world's own
Objects of the same name and type, as they already did for public
recordings, so each world reads and writes only its own bodies. A test
simulates one Coffee world's task in a second world and checks the
task's cup ids and cup poses.

Coffee now runs with both oracles but does not solve the test task, as
the envs README now says.
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