|
| 1 | +.. _migrating-to-isaaclab-3-0: |
| 2 | + |
| 3 | +Migrating to IsaacLab 3.0 |
| 4 | +========================= |
| 5 | + |
| 6 | +.. currentmodule:: isaaclab |
| 7 | + |
| 8 | +IsaacLab 3.0 introduces a significant change to quaternion ordering throughout the codebase. |
| 9 | +This guide explains what changed, why it matters, and how to update your code. |
| 10 | + |
| 11 | + |
| 12 | +What Changed: Quaternion Format |
| 13 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 14 | + |
| 15 | +**The quaternion format changed from WXYZ to XYZW.** |
| 16 | + |
| 17 | ++------------------+----------------------------------+----------------------------------+ |
| 18 | +| Component | Old Format (WXYZ) | New Format (XYZW) | |
| 19 | ++==================+==================================+==================================+ |
| 20 | +| Order | ``(w, x, y, z)`` | ``(x, y, z, w)`` | |
| 21 | ++------------------+----------------------------------+----------------------------------+ |
| 22 | +| Identity | ``(1.0, 0.0, 0.0, 0.0)`` | ``(0.0, 0.0, 0.0, 1.0)`` | |
| 23 | ++------------------+----------------------------------+----------------------------------+ |
| 24 | + |
| 25 | + |
| 26 | +Why This Change? |
| 27 | +---------------- |
| 28 | + |
| 29 | +The new XYZW format aligns with: |
| 30 | + |
| 31 | +- **Warp**: NVIDIA's spatial computing framework |
| 32 | +- **PhysX**: PhysX physics engine |
| 33 | +- **Newton**: Newton multi-solver framework |
| 34 | + |
| 35 | +This alignment removes the need for internal quaternion conversions, making the code simpler, |
| 36 | +faster, and less error-prone. |
| 37 | + |
| 38 | + |
| 39 | +What You Need to Update |
| 40 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 41 | + |
| 42 | +Any hard-coded quaternion values in your code need to be converted from WXYZ to XYZW. |
| 43 | +This includes: |
| 44 | + |
| 45 | +1. **Configuration files** - ``rot`` parameters in asset configs |
| 46 | +2. **Task definitions** - Goal poses, initial states |
| 47 | +3. **Controller parameters** - Target orientations |
| 48 | +4. **Documentation** - Code examples with quaternions |
| 49 | + |
| 50 | +Also, if you were relying on the :func:`~isaaclab.utils.math.convert_quat` function to convert quaternions, this should |
| 51 | +no longer be needed. (This would happen if you were pulling values from the views directly.) |
| 52 | + |
| 53 | +Example: Updating Asset Configuration |
| 54 | +------------------------------------- |
| 55 | + |
| 56 | +**Before (WXYZ):** |
| 57 | + |
| 58 | +.. code-block:: python |
| 59 | +
|
| 60 | + from isaaclab.assets import AssetBaseCfg |
| 61 | +
|
| 62 | + cfg = AssetBaseCfg( |
| 63 | + init_state=AssetBaseCfg.InitialStateCfg( |
| 64 | + pos=(0.0, 0.0, 0.5), |
| 65 | + rot=(1.0, 0.0, 0.0, 0.0), # OLD: w, x, y, z |
| 66 | + ), |
| 67 | + ) |
| 68 | +
|
| 69 | +**After (XYZW):** |
| 70 | + |
| 71 | +.. code-block:: python |
| 72 | +
|
| 73 | + from isaaclab.assets import AssetBaseCfg |
| 74 | +
|
| 75 | + cfg = AssetBaseCfg( |
| 76 | + init_state=AssetBaseCfg.InitialStateCfg( |
| 77 | + pos=(0.0, 0.0, 0.5), |
| 78 | + rot=(0.0, 0.0, 0.0, 1.0), # NEW: x, y, z, w |
| 79 | + ), |
| 80 | + ) |
| 81 | +
|
| 82 | +
|
| 83 | +Using the Quaternion Finder Tool |
| 84 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 85 | + |
| 86 | +We provide a tool to help you find and fix quaternions in your codebase automatically. This is not a bulletproof tool, |
| 87 | +but it should help you find most of the quaternions that need to be updated. You *should* review the results manually. |
| 88 | + |
| 89 | +.. warning:: |
| 90 | + Do not run the tool on the whole codebase! If you run the tool on our own packages (isaaclab, or isaaclab_tasks for |
| 91 | + instance) it will find all the quaternions that we already converted. This tool is only meant to be used on your own |
| 92 | + codebase with no overlap with our own packages. |
| 93 | + |
| 94 | +Finding Quaternions |
| 95 | +------------------- |
| 96 | + |
| 97 | +Run the tool to scan your code for potential quaternions: |
| 98 | + |
| 99 | +.. code-block:: bash |
| 100 | +
|
| 101 | + # Scan the 'source' directory (default) |
| 102 | + python scripts/tools/find_quaternions.py |
| 103 | +
|
| 104 | + # Scan a specific path |
| 105 | + python scripts/tools/find_quaternions.py --path my_project/ |
| 106 | +
|
| 107 | + # Compare against a different branch |
| 108 | + python scripts/tools/find_quaternions.py --base develop |
| 109 | +
|
| 110 | +.. tip:: |
| 111 | + We recommend always running the tool with a custom base branch *and* a specific path. |
| 112 | + |
| 113 | + |
| 114 | +The tool will show you: |
| 115 | + |
| 116 | +- Quaternions that haven't been updated (marked as ``UNCHANGED``) |
| 117 | +- Whether each looks like a WXYZ identity quaternion (``WXYZ_IDENTITY``) |
| 118 | +- Whether the format is likely WXYZ (``LIKELY_WXYZ``) |
| 119 | + |
| 120 | + |
| 121 | +Understanding the Output |
| 122 | +------------------------ |
| 123 | + |
| 124 | +.. code-block:: text |
| 125 | +
|
| 126 | + my_project/robot_cfg.py:42:8 ⚠ UNCHANGED [WXYZ_IDENTITY] |
| 127 | + Values: [1.0, 0.0, 0.0, 0.0] |
| 128 | + Source: rot=(1.0, 0.0, 0.0, 0.0), |
| 129 | +
|
| 130 | +This tells you: |
| 131 | + |
| 132 | +- **File and line**: ``my_project/robot_cfg.py:42`` |
| 133 | +- **Status**: ``UNCHANGED`` means this line hasn't been modified yet |
| 134 | +- **Flag**: ``WXYZ_IDENTITY`` means it's the identity quaternion in old WXYZ format |
| 135 | +- **Values**: The actual quaternion values found |
| 136 | +- **Source**: The line of code for context |
| 137 | + |
| 138 | + |
| 139 | +Filtering Results |
| 140 | +----------------- |
| 141 | + |
| 142 | +Focus on specific types of quaternions: |
| 143 | + |
| 144 | +.. code-block:: bash |
| 145 | +
|
| 146 | + # Only show identity quaternions [1, 0, 0, 0] |
| 147 | + python scripts/tools/find_quaternions.py --check-identity |
| 148 | +
|
| 149 | + # Only show quaternions likely in WXYZ format |
| 150 | + python scripts/tools/find_quaternions.py --likely-wxyz |
| 151 | +
|
| 152 | + # Show ALL potential quaternions (ignore format heuristics) |
| 153 | + python scripts/tools/find_quaternions.py --all-quats |
| 154 | +
|
| 155 | +
|
| 156 | +Fixing Quaternions Automatically |
| 157 | +-------------------------------- |
| 158 | + |
| 159 | +The tool can automatically convert quaternions from WXYZ to XYZW: |
| 160 | + |
| 161 | +.. code-block:: bash |
| 162 | +
|
| 163 | + # Interactive mode: prompts before each fix |
| 164 | + python scripts/tools/find_quaternions.py --fix |
| 165 | +
|
| 166 | + # Only fix identity quaternions (safest option) |
| 167 | + python scripts/tools/find_quaternions.py --fix-identity-only |
| 168 | +
|
| 169 | + # Preview changes without applying them |
| 170 | + python scripts/tools/find_quaternions.py --fix --dry-run |
| 171 | +
|
| 172 | + # Apply all fixes without prompting |
| 173 | + python scripts/tools/find_quaternions.py --fix --force |
| 174 | +
|
| 175 | +
|
| 176 | +Interactive Fix Example |
| 177 | +----------------------- |
| 178 | + |
| 179 | +When running with ``--fix``, you'll see something like: |
| 180 | + |
| 181 | +.. code-block:: text |
| 182 | +
|
| 183 | + ──────────────────────────────────────────────────────────────────────────────── |
| 184 | + 📍 my_project/robot_cfg.py:42 [WXYZ_IDENTITY] |
| 185 | + ──────────────────────────────────────────────────────────────────────────────── |
| 186 | + 40 | init_state=AssetBaseCfg.InitialStateCfg( |
| 187 | + 41 | pos=(0.0, 0.0, 0.5), |
| 188 | + >>> 42 | rot=(1.0, 0.0, 0.0, 0.0), |
| 189 | + 43 | ), |
| 190 | + 44 | ) |
| 191 | + ──────────────────────────────────────────────────────────────────────────────── |
| 192 | + Change: [1.0, 0.0, 0.0, 0.0] → [0.0, 0.0, 0.0, 1.0] |
| 193 | + Result: rot=(0.0, 0.0, 0.0, 1.0), |
| 194 | + Apply this fix? [Y/n/a/q]: |
| 195 | +
|
| 196 | +Options: |
| 197 | + |
| 198 | +- **Y** (yes): Apply this fix |
| 199 | +- **n** (no): Skip this one |
| 200 | +- **a** (all): Apply all remaining fixes without asking |
| 201 | +- **q** (quit): Stop fixing |
| 202 | + |
| 203 | + |
| 204 | +How the Tool Works |
| 205 | +------------------ |
| 206 | + |
| 207 | +The tool uses several techniques to find quaternions: |
| 208 | + |
| 209 | +1. **Python files**: Parses the code using AST (Abstract Syntax Tree) to find |
| 210 | + 4-element tuples and lists with numeric values. |
| 211 | + |
| 212 | +2. **JSON files**: Uses regex to find 4-element arrays. |
| 213 | + |
| 214 | +3. **RST documentation**: Searches for quaternion-like patterns in docs. |
| 215 | + |
| 216 | +To identify if something is a quaternion, the tool checks: |
| 217 | + |
| 218 | +- Is it exactly 4 numeric values? |
| 219 | +- Does the sum of squares ≈ 1? (unit quaternion property) |
| 220 | +- Does it match known patterns like identity quaternions? |
| 221 | + |
| 222 | +To determine if it's in WXYZ format: |
| 223 | + |
| 224 | +- Is the first value 1.0 and rest are 0? (WXYZ identity) |
| 225 | +- Is the first value a common cos(θ/2) value like 0.707, 0.866, etc.? |
| 226 | +- Is the pattern consistent with first-element being the scalar part? |
| 227 | + |
| 228 | + |
| 229 | +Best Practices for Migration |
| 230 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 231 | + |
| 232 | +1. **Start with a clean git state** - Commit your work before running fixes. |
| 233 | + |
| 234 | +2. **Run the tool first without ``--fix``** - Review what will be changed. |
| 235 | + |
| 236 | +3. **Fix identity quaternions first** - They're the most common and safest: |
| 237 | + |
| 238 | + .. code-block:: bash |
| 239 | +
|
| 240 | + python scripts/tools/find_quaternions.py --fix-identity-only |
| 241 | +
|
| 242 | +4. **Review non-identity quaternions manually** - Some 4-element lists might |
| 243 | + not be quaternions (e.g., RGBA colors, bounding boxes). |
| 244 | + |
| 245 | +5. **Test your code** - Run your simulations to verify everything works correctly. |
| 246 | + |
| 247 | +6. **Check documentation** - Update any docs or comments that mention quaternion format. |
| 248 | + |
| 249 | +API Changes |
| 250 | +~~~~~~~~~~~ |
| 251 | + |
| 252 | +The ``convert_quat`` function has been removed |
| 253 | +---------------------------------------------- |
| 254 | + |
| 255 | +Previously, IsaacLab had a utility function to convert between quaternion formats: |
| 256 | + |
| 257 | +.. code-block:: python |
| 258 | +
|
| 259 | + # OLD - No longer needed |
| 260 | + from isaaclab.utils.math import convert_quat |
| 261 | + quat_xyzw = convert_quat(quat_wxyz, "xyzw") |
| 262 | +
|
| 263 | +Since everything now uses XYZW natively, this function is no longer needed. |
| 264 | +If you were using it, simply remove the conversion calls. |
| 265 | + |
| 266 | + |
| 267 | +Math utility functions now expect XYZW |
| 268 | +-------------------------------------- |
| 269 | + |
| 270 | +All quaternion functions in :mod:`isaaclab.utils.math` now expect and return |
| 271 | +quaternions in XYZW format: |
| 272 | + |
| 273 | +- :func:`~isaaclab.utils.math.quat_mul` |
| 274 | +- :func:`~isaaclab.utils.math.quat_apply` |
| 275 | +- :func:`~isaaclab.utils.math.quat_from_euler_xyz` |
| 276 | +- :func:`~isaaclab.utils.math.euler_xyz_from_quat` |
| 277 | +- :func:`~isaaclab.utils.math.quat_from_matrix` |
| 278 | +- :func:`~isaaclab.utils.math.matrix_from_quat` |
| 279 | +- And all other quaternion utilities |
| 280 | + |
| 281 | + |
| 282 | +Need Help? |
| 283 | +~~~~~~~~~~ |
| 284 | + |
| 285 | +If you encounter issues during migration: |
| 286 | + |
| 287 | +1. Check the `IsaacLab GitHub Issues <https://github.com/isaac-sim/IsaacLab/issues>`_ |
| 288 | +2. Review the `CHANGELOG <https://github.com/isaac-sim/IsaacLab/blob/main/source/isaaclab/docs/CHANGELOG.rst>`_ |
| 289 | +3. Join the community on `Discord <https://discord.gg/nvidiaomniverse>`_ |
0 commit comments