Skip to content

fix(urdf): rotate inertia tensors from the inertial frame into the link frame - #707

Open
karkikamal098 wants to merge 1 commit into
petercorke:mainfrom
karkikamal098:fix/urdf-inertia-rotation
Open

karkikamal098 wants to merge 1 commit into
petercorke:mainfrom
karkikamal098:fix/urdf-inertia-rotation

Conversation

@karkikamal098

Copy link
Copy Markdown
Contributor

Summary

URDF gives each link's inertia tensor in its <inertial> frame, whose pose relative to the link frame is <origin xyz rpy>. Link.I expects the tensor about the centre of mass with axes parallel to the link frame. The loader kept only the translation of that origin and passed the tensor through unrotated, so any link with a non-zero inertial rpy got a wrong inertia tensor, and therefore wrong rne, inertia, coriolis and gravload, with no warning.

This rotates the tensor into the link frame, I_link = R I Rᵀ, in a small helper in URDFRobot.py. r is unchanged, since xyz is already the centre of mass in the link frame.

Affected models include those with rotated inertial frames in the bundled data (the Trossen arms, and the Clearpath Ridgeback base used by FrankieOmni) and robot_descriptions models such as the UR series.

Related issue

Related to #686 and #688 (dynamics accuracy of URDF models).

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally: ran the full suite from source using the pure-Python fallbacks (no C++ toolchain here): 671 passed. The 20 failures are identical on main and all need the compiled extension or IPython.
  • Added tests: tests/test_urdf_inertial.py, covering an unrotated frame, a yaw that swaps the x/y moments, a general rotation against R I Rᵀ, the centre of mass, and an rne check where a 90° roll moves iyy = 2 onto the joint axis, so a unit joint acceleration needs torque 2 (3 before the fix). The three rotation tests fail without this change.
  • Type hints / docstrings updated
  • PR is small and focused
  • No project-specific test or data files added

…nk frame

URDF gives each link's inertia tensor in its <inertial> frame, which
<origin rpy> may rotate relative to the link frame. The loader kept only
the origin translation and passed the tensor through unrotated, so links
with rotated inertial frames got wrong inertia, rne, coriolis and
gravload results. Apply I_link = R I R^T. Related to petercorke#686 and petercorke#688.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (848114b) to head (0e59ae6).

Files with missing lines Patch % Lines
src/roboticstoolbox/models/URDF/URDFRobot.py 0.00% 11 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #707   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        143     143           
  Lines      14269   14279   +10     
=====================================
- Misses     14269   14279   +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant