Repository navigation
Improves the implementation of euler_xyz_from_quat - #2365
Conversation
jtigue-bdai
left a comment
There was a problem hiding this comment.
@ShaoshuSu thanks for the addition. We are planning on some upgrades to our testing infrastructure so once those are in we can help you restructure your tests.
|
No problem. Looking forward to these test upgrades! : ) |
|
@ShaoshuSu we have landed the pytest infrastructure change. Please update your implementation when convenient. |
|
Hi @jtigue-bdai, By the way, I'm not sure whether the default value for I'd appreciate your advice on this. Thanks! |
## Description Previously, `euler_xyz_from_quat` returned Euler angles in the [0, 2π) range, which is uncommon in robotics applications. As a result, several users implemented their own workarounds to adjust the angle range to (−π, π]. Examples include: - **Isaac-RL-Two-wheel-Legged-Bot**: Custom unwrapping implemented in [`rewards.py#L17`](https://github.com/jaykorea/Isaac-RL-Two-wheel-Legged-Bot/blob/057f81ed3aa4aff91551fce5c54256e47cece29a/lab/flamingo/tasks/constraint_based/locomotion/velocity/mdp/rewards.py#L17). - **lorenzo-bianchi/IsaacLab**: Manual angle shifting in [`quadcopter_env_v1.py#L219`](https://github.com/lorenzo-bianchi/IsaacLab/blob/247f66db3691046ecdfecb311268eccc729048ec/source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/direct/quadcopter/quadcopter_env_v1.py#L219). - **kscalelabs/klab**: Custom angle normalization in [`imu.py#L17`](https://github.com/kscalelabs/klab/blob/edf749f5177ba296a076d13380cd0fb1e5846e3f/exts/zbot2/zbot2/tasks/locomotion/velocity/mdp/imu.py#L17). To address this issue, we have updated the default angle range from [0, 2π) to (−π, π] by removing the `% (2 * torch.pi)` operation at the return statement, since the [atan2 function](https://en.wikipedia.org/wiki/Atan2) naturally outputs angles within the (−π, π] range. We also introduced a new parameter, `wrap_to_2pi: bool = False`. Setting this parameter to `True` will maintain the previous behavior: - **Default (`wrap_to_2pi=False`)**: Angles returned in the range (−π, π]. - **Optional (`wrap_to_2pi=True`)**: Angles wrapped in the original [0, 2π) range. Additionally, multiple test samples have been added to evaluate and ensure performance and accuracy across different scenarios. ### What’s Changed - **Default behavior** updated to (−π, π] (non-breaking). - **New argument** `wrap_to_2pi` for optional wrapping. - **Unit tests** added for both wrapped and unwrapped outputs. --- Fixes isaac-sim#2364 ## Type of Change - **Enhancement** (non-breaking addition of functionality) --- ## Checklist - [x] Ran `./isaaclab.sh --format` and all pre-commit checks pass - [x] Updated docstrings to describe `wrap_to_2pi` parameter - [x] Added tests covering both wrapped and unwrapped outputs - [x] No new warnings introduced - [ ] Updated changelog and bumped version in `config/extension.toml` - [x] Confirmed my name is listed in `CONTRIBUTORS.md` --------- Co-authored-by: Kelly Guo <[email protected]>
## Description Previously, `euler_xyz_from_quat` returned Euler angles in the [0, 2π) range, which is uncommon in robotics applications. As a result, several users implemented their own workarounds to adjust the angle range to (−π, π]. Examples include: - **Isaac-RL-Two-wheel-Legged-Bot**: Custom unwrapping implemented in [`rewards.py#L17`](https://github.com/jaykorea/Isaac-RL-Two-wheel-Legged-Bot/blob/057f81ed3aa4aff91551fce5c54256e47cece29a/lab/flamingo/tasks/constraint_based/locomotion/velocity/mdp/rewards.py#L17). - **lorenzo-bianchi/IsaacLab**: Manual angle shifting in [`quadcopter_env_v1.py#L219`](https://github.com/lorenzo-bianchi/IsaacLab/blob/247f66db3691046ecdfecb311268eccc729048ec/source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/direct/quadcopter/quadcopter_env_v1.py#L219). - **kscalelabs/klab**: Custom angle normalization in [`imu.py#L17`](https://github.com/kscalelabs/klab/blob/edf749f5177ba296a076d13380cd0fb1e5846e3f/exts/zbot2/zbot2/tasks/locomotion/velocity/mdp/imu.py#L17). To address this issue, we have updated the default angle range from [0, 2π) to (−π, π] by removing the `% (2 * torch.pi)` operation at the return statement, since the [atan2 function](https://en.wikipedia.org/wiki/Atan2) naturally outputs angles within the (−π, π] range. We also introduced a new parameter, `wrap_to_2pi: bool = False`. Setting this parameter to `True` will maintain the previous behavior: - **Default (`wrap_to_2pi=False`)**: Angles returned in the range (−π, π]. - **Optional (`wrap_to_2pi=True`)**: Angles wrapped in the original [0, 2π) range. Additionally, multiple test samples have been added to evaluate and ensure performance and accuracy across different scenarios. ### What’s Changed - **Default behavior** updated to (−π, π] (non-breaking). - **New argument** `wrap_to_2pi` for optional wrapping. - **Unit tests** added for both wrapped and unwrapped outputs. --- Fixes isaac-sim#2364 ## Type of Change - **Enhancement** (non-breaking addition of functionality) --- ## Checklist - [x] Ran `./isaaclab.sh --format` and all pre-commit checks pass - [x] Updated docstrings to describe `wrap_to_2pi` parameter - [x] Added tests covering both wrapped and unwrapped outputs - [x] No new warnings introduced - [ ] Updated changelog and bumped version in `config/extension.toml` - [x] Confirmed my name is listed in `CONTRIBUTORS.md` --------- Co-authored-by: Kelly Guo <[email protected]>
## Description Previously, `euler_xyz_from_quat` returned Euler angles in the [0, 2π) range, which is uncommon in robotics applications. As a result, several users implemented their own workarounds to adjust the angle range to (−π, π]. Examples include: - **Isaac-RL-Two-wheel-Legged-Bot**: Custom unwrapping implemented in [`rewards.py#L17`](https://github.com/jaykorea/Isaac-RL-Two-wheel-Legged-Bot/blob/057f81ed3aa4aff91551fce5c54256e47cece29a/lab/flamingo/tasks/constraint_based/locomotion/velocity/mdp/rewards.py#L17). - **lorenzo-bianchi/IsaacLab**: Manual angle shifting in [`quadcopter_env_v1.py#L219`](https://github.com/lorenzo-bianchi/IsaacLab/blob/247f66db3691046ecdfecb311268eccc729048ec/source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/direct/quadcopter/quadcopter_env_v1.py#L219). - **kscalelabs/klab**: Custom angle normalization in [`imu.py#L17`](https://github.com/kscalelabs/klab/blob/edf749f5177ba296a076d13380cd0fb1e5846e3f/exts/zbot2/zbot2/tasks/locomotion/velocity/mdp/imu.py#L17). To address this issue, we have updated the default angle range from [0, 2π) to (−π, π] by removing the `% (2 * torch.pi)` operation at the return statement, since the [atan2 function](https://en.wikipedia.org/wiki/Atan2) naturally outputs angles within the (−π, π] range. We also introduced a new parameter, `wrap_to_2pi: bool = False`. Setting this parameter to `True` will maintain the previous behavior: - **Default (`wrap_to_2pi=False`)**: Angles returned in the range (−π, π]. - **Optional (`wrap_to_2pi=True`)**: Angles wrapped in the original [0, 2π) range. Additionally, multiple test samples have been added to evaluate and ensure performance and accuracy across different scenarios. ### What’s Changed - **Default behavior** updated to (−π, π] (non-breaking). - **New argument** `wrap_to_2pi` for optional wrapping. - **Unit tests** added for both wrapped and unwrapped outputs. --- Fixes isaac-sim#2364 ## Type of Change - **Enhancement** (non-breaking addition of functionality) --- ## Checklist - [x] Ran `./isaaclab.sh --format` and all pre-commit checks pass - [x] Updated docstrings to describe `wrap_to_2pi` parameter - [x] Added tests covering both wrapped and unwrapped outputs - [x] No new warnings introduced - [ ] Updated changelog and bumped version in `config/extension.toml` - [x] Confirmed my name is listed in `CONTRIBUTORS.md` --------- Co-authored-by: Kelly Guo <[email protected]>
# Description `euler_xyz_from_quat` returns angles in `(-pi, pi]` by default since #2365. `AssemblyEnv._apply_action()` and `DisassemblyEnv._apply_action()` compute the `curr_yaw` attribute with the Factory yaw mapping, which still assumes the former `[0, 2*pi)` range: yaws above 235 degrees are moved down by `2*pi`, so the span `[-125, 235]` degrees is not interrupted by the yaw joint limit. With signed input the mapping does nothing, and a yaw between 180 and 235 degrees comes out between -180 and -125 degrees. This PR requests `wrap_to_2pi=True` for these two calls, as #8804 did for FORGE. Nothing in the repository reads `curr_yaw` today, so there is no behavior change for the current tasks. The fix restores the attribute's intended range so that code reading it, such as a nut-thread style rotation check using `ee_success_yaw` from the AutoMate config, gets the expected value. Related: #8779, #8804 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `main` ## Validation - AutoMate Assembly runs with the change (PhysX), and `curr_yaw` stays in `[-125, 235]` degrees. - Searched the repository: nothing reads `curr_yaw`, so the current tasks are unaffected. - `uv run isaaclab --format` passed every hook, including the ruff hooks, the license headers and the changelog fragment check. - No new unit test. The changed calls live inside `DirectRLEnv` methods that need a simulated scene, so the only way to unit-test them would be to replay the production expression. ## 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 `uv run isaaclab --format` - [ ] I have made corresponding changes to the documentation (not applicable: no public API change) - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
# Description `euler_xyz_from_quat` returns angles in `(-pi, pi]` by default since #2365. `AssemblyEnv._apply_action()` and `DisassemblyEnv._apply_action()` compute the `curr_yaw` attribute with the Factory yaw mapping, which still assumes the former `[0, 2*pi)` range: yaws above 235 degrees are moved down by `2*pi`, so the span `[-125, 235]` degrees is not interrupted by the yaw joint limit. With signed input the mapping does nothing, and a yaw between 180 and 235 degrees comes out between -180 and -125 degrees. This PR requests `wrap_to_2pi=True` for these two calls, as #8804 did for FORGE. Nothing in the repository reads `curr_yaw` today, so there is no behavior change for the current tasks. The fix restores the attribute's intended range so that code reading it, such as a nut-thread style rotation check using `ee_success_yaw` from the AutoMate config, gets the expected value. Related: #8779, #8804 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `main` ## Validation - AutoMate Assembly runs with the change (PhysX), and `curr_yaw` stays in `[-125, 235]` degrees. - Searched the repository: nothing reads `curr_yaw`, so the current tasks are unaffected. - `uv run isaaclab --format` passed every hook, including the ruff hooks, the license headers and the changelog fragment check. - No new unit test. The changed calls live inside `DirectRLEnv` methods that need a simulated scene, so the only way to unit-test them would be to replay the production expression. ## 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 `uv run isaaclab --format` - [ ] I have made corresponding changes to the documentation (not applicable: no public API change) - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there (cherry picked from commit 87a150d)
# Description `euler_xyz_from_quat` returns angles in `(-pi, pi]` by default since #2365. `FactoryEnv._get_curr_successes(check_rot=True)`, the nut-thread rotation check (`wrap_yaw(curr_yaw) < ee_success_yaw`), still assumes the former `[0, 2*pi)` range: `factory_utils.wrap_yaw` moves yaws above 235 degrees down by `2*pi`, so the span `[-125, 235]` degrees is not interrupted by the yaw joint limit. With signed input this mapping does nothing, and a yaw between 180 and 235 degrees comes out between -180 and -125 degrees, so it counts as "rotated". #8804 fixed the same assumption in `ForgeEnv._apply_action()`. This PR requests `wrap_to_2pi=True` in the rotation check, and the `wrap_yaw` docstring now states the input range it expects. Factory NutThread cannot reach the affected interval: it starts near 105 degrees yaw and only rotates toward smaller yaw. FORGE NutThread can. Its yaw action is bounded to [-90, 180] degrees in the world frame, and commanding the 180-degree bound makes the hand overshoot to about 182 degrees. If the nut is also pressed down to the success height, the hand has turned the wrong way, yet the check counts it as success. FORGE uses this flag for its success-prediction reward and for the logged success rate. Related: #8779, #8804 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `main` ## Validation - Direct check of `FactoryEnv._get_curr_successes` on Factory and FORGE NutThread (PhysX). The nut is placed at the success pose and the hand yaw is swept from -120 to 235 degrees with roll at pi. - Before: success was reported for every yaw from 180 to 230 degrees. - After: success is reported only for yaw below `ee_success_yaw` (0 degrees). - Rollouts on FORGE NutThread (256 envs, #8804 applied as on `main`): - Pressing the nut down, then commanding the 180-degree yaw bound for the second half of the episode, gave 186 env-steps counted as success before this change and 0 after. The hand yaw reached up to 182 degrees. - Random, hold and other constant-yaw actions kept the yaw below 122 degrees, and both versions agreed on every step. - Rollouts on Factory NutThread under the same action policies: the yaw stayed between -67 and 120 degrees, and both versions agreed on every step. - `uv run isaaclab --format` passed every hook, including the ruff hooks, the license headers and the changelog fragment check. - No new unit test. The changed call lives inside a `DirectRLEnv` method that needs a simulated scene, so the only way to unit-test it would be to replay the production expression. ## 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 `uv run isaaclab --format` - [ ] I have made corresponding changes to the documentation (not applicable: no public API change) - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
# Description `euler_xyz_from_quat` returns angles in `(-pi, pi]` by default since #2365. `FactoryEnv._get_curr_successes(check_rot=True)`, the nut-thread rotation check (`wrap_yaw(curr_yaw) < ee_success_yaw`), still assumes the former `[0, 2*pi)` range: `factory_utils.wrap_yaw` moves yaws above 235 degrees down by `2*pi`, so the span `[-125, 235]` degrees is not interrupted by the yaw joint limit. With signed input this mapping does nothing, and a yaw between 180 and 235 degrees comes out between -180 and -125 degrees, so it counts as "rotated". #8804 fixed the same assumption in `ForgeEnv._apply_action()`. This PR requests `wrap_to_2pi=True` in the rotation check, and the `wrap_yaw` docstring now states the input range it expects. Factory NutThread cannot reach the affected interval: it starts near 105 degrees yaw and only rotates toward smaller yaw. FORGE NutThread can. Its yaw action is bounded to [-90, 180] degrees in the world frame, and commanding the 180-degree bound makes the hand overshoot to about 182 degrees. If the nut is also pressed down to the success height, the hand has turned the wrong way, yet the check counts it as success. FORGE uses this flag for its success-prediction reward and for the logged success rate. Related: #8779, #8804 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `main` ## Validation - Direct check of `FactoryEnv._get_curr_successes` on Factory and FORGE NutThread (PhysX). The nut is placed at the success pose and the hand yaw is swept from -120 to 235 degrees with roll at pi. - Before: success was reported for every yaw from 180 to 230 degrees. - After: success is reported only for yaw below `ee_success_yaw` (0 degrees). - Rollouts on FORGE NutThread (256 envs, #8804 applied as on `main`): - Pressing the nut down, then commanding the 180-degree yaw bound for the second half of the episode, gave 186 env-steps counted as success before this change and 0 after. The hand yaw reached up to 182 degrees. - Random, hold and other constant-yaw actions kept the yaw below 122 degrees, and both versions agreed on every step. - Rollouts on Factory NutThread under the same action policies: the yaw stayed between -67 and 120 degrees, and both versions agreed on every step. - `uv run isaaclab --format` passed every hook, including the ruff hooks, the license headers and the changelog fragment check. - No new unit test. The changed call lives inside a `DirectRLEnv` method that needs a simulated scene, so the only way to unit-test it would be to replay the production expression. ## 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 `uv run isaaclab --format` - [ ] I have made corresponding changes to the documentation (not applicable: no public API change) - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there (cherry picked from commit 56ed7fd)
Description
Previously,
euler_xyz_from_quatreturned Euler angles in the [0, 2π) range, which is uncommon in robotics applications. As a result, several users implemented their own workarounds to adjust the angle range to (−π, π]. Examples include:rewards.py#L17.quadcopter_env_v1.py#L219.imu.py#L17.To address this issue, we have updated the default angle range from [0, 2π) to (−π, π] by removing the
% (2 * torch.pi)operation at the return statement, since the atan2 function naturally outputs angles within the (−π, π] range.We also introduced a new parameter,
wrap_to_2pi: bool = False. Setting this parameter toTruewill maintain the previous behavior:wrap_to_2pi=False): Angles returned in the range (−π, π].wrap_to_2pi=True): Angles wrapped in the original [0, 2π) range.Additionally, multiple test samples have been added to evaluate and ensure performance and accuracy across different scenarios.
What’s Changed
wrap_to_2pifor optional wrapping.Fixes #2364
Type of Change
Checklist
./isaaclab.sh --formatand all pre-commit checks passwrap_to_2piparameterconfig/extension.tomlCONTRIBUTORS.md