Add reusable demo utilities and DemoBase lifecycle class - #354
Open
yuecideng wants to merge 19 commits into
Open
Add reusable demo utilities and DemoBase lifecycle class#354yuecideng wants to merge 19 commits into
yuecideng wants to merge 19 commits into
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Multi-environment demos (e.g. examples/sim/demo) need to forward num_envs to SimulationManagerCfg. Add a num_envs parameter to create_default_sim and unit-test it alongside maybe_init_gpu_physics and the default-light path. Co-Authored-By: Claude <noreply@anthropic.com>
Migrate press_softbody, pick_up_cloth, grasp_cup_to_caffe and scoop_ice to the DemoBase lifecycle and shared demo_utils helpers (add_demo_args, create_default_sim, maybe_open_window, maybe_init_gpu_physics, maybe_wait_for_user). This completes the demo utility rollout called for in the demo-base design spec. Behavior is preserved (robot/object configs, IK seeds, trajectory interpolation and sim.update step counts are unchanged) with three intentional improvements: - Guaranteed sim.destroy() via DemoBase.main() try/finally, fixing the exit-time segfault (exit 139) that violated the sim-shutdown contract. - Respect --headless consistently (no hardcoded headless=True) and open the window via maybe_open_window. - --auto_play skips interactive prompts and the keep-alive loop so demos terminate for headless integration runs. press_softbody and pick_up_cloth run end-to-end headless --auto_play with a clean exit (exit 0). Co-Authored-By: Claude <noreply@anthropic.com>
Add a 'Writing Demo Scripts' tutorial covering add_demo_args, create_default_sim, DemoRecording, replay_trajectory and the DemoBase lifecycle, and register it in the tutorial toctree. Expose demo_utils and demo_base in the API reference (autosummary + automodule sections) so the tutorial cross-references resolve. Co-Authored-By: Claude <noreply@anthropic.com>
Sync the demo-base feature with the latest main (44 commits), which refactored atomic actions in parallel: - #346 refactor atomic actions into a primitives package - #349 env-batched parallel motion generation (AtomicActionEngine.run now returns a (B,) success tensor; compute_ik returns a batched success tensor) - #371 simplify atomic action tutorials (extract helpers into tutorial_utils.py, flat style) Conflict resolution (7 files: 6 atomic_action tutorials + tutorial_utils.py): - tutorial_utils.py: take main's version. It is a strict superset of the PR's (keeps create_ur5_gripper_robot_cfg, make_ur5_solver_cfg, draw_axis_marker, start/stop_auto_play_recording and adds create_tutorial_simulation, add_ur5_gripper_robot, create_toppra_motion_generator, prepare_tutorial_scene, env-batched replay_trajectory, broadcast_pose_batch, etc.). - 6 tutorials: keep the PR's DemoBase migration and adapt to main's env-batched API. engine.run success changed from a scalar is_success to a (B,) tensor, so the guard is now 'if not success.all():' (compute_ik already used torch.all). Target constructor params (qpos/name/xpos/semantics/object_target_pose) match main's core.py. This also restores the sim.destroy() cleanup that main's flat tutorials lack (DemoBase.main try/finally), avoiding the exit-time segfault. Verified: 19 unit tests pass; move_joints and pickup run headless --auto_play end-to-end with a clean exit (exit 0). Co-Authored-By: Claude <noreply@anthropic.com>
yuecideng
marked this pull request as ready for review
July 28, 2026 15:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a shared demo utility layer for simulation scripts and refactors the six
scripts/tutorials/atomic_action/tutorials to use it.New components:
embodichain.lab.sim.utility.demo_utils: argument parsing, default simulation setup, recording context manager, trajectory replay, and window/user helpers.embodichain.lab.sim.demo_base.DemoBase: optional lifecycle base class for demos.The existing
scripts/tutorials/atomic_action/tutorial_utils.pynow re-exports generic helpers while keeping UR5-specific configuration functions. All six atomic-action tutorials were migrated toDemoBaseand the shared helpers; behavior is preserved.Dependencies: None
Type of change
Checklist
black .command to format the code base.