gazebosim / sdformat

Simulation Description Format (SDFormat) parser and description files.
http://sdformat.org
Apache License 2.0
169 stars 97 forks source link

Associate sdf::Element with line number in file #226

Closed osrf-migration closed 3 years ago

osrf-migration commented 4 years ago

Original report (archived issue) by Anonymous.


Currently, during parsing, it is impossible to examine an arbitrary sdf::Thing (or sdf::Element) and provide any feedback on the element and link it to where it came from in the original source file. This definitely handicaps error and warning messages.

osrf-migration commented 4 years ago

Original comment by Eric Cousineau (Bitbucket: eacousineau, GitHub: EricCousineau-TRI).


FTR This is a request relevant to use in Drake.

osrf-migration commented 4 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


libsdformat currently uses tinyxml for xml parsing, which doesn't retain line numbers from the original document as far as I can see from its API. It looks like tinyxml2 does store line numbers:

pull request #403 was submitted by an external contributor to switch to tinyxml2, but it was not considered a priority at the time. There are a few places where tinyxml types are exposed in the API, so those must be fixed as part of the porting process.

EricCousineau-TRI commented 4 years ago

As an interim (pre-tinyxml2), it may possible to still provide more information by means of tracing with an XPath error.

I had tinkered with something like this in urdf_parser_py, inspired by some MathWorks-related code. Example: https://github.com/ros/urdf_parser_py/blob/f7f25be76c5dfbe51d4e87367553ec180d8f5683/test/test_urdf_error.py#L124 To inline this, you could say something like:

Error encountered when parsing /robot[@name='test']/link[@name='b']/inertial/origin[@xyz]

FYI @SeanCurtis-TRI

EricCousineau-TRI commented 3 years ago

FYI @aaronchongth