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 empty //inertial/pose/@relative_to during 1_7->1.8 conversion #720

Merged
merged 7 commits into from
Sep 29, 2021

Conversation

scpeters
Copy link
Member

@scpeters scpeters commented Sep 29, 2021

🦟 Bug fix

Fixes warnings when loading models from 1.7 or earlier with //inertial/pose/@relative_to, part of gazebosim/gz-sim#1056

Summary

The //inertial/pose/@relative_to attribute was removed from the 1.8 spec in 93f8c56, which causes warnings when loading a file from 1.7 or earlier that contains this attribute. This PR removes this attribute during conversion from 1.7 -> 1.8 if the attribute is empty, which should silence many of the warnings, while retaining those warnings that may require action from the user.

I added an empty attribute to a test/sdf file in 34d9587, which causes a warning that causes UNIT_ign_TEST to fail. The failure is fixed by new functionality in the Converter class, which allows removal of empty attributes or elements.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
The <remove_empty/> tag in a .convert file will remove any
empty attributes or elemements with no child elements
or text values that match the specified name.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
This attribute was removed from the 1.8 spec, but causes
warnings during forward conversion. This removes empty
attributes to silence trivial warnings.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@github-actions github-actions bot added the 🏢 edifice Ignition Edifice label Sep 29, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2021

Codecov Report

Merging #720 (59ae47c) into sdf11 (91d0d01) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 59ae47c differs from pull request most recent head 9588e0f. Consider uploading reports for the commit 9588e0f to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##            sdf11     #720   +/-   ##
=======================================
  Coverage   88.08%   88.09%           
=======================================
  Files          73       73           
  Lines       11023    11030    +7     
=======================================
+ Hits         9710     9717    +7     
  Misses       1313     1313           
Impacted Files Coverage Δ
src/Converter.cc 93.19% <100.00%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91d0d01...9588e0f. Read the comment docs.

azeey
azeey previously approved these changes Sep 29, 2021
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.

Just a few minor comments.

src/Converter.cc Outdated Show resolved Hide resolved
src/Converter.hh Outdated
@@ -100,9 +100,11 @@ namespace sdf

/// \brief Remove an element.
/// \param[in] _elem The element that has the _removeElem child.
/// \param[in] _removeElem The element to remove.
/// \param[in] _removeElem The metadata about what to remove.
/// \param[in] _removeEmpty If true, only remove empty nodes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you document how this works for attributes and elements? From what I can understand, for attributes, it removes just the attribute if it's empty. For elements, it removes the element if it has an empty value and has no children, but it can have attributes.

Copy link
Member Author

Choose a reason for hiding this comment

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

would it be better to change the behavior for removing elements if they also have no attributes? We aren't yet using that functionality, so I couldn't decide. For now, I'll just document it as you suggest

Copy link
Member Author

Choose a reason for hiding this comment

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

updated documentation and renamed the parameter to _removeOnlyEmpty in e6eb293

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to chain these? By that I mean, would it be possible to remove the attributes first and then remove the element? If so, then I'd say let's make it so that it removes elements only if they have no attributes. This would make it possible to remove just the deprecated attributes first and remove the element if it doesn't contain anything else. For example:

<test_elem attr1="" attr2="some_val"/>
<test_elem attr1="" />

If we deprecate the use of //test_elem and know that //test_elem[@attr1=""] is the default, we can do

<remove_empty attribute='attr1'/>
<remove_empty element='test_elem'/>

and it will only delete the second //test_elem and we would be able to issue a warning about the first //test_elem

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, I'll rework the function logic accordingly

Copy link
Member Author

Choose a reason for hiding this comment

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

done in 9588e0f

src/Converter_TEST.cc Show resolved Hide resolved
src/Converter_TEST.cc Show resolved Hide resolved
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters dismissed azeey’s stale review September 29, 2021 18:56

need to rework function logic

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters requested a review from azeey September 29, 2021 21:21
@scpeters scpeters merged commit bf3cbef into sdf11 Sep 29, 2021
@scpeters scpeters deleted the scpeters/inertial_pose_relative_to_warning branch September 29, 2021 22:29
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-03-25-fortress-edifice-citadel/1343/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏢 edifice Ignition Edifice
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants