Skip to content

Changes Quaternion convention from WXYZ to XYZW - #4437

Merged
kellyguo11 merged 39 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/quat
Jan 30, 2026
Merged

kellyguo11 merged 39 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/quat

Conversation

@AntoineRichard

@AntoineRichard AntoineRichard commented Jan 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Changes the quaternion convention in IsaacLab to match that of:

  • ROS
  • PhysX
  • Newton
  • Scipy
  • Low level USD

Fixes https://github.com/isaac-sim/IsaacLab-Internal/issues/744

This PR brings massive changes throughout the code base. Almost all users should expect their code to be impacted by these changes. We provide a tool that should help users navigate these changes.

./scripts/tools/find_quaternions.py provides users with an automated script to search throughout the code base some quaternions that do not differ between the current code and a given commit. This can be used to track if your code has changed the order of its hard-coded quaternions.

For instance running the following will show all the quaternions that might need to be updated inside your extension. The dry-run flag will make it so that the script does not attempt to modify the quaternions.

./scripts/tools/find_quaternions.py --path PATH_TO_YOUR_EXTENSION --all-quats --fix --context 4 --dry-run

If you want to modify the quaternions the script comes with an interactive mode where it prompts you with changes to be made, to do so remove the --dry-run flag:

./scripts/tools/find_quaternions.py --path PATH_TO_YOUR_EXTENSION --all-quats --fix --context 4

The --context flag provides more or less context before and after the line where a quaternion was found.

Here is a sample of the interactive mode:

Searching 968 Python, 11 JSON, and 6 RST files...
Comparing against: main
Found 178 files changed from main

Found 69 potential quaternions to review:

====================================================================================================

────────────────────────────────────────────────────────────────────────────────
📍 source/isaaclab_assets/isaaclab_assets/robots/anymal.py:173 [AMBIGUOUS]
────────────────────────────────────────────────────────────────────────────────
     169 | # Configuration - Sensors.
     170 | ##
     171 | 
     172 | ANYMAL_LIDAR_CFG = VELODYNE_VLP_16_RAYCASTER_CFG.replace(
>>>  173 |     offset=RayCasterCfg.OffsetCfg(pos=(-0.310, 0.000, 0.159), rot=(0.0, 0.0, 0.0, 1.0))
     174 | )
     175 | """Configuration for the Velodyne VLP-16 sensor mounted on the ANYmal robot's base."""
────────────────────────────────────────────────────────────────────────────────
  Change: [0.0, 0.0, 0.0, 1.0] → [0.0, 0.0, 1.0, 0.0]
  Result: offset=RayCasterCfg.OffsetCfg(pos=(-0.310, 0.000, 0.159), rot=(0.0, 0.0, 1.0, 0.0))
Apply this fix? [Y/n/a/q]: Y
  ✅ Fixed!

────────────────────────────────────────────────────────────────────────────────
📍 source/isaaclab_mimic/test/test_curobo_planner_franka.py:42 [AMBIGUOUS]
────────────────────────────────────────────────────────────────────────────────
      38 | 
      39 | # Predefined EE goals for the test
      40 | # Each entry is a tuple of: (goal specification, goal ID)
      41 | predefined_ee_goals_and_ids = [
>>>   42 |     ({"pos": [0.70, -0.25, 0.25], "quat": [0.0, 0.707, 0.0, 0.707]}, "Behind wall, left"),
      43 |     ({"pos": [0.70, 0.25, 0.25], "quat": [0.0, 0.707, 0.0, 0.707]}, "Behind wall, right"),
      44 |     ({"pos": [0.65, 0.0, 0.45], "quat": [1.0, 0.0, 0.0, 0.0]}, "Behind wall, center, high"),
      45 |     ({"pos": [0.80, -0.15, 0.35], "quat": [0.0, 0.5, 0.0, 0.866]}, "Behind wall, far left"),
      46 |     ({"pos": [0.80, 0.15, 0.35], "quat": [0.0, 0.5, 0.0, 0.866]}, "Behind wall, far right"),
────────────────────────────────────────────────────────────────────────────────
  Change: [0.0, 0.707, 0.0, 0.707] → [0.707, 0.0, 0.707, 0.0]
  Result: ({"pos": [0.70, -0.25, 0.25], "quat": [0.707, 0.0, 0.707, 0.0]}, "Behind wall, left"),
Apply this fix? [Y/n/a/q]: Y
  ✅ Fixed!

────────────────────────────────────────────────────────────────────────────────
📍 source/isaaclab_mimic/test/test_curobo_planner_franka.py:43 [AMBIGUOUS]
────────────────────────────────────────────────────────────────────────────────
      39 | # Predefined EE goals for the test
      40 | # Each entry is a tuple of: (goal specification, goal ID)
      41 | predefined_ee_goals_and_ids = [
      42 |     ({"pos": [0.70, -0.25, 0.25], "quat": [0.707, 0.0, 0.707, 0.0]}, "Behind wall, left"),
>>>   43 |     ({"pos": [0.70, 0.25, 0.25], "quat": [0.0, 0.707, 0.0, 0.707]}, "Behind wall, right"),
      44 |     ({"pos": [0.65, 0.0, 0.45], "quat": [1.0, 0.0, 0.0, 0.0]}, "Behind wall, center, high"),
      45 |     ({"pos": [0.80, -0.15, 0.35], "quat": [0.0, 0.5, 0.0, 0.866]}, "Behind wall, far left"),
      46 |     ({"pos": [0.80, 0.15, 0.35], "quat": [0.0, 0.5, 0.0, 0.866]}, "Behind wall, far right"),
      47 | ]
────────────────────────────────────────────────────────────────────────────────
  Change: [0.0, 0.707, 0.0, 0.707] → [0.707, 0.0, 0.707, 0.0]
  Result: ({"pos": [0.70, 0.25, 0.25], "quat": [0.707, 0.0, 0.707, 0.0]}, "Behind wall, right"),
Apply this fix? [Y/n/a/q]: Y
  ✅ Fixed!

Type of change

  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

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

@github-actions github-actions Bot added documentation Improvements or additions to documentation asset New asset feature or request isaac-mimic Related to Isaac Mimic team labels Jan 22, 2026
@AntoineRichard
AntoineRichard marked this pull request as ready for review January 23, 2026 13:49
@greptile-apps

greptile-apps Bot commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

Skipped: This PR changes more files than the configured file change limit: (142 files found, 100 file limit)

@kellyguo11

Copy link
Copy Markdown
Contributor

@njawale42 @peterd-NV @michaellin6 fyi - we'll likely need to update the curobo, mimic, and IK tests with these changes.

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

@ooctipus could you check the fabric stuff? I think I may have used the wrong ordering, but it still passes the tests somehow?

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

@kellyguo11 Looks like the regular test suites are passing. Do you know if we could run the whole set of tests on this PR?

@Mayankm96 Mayankm96 changed the title Quaternion convention change from WXYZ to XYZW Changes Quaternion convention from WXYZ to XYZW Jan 26, 2026
@ooctipus

ooctipus commented Jan 26, 2026 •

Copy link
Copy Markdown
Collaborator

I think fabric looks right!

@kellyguo11

Copy link
Copy Markdown
Contributor

latest CI run seems to have a lot more test failures in the camera classes and test_views_xform_prim and some other places. are these from recent updates to develop? also linter check is failing.

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

I just merged develop and fixed a couple things. It looks like almost everything is passing now?

@michaellin6

Copy link
Copy Markdown
Contributor

I took a quick look at the Pink IK related tests and env scripts, and the quat conventions have been updated correctly. If test_pink_ik.py is passing then it should be good on that side.

@kellyguo11

Copy link
Copy Markdown
Contributor

Thanks @michaellin6! looks like all the other failing ones are in the mimic extension now, we can probably disable those until mimic migrates to 3.0.

not sure why the factory environment test is timing out though. does that one run fine locally?

@kellyguo11

Copy link
Copy Markdown
Contributor

@AntoineRichard submitted a fix to your branch for the factory environments - AntoineRichard#6. let's merge this in once that's there

Fixes quaternion issues with factory environments
@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

@AntoineRichard submitted a fix to your branch for the factory environments - AntoineRichard#6. let's merge this in once that's there

Thanks @kellyguo11 . It looks like they use the isaacsim math utils. Should we ask someone to change to our internal helpers?

@AntoineRichard

AntoineRichard commented Jan 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Looks like the tests are getting datasets generate in WXYZ formats :/. I can make a utility to help convert the old datasets, but eventually we'll have to regenerate them. @kellyguo11

@kellyguo11
kellyguo11 merged commit 9659a5c into isaac-sim:develop Jan 30, 2026
kellyguo11 added a commit that referenced this pull request May 27, 2026
…#5754)

# Description


`scripts/imitation_learning/locomanipulation_sdg/gr00t/convert_dataset.py`
still passed `scalar_first=True` to `Rotation.from_quat` / `as_quat`,
but
since #4437 (Jan 2026) Isaac Lab returns body poses in XYZW. The script
therefore mis-interpreted recorded poses as WXYZ, corrupting every
relative-pose computation (hands, object, fixture, goal) in the GR00T
training data and causing trained policies to produce twisted-arm
rollouts.

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

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

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

## Screenshots

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.
-->

## Checklist

- [ ] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) 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

<!--
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
-->

Co-authored-by: Kelly Guo <[email protected]>
StafaH added a commit that referenced this pull request Sep 24, 2026
# Description

Third PR in a series that splits the core cleanup in #7949 into small,
reviewable pieces. This one fixes five small bugs in `isaaclab.utils`
and the camera utilities. Each fix has a regression test that fails
without it.

**Fixes**
- `utils.math.unproject_depth`: homogeneous pixel coordinates were built
as `(1, u, v)` instead of `(u, v, 1)` (`pad(..., (0, 0, 1, 0))` instead
of `(0, 0, 0, 1)`), so every unprojected point was wrong and the first
image row became `inf`/`nan`. This regressed in #4437 (quaternion
convention change), where the padding was flipped together with the
quaternion code. It also affects `create_pointcloud_from_depth` /
`create_pointcloud_from_rgbd` and the `run_usd_camera.py` /
`run_ray_caster_camera.py` tutorials. This fix is in its own commit.
- `sensors.camera.utils.create_pointcloud_from_rgbd`: a color tuple or
`rgb=None` called `torch.Tensor(data, device=..., dtype=...)`, which
always raises `TypeError`. The uniform color is now built with
`torch.tensor(...).repeat(...)` on the point cloud's device. The comment
and docstring claiming the default color is white are corrected (it is
black).
- `utils.math.quat_slerp`: `q2 *= -1.0` negated the caller's tensor in
place when taking the shorter arc; it is now `q2 = -q2`.
- `utils.sensors.convert_camera_intrinsics_to_usd`: `abs()` was applied
to the boolean `(c_x - w/2) > 1e-4 or ...`, so a principal point left of
or above the image center never triggered the aperture-offset warning.
- `utils.datasets.HDF5DatasetFileHandler.create`: a bare file name gave
`os.path.dirname(...) == ""` and `os.makedirs("")` raised. The directory
is now only created when there is one.

**Tests** (focused checks, no new test files; together they run in about
2.5 s). The aperture-offset warning fix is a one-line `abs()` correction
and is not covered by a dedicated test.
- `test/utils/test_math.py`: new `test_unproject_depth` (compares
against the pinhole model); the existing `test_quat_slerp` now also
asserts that `q2` is left unchanged.
- `test/utils/test_hdf5_dataset_file_handler.py`:
`test_create_dataset_file` also covers a bare file name.
- `test/sensors/test_opencv_distortion.py` (kit-less):
`test_pointcloud_from_rgbd_uniform_color` (color tuple and `None`).

All of these fail against `develop` sources and pass with the fixes; the
three touched test files pass in full.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Type of change

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

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 24, 2026
# Description

Third PR in a series that splits the core cleanup in #7949 into small,
reviewable pieces. This one fixes five small bugs in `isaaclab.utils`
and the camera utilities. Each fix has a regression test that fails
without it.

**Fixes**
- `utils.math.unproject_depth`: homogeneous pixel coordinates were built
as `(1, u, v)` instead of `(u, v, 1)` (`pad(..., (0, 0, 1, 0))` instead
of `(0, 0, 0, 1)`), so every unprojected point was wrong and the first
image row became `inf`/`nan`. This regressed in #4437 (quaternion
convention change), where the padding was flipped together with the
quaternion code. It also affects `create_pointcloud_from_depth` /
`create_pointcloud_from_rgbd` and the `run_usd_camera.py` /
`run_ray_caster_camera.py` tutorials. This fix is in its own commit.
- `sensors.camera.utils.create_pointcloud_from_rgbd`: a color tuple or
`rgb=None` called `torch.Tensor(data, device=..., dtype=...)`, which
always raises `TypeError`. The uniform color is now built with
`torch.tensor(...).repeat(...)` on the point cloud's device. The comment
and docstring claiming the default color is white are corrected (it is
black).
- `utils.math.quat_slerp`: `q2 *= -1.0` negated the caller's tensor in
place when taking the shorter arc; it is now `q2 = -q2`.
- `utils.sensors.convert_camera_intrinsics_to_usd`: `abs()` was applied
to the boolean `(c_x - w/2) > 1e-4 or ...`, so a principal point left of
or above the image center never triggered the aperture-offset warning.
- `utils.datasets.HDF5DatasetFileHandler.create`: a bare file name gave
`os.path.dirname(...) == ""` and `os.makedirs("")` raised. The directory
is now only created when there is one.

**Tests** (focused checks, no new test files; together they run in about
2.5 s). The aperture-offset warning fix is a one-line `abs()` correction
and is not covered by a dedicated test.
- `test/utils/test_math.py`: new `test_unproject_depth` (compares
against the pinhole model); the existing `test_quat_slerp` now also
asserts that `q2` is left unchanged.
- `test/utils/test_hdf5_dataset_file_handler.py`:
`test_create_dataset_file` also covers a bare file name.
- `test/sensors/test_opencv_distortion.py` (kit-less):
`test_pointcloud_from_rgbd_uniform_color` (color tuple and `None`).

All of these fail against `develop` sources and pass with the fixes; the
three touched test files pass in full.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Type of change

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

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

(cherry picked from commit ddc6ec4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

asset New asset feature or request documentation Improvements or additions to documentation infrastructure isaac-mimic Related to Isaac Mimic team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants