Skip to content

Simplify atomic action tutorials - #371

Merged
yuecideng merged 1 commit into
mainfrom
enhance/atomic-action-tutorials
Jul 10, 2026
Merged

Simplify atomic action tutorials#371
yuecideng merged 1 commit into
mainfrom
enhance/atomic-action-tutorials

Conversation

@yuecideng

Copy link
Copy Markdown
Contributor

Description

This PR simplifies the atomic-action tutorials while preserving the action configuration and typed-target flow that the examples are intended to teach.

It adds an optional explicit TCP grasp pose to GraspTarget, allowing PickUp to consume geometry- or perception-selected grasps without duplicating pickup trajectory construction. Shared tutorial setup, antipodal semantics, recording, and replay helpers remove repeated simulation boilerplate. The coordinated demos now execute through AtomicActionEngine, and coordinated placement reuses PickUp instead of a tutorial-local planner.

Dependencies: None.
Issue reference: N/A.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves an existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

Headless --auto_play runs generated MP4 recordings for all eight atomic-action tutorials.

Checklist

  • I have run Black formatting checks.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove the explicit-grasp and tutorial-helper changes work.
  • Dependencies have not changed.

Extract shared tutorial setup and replay helpers, support explicit PickUp grasp poses, and route coordinated demos through the atomic action engine.
CopilotAI review requested due to automatic review settings July 10, 2026 07:07
@yuecidengyuecideng added docs Improvements or additions to documentation enhancement New feature or request atomic action atomic action related functionality labels Jul 10, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the atomic-action tutorial scripts to reduce duplicated simulation boilerplate while preserving the typed-target + action-configuration workflow they demonstrate. It also extends the GraspTarget target type to optionally carry an explicit TCP grasp pose, allowing PickUp to consume externally-selected grasps without re-sampling.

Changes:

  • Added optional grasp_xpos to GraspTarget and updated PickUp to use it when provided.
  • Centralized tutorial setup, antipodal semantics construction, and replay/record helpers in tutorial_utils.py; updated tutorials to reuse these helpers and run through AtomicActionEngine.
  • Added/updated tests and docs to cover the explicit-grasp flow and revised tutorial utilities.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
tests/sim/atomic_actions/test_tutorial_utils.pyAdds a unit test for the new antipodal-semantics helper behavior.
tests/sim/atomic_actions/test_actions.pyAdds a unit test ensuring PickUp accepts an explicit grasp pose and skips affordance sampling.
scripts/tutorials/atomic_action/tutorial_utils.pyIntroduces shared tutorial simulation setup, antipodal semantics builder, and replay/record helpers.
scripts/tutorials/atomic_action/press.pyReworks Press tutorial to use shared helpers and engine-driven execution/replay.
scripts/tutorials/atomic_action/place.pyReworks Place tutorial to use shared helpers, shared antipodal semantics, and unified replay.
scripts/tutorials/atomic_action/pickup.pyReworks PickUp tutorial to use shared setup/semantics and unified replay.
scripts/tutorials/atomic_action/move_joints.pyReworks MoveJoints tutorial to use shared setup and unified replay.
scripts/tutorials/atomic_action/move_held_object.pyReworks MoveHeldObject tutorial to use shared setup/semantics and unified replay.
scripts/tutorials/atomic_action/move_end_effector.pyReworks MoveEndEffector tutorial to use shared setup and unified replay.
scripts/tutorials/atomic_action/coordinated_placement.pyUpdates coordinated placement demo to reuse PickUp, run coordinated action through AtomicActionEngine, and reuse replay helper.
scripts/tutorials/atomic_action/coordinated_pickment.pyUpdates coordinated pickment demo to run through AtomicActionEngine and reuse replay helper.
embodichain/lab/sim/atomic_actions/primitives/pick_up.pyUpdates PickUp.execute() to accept an explicit grasp_xpos in GraspTarget.
embodichain/lab/sim/atomic_actions/core.pyExtends GraspTarget dataclass with optional grasp_xpos and documents its intended shapes/behavior.
docs/source/overview/sim/atomic_actions/index.mdUpdates docs to reflect the extended GraspTarget signature and semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +135 to +139
else:
grasp_xpos = self.builder.resolve_pose_target(
target.grasp_xpos, n_envs=self.n_envs
)
is_success = torch.ones(self.n_envs, dtype=torch.bool, device=self.device)
Comment on lines +395 to +399
sim.update(step=trajectory_sim_steps)
if on_trajectory_step is not None:
on_trajectory_step(step_idx, total_steps)
time.sleep(1e-2)

Comment on lines +406 to +407
sim.update(step=hold_sim_steps)
time.sleep(1e-2)
@yuecideng
yuecideng merged commit bb4e4b9 into mainJul 10, 2026
6 checks passed
@yuecideng
yuecideng deleted the enhance/atomic-action-tutorials branch July 10, 2026 08:54
yuecideng added a commit that referenced this pull request Jul 28, 2026
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>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

atomic actionatomic action related functionalitydocsImprovements or additions to documentationenhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yuecideng