Skip to content

Preserve small rotations in quaternion-to-axis-angle conversion - #564

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/stable-small-quaternion-axisangles
Open

sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/stable-small-quaternion-axisangles

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Fixes #563.

Compute the principal angle with atan2 using the quaternion's vector magnitude. Arccos of the scalar loses valid small rotations once that scalar rounds to one, returning zero even above the existing tolerance.

Retain the principal-angle range, negative-pi half-turn convention, subthreshold zero output and scalar-range validation. Input arrays are not modified.

Validation

Twenty-seven regression cases cover small and ordinary angles, equivalent quaternion signs, identity/subthreshold cases, half turns and invalid scalar controls. Expected rotations are checked analytically and against MuJoCo's actual mju_axisAngle2Quat/mju_quat2Vel functions, with rotation-matrix roundtrips.

  • New tests on unchanged main: 9 failed, 18 passed.
  • Selected baseline: 135 passed.
  • dm_control/utils and dm_control/composer/variation: 162 passed on Python 3.11.16 and 3.12.11, with MuJoCo 3.14.0.
  • Pylint errors-only passed with MuJoCo C-extension inspection enabled. Pyink checks on changed source lines/new tests, compilation and git diff --check passed.

Validation was local on macOS. One existing zero-axis-angle RuntimeWarning remains unchanged. Tests use native conversion routines, not rendering or the complete control-suite simulation matrix. Nonunit quaternion semantics and rotations below the existing tolerance are outside the intended change.

Based on main at a04e3e4cf56c12117d2294bb090f9acec21e5c67. No dependencies or workflows change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Small quaternion rotations are lost in axis-angle conversion

1 participant