Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing with display_urdf a URDF file with the encoding indicated in the xml header #82

Open
traversaro opened this issue Nov 7, 2023 · 2 comments · Fixed by #83
Open

Comments

@traversaro
Copy link
Contributor

traversaro commented Nov 7, 2023

Passing a urdf file that starts with <?xml version='1.0' encoding='UTF-8'?> to display_urdf fails with a error.

Reproduction script using mamba

mamba create -n urdfdom-py urdfdom-py
mamba activate urdfdom-py
wget https://raw.githubusercontent.com/icub-tech-iit/ergocub-gazebo-simulations/1179630a88541479df51ebb108a21865ea251302/models/stickBot/model.urdf
$CONDA_PREFIX/lib/urdfdom_py/display_urdf model.urdf

fails with:

Traceback (most recent call last):
  File "/home/traversaro/miniforge3/envs/urdfdom-py/lib/urdfdom_py/display_urdf", line 33, in <module>
    sys.exit(load_entry_point('urdfdom-py==1.2.1', 'console_scripts', 'display_urdf')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/traversaro/miniforge3/envs/urdfdom-py/lib/python3.12/site-packages/urdf_parser_py/display_urdf.py", line 15, in main
    robot = URDF.from_xml_string(args.file.read())
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/traversaro/miniforge3/envs/urdfdom-py/lib/python3.12/site-packages/urdf_parser_py/xml_reflection/core.py", line 610, in from_xml_string
    node = etree.fromstring(xml_string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/lxml/etree.pyx", line 3257, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1911, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

mamba list:

(urdfdom-py) traversaro@IITICUBLAP257:~$ mamba list
# packages in environment at /home/traversaro/miniforge3/envs/urdfdom-py:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
ca-certificates           2023.7.22            hbcca054_0    conda-forge
icu                       73.2                 h59595ed_0    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
libexpat                  2.5.0                hcb278e6_1    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 13.2.0               h807b86a_2    conda-forge
libgomp                   13.2.0               h807b86a_2    conda-forge
libiconv                  1.17                 h166bdaf_0    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libsqlite                 3.44.0               h2797004_0    conda-forge
libstdcxx-ng              13.2.0               h7e041cc_2    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libxml2                   2.11.5               h232c23b_1    conda-forge
libxslt                   1.1.37               h0054252_1    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
lxml                      4.9.3           py312he528aba_1    conda-forge
ncurses                   6.4                  h59595ed_2    conda-forge
openssl                   3.1.4                hd590300_0    conda-forge
pip                       23.3.1             pyhd8ed1ab_0    conda-forge
python                    3.12.0          hab00c5b_0_cpython    conda-forge
python_abi                3.12                    4_cp312    conda-forge
pyyaml                    6.0.1           py312h98912ed_1    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                68.2.2             pyhd8ed1ab_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
urdfdom-py                1.2.1           py312h7900ff3_3    conda-forge
wheel                     0.41.3             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge

Downstream issue: icub-tech-iit/ergocub-gazebo-simulations#49 .

@traversaro
Copy link
Contributor Author

As an additional detail from icub-tech-iit/ergocub-gazebo-simulations#49, it turns out that the encoding='UTF-8' is added by the URDF export code of urdfpy/urchin in https://github.com/fishbotics/urchin/blob/5a8068a9c6f4c0d43a57d6bdb4c9be52d9fd0549/urchin/urdf.py#L3714 .

@clalancette clalancette linked a pull request Nov 8, 2023 that will close this issue
@clalancette
Copy link
Contributor

See #83, which should fix this.

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 a pull request may close this issue.

2 participants