Skip to content

Commit 5a4fff3

Browse files
authored
Merge pull request #165 from gbionics/copilot/fix-failing-github-actions-check
Fix inverted principal-axes rotation convention in USD inertia read/write
2 parents 89bc4e0 + 20e1fc3 commit 5a4fff3

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sphinx
22
sphinx-rtd-theme
33
sphinx-book-theme
4-
sphinx-shibuya
4+
shibuya
55
sphinx-autodoc-typehints
66
sphinx-book-theme
77
sphinx-copybutton

src/adam/model/conversions/usd.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ def _inertia_to_principal_axes(I: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
7171
if np.linalg.det(eigvecs) < 0.0:
7272
eigvecs[:, 0] *= -1.0
7373

74-
# USD stores principalAxes as the rotation from the body frame in which I
75-
# is expressed to the principal-inertia frame, i.e. the transpose/inverse
76-
# of the matrix whose columns are the principal axes expressed in the body
77-
# frame.
78-
quat_wxyz = R.from_matrix(eigvecs.T).as_quat(scalar_first=True)
74+
# USD stores principalAxes as the rotation from the principal-inertia
75+
# frame to the body frame in which I is expressed, i.e. the matrix whose
76+
# columns are the principal axes expressed in the body frame.
77+
quat_wxyz = R.from_matrix(eigvecs).as_quat(scalar_first=True)
7978
return eigvals, quat_wxyz
8079

8180

src/adam/model/usd_factory/usd_model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,18 @@ def _mass_api_to_inertial(self, prim: Any) -> USDInertial:
217217
else self.Gf.Quatf(1.0, 0.0, 0.0, 0.0)
218218
)
219219

220-
# USD stores principalAxes as the rotation from the link frame to the
221-
# principal-inertia frame (R_link_to_principal). Rotate the diagonal
222-
# inertia tensor back into the link frame directly, avoiding any
220+
# USD stores principalAxes as the rotation from the principal-inertia
221+
# frame to the link frame (R_principal_to_link). Rotate the diagonal
222+
# inertia tensor into the link frame directly, avoiding any
223223
# Euler-angle conversion and the associated gimbal-lock singularity.
224224
#
225-
# I_link = R^T @ diag(Ixx, Iyy, Izz) @ R
225+
# I_link = R @ diag(Ixx, Iyy, Izz) @ R^T
226226
#
227-
# where R = R.from_quat(principal_axes) maps linkprincipal frame.
227+
# where R = R.from_quat(principal_axes) maps principallink frame.
228228
R_principal = _rotation_from_usd_quat(principal_axes)
229229
R_mat = R_principal.as_matrix()
230230
I_diag = np.diag(diagonal_inertia)
231-
I_link = R_mat.T @ I_diag @ R_mat
231+
I_link = R_mat @ I_diag @ R_mat.T
232232

233233
return USDInertial(
234234
mass=mass,

0 commit comments

Comments
 (0)