Fix Euler rotation order to use ZYX (intrinsic) instead of default XYZ (intrinsic)#16
Open
petertheprocess wants to merge 1 commit intofan-ziqi:mainfrom
Open
Fix Euler rotation order to use ZYX (intrinsic) instead of default XYZ (intrinsic)#16petertheprocess wants to merge 1 commit intofan-ziqi:mainfrom
petertheprocess wants to merge 1 commit intofan-ziqi:mainfrom
Conversation
Owner
|
Thank you for fixing it! Will you continue implementing the changes in the TODO list? |
Author
For now, I think it’s better to leave it as is. The TODO list requires a bit more refactoring, and I’d prefer to handle that in a separate PR when I have more time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
Three.js Object3D.rotation.set() uses XYZ euler order by default, which differs from the euler order used in URDF formats, and the self-built
quaternionToEulerfunction https://github.com/petertheprocess/robot_viewer/blob/53d3103c2a818d20358fc2bec423303147212fa0/src/adapters/MJCFAdapter.js#L999-L1024.This caused incorrect orientation of visual/collision meshes and inertial visualizations.
Solution
Explicitly specify 'ZYX' euler order when setting rotations to ensure consistency with robot model format conventions.
Result
Using agilex_piper mjcf from mujoco_menagerie as demonstration
Before (Default XYZ)
After (ZYX)
TODO for improvement
UnifiedRobotModel.js: Switch from Euler angles (origin.rpy) to Quaternions during the model load stage. Storing rotations as Quaternions avoids ambiguity in the rendering pipeline and eliminates the risk of missing the explicit 'ZYX' order in Three.jsrotation.set()calls.More ref for euler order