Commit db85fabb authored by peterd-NV's avatar peterd-NV Committed by Kelly Guo

Adds matrix4d patch to support Pinocchio 2.7.0 (#352)

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

This change adds a patch in AppLauncher to override the Matrix4d
constructor to convert it's arguments into a list of floats for
compatibility with Pinocchio 2.7.0. This serves as a workaround until
Isaac Sim is patched with the fix in a later release.

The conda installation of Pinocchio 3.4.0 has been removed now that this
solution enables support for Pinocchio 2.7.0.

The corresponding documentation has also been updated now that this
workaround is in place. This includes:
1. Removing the note in Issac lab Mimic docs informing users of the
error
2. Restoring the Isaac Lab pip installation docs to original state (not
using environment.yml to create the conda env)

Fixes # (issue)

Fixes error when running XR teleop with Pinocchio 2.7.0

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)
- This change requires a documentation update

Please attach before and after screenshots of the change if applicable.

<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ | _gif/png after_ |

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent c4c3f377
......@@ -363,12 +363,6 @@ We recommend 10 successful demonstrations for good data generation results.
The robot uses simplified collision meshes for physics calculations that differ from the detailed visual meshes displayed in the simulation. Due to this difference, you may occasionally observe visual artifacts where parts of the robot appear to penetrate other objects or itself, even though proper collision handling is occurring in the physics simulation.
.. warning::
When first starting the simulation window, you may encounter the following ``Gf.Matrix4d`` error:
``TypeError: No registered converter was able to produce a C++ rvalue of type std::vector<double, std::allocator<double> > from this Python object of type tuple``.
This error can be ignored and will not affect the data collection process.
The error will be patched in a future release of Isaac Sim.
You can replay the collected demonstrations by running the following command:
.. code:: bash
......
......@@ -47,7 +47,7 @@ If you encounter any issues, please report them to the
.. code-block:: bash
conda env create -n env_isaaclab -f environment.yml python=3.10
conda create -n env_isaaclab python=3.10
conda activate env_isaaclab
.. tab-item:: venv environment
......
......@@ -4,4 +4,3 @@ channels:
dependencies:
- python=3.10
- importlib_metadata
- pinocchio=3.4.0 # pip install of pinocchio==3.4.0(required by isaac sim extensions) does not work with numpy<2
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.36.18"
version = "0.36.19"
# Description
title = "Isaac Lab framework for Robot Learning"
......
Changelog
---------
0.36.18 (2025-04-09)
0.36.19 (2025-04-09)
~~~~~~~~~~~~~~~~~~~~
Changed
......@@ -12,7 +12,7 @@ Changed
the cuda device, which results in NCCL errors on distributed setups.
0.36.17 (2025-04-01)
0.36.18 (2025-04-01)
~~~~~~~~~~~~~~~~~~~~
Fixed
......@@ -21,6 +21,15 @@ Fixed
* Added check in RecorderManager to ensure that the success indicator is only set if the termination manager is present.
0.36.17 (2025-03-26)
~~~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
* Added override in AppLauncher to apply patch for ``pxr.Gf.Matrix4d`` to work with Pinocchio 2.7.0.
0.36.16 (2025-03-25)
~~~~~~~~~~~~~~~~~~~~
......
......@@ -123,6 +123,10 @@ class AppLauncher:
# Integrate env-vars and input keyword args into simulation app config
self._config_resolution(launcher_args)
# Internal: Override SimulationApp._start_app method to apply patches after app has started.
self.__patch_simulation_start_app(launcher_args)
# Create SimulationApp, passing the resolved self._config to it for initialization
self._create_app()
# Load IsaacSim extensions
......@@ -908,3 +912,98 @@ class AppLauncher:
"""Handle the abort/segmentation/kill signals."""
# close the app
self._app.close()
def __patch_simulation_start_app(self, launcher_args: dict):
if not launcher_args.get("enable_pinocchio", False):
return
if launcher_args.get("disable_pinocchio_patch", False):
return
original_start_app = SimulationApp._start_app
def _start_app_patch(sim_app_instance, *args, **kwargs):
original_start_app(sim_app_instance, *args, **kwargs)
self.__patch_pxr_gf_matrix4d(launcher_args)
SimulationApp._start_app = _start_app_patch
def __patch_pxr_gf_matrix4d(self, launcher_args: dict):
import traceback
import carb
from pxr import Gf
carb.log_warn(
"Due to an issue with Pinocchio and pxr.Gf.Matrix4d, patching the Matrix4d constructor to convert arguments"
" into a list of floats."
)
# Store the original Matrix4d constructor
original_matrix4d = Gf.Matrix4d.__init__
# Define a wrapper function to handle different input types
def patch_matrix4d(self, *args, **kwargs):
try:
# Case 1: No arguments (identity matrix)
if len(args) == 0:
original_matrix4d(self, *args, **kwargs)
return
# Case 2: Single argument
elif len(args) == 1:
arg = args[0]
# Case 2a: Already a Matrix4d
if isinstance(arg, Gf.Matrix4d):
original_matrix4d(self, arg)
return
# Case 2b: Tuple of tuples (4x4 matrix) OR List of lists (4x4 matrix)
elif (isinstance(arg, tuple) and len(arg) == 4 and all(isinstance(row, tuple) for row in arg)) or (
isinstance(arg, list) and len(arg) == 4 and all(isinstance(row, list) for row in arg)
):
float_list = [float(item) for row in arg for item in row]
original_matrix4d(self, *float_list)
return
# Case 2c: Flat list of 16 elements
elif isinstance(arg, (list, tuple)) and len(arg) == 16:
float_list = [float(item) for item in arg]
original_matrix4d(self, *float_list)
return
# Case 2d: Another matrix-like object with elements accessible via indexing
elif hasattr(arg, "__getitem__") and hasattr(arg, "__len__"):
with contextlib.suppress(IndexError, TypeError):
if len(arg) == 16:
float_list = [float(arg[i]) for i in range(16)]
original_matrix4d(self, *float_list)
return
# Try to extract as 4x4 matrix
elif len(arg) == 4 and all(len(row) == 4 for row in arg):
float_list = [float(arg[i][j]) for i in range(4) for j in range(4)]
original_matrix4d(self, *float_list)
return
# Case 3: 16 separate arguments (individual matrix elements)
elif len(args) == 16:
float_list = [float(arg) for arg in args]
original_matrix4d(self, *float_list)
return
# Default: Use original constructor
original_matrix4d(self, *args, **kwargs)
except Exception as e:
carb.log_error(f"Matrix4d wrapper error: {e}")
traceback.print_stack()
# Fall back to original constructor as last resort
try:
original_matrix4d(self, *args, **kwargs)
except Exception as inner_e:
carb.log_error(f"Original Matrix4d constructor also failed: {inner_e}")
# Initialize as identity matrix if all else fails
original_matrix4d(self)
Gf.Matrix4d.__init__ = patch_matrix4d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment