-
Notifications
You must be signed in to change notification settings - Fork 269
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 loading a model SDF file in the Server class #1775
Conversation
Codecov Report
@@ Coverage Diff @@
## gz-sim7 #1775 +/- ##
===========================================
+ Coverage 64.16% 64.21% +0.05%
===========================================
Files 335 336 +1
Lines 26508 26864 +356
===========================================
+ Hits 17008 17251 +243
- Misses 9500 9613 +113
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
94cc75a
to
21d4161
Compare
Since Do you think that you could break this out into UNIT_Server_Rendering_TEST to make it a separate executable and also contain the rendering dep? |
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 and works in debug builds. The only blocking comment is about the use of asserts
. I also agree with @mjcarroll that we should put the test in a separate file.
src/Server.cc
Outdated
// world and add the model to it. | ||
const sdf::Model model = *(sdfRoot.Model()); | ||
errors = this->dataPtr->sdfRoot.LoadSdfString(DefaultWorld::World()); | ||
assert(this->dataPtr->sdfRoot.WorldCount() == 1); |
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 we use assert
in our code base very much, so this seems out of place, but I'm not opposed to using it.
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.
Yeah, I was worndering about that. The other options that come to mind would be to catch this via if statement, or leave this uncaught. I have no strong preference, I'll go with whatever you-all think is best.
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 it would be sufficient to add an if
statement and returning early if world
is nullptr
.
src/Server_TEST.cc
Outdated
auto loadedEngNames = gz::rendering::loadedEngines(); | ||
if (loadedEngNames.empty()) | ||
{ | ||
gzdbg << "No rendering engine is loaded yet" << std::endl; |
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.
This works, but I think the recommended way to return a failure with a reason is for the function to return an AssertionResult
(http://google.github.io/googletest/advanced.html#using-a-function-that-returns-an-assertionresult)
src/Server_TEST.cc
Outdated
if (!engine) | ||
{ | ||
gzerr << "Internal error: failed to load engine [" << engineName | ||
<< "]. Grid plugin won't work." << std::endl; |
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.
Is the grid plugin relevant here?
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.
No. FWIW, I took this from RenderingGuiPlugin::FindScene
. I'll update this.
OK, sure. Note that (for now) there's only going to be one test in the new executable: |
Yes, I think that will be fine. |
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
* Remove unnecessary sdf::Root constructor call. * Avoid an unnecessary copy of an sdf::Model instance. * Remove asserts. Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Previous comments should be addressed now:
|
Looking better, I think that Windows and macOS are having failures in the test that you added. The Ubuntu failure is known and can be ignored. |
Looks like the windows tests are failing on the stable CI as well https://build.osrfoundation.org/job/ign_gazebo-gz-sim7-win/17/ |
Oops, you are right, I misread that. Also, I'm interested in why these compiler warnings have all appeared in the Windows build here, I thought that we just addressed that via the #1771 |
This branch needs to merge from |
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
src/Server_TEST.cc
Outdated
@@ -519,6 +519,18 @@ TEST_P(ServerFixture, SdfStringServerConfig) | |||
EXPECT_EQ(2u, *server.SystemCount()); | |||
} | |||
|
|||
///////////////////////////////////////////////// | |||
TEST_P(ServerFixture, LoadSdfModel) |
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.
Can this be removed or be added to the other file? We need to reduce the number of tests in Server_TEST.cc
.
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.
Fine with me. This test will then be in Server_Rendering_TEST.cc
and not require rendering, but I understand we are OK with that. (Or I guess I could just remove it.)
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
I pushed another batch of changes:
CI looks a lot more green now, but that might be in part because edit: looking at the logs, it seems that As a side note: after I moved |
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
It's likely that the detection is broken because of missing application. I believe that you need to have Currently, these things will come back as "STATUS" messages, but maybe we can elevate them to warning to make it more obvious. |
src/Server.cc
Outdated
// world and add the model to it. | ||
const sdf::Model model = *(sdfRoot.Model()); | ||
errors = this->dataPtr->sdfRoot.LoadSdfString(DefaultWorld::World()); | ||
assert(this->dataPtr->sdfRoot.WorldCount() == 1); |
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 it would be sufficient to add an if
statement and returning early if world
is nullptr
.
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
🎉 New feature
Closes #1711
Summary
The constructor of the Server class has been updated to handle SDF files that contain a model without a world. The model is loaded into the default world.
Test it
One should be able to create Server instances using model SDF files, for instance:
test/worlds/models/sphere/model.sdf
.Checklist
codecheck
passed (See contributing)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.