gazebosim / gazebosim/sdformat

URDF to SDF conversion silently ignores <gazebo> tag with non-existing reference

Open
#1,372 3 comments 1 reaction 0 assignees View on GitHub
enhancement help wanted
Dominant language
C++
Stars
216
Forks
125
Avg merge
1d 14h
Merged PRs (30d)
14

Description

## Desired behavior

If I try to convert the following URDF model, saved in a file called `oneLink.urdf`:
~~~xml









1
100
0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315


~~~

to SDF with sdformat 14.0.0 (i.e. via `gz sdf -p ./oneLink.urdf > oneLink.sdf`), I obtaine the following result, without any additional output:

~~~xml
(gzsdf) traversaro@IITBMP014LW012:~/test34$ gz sdf -p ./oneLink.urdf




0 0 0 0 0 0
1

0.01
0
0
0.01
0
0.01



~~~

Note how the `imu` sensors is completely ignored, without any warning message or error. Why is this happening? Because, despite the apperance, the `link1` string in `` is not the same string as `lіnk1` in ``. The second letter of the string in the first case is `i` , i.e. [unicode character U+0069 (Latin Small Letter I)](https://www.compart.com/en/unicode/U+0069), while in the second case is [unicode character U+0456 (Cyrillic Small Letter Byelorussian-Ukrainian I)](https://www.compart.com/en/unicode/U+0456).

Clearly I crafted this example to make it explicitly tricky to spot (see https://gist.github.com/StevenACoffman/a5f6f682d94e38ed804182dc2693ed4b if you want to have fun), but in general it would be convenient if the URDF --> SDF parser detected `` that referenced to non-existing elements, and printed at least a warning, to help in case of typos.

## Alternatives considered

Continue not to print any warning if a `` tag refers to a non existing element.

## Implementation suggestion

I checked the code, and indeed first the parser parsers all the `` tags in https://github.com/gazebosim/sdformat/blob/f3607761d3846dba0b660880484ff1e5eb1e9425/src/parser_urdf.cc#L3372, and then only later when it parses links, collisions, visuals and joints, it uses the related sdf extensions if any is found (see for example https://github.com/gazebosim/sdformat/blob/f3607761d3846dba0b660880484ff1e5eb1e9425/src/parser_urdf.cc#L2870C3-L2870C12 or https://github.com/gazebosim/sdformat/blob/f3607761d3846dba0b660880484ff1e5eb1e9425/src/parser_urdf.cc#L3182).

Probably we should add a boolean flag or similar to each SDF extension, that is set to true once a SDF extension is consumed. If an SDF extension is not used at the end of the parsing, a warning should be printed.

## Additional context

We experienced this with @Gio-DS .

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.