-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix LEAPP projected gravity export #6007
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
Merged
lgulich
merged 8 commits into
isaac-sim:develop
from
lgulich:lgulich/leapp-root-quat-gravity
Jun 8, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
30d66c0
Fix LEAPP projected gravity export
lgulich 6b40897
Merge branch 'develop' into lgulich/leapp-root-quat-gravity
lgulich 57bcf60
Move LEAPP proxy tests to export test directory
lgulich d30f2b7
Mark isaaclab_rl test move as changelog skip
lgulich e290070
Merge branch 'develop' into lgulich/leapp-root-quat-gravity
lgulich 2bd4a4b
Fix recurrent LEAPP export dropping the LSTM hidden state
lgulich ae5481a
Merge branch 'develop' into lgulich/leapp-root-quat-gravity
lgulich 6f18d1c
Revert recurrent hidden_state attribute change
lgulich 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
6 changes: 6 additions & 0 deletions
6
source/isaaclab/changelog.d/lgulich-leapp-root-quat-gravity.rst
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,6 @@ | ||
| Fixed | ||
| ^^^^^ | ||
|
|
||
| * Fixed LEAPP export of :func:`isaaclab.envs.mdp.projected_gravity` to expose | ||
| root orientation as the graph input and compute projected gravity inside the | ||
| exported graph. |
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
Empty file.
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,104 @@ | ||
| # 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 math | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| pytest.importorskip("leapp") | ||
|
lgulich marked this conversation as resolved.
|
||
|
|
||
| from isaaclab.envs import mdp | ||
| from isaaclab.test.mock_interfaces.assets.mock_articulation import MockArticulationData | ||
| from isaaclab.utils import math as math_utils | ||
| from isaaclab.utils.leapp import utils as leapp_utils | ||
| from isaaclab.utils.leapp.export_annotator import ExportPatcher | ||
| from isaaclab.utils.leapp.leapp_semantics import InputKindEnum | ||
| from isaaclab.utils.leapp.proxy import _DataProxy, _EnvProxy | ||
|
|
||
|
|
||
| class _TestScene(dict): | ||
| """Minimal scene mapping for LEAPP proxy tests.""" | ||
|
|
||
| sensors = {} | ||
|
|
||
|
|
||
| def _make_articulation_data() -> tuple[MockArticulationData, torch.Tensor]: | ||
| """Create mock articulation data with a non-identity root orientation.""" | ||
| data = MockArticulationData(num_instances=2, num_joints=0, num_bodies=1, device="cpu") | ||
| root_pose_w = torch.zeros(2, 7, dtype=torch.float32) | ||
| root_pose_w[:, 6] = 1.0 | ||
| root_pose_w[1, 3] = math.sin(math.pi / 4.0) | ||
| root_pose_w[1, 6] = math.cos(math.pi / 4.0) | ||
| data.set_root_link_pose_w(root_pose_w) | ||
| return data, root_pose_w | ||
|
|
||
|
|
||
| def _capture_leapp_inputs(monkeypatch: pytest.MonkeyPatch) -> list: | ||
| """Capture LEAPP input annotations while returning their tensor references.""" | ||
| annotated_inputs = [] | ||
|
|
||
| def _record_input_tensor(task_name, semantics): | ||
| annotated_inputs.append((task_name, semantics)) | ||
| return semantics.ref | ||
|
|
||
| monkeypatch.setattr(leapp_utils.annotate, "input_tensors", _record_input_tensor) | ||
| return annotated_inputs | ||
|
|
||
|
|
||
| def test_direct_projected_gravity_b_read_preserves_vector3d_input(monkeypatch: pytest.MonkeyPatch): | ||
| """Test direct data proxy reads keep projected gravity as its own semantic input.""" | ||
| annotated_inputs = _capture_leapp_inputs(monkeypatch) | ||
| data, _ = _make_articulation_data() | ||
|
|
||
| proxy = _DataProxy( | ||
| data, | ||
| entity_name="robot", | ||
| task_name="Isaac-Velocity-Flat-G1-v0", | ||
| property_resolution_cache={}, | ||
| cache={}, | ||
| input_name_resolver=lambda property_name: f"robot_{property_name}", | ||
| ) | ||
|
|
||
| assert proxy.projected_gravity_b.torch.shape == (2, 3) | ||
|
|
||
| assert len(annotated_inputs) == 1 | ||
| task_name, semantics = annotated_inputs[0] | ||
| assert task_name == "Isaac-Velocity-Flat-G1-v0" | ||
| assert semantics.name == "robot_projected_gravity_b" | ||
| assert semantics.kind == InputKindEnum.VECTOR3D | ||
| assert semantics.extra == {"isaaclab_connection": "state:robot:projected_gravity_b"} | ||
|
|
||
|
|
||
| def test_projected_gravity_observation_exports_root_quat_w_input(monkeypatch: pytest.MonkeyPatch): | ||
| """Test the projected-gravity observation is export-lowered through root quaternion.""" | ||
| annotated_inputs = _capture_leapp_inputs(monkeypatch) | ||
| data, root_pose_w = _make_articulation_data() | ||
| scene = _TestScene({"robot": SimpleNamespace(data=data)}) | ||
| env = SimpleNamespace(scene=scene) | ||
| proxy_env = _EnvProxy(env, "Isaac-Velocity-Flat-G1-v0", {}, {}) | ||
|
|
||
| term_cfg = SimpleNamespace(func=mdp.projected_gravity, noise="noise") | ||
| obs_manager = SimpleNamespace(_group_obs_term_cfgs={"policy": [term_cfg]}, compute=lambda *args, **kwargs: None) | ||
| patcher = ExportPatcher(export_method="onnx-dynamo", required_obs_groups={"policy"}) | ||
| patcher.task_name = "Isaac-Velocity-Flat-G1-v0" | ||
| patcher._patch_observation_manager(obs_manager, proxy_env) | ||
|
|
||
| projected_gravity_b = term_cfg.func(env) | ||
|
|
||
| expected = math_utils.quat_apply_inverse( | ||
| root_pose_w[:, 3:7], | ||
| torch.tensor([[0.0, 0.0, -1.0]], dtype=torch.float32).expand(2, 3), | ||
| ) | ||
| assert torch.allclose(projected_gravity_b, expected) | ||
| assert term_cfg.noise is None | ||
|
|
||
| assert len(annotated_inputs) == 1 | ||
| task_name, semantics = annotated_inputs[0] | ||
| assert task_name == "Isaac-Velocity-Flat-G1-v0" | ||
| assert semantics.name == "robot_root_quat_w" | ||
| assert semantics.kind == InputKindEnum.BODY_ROTATION | ||
| assert semantics.extra == {"isaaclab_connection": "state:robot:root_quat_w"} | ||
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.
Uh oh!
There was an error while loading. Please reload this page.