Skip to content

Deprecates state properties calls#5423

Merged
AntoineRichard merged 7 commits intoisaac-sim:developfrom
AntoineRichard:antoiner/state-observation-mdp-migration
May 8, 2026
Merged

Deprecates state properties calls#5423
AntoineRichard merged 7 commits intoisaac-sim:developfrom
AntoineRichard:antoiner/state-observation-mdp-migration

Conversation

@AntoineRichard
Copy link
Copy Markdown
Collaborator

@AntoineRichard AntoineRichard commented Apr 28, 2026

Description

Reduce higher-level dependency on packed state tensors in targeted IsaacLab call sites without changing existing task observation keys.

This PR:

  • changes Pink IK to read body_link_pose_w directly instead of slicing body_link_state_w;
  • changes Dexsuite orientation rewards to use root_link_quat_w directly instead of slicing root_state_w;
  • adds explicit pick-place helpers for robot link pose and velocity;
  • keeps get_all_robot_link_state() available for compatibility, but marks it deprecated for removal in IsaacLab 4.0;
  • keeps existing robot_links_state task config entries unchanged.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Screenshots

N/A

Test Plan

  • ./isaaclab.sh -p -m py_compile source/isaaclab/isaaclab/envs/mdp/__init__.pyi source/isaaclab/isaaclab/envs/mdp/actions/pink_task_space_actions.py source/isaaclab/isaaclab/envs/mdp/observations.py source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/__init__.pyi source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/observations.py source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/dexsuite/mdp/rewards.py
  • ./isaaclab.sh -f
  • git diff --check origin/develop..HEAD
  • rg -n "body_link_state_w|root_state_w" source/isaaclab/isaaclab/envs/mdp/actions/pink_task_space_actions.py source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/observations.py source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/dexsuite/mdp/rewards.py (no matches)
  • Existing/new MDP pytest not run locally. Per review, new MDP tests were removed and should be added in a separate PR. Local pytest collection is also blocked in this worktree because ./isaaclab.sh -p selects /usr/bin/python3.12 without torch.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

Notes:

  • The unchecked warning item is intentional: this PR adds a DeprecationWarning to get_all_robot_link_state() so users can migrate before IsaacLab 4.0.
  • The unchecked test item follows review feedback: MDP tests should be added in a separate PR.

Add core MDP terms for body link pose and velocity fields so observation code can avoid packed state tensors.

Update Pink IK base link lookup to read the explicit body link pose field.
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Apr 28, 2026
Comment thread source/isaaclab/isaaclab/envs/mdp/actions/pink_task_space_actions.py Outdated
Comment thread source/isaaclab/test/envs/test_mdp_observations.py Outdated
Comment thread source/isaaclab/isaaclab/envs/mdp/observations.py Outdated
Comment thread source/isaaclab_tasks/test/test_pick_place_observations.py Outdated
Comment thread source/isaaclab/isaaclab/envs/mdp/observations.py
Comment thread source/isaaclab/isaaclab/envs/mdp/__init__.pyi
@AntoineRichard AntoineRichard changed the title Add explicit link observation helpers Deprecates state properties calls Apr 28, 2026
@AntoineRichard
Copy link
Copy Markdown
Collaborator Author

Addressed review feedback in 5a1bcbfd781:

  • Removed the new generic core MDP terms and their exports/changelog entry.
  • Removed the new MDP test files; tests can be added in a follow-up PR.
  • Simplified Pink IK and Dexsuite call sites as suggested.
  • Strengthened get_all_robot_link_state() deprecation warning and added the IsaacLab 4.0 removal TODO.
  • Updated the PR body to follow the IsaacLab template.

Copy link
Copy Markdown

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Choose a reason for hiding this comment

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

🤖 Isaac Lab Review Bot

Summary

This PR migrates three call sites from packed state tensors (body_link_state_w, root_state_w) to direct property accessors (body_link_pose_w, root_link_quat_w, body_link_vel_w). It adds new observation helpers for pose and velocity separately, and deprecates the combined get_all_robot_link_state() function for removal in IsaacLab 4.0. The changes are semantically correct and align with the codebase's direction toward explicit property access over tensor slicing.

Architecture Impact

Low impact, self-contained changes:

  • pink_task_space_actions.py: The Pink IK controller's base link frame lookup is internal to the action term. No downstream callers affected.
  • dexsuite/mdp/rewards.py: The orientation_command_error_tanh reward function is called by the reward manager based on task config. The semantic change is correct—root_link_quat_w provides the same quaternion that was previously sliced from root_state_w[:, 3:7].
  • pick_place/mdp/observations.py: New functions are exported via __init__.pyi and available to task configs. The deprecated get_all_robot_link_state wrapper maintains backward compatibility.

