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

Remove robot not found error when parsing fails #1290

Merged
merged 5 commits into from
Jun 21, 2023

Conversation

marcoag
Copy link
Member

@marcoag marcoag commented Jun 9, 2023

🦟 Bug fix

Fixes #151

Summary

When a file fails to be parsed as SDF the parser.cc tries to parse it as URDF generating the following error:

Error:   Could not find the 'robot' element in the xml file
             at line 109 in ./urdf_parser/src/model.cpp

This becomes confusing the file could just be a malformed SDF.

This PR adds a check for the robot tag before attempting the parse in order to avoid the misleading error. It also adds an error in case it's not found indicating that the file could not be identified as SDF nor URDF.

NOTE: I'm targeting sdf13 as I consider this a bug fix but let me know if this should go into master.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@marcoag marcoag requested review from azeey and scpeters as code owners June 9, 2023 09:18
@github-actions github-actions bot added 🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic labels Jun 9, 2023
@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Merging #1290 (7ac91df) into sdf13 (a2eb081) will decrease coverage by 0.08%.
The diff coverage is 81.25%.

❗ Current head 7ac91df differs from pull request most recent head b4c995f. Consider uploading reports for the commit b4c995f to get more accurate results

@@            Coverage Diff             @@
##            sdf13    #1290      +/-   ##
==========================================
- Coverage   87.67%   87.59%   -0.08%     
==========================================
  Files         128      128              
  Lines       16814    16826      +12     
==========================================
- Hits        14741    14739       -2     
- Misses       2073     2087      +14     
Impacted Files Coverage Δ
src/parser.cc 86.80% <81.25%> (-0.37%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much needed UX improvement, so thanks!! I've left some minor comments, but overall it looks great! Would you be able to add some tests?

src/parser.cc Outdated Show resolved Hide resolved
src/parser.cc Outdated Show resolved Hide resolved
src/parser.cc Outdated Show resolved Hide resolved
src/parser.cc Outdated Show resolved Hide resolved
@marcoag
Copy link
Member Author

marcoag commented Jun 12, 2023

When adding the tests I realized that we need to check for the <sdf> tag and ONLY if not present then we could print the "nor SDFormat nor URDF" fail. Otherwise the error will show up on malformed SDFormat files and it gets confusing.

Added relevant changes in 029b204.

Marco A. Gutierrez added 2 commits June 13, 2023 11:30
@marcoag
Copy link
Member Author

marcoag commented Jun 13, 2023

a1a3ba9 adds one more test that checks the Could not find the 'robot' element in the xml file error is not printed when parsing a malformed SDF file.

@azeey azeey merged commit b363e0e into sdf13 Jun 21, 2023
@azeey azeey deleted the remove_robot_not_found_error branch June 21, 2023 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Trying to parse an invalid file gives URDF parser error
2 participants