IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

Improve the implementation of euler_xyz_from_quat

Open ShaoshuSu opened this issue 8 months ago • 1 comments

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:

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_2pi for 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 --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

ShaoshuSu avatar Apr 24 '25 04:04 ShaoshuSu

No problem. Looking forward to these test upgrades! : )

ShaoshuSu avatar Apr 29 '25 23:04 ShaoshuSu

@ShaoshuSu we have landed the pytest infrastructure change. Please update your implementation when convenient.

jtigue-bdai avatar May 15 '25 21:05 jtigue-bdai

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!

ShaoshuSu avatar May 17 '25 20:05 ShaoshuSu