ros / urdf_parser_py

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

Default Robot class is generated without the version attribute #59

Closed FabioBergonti closed 10 months ago

FabioBergonti commented 4 years ago

The robot class is generated without the version attribute and if I run:

import urdf_parser_py
import xml
xml.etree.ElementTree.tostring(urdf_parser_py.urdf.URDF("robot_name").to_xml())

I got this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/urdf_parser_py/xml_reflection/core.py", line 588, in to_xml
  File "build/bdist.linux-x86_64/egg/urdf_parser_py/xml_reflection/core.py", line 581, in write_xml
  File "build/bdist.linux-x86_64/egg/urdf_parser_py/xml_reflection/core.py", line 554, in add_to_xml
  File "build/bdist.linux-x86_64/egg/urdf_parser_py/xml_reflection/core.py", line 336, in add_to_xml
AttributeError: 'Robot' object has no attribute 'version'

Is it possible to set the default robot class with version attribute equal to 1.0? In this way I can avoid to specify every time the robot version.

import urdf_parser_py
import xml
xml.etree.ElementTree.tostring(urdf_parser_py.urdf.URDF("robot_name", 1.0).to_xml())

I did these tests on melodic-devel branch

clalancette commented 4 years ago

This is definitely a problem; thanks for pointing it out. Please see https://github.com/ros/urdf_parser_py/pull/62 for a fix.

FabioBergonti commented 4 years ago

This is definitely a problem; thanks for pointing it out. Please see #62 for a fix.

Thank you @clalancette I checked the PR and I confirm that it solves the problem

clalancette commented 10 months ago

Since we merged in #62 ages ago, closing this out.