-
Notifications
You must be signed in to change notification settings - Fork 3k
Migrates Pink IK to Newton branch #4514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
michaellin6
wants to merge
10
commits into
isaac-sim:dev/newton
Choose a base branch
from
michaellin6:mlin/pink_ik_newton
base: dev/newton
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,976
−61
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d26d8ac
moving in ik controller and mimic envs
michaellin6 3c78e63
fixing errors related to Articulation API and warp array vs torch
michaellin6 f87733c
mimic env spawning and runnable with test_pink_ik.py
michaellin6 201f27d
Added gravity compensation to Articulation. Updated Unitree parameter…
michaellin6 d4cd2ca
pink ik test passing on fixed based g1 and locomanipulation g1 envs
michaellin6 3642056
changed pink ik test to use seconds instead of steps. Added stage
michaellin6 5abce7b
passing all tests on G1. Fixed gravity compensation method by adding …
michaellin6 916b1c8
fixed linter errors
michaellin6 447d2ee
removing files that are not ready for migration
michaellin6 78f27ba
Merge branch 'dev/newton' into mlin/pink_ik_newton
michaellin6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| """Pink IK controller package for IsaacLab. | ||
|
|
||
| This package provides integration between Pink inverse kinematics solver and IsaacLab. | ||
| """ | ||
|
|
||
| from .null_space_posture_task import NullSpacePostureTask | ||
| from .pink_ik import PinkIKController | ||
| from .pink_ik_cfg import PinkIKControllerCfg |
116 changes: 116 additions & 0 deletions
116
source/isaaclab/isaaclab/controllers/pink_ik/local_frame_task.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| import numpy as np | ||
| from collections.abc import Sequence | ||
|
|
||
| import pinocchio as pin | ||
| from pink.tasks.frame_task import FrameTask | ||
|
|
||
| from .pink_kinematics_configuration import PinkKinematicsConfiguration | ||
|
|
||
|
|
||
| class LocalFrameTask(FrameTask): | ||
| """ | ||
| A task that computes error in a local (custom) frame. | ||
| Inherits from FrameTask but overrides compute_error. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| frame: str, | ||
| base_link_frame_name: str, | ||
| position_cost: float | Sequence[float], | ||
| orientation_cost: float | Sequence[float], | ||
| lm_damping: float = 0.0, | ||
| gain: float = 1.0, | ||
| ): | ||
| """ | ||
| Initialize the LocalFrameTask with configuration. | ||
|
|
||
| This task computes pose errors in a local (custom) frame rather than the world frame, | ||
| allowing for more flexible control strategies where the reference frame can be | ||
| specified independently. | ||
|
|
||
| Args: | ||
| frame: Name of the frame to control (end-effector or target frame). | ||
| base_link_frame_name: Name of the base link frame used as reference frame | ||
| for computing transforms and errors. | ||
| position_cost: Cost weight(s) for position error. Can be a single float | ||
| for uniform weighting or a sequence of 3 floats for per-axis weighting. | ||
| orientation_cost: Cost weight(s) for orientation error. Can be a single float | ||
| for uniform weighting or a sequence of 3 floats for per-axis weighting. | ||
| lm_damping: Levenberg-Marquardt damping factor for numerical stability. | ||
| Defaults to 0.0 (no damping). | ||
| gain: Task gain factor that scales the overall task contribution. | ||
| Defaults to 1.0. | ||
| """ | ||
| super().__init__(frame, position_cost, orientation_cost, lm_damping, gain) | ||
| self.base_link_frame_name = base_link_frame_name | ||
| self.transform_target_to_base = None | ||
|
|
||
| def set_target(self, transform_target_to_base: pin.SE3) -> None: | ||
| """Set task target pose in the world frame. | ||
|
|
||
| Args: | ||
| transform_target_to_world: Transform from the task target frame to | ||
| the world frame. | ||
| """ | ||
| self.transform_target_to_base = transform_target_to_base.copy() | ||
|
|
||
| def set_target_from_configuration(self, configuration: PinkKinematicsConfiguration) -> None: | ||
| """Set task target pose from a robot configuration. | ||
|
|
||
| Args: | ||
| configuration: Robot configuration. | ||
| """ | ||
| if not isinstance(configuration, PinkKinematicsConfiguration): | ||
| raise ValueError("configuration must be a PinkKinematicsConfiguration") | ||
| self.set_target(configuration.get_transform(self.frame, self.base_link_frame_name)) | ||
|
|
||
| def compute_error(self, configuration: PinkKinematicsConfiguration) -> np.ndarray: | ||
| """ | ||
| Compute the error between current and target pose in a local frame. | ||
| """ | ||
| if not isinstance(configuration, PinkKinematicsConfiguration): | ||
| raise ValueError("configuration must be a PinkKinematicsConfiguration") | ||
| if self.transform_target_to_base is None: | ||
| raise ValueError(f"no target set for frame '{self.frame}'") | ||
|
|
||
| transform_frame_to_base = configuration.get_transform(self.frame, self.base_link_frame_name) | ||
| transform_target_to_frame = transform_frame_to_base.actInv(self.transform_target_to_base) | ||
|
|
||
| error_in_frame: np.ndarray = pin.log(transform_target_to_frame).vector | ||
| return error_in_frame | ||
|
|
||
| def compute_jacobian(self, configuration: PinkKinematicsConfiguration) -> np.ndarray: | ||
| r"""Compute the frame task Jacobian. | ||
|
|
||
| The task Jacobian :math:`J(q) \in \mathbb{R}^{6 \times n_v}` is the | ||
| derivative of the task error :math:`e(q) \in \mathbb{R}^6` with respect | ||
| to the configuration :math:`q`. The formula for the frame task is: | ||
|
|
||
| .. math:: | ||
|
|
||
| J(q) = -\text{Jlog}_6(T_{tb}) {}_b J_{0b}(q) | ||
|
|
||
| The derivation of the formula for this Jacobian is detailed in | ||
| [Caron2023]_. See also | ||
| :func:`pink.tasks.task.Task.compute_jacobian` for more context on task | ||
| Jacobians. | ||
|
|
||
| Args: | ||
| configuration: Robot configuration :math:`q`. | ||
|
|
||
| Returns: | ||
| Jacobian matrix :math:`J`, expressed locally in the frame. | ||
| """ | ||
| if self.transform_target_to_base is None: | ||
| raise Exception(f"no target set for frame '{self.frame}'") | ||
| transform_frame_to_base = configuration.get_transform(self.frame, self.base_link_frame_name) | ||
| transform_frame_to_target = self.transform_target_to_base.actInv(transform_frame_to_base) | ||
| jacobian_in_frame = configuration.get_frame_jacobian(self.frame) | ||
| J = -pin.Jlog6(transform_frame_to_target) @ jacobian_in_frame | ||
| return J | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring parameter name doesn't match function parameter