scpeters-test / sdformat

Simulation Description Format (SDF) parser and description files.
http://sdformat.org
Other
1 stars 0 forks source link

Trying to parse an invalid file gives URDF parser error #151

Open scpeters-test opened 7 years ago

scpeters-test commented 7 years ago

Original report (archived issue) by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


When trying to parse an invalid SDF file, we get two error messages:

Error [parser_urdf.cc:3423] Unable to call parseURDF on robot model
Error [parser.cc:340] parse as old deprecated model file failed.

These messages are very misleading, because they suggest we're trying to parse an URDF file or a deprecated file, when in reality, it might simply be a malformed SDF file.

What happens is that the readString function first tries to load as an SDF, and if that fails, it silently tries to load the file as URDF.

scpeters-test commented 6 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


Actually, I would argue it is better to completely remove error messages from readString. If this function is being used to test if a string is valid SDF or not, the errors are spammy; returning false should be enough feedback for the user.

scpeters-test commented 5 years ago

Original comment by Jordan Lack (Bitbucket: jordanlack).


Currently running into this problem. Not sure what's wrong with my SDF yet(gz sdf -k file.sdf returns Check Complete), but the errors I see made me believe it's parsing an URDF.

scpeters-test commented 5 years ago

Original comment by Jordan Lack (Bitbucket: jordanlack).


After build from source and debugging this a bit, I think some more info needs to be put in whatever log msgs are generated from this failure. It helped me a lot by putting in the filename of the file(s) that are generating the error messages. Helped me know where to start looking

scpeters-test commented 4 years ago

Original comment by Addisu Z. Taddese (Bitbucket: azeey, GitHub: azeey).


Another instance of this is just a file with a missing <sdf> tag.

#!xml

  <model name="husky">
    <link name="base_link"/>
  </model>

Running ign sdf -k on this prints

Error:   Could not find the 'robot' element in the xml file
         at line 80 in /build/urdfdom-YMMa9X/urdfdom-1.0.0/urdf_parser/src/model.cpp
Error: SDF parsing the xml failed.

which seems to indicate that a <robot> element is missing becaues it's trying to parse it as a URDF.

scpeters-test commented 4 years ago

Original comment by Addisu Z. Taddese (Bitbucket: azeey, GitHub: azeey).