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

Allow only one of actor/light/model for <include> tags #433

Merged
merged 7 commits into from
Dec 22, 2020

Conversation

brawner
Copy link
Collaborator

@brawner brawner commented Dec 9, 2020

This is a first take on updating sdformat and libsdformat to allow included files to only contain one element of type actor/light/model.

The related issue (#395) explains in better detail, but essentially because the include tag can override attributes and elements like //include/name, //include/pose it should only be asked to include sdf files with one element to avoid ambiguity.

Added models for testing included in 3271f33
Modified spec and logic in 3a3a947

Fixes: #395

@brawner brawner requested a review from azeey December 9, 2020 01:15
@brawner brawner force-pushed the brawner/include-one-model-sdfs branch 2 times, most recently from b84e9e5 to 3a3a947 Compare December 9, 2020 01:24
@brawner
Copy link
Collaborator Author

brawner commented Dec 9, 2020

Force pushed to fix linter issues

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.

Looks great! I left mostly minor nitpick comments and asked for an additional test.

test/integration/model/model_actor_light/model.sdf Outdated Show resolved Hide resolved
test/integration/nested_multiple_elements_error.cc Outdated Show resolved Hide resolved
sdf::filesystem::append(g_modelsPath, "nested_multiple_models_error");

sdf::Root root;
sdf::Errors errors = root.Load(worldFile);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically, this (nested_multiple_models_error/model.sdf) is not a world file, it's a model that is including other resources. Could you add a test where you have something like this:

<?xml version="1.0" ?>
<sdf version="1.8">

  <world name="world_multiple_models_error">
    <include>
      <!-- This search path for this model must be added by the test code -->
      <uri>multiple_models</uri>
      <pose>1 1 1 1.570796326794895 0 0</pose>
    </include>
  </world>
</sdf>

I think the include mechanism is the same for both worlds and models, but it would be nice to cover both in our tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added nested_multiple_elements_error_world

}

//////////////////////////////////////////////////
TEST(IncludesTest, nested_multiple_models_error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I believe test names use CamelCase.

@brawner brawner marked this pull request as ready for review December 11, 2020 22:32
@brawner brawner force-pushed the brawner/include-one-model-sdfs branch from 9e58b53 to 11d8996 Compare December 11, 2020 22:32
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed and moved the sdf file to the sdf directory under nested_multilpe_elements_error_world.sdf

@@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<sdf version="1.8">
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 this file can be a standalone file in /test/sdf since it represents a world. A model.config file in a directory is used for models.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

src/parser.cc Outdated
{
topLevelElem = includeSDF->Root()->GetElement("light");
_errors.push_back({ErrorCode::ELEMENT_INVALID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Per our discussion the other day, I think we should make this a warning for libsdformat11. Since we don't have a way to include warnings in sdf::Errors, we would just print a warning message via sdfwarn.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After some rebasing, I now have this added.

@brawner brawner force-pushed the brawner/include-one-model-sdfs branch 3 times, most recently from 64f8ccc to 5a424bd Compare December 15, 2020 21:19
@brawner
Copy link
Collaborator Author

brawner commented Dec 15, 2020

I broke out the changes to sdf::Root in #444

@brawner brawner force-pushed the brawner/include-one-model-sdfs branch from 3a79445 to 89ed957 Compare December 15, 2020 22:00
@codecov-io
Copy link

codecov-io commented Dec 15, 2020

Codecov Report

Merging #433 (89ed957) into master (28e16c8) will increase coverage by 0.18%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #433      +/-   ##
==========================================
+ Coverage   87.52%   87.71%   +0.18%     
==========================================
  Files          62       63       +1     
  Lines        9542     9721     +179     
==========================================
+ Hits         8352     8527     +175     
- Misses       1190     1194       +4     
Impacted Files Coverage Δ
src/parser.cc 79.41% <94.44%> (+0.27%) ⬆️
src/Capsule.cc 96.61% <0.00%> (ø)
src/Actor.cc 86.09% <0.00%> (+0.29%) ⬆️
src/Geometry.cc 93.64% <0.00%> (+0.64%) ⬆️
src/Cylinder.cc 95.91% <0.00%> (+2.81%) ⬆️

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 28e16c8...89ed957. Read the comment docs.

@azeey azeey added this to the SDFormat 1.8 / libsdformat11 milestone Dec 17, 2020
@brawner brawner force-pushed the brawner/include-one-model-sdfs branch from 89ed957 to 7a019d3 Compare December 21, 2020 21:37
@brawner brawner requested a review from azeey December 21, 2020 21:39
@azeey
Copy link
Collaborator

azeey commented Dec 22, 2020

Please use squash and merge.

@brawner brawner merged commit e0e09f9 into master Dec 22, 2020
@brawner brawner deleted the brawner/include-one-model-sdfs branch December 22, 2020 23:33
@brawner
Copy link
Collaborator Author

brawner commented Dec 22, 2020

Thanks for the review @azeey, squashed and merged!

azeey added a commit that referenced this pull request Jul 14, 2021
#619)

#433 and #444 made it so that only one root level model, actor or light can be contained in an SDFormat file. So as to not break existing behavior, only a warning was issued if more than one is found. These have now been converted to errors. This PR also removes deprecated functions for accessing multiple model, actor or light elements from sdf::Root.

Signed-off-by: Addisu Z. Taddese <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Including an SDFormat model file containing multiple models is ambiguous
3 participants