-
Notifications
You must be signed in to change notification settings - Fork 293
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 SDF model to be constructed in a single shot #1560
Conversation
src/systems/physics/Physics.cc
Outdated
// ability won't actually get leveraged by gz-sim because it | ||
// specifically uses AttachMeshShapeFeature and AttachHeightMapFeature | ||
// for those shapes. The physics plugin implementer needs to know to | ||
// implement those specific features instead. |
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.
the reason for this is that the mesh and heightmap SDFormat elements contain URI's that in many cases point to fuel resources, but libsdformat doesn't depend on fuel. The Attach*ShapeFeature
s accept gz::common
types that contain the mesh and heightmap info, and gz-sim
is responsible for fetching the data and populating those types.
Properly implementing the ConstructSdfMesh
and ConstructSdfHeightmap
would involve resolving those URIs, which seems beyond the responsibility of a physics plugin, so perhaps we should just deprecate those features from gz-physics
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 think the motivation totally makes sense.
I think what I'd propose is to move the implementations of the uri resolving functionality into a reusable utility function in the SDFormat
library. Maybe even have them as methods in MeshShape
and HeightmapShape
classes for maximum visibility. The utility functions could just output the same data structures that are being passed into AttachMeshShape
and AttachHeightmapShape
so the physics plugin developer can easily recycle the implementations of those functions for ConstructSdfCollision
.
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've been confused by this in the past (gazebosim/gz-physics#9):
"For example, what does ConstructCollision do? Does it create and attach a collision to a link? How is that different from AttachMeshShape? If they do similar things, why are their names so different?"
mesh and heightmap SDFormat elements contain URI's that in many cases point to fuel resources, but libsdformat doesn't depend on fuel
SDF has the ability of resolving Fuel URIs for <include>
s, we pass it a Fuel-Tools callback so it knows how to resolve those:
Lines 66 to 68 in 417609c
// Configure SDF to fetch assets from ignition fuel. | |
sdf::setFindCallback(std::bind(&ServerPrivate::FetchResource, | |
this->dataPtr.get(), std::placeholders::_1)); |
So it could also resolve the URIs for other assets.
I think the main problem is that SDFormat doesn't depend on Gazebo Common, which is a huge dependency and brings external graphics libraries, so it can't return gz::common
types.
I guess one option is passing those resolved URIs to gz-rendering
and gz-physics
, and each implementation decides how to load the assets. They can use gz::common
if they want. It may cause a lot of duplication across various plugins though, or inconsistencies on how the meshes are loaded if they use different loaders.
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 the main problem is that SDFormat doesn't depend on Gazebo Common, which is a huge dependency and brings external graphics libraries, so it can't return
gz::common
types.
yeah, I think this is the real crux of the problem. Perhaps we could add basic Mesh and HeightmapData classes to gz-math, while keeping the parsers in gz-common? Then libsdformat could return the gz-math types, and the find-file callback function could use fuel and gz-common's parsers to resolve the URI into the math object
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 @mjcarroll has a solution with gazebosim/sdformat#1147 so that the SDF DOM object passed into gz-physics has all the resource paths resolved.
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 @mjcarroll has a solution with gazebosim/sdformat#1147 so that the SDF DOM object passed into gz-physics has all the resource paths resolved.
that means we don't need to use fuel, but it's still just a file path provided by libsdformat
, but something will still need to parse that file, and in general we can't assume that the physics implementation will be able to parse it, so I think that wouldn't resolve the matter of properly implementing ConstructSdfMesh
or ConstructSdfHeightmap
in the general case so that AttachMeshShape
and AttacheHeightmapShape
aren't needed
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.
There is a segfault when I try to load vanilla bullet
.
In particular code is failing here:
Another issue
This is not working with TPE, because this engine doesn't support the physics feature GetJointFromModel
[Wrn] [SystemLoader.cc:56] Trying to load deprecated plugin [ignition-gazebo-physics-system]. Using [gz-sim-physics-system] instead.
[Wrn] [Physics.cc:884] Plugin [gz::physics::tpeplugin::Plugin] misses required features:
- N2gz7physics17GetJointFromModelE
The seg fault issue with the classic bullet plugin is fixed by gazebosim/gz-physics#393 and the TPE failing to load is fixed by 4b01010. I think the joint offset issue for |
@osrf-jenkins retest this please |
@mxgrey we have a whole slew of test failures here that aren't in |
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Removed the This PR can either be merged into |
Signed-off-by: Michael X. Grey <grey@openrobotics.org>
Signed-off-by: Michael X. Grey <grey@openrobotics.org>
Signed-off-by: Michael X. Grey <grey@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com> Signed-off-by: Michael Carroll <michael@openrobotics.org>
be1128f
to
55ebcd3
Compare
Signed-off-by: Michael Carroll <michael@openrobotics.org>
142ff5f
to
79fe3ba
Compare
@osrf-jenkins retest this please |
@osrf-jenkins retest this please |
Codecov Report
@@ Coverage Diff @@
## gz-sim7 #1560 +/- ##
===========================================
+ Coverage 64.16% 64.25% +0.09%
===========================================
Files 335 336 +1
Lines 26508 26889 +381
===========================================
+ Hits 17008 17277 +269
- Misses 9500 9612 +112
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
🎉 New feature
Summary
This PR tweaks the behavior of the physics system so that when constructing a model it will first check if a
ModelSdf
component is available for the entity. If so, it uses that component to fill in all the model information, overriding the fields that are given by the other entity components (e.g. name and pose).When creating a link, the physics engine will first check if a link of the same name for that model was already constructed. If so, the construction step is skipped, the link is queried from the model, and it gets added to the entity map. Same for joints and collision objects.
The net result of these behavioral changes is that physics engines which can only construct models all at once are able to be used for the typical use cases, while physics engines that can construct models incrementally can still do so when the user wants them to.
Test it
Try running with the dartsim plugin. Even though the behavior changed, there is no noticeable difference in the outcome.
The ability to test these changes with a
bullet-featherstone
plugin is forthcoming. The implementation is finished, but I am debugging some segfaults from inside of bullet at the moment.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.