-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
b84e9e5
to
3a3a947
Compare
Force pushed to fix linter issues |
There was a problem hiding this 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.
sdf::filesystem::append(g_modelsPath, "nested_multiple_models_error"); | ||
|
||
sdf::Root root; | ||
sdf::Errors errors = root.Load(worldFile); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
9e58b53
to
11d8996
Compare
@@ -0,0 +1,6 @@ | |||
<?xml version="1.0"?> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
64f8ccc
to
5a424bd
Compare
I broke out the changes to sdf::Root in #444 |
3a79445
to
89ed957
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
89ed957
to
7a019d3
Compare
Please use squash and merge. |
Thanks for the review @azeey, squashed and merged! |
#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 <addisu@openrobotics.org>
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