ros / urdf_parser_py

Standalone URDF parser for Python.
84 stars 48 forks source link

Add XPath information when a parse error is encountered #8

Closed eacousineau closed 7 years ago

eacousineau commented 7 years ago

This feature adds a little more information and provides an XPath if a parser error occurs specific to the XML Reflection (not a basic XML error).

For example, in Romeo, if the lower limit for REyeYaw were changed to something such as this:

  <joint name="REyeYaw" type="revolute">
...
    <limit effort="0" lower="-0.5235___98766666667" upper="0.523598766666667" velocity="0" />
  </joint>

The current implementation reports the following error:

ValueError: invalid literal for float(): -0.5235___98766666667

With this implementation, this error is changed to:

urdf_parser_py.xml_reflection.core.ParseError: ParseError in /robot[@name='romeo']/joint[@name='REyeYaw']/limit[@lower]:
invalid literal for float(): -0.5235___98766666667

I have attempted to make this a semi-valid XPath, but haven't a chance to do much extensive parsing.

eacousineau commented 7 years ago

Looks like the Travis build is failing because "lxml" is not found on the test machine.

I had run the tests on my machine as follows:

mkcd() { mkdir "$@" && cd "${!#}"; }
mkcd build
cmake ..
make test
wjwwood commented 7 years ago

I guess you would need to add a dependency on lxml (e.g. https://pypi.python.org/pypi/lxml/3.7.2) if you wanted to make use of it.

clalancette commented 7 years ago

Actually, this package already depended on lxml, it just wasn't properly reflected in the travis.yml file. I've now fixed that, so in theory tests can pass again. @eacousineau, we are also switching to the indigo-devel branch by default, so if you could rebase your commits against indigo-devel, and then submit a new PR, that would be great (and would kick off the travis checks again). I'm going to close this PR just so we can start fresh. Thanks for the contribution!