Implementation Verdict

Ship it — Minor documentation improvement suggested.

Test Coverage

The PR description explicitly acknowledges that MDP tests were removed per review feedback and should be added in a separate PR. This is a gap:

  • No regression test for get_all_robot_link_state() deprecation warning
  • No test verifying get_all_robot_link_pose() and get_all_robot_link_velocity() return correct shapes/values
  • The existing CI passes because the changes are semantically equivalent and existing task tests exercise the code paths indirectly

For a deprecation PR, the lack of explicit unit tests is acceptable given all CI passes, but the follow-up test PR should be tracked.

CI Status

All checks pass ✅. The comprehensive CI coverage (isaaclab core, isaaclab_tasks, training environments) provides confidence that the semantic changes are correct across backends.

Findings

🔵 Improvement: source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/observations.py:93 — Misleading variable name in deprecated function

The get_all_robot_link_state function's docstring is missing. While deprecated, it should still document what it returns for users who haven't migrated yet:

def get_all_robot_link_state(
    env: ManagerBasedRLEnv,
) -> torch.Tensor:
    """Robot link states in the world frame (DEPRECATED).

    .. deprecated:: 1.5.30
        Use :func:`get_all_robot_link_pose` and :func:`get_all_robot_link_velocity` instead.
        Will be removed in IsaacLab 4.0.

    Returns:
        Link states with shape ``[num_envs, num_bodies, 13]`` and layout
        ``[x, y, z, qx, qy, qz, qw, vx, vy, vz, wx, wy, wz]``.
    """

🔵 Improvement: source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/observations.py:81-95 — Consider adding shape documentation consistency

The new get_all_robot_link_pose documents shape as [num_envs, num_bodies, 7] and get_all_robot_link_velocity as [num_envs, num_bodies, 6]. The deprecated function should document the combined shape [num_envs, num_bodies, 13] for completeness, but the torch.cat(..., dim=-1) correctly produces this.

🔵 Improvement: source/isaaclab_tasks/docs/CHANGELOG.rst:7-8 — Clarify which robots are affected

The changelog entry says "GR1T2 and Unitree G1 pick-place robot link pose and velocity MDP helpers" but the actual changes in observations.py are generic (hardcoded "robot" scene key). The changelog should either clarify these are generic helpers used by those tasks, or the functions should be documented as generic.

🟢 Verified Correct: source/isaaclab/isaaclab/envs/mdp/actions/pink_task_space_actions.py:221

The change from body_link_state_w.torch[:, self._base_link_idx, :7] to body_link_pose_w.torch[:, self._base_link_idx] is semantically equivalent. body_link_pose_w has shape [num_envs, num_bodies, 7] containing [x, y, z, qx, qy, qz, qw], which is exactly what the :7 slice was extracting from the state tensor.

🟢 Verified Correct: source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/dexsuite/mdp/rewards.py:221

The change from root_state_w.torch[:, 3:7] to root_link_quat_w.torch is semantically equivalent. Both provide the root quaternion in [qx, qy, qz, qw] format. The root_link_quat_w property directly returns this without the slice overhead.

🟢 Verified Correct: source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/init.pyi:7-26

The stub file correctly exports the new functions and maintains the deprecated function for backward compatibility. The __all__ list and imports are properly synchronized.

@AntoineRichard AntoineRichard marked this pull request as ready for review April 28, 2026 15:59
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR reduces dependency on packed state tensors by switching call sites to read pose/velocity properties directly (body_link_pose_w, root_link_quat_w, body_link_vel_w) instead of slicing combined state tensors. Backward compatibility is maintained through a deprecated get_all_robot_link_state shim that will be removed in IsaacLab 4.0.

Confidence Score: 4/5

Safe to merge; changes are semantically equivalent refactors with a clean deprecation path and no breaking behavior.

All findings are P2 (style/non-critical). The core refactors are correct — body_link_pose_w returns the same 7-element pose as body_link_state_w[:7], and root_link_quat_w is equivalent to root_state_w[:, 3:7] for standard articulations. The compatibility shim is functionally correct but introduces a per-step torch.cat allocation for any remaining users of the deprecated function.

