Skip to content

fix(urdf): report stage, element and line when URDF/xacro loading fails - #701

Merged
petercorke merged 5 commits into
petercorke:mainfrom
karkikamal098:fix/urdf-error-reporting
Sep 27, 2026
Merged

petercorke merged 5 commits into
petercorke:mainfrom
karkikamal098:fix/urdf-error-reporting

Conversation

@karkikamal098

Copy link
Copy Markdown
Contributor

Summary

Part of #673 (URDF/xacro error reporting with line numbers).

A broken URDF or xacro used to surface as a bare KeyError('forearm'), an XML ParseError pointing into the xacro-expanded text the user never saw, or a ValueError with no element name. Loading now raises URDFError, a ValueError subclass so existing handlers keep working, whose message reports:

  • the stage that failed: xml (not well-formed), xacro (expansion failed) or urdf (valid XML, invalid robot);
  • the element chain, innermost first, e.g. <inertial> inside <link name="arm">;
  • the line (and column for XML errors), plus xacro's include/macro stack for xacro failures;
  • the path of a saved copy of the expanded URDF that the line number refers to.

Undefined parent/child link references, a missing joint type, missing <mass>/<inertia> and duplicate names now say which joint or link is at fault. A missing file raises FileNotFoundError with the resolved path instead of failing inside xacrodoc. URDFError is exported from roboticstoolbox.tools.urdf.

The happy path is unchanged: the wrappers only convert exceptions that already escaped.

Related issue

Part of #673.

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally: not run, my machine has no C++ toolchain yet, so I could not build the package. All changed files compile and lint clean under the repo's ruff rules; CI will run the suite.
  • Added tests: tests/test_urdf_errors.py, 13 cases covering malformed XML in source and expanded text, undefined property, missing package, undefined link, missing/invalid attributes, duplicate names, missing file, and a valid-string regression
  • Type hints use modern syntax; docstrings in reST
  • PR is small and focused
  • No project-specific test or data files added

karkikamal098 and others added 2 commits September 26, 2026 19:10
…load

Part of petercorke#673. Loading failures now raise URDFError (a ValueError) that
names the failing stage (xml / xacro / urdf), the element chain, the
line in a saved copy of the expanded URDF, and xacro's include/macro
stack, instead of leaking a bare KeyError, ParseError or ValueError.
Undefined link references, missing joint type, missing mass/inertia and
duplicate names now say which joint or link is at fault.
@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 172 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (fee6bb0) to head (30b524f).

Files with missing lines Patch % Lines
src/roboticstoolbox/tools/urdf/urdf.py 0.00% 92 Missing ⚠️
src/roboticstoolbox/models/URDF/URDFRobot.py 0.00% 80 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main    #701    +/-   ##
======================================
  Coverage   0.00%   0.00%            
======================================
  Files        143     143            
  Lines      14115   14269   +154     
======================================
- Misses     14115   14269   +154     

☔ 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.

@petercorke

Copy link
Copy Markdown
Owner

Thank you for your interest in RTB, and for the thorough work here -- this is exactly the error reporting #673 was after. Since your environment couldn't build the C++ extension, I built and ran the full test suite against this myself (762 tests) to cover that gap -- zero regressions across every model the repo ships. Merging.

@petercorke
petercorke merged commit 848114b into petercorke:main Sep 27, 2026
24 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 27, 2026
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.

2 participants