Pickup action support upright#352
Open
matafela wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
PickUpCfgwithobj_upright_directionandrotate_upright, and apply an optional grasp-frame rotation offset duringPickUp.execute(). - Add
axis_angle_to_rotation_matrix()utility inembodichain.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: |
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
Pickup action support upright.
example:
scripts/tutorials/atomic_action/move_held_object.pyType of change
Screenshots
2026.07.03.19.41.15.webm
Checklist
black .command to format the code base.