Skip to content

Pickup action support upright#352

Open
matafela wants to merge 1 commit into
mainfrom
cj/make-upright
Open

Pickup action support upright#352
matafela wants to merge 1 commit into
mainfrom
cj/make-upright

Conversation

@matafela

@matafela matafela commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Pickup action support upright.

example: scripts/tutorials/atomic_action/move_held_object.py

Type of change

  • Enhancement (non-breaking change which improves an existing functionality)

Screenshots

2026.07.03.19.41.15.webm

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.

Copilot AI 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

Adds “upright” support to the PickUp atomic action by allowing an optional post-grasp rotation bias, plus a math utility to build rotation matrices from axis-angle and a tutorial update demonstrating the new knobs.

Changes:

  • Extend PickUpCfg with obj_upright_direction and rotate_upright, and apply an optional grasp-frame rotation offset during PickUp.execute().
  • Add axis_angle_to_rotation_matrix() utility in embodichain.utils.math.
  • Update the atomic-action tutorial script to use the new upright parameters and adjust target pose / lift height.

Reviewed changes

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

File Description
scripts/tutorials/atomic_action/move_held_object.py Updates tutorial configuration/target pose to exercise upright-capable pickup.
embodichain/utils/math.py Adds axis-angle → rotation-matrix conversion helper.
embodichain/lab/sim/atomic_actions/actions.py Adds new PickUp config options and applies an optional upright-oriented rotation offset.

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

Comment on lines +811 to +827
# apply grasp yr rotation offset if specified
if self.cfg.rotate_upright is not None:
if self.cfg.obj_upright_direction is None:
upright_direction = torch.tensor([0, 0, 1], device=self.device)
else:
upright_direction = self.cfg.obj_upright_direction.to(self.device)
obj_pose = sem.entity.get_local_pose(to_matrix=True)
obj_upright = (upright_direction * obj_pose[:, :3, :3]).sum(axis=1)
grasp_ry = grasp_xpos[:, :3, 1]
dot_result = (grasp_ry * obj_upright).sum(axis=1)
# revert flag is -1 if the dot product is negative, 1 if positive
revert_flag = torch.where(dot_result < 0, 1.0, -1.0)
grasp_rx = grasp_xpos[:, :3, 0]
rota_axis_angle = self.cfg.rotate_upright * revert_flag * grasp_rx
rota_offset = axis_angle_to_rotation_matrix(rota_axis_angle)
upright_grasp_rota = torch.bmm(grasp_xpos[:, :3, :3], rota_offset)
grasp_xpos[:, :3, :3] = upright_grasp_rota
Comment on lines +114 to +118
obj_upright_direction: torch.Tensor | None = None
"""Optional object local direction to align with world up after grasping. By dafault we will use (0, 0, 1)."""

rotate_upright: float | None = None
"""Optional rotation (radians) about the grasp y-axis to apply to the grasp pose"""
Comment on lines +811 to +813
# apply grasp yr rotation offset if specified
if self.cfg.rotate_upright is not None:
if self.cfg.obj_upright_direction is None:
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