Improve the implementation of euler_xyz_from_quat
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. -
lorenzo-bianchi/IsaacLab: Manual angle shifting in
quadcopter_env_v1.py#L219. -
kscalelabs/klab: Custom angle normalization in
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 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_2pifor optional wrapping. - Unit tests added for both wrapped and unwrapped outputs.
Fixes https://github.com/isaac-sim/IsaacLab/issues/2364
Type of Change
- Enhancement (non-breaking addition of functionality)
Checklist
- [x] Ran
./isaaclab.sh --formatand all pre-commit checks pass - [x] Updated docstrings to describe
wrap_to_2piparameter - [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
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, I've completed the requested modifications. Please let me know if you have any further questions or suggestions.
By the way, I'm not sure whether the default value for wrap_to_2pi should be True (the previous default) or False (introduced in this PR). I know we often set wrap_to_2pi=False and expect the output range (-π, π]. However, are there specific scenarios where wrap_to_2pi=True would be preferred?
I'd appreciate your advice on this.
Thanks!