fix(urdf): report stage, element and line when URDF/xacro loading fails - #701
Open
karkikamal098 wants to merge 1 commit into
Open
karkikamal098 wants to merge 1 commit into
karkikamal098 wants to merge 1 commit into
Conversation
…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
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
Part of #673 (URDF/xacro error reporting with line numbers).
A broken URDF or xacro used to surface as a bare
KeyError('forearm'), an XMLParseErrorpointing into the xacro-expanded text the user never saw, or aValueErrorwith no element name. Loading now raisesURDFError, aValueErrorsubclass so existing handlers keep working, whose message reports:xml(not well-formed),xacro(expansion failed) orurdf(valid XML, invalid robot);<inertial> inside <link name="arm">;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 raisesFileNotFoundErrorwith the resolved path instead of failing inside xacrodoc.URDFErroris exported fromroboticstoolbox.tools.urdf.The happy path is unchanged: the wrappers only convert exceptions that already escaped.
Related issue
Part of #673.
Checklist
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