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

Offer an API option to display new warnings on problems with URDF to SDF conversions #1171

Closed
wants to merge 3 commits into from

Conversation

j-rivero
Copy link
Contributor

@j-rivero j-rivero commented Sep 26, 2022

🎉 New feature

Should help providing an API option to have explicit warnings for #199 and #1007.

Summary

The PR tries to address the lack of the explicit information on decisions made that end up ignoring some link definitions in the user input which can lead to many problems see #199 and #1007.

For keeping backwards compatibility, no new warning is raised unless the consumer of sdformat readFile

The PR implements a new API function:

bool readFile(const std::string &_filename, SDFPtr _sdf, bool _enable_new_warnings);

that allows users of sdf to enable new extra warnings.

If the parameter is enabled, the problems with links being ignored silently (not really, but the issues were stored in the logs) are promoted to warnings using gzwarn in the CreateSDF function.

Test it

Should be fairly trivial to change Gazebo or other consumer of the readFile API to use the new parameter. Examples of code that triggers problems can be found in #199 and #1007. Simple patch for gazebo9:

diff --git a/tools/gz.cc b/tools/gz.cc
index 7a8f3d6b16..116c94541f 100644
--- a/tools/gz.cc
+++ b/tools/gz.cc
@@ -1070,6 +1070,10 @@ bool SDFCommand::RunImpl()
     }
   }
 
+  bool new_warnings = true;
+  if (common::getEnv("GAZEBO11_BACKWARDS_COMPAT_WARNINGS_ERRORS"))
+    new_warnings = false;
+
   if (!sdf::init(sdf))
   {
     std::cerr << "ERROR: SDF parsing the xml failed" << std::endl;
@@ -1124,7 +1128,7 @@ bool SDFCommand::RunImpl()
     if (!boost::filesystem::exists(path))
       std::cerr << "Error: File doesn't exist[" << path.string() << "]\n";
 
-    if (!sdf::readFile(path.string(), sdf))
+    if (!sdf::readFile(path.string(), sdf, new_warnings))
     {
       std::cerr << "Error: SDF parsing the xml failed\n";
       return false;

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • 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)

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.

@j-rivero j-rivero changed the title Offer an API option to display new arnings on problems with URDF to SDF conversion Offer an API option to display new warnings on problems with URDF to SDF conversion Sep 26, 2022
@github-actions github-actions bot added Gazebo 1️1️ Dependency of Gazebo classic version 11 🏰 citadel Ignition Citadel labels Sep 26, 2022
@j-rivero j-rivero changed the title Offer an API option to display new warnings on problems with URDF to SDF conversion Offer an API option to display new warnings on problems with URDF to SDF conversions Sep 26, 2022
@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Merging #1171 (afbd18b) into sdf9 (b7f0cba) will increase coverage by 0.00%.
The diff coverage is 76.19%.

❗ Current head afbd18b differs from pull request most recent head 1d755ae. Consider uploading reports for the commit 1d755ae to get more accurate results

@@           Coverage Diff           @@
##             sdf9    #1171   +/-   ##
=======================================
  Coverage   87.82%   87.82%           
=======================================
  Files          64       65    +1     
  Lines       10095    10112   +17     
=======================================
+ Hits         8866     8881   +15     
- Misses       1229     1231    +2     
Impacted Files Coverage Δ
src/parser_urdf.cc 84.47% <72.41%> (+0.10%) ⬆️
src/parser.cc 78.88% <77.77%> (-0.18%) ⬇️
include/sdf/parser_urdf.hh 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

/// while providing an option to increase the warnings with new
/// relevant issues.
/// \return True if successful.
bool readFile(const std::string &_filename, SDFPtr _sdf,
Copy link
Collaborator

Choose a reason for hiding this comment

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

While I think this is super helpful, I'm not sure adding a new overload is the best option. In Citadel, we only have two existing overloads, so this adds a third. In Garden, we have 6 overloads already! and how this will interact with all of them when forward ported is not clear. Starting from Fortress, these functions take a ParserConfig object, so adding it to that makes sense, but for citadel, I would prefer if we could use a different approach. Perhaps an env variable? Or backport ParserConfig?

Copy link
Member

Choose a reason for hiding this comment

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

before handling sdf9, I'd like to review a pull request that targets sdf12 and uses ParserConfig. Once we have completed that review, we can decide how we want to backport it to sdf9. Does that sound ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I'll try to create it in the next days.

Copy link
Collaborator

@aaronchongth aaronchongth Feb 14, 2023

Choose a reason for hiding this comment

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

Hello @azeey, @j-rivero, @scpeters! Circling back to this discussion, I've implemented the ideas for sdf12, #1238,

  • changing sdfdbg to sdfwarn whenever links are ignored during urdf->sdf conversion
  • adding a setting in ParserConfig to convert urdf links with no inertia or masses smaller than 1e-6 to frames

I found that using warnings directly do not trigger any regressions, users will however start seeing them in their workflows without any change in behavior (might be a good thing, since these links are most likely mistakes)

Let me know what yall think!

Edit: I've previously opened a similar PR targeting sdf9 accidentally, and it seems to pass all the CIs as well. #1230

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think converting the debug messages to warnings (without any config flags) is reasonable since my expectation is that users generally do not rely on this behavior being the normal, i.e, we want to avoid spamming users who expect links to be ignored and they're okay with it, but I don't think that's most users.

Copy link
Collaborator

@aaronchongth aaronchongth Mar 22, 2023

Choose a reason for hiding this comment

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

We just got #1238 merged into sdf12, changing debug messages to warnings, with more explicit information if links or joints were ignored, and suggestions to resolve those issues. There's no behavior change (but with 1 bug fix), and ParserConfig was not used. If it looks ok, we can probably try to cherry pick that back to sdf9 for gazebo11 and citadel?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@j-rivero @azeey #1258 is the cherry-pick towards sdf9, it looks like the new warnings are not causing any regressions. Do yall think we still need an option to display newer warnings?

@azeey
Copy link
Collaborator

azeey commented Jun 21, 2023

Closing since #1238 and #1258 have been merged.

@azeey azeey closed this Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel Gazebo 1️1️ Dependency of Gazebo classic version 11
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants