Skip to content

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

Open
karkikamal098 wants to merge 1 commit into
petercorke:mainfrom
karkikamal098:fix/urdf-error-reporting
Open

karkikamal098 wants to merge 1 commit into
petercorke:mainfrom
karkikamal098:fix/urdf-error-reporting

Conversation

@karkikamal098

Copy link
Copy Markdown

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

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

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