Skip to content

Refactor atomic actions into primitives package - #346

Merged
yuecideng merged 7 commits into
mainfrom
enhance/atomic-action-primitives
Jul 4, 2026
Merged

Refactor atomic actions into primitives package#346
yuecideng merged 7 commits into
mainfrom
enhance/atomic-action-primitives

Conversation

@yuecideng

Copy link
Copy Markdown
Contributor

Description

This PR refactors the built-in atomic action implementations into a dedicated embodichain.lab.sim.atomic_actions.primitives subpackage while preserving existing public imports.

Summary:

  • Moves each built-in atomic action implementation into one primitive module under atomic_actions/primitives/.
  • Keeps embodichain.lab.sim.atomic_actions as the recommended public API and atomic_actions.actions as a backward-compatible re-export facade.
  • Adds API reference coverage for the new primitives subpackage.
  • Updates the atomic actions tutorial, overview docs, and add-atomic-action skill to point future built-ins at the new layout.

Dependencies: None.

Fixes: 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

N/A

Verification

  • black .
  • black --check --diff --color ./
  • git diff --check
  • python -m compileall -q embodichain/lab/sim/atomic_actions
  • pytest tests/sim/atomic_actions -q (93 passed)
  • python -m sphinx -b html docs/source /tmp/embodichain-docs-atomic-actions (succeeded with existing project-wide warnings)
  • All five atomic action tutorials were smoke-tested earlier with --headless --auto_play --device cpu

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Dependencies have been updated, if applicable.

Move built-in atomic action implementations into atomic_actions.primitives while preserving existing package-level and actions.py imports. Update tutorial, API reference, overview docs, and the add-atomic-action skill to reflect the new layout.
CopilotAI review requested due to automatic review settings July 1, 2026 11:16
@yuecidengyuecideng added enhancement New feature or request docs Improvements or additions to documentation refactor atomic action atomic action related functionality labels Jul 1, 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 reorganizes EmbodiChain’s built-in atomic action implementations into a dedicated embodichain.lab.sim.atomic_actions.primitives subpackage while keeping existing public and legacy import paths working, and updates the docs/skill guidance accordingly.

Changes:

  • Split each built-in atomic action into its own module under atomic_actions/primitives/ and added a primitives package export surface.
  • Converted atomic_actions/actions.py into a backward-compatible re-export facade and updated atomic_actions/__init__.py to import from primitives.
  • Extended Sphinx API reference and tutorial/overview docs (plus the add-atomic-action skill) to reflect the new layout.

Reviewed changes

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

Show a summary per file
FileDescription
embodichain/lab/sim/atomic_actions/primitives/place.pyNew Place primitive module.
embodichain/lab/sim/atomic_actions/primitives/pick_up.pyNew PickUp primitive module (grasp planning + held-object state).
embodichain/lab/sim/atomic_actions/primitives/move_joints.pyNew MoveJoints primitive module (joint-space planning).
embodichain/lab/sim/atomic_actions/primitives/move_held_object.pyNew MoveHeldObject primitive module (object-pose target while holding).
embodichain/lab/sim/atomic_actions/primitives/move_end_effector.pyNew MoveEndEffector primitive module (EEF pose planning).
embodichain/lab/sim/atomic_actions/primitives/_helpers.pyShared internal helpers extracted for primitives.
embodichain/lab/sim/atomic_actions/primitives/init.pyNew primitives package exports.
embodichain/lab/sim/atomic_actions/actions.pyReplaced concrete implementations with compatibility re-exports.
embodichain/lab/sim/atomic_actions/init.pyPublic API now imports built-ins from primitives.
docs/source/tutorial/atomic_actions.rstTutorial updated to describe new primitives layout and export steps.
docs/source/overview/sim/atomic_actions/index.mdOverview updated to mention primitives and legacy facade.
docs/source/api_reference/embodichain/embodichain.lab.sim.atomic_actions.rstAPI reference updated with layout notes + hidden toctree to primitives.
docs/source/api_reference/embodichain/embodichain.lab.sim.atomic_actions.primitives.rstNew API reference page documenting primitive modules.
.agents/skills/add-atomic-action/SKILL.mdSkill guidance updated to scaffold built-ins under primitives/ and docs paths.

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

third_phase_name="back",
)

lift_offset = torch.tensor([0, 0, 1], device=self.device) * self.cfg.lift_height
Comment on lines +158 to +161
lift_xpos = self.builder.apply_local_offset(
grasp_xpos,
torch.tensor([0, 0, 1], device=self.device) * self.cfg.lift_height,
)
CopilotAI review requested due to automatic review settings July 3, 2026 14:12

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

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

Comment on lines +82 to +85
def should_wait_for_tutorial_input(args: argparse.Namespace) -> bool:
"""Return whether the tutorial should pause for terminal input."""
return not getattr(args, "auto_play", False)

Comment on lines +36 to +39
logger.log_error(
f"object_target_pose must be (4, 4) or ({n_envs}, 4, 4), but got {target.shape}",
ValueError,
)
CopilotAI review requested due to automatic review settings July 3, 2026 16:10

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

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Comment on lines +254 to +257
next_state=WorldState(
last_qpos=full[:, -1, :].clone(),
held_object=support_held_object,
),
)
)
is False
)
@yuecideng
yuecideng merged commit 0841962 into mainJul 4, 2026
6 checks passed
@yuecideng
yuecideng deleted the enhance/atomic-action-primitives branch July 4, 2026 03:00
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 requestrefactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yuecideng