observations.py — the torch.cat allocation in the deprecated shim and the per-step warning behaviour are worth a second look before IsaacLab 4.0 removal.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/envs/mdp/actions/pink_task_space_actions.py Switches base-link frame lookup from slicing body_link_state_w[:7] to body_link_pose_w; semantically equivalent, cleaner, and avoids loading velocity data.
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/dexsuite/mdp/rewards.py Replaces root_state_w[:, 3:7] quaternion slice with root_link_quat_w for orientation reward; semantically equivalent for standard articulations.
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/observations.py Adds get_all_robot_link_pose and get_all_robot_link_velocity helpers; deprecates get_all_robot_link_state with a torch.cat compatibility shim (new per-step allocation).
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/mdp/init.pyi Adds the two new observation helpers to all and re-exports; ordering is alphabetically correct.
source/isaaclab/config/extension.toml Version bumped 4.6.21 → 4.6.22 to accompany the pink IK change.
source/isaaclab_tasks/config/extension.toml Version bumped 1.5.29 → 1.5.30 to accompany the task-side changes.
source/isaaclab/docs/CHANGELOG.rst Changelog entry added for 4.6.22 describing the pink IK lookup change.
source/isaaclab_tasks/docs/CHANGELOG.rst Changelog entry added for 1.5.30 covering new helpers, dexsuite reward change, and the deprecation notice.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Observation / Reward Manager] -->|calls| B{Function}
    B -->|new path| C[get_all_robot_link_pose
body_link_pose_w
shape: num_envs x num_bodies x 7]
    B -->|new path| D[get_all_robot_link_velocity
body_link_vel_w
shape: num_envs x num_bodies x 6]
    B -->|deprecated path| E[get_all_robot_link_state
emits DeprecationWarning]
    E --> C
    E --> D
    E -->|torch.cat dim=-1| F[Returns num_envs x num_bodies x 13
for backward compatibility]
    C --> G[Consumers: pick-place configs]
    D --> G
    H[Pink IK Action] -->|body_link_pose_w index| I[base_link_frame_in_world_origin
shape: num_envs x 7]
    J[Dexsuite Reward] -->|root_link_quat_w| K[des_quat_w via quat_mul]
Loading

Reviews (1): Last reviewed commit: "Address state observation review feedbac..." | Re-trigger Greptile

Comment on lines 101 to +111
def get_all_robot_link_state(
env: ManagerBasedRLEnv,
) -> torch.Tensor:
body_pos_w = env.scene["robot"].data.body_link_state_w.torch[:, :, :]
all_robot_link_pos = body_pos_w

return all_robot_link_pos
# TODO: Remove this compatibility helper in IsaacLab 4.0.
warnings.warn(
"`get_all_robot_link_state` is deprecated and will be removed in IsaacLab 4.0. "
"Use `get_all_robot_link_pose` and `get_all_robot_link_velocity` instead.",
DeprecationWarning,
stacklevel=2,
)
return torch.cat((get_all_robot_link_pose(env), get_all_robot_link_velocity(env)), dim=-1)
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.

P2 Warning fires every training step at the same call site

DeprecationWarning is emitted inside get_all_robot_link_state, which is invoked by the observation manager on every environment step. Python's default warning filter (once) deduplicates on the (message, category, module, lineno) tuple, so the warning will fire exactly once per interpreter session from a fixed call site — which is fine for interactive use.

However, if the observation manager calls this function through a wrapper or dispatch table where the call-site line number varies (e.g., functools.partial, dynamic getattr, or vectorized dispatch), the filter key may differ and the warning can fire repeatedly. Consider adding a short note to the deprecation message or docstring advising users to suppress the warning in training loops with warnings.filterwarnings("ignore", category=DeprecationWarning).

DeprecationWarning,
stacklevel=2,
)
return torch.cat((get_all_robot_link_pose(env), get_all_robot_link_velocity(env)), dim=-1)
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.

P2 Compatibility shim allocates a new tensor on every call

get_all_robot_link_state now issues torch.cat(...), allocating a fresh [num_envs, num_bodies, 13] tensor on every invocation, whereas the original code returned the existing body_link_state_w tensor zero-copy. Any task config still using robot_links_state will incur this allocation every step until migrated. Acceptable for a temporary shim, but worth noting for users who observe VRAM or step-time regressions before migrating.

@kellyguo11 kellyguo11 moved this to In review in Isaac Lab May 3, 2026
# Conflicts:
#	source/isaaclab/config/extension.toml
#	source/isaaclab/docs/CHANGELOG.rst
#	source/isaaclab_tasks/config/extension.toml
#	source/isaaclab_tasks/docs/CHANGELOG.rst
@AntoineRichard AntoineRichard merged commit 8c5e2ad into isaac-sim:develop May 8, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Isaac Lab May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants