Skip to content

Fix quaternion convention in locomanip SDG lerobot conversion dataset#5754

Open
jaybdub wants to merge 1 commit into
isaac-sim:developfrom
jaybdub:jwelsh/locomanipulation_sdg_fix_quat_convert
Open

Fix quaternion convention in locomanip SDG lerobot conversion dataset#5754
jaybdub wants to merge 1 commit into
isaac-sim:developfrom
jaybdub:jwelsh/locomanipulation_sdg_fix_quat_convert

Conversation

@jaybdub
Copy link
Copy Markdown
Contributor

@jaybdub jaybdub commented May 22, 2026

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.

Type of change

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

Screenshots

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

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 bug Something isn't working isaac-mimic Related to Isaac Mimic team labels May 22, 2026
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

PR #5754: Fix quaternion convention in locomanip SDG lerobot conversion dataset

Summary

This PR fixes a quaternion convention mismatch in the locomanipulation SDG dataset conversion script. After PR #4437 changed Isaac Lab from WXYZ to XYZW convention (Jan 2026), this script was still using scalar_first=True when calling scipy's Rotation.from_quat() and as_quat(), causing all converted datasets to have corrupted pose data.

Analysis

✅ Correctness of the Fix

The fix is correct. Here's the breakdown:

Convention Quaternion Order scipy scalar_first
WXYZ (old Isaac Lab) (w, x, y, z) True
XYZW (current Isaac Lab) (x, y, z, w) False (default)

Since Isaac Lab now uses XYZW (scalar-last) and scipy's from_quat() / as_quat() default to scalar_first=False, removing the explicit scalar_first=True parameter correctly aligns the code with the new convention.

✅ Documentation Updates

The docstrings are properly updated:

  • pose_to_transform: Updated to document "scalar-last (x, y, z, w) order" and references isaaclab.assets.ArticulationData.body_link_pose_w
  • pose_from_transform: Updated to match the same convention documentation

⚠️ Minor Observations

  1. No regression test included: The PR description checklist shows testing is not checked. For a bug fix affecting training data quality, a unit test verifying the conversion matches expected output would be valuable.

  2. Downstream impact: Since this changes the output format for all converted datasets, any existing converted datasets would need to be regenerated. This is expected behavior for a bug fix.

Checklist Review

Item Status
Bug fix classification ✅ Correct
Quaternion math ✅ Correct
Docstrings ✅ Updated
Pre-commit checks ⏳ Not confirmed in checklist
Tests added ❌ Not added
Changelog updated ❌ Not checked

Recommendation

The core fix is technically correct and addresses a real data corruption issue. Consider adding:

  1. A simple unit test to guard against future convention regressions
  2. Changelog fragment for this bug fix

This review was generated by the Isaac Lab Review Bot. CI checks are currently pending.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 22, 2026

Greptile Summary

This PR fixes a quaternion convention mismatch in scripts/imitation_learning/locomanipulation_sdg/gr00t/convert_dataset.py. Since PR #4437 (Jan 2026), Isaac Lab returns body poses with quaternions in XYZW (scalar-last) order, but the conversion script was still passing scalar_first=True to scipy's Rotation.from_quat/as_quat, causing every relative-pose computation to silently misinterpret the quaternion components and corrupt GR00T training data.

  • Removes scalar_first=True from Rotation.from_quat and rotation.as_quat(), aligning the script with Isaac Lab's current XYZW convention.
  • Updates docstrings for pose_to_transform and pose_from_transform to explicitly document the scalar-last convention and references body_link_pose_w for traceability.

Confidence Score: 5/5

The change is a two-line fix with no side-effects — it removes an incorrect flag from two scipy calls and updates matching docstrings. The rest of the codebase (rollout_policy.py) already operates with XYZW quaternions, confirming the direction is correct.

Both the conversion direction (from_quat) and output direction (as_quat) are updated consistently. The rollout script independently establishes that the environment emits XYZW and defaults to that format, corroborating the fix. No other files in the scripts/imitation_learning tree use scalar_first.

No files require special attention.

Important Files Changed

Filename Overview
scripts/imitation_learning/locomanipulation_sdg/gr00t/convert_dataset.py Removes scalar_first=True from Rotation.from_quat/as_quat in pose_to_transform and pose_from_transform, correctly aligning quaternion parsing with Isaac Lab's XYZW convention; docstrings updated accordingly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["HDF5 Dataset\n(Isaac Lab XYZW poses)"] --> B["pose_to_transform()\nRotation.from_quat(q)\ndefault: scalar_first=False = XYZW ✅"]
    B --> C["RigidTransform\nbatch Rotation"]
    C --> D["compute_relative_pose()\nbase_pose.inv() * target"]
    D --> E["pose_from_transform()\nrotation.as_quat()\ndefault: scalar_first=False = XYZW ✅"]
    E --> F["7D pose array\n[x,y,z, x,y,z,w]"]
    F --> G["Parquet / GR00T\nTraining Dataset"]
Loading

Reviews (1): Last reviewed commit: "fix quaternion scalar_first=True bug in ..." | Re-trigger Greptile

@rthaker01 rthaker01 requested a review from peterd-NV May 22, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-mimic Related to Isaac Mimic team

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants