-
Notifications
You must be signed in to change notification settings - Fork 300
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
Physics System populates link bounding boxes #2821
base: gz-sim9
Are you sure you want to change the base?
Physics System populates link bounding boxes #2821
Conversation
Signed-off-by: Gabriel Pacheco <[email protected]>
Signed-off-by: Gabriel Pacheco <[email protected]>
Signed-off-by: Gabriel Pacheco <[email protected]>
Signed-off-by: Gabriel Pacheco <[email protected]>
* Following gazebosim#2353 (comment) * This allows to use the ECM as cache if bounding box doesn't have to be recomputed and is more suitable so that other systems can determine the AABB if necessary (e.g. physics system if checks are enabled) Signed-off-by: Gabriel Pacheco <[email protected]>
This could be helpful if users want to explicetly compute the AABB from the link SDF collision shapes. For instance, the Physics system can fallback and use this method in case the selected engine does not support AABB calculation. Signed-off-by: Gabriel Pacheco <[email protected]>
Signed-off-by: Gabriel Pacheco <[email protected]>
Signed-off-by: Gabriel Pacheco <[email protected]>
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.
did a first pass review, overall approach looks good
src/Link.cc
Outdated
|
||
////////////////////////////////////////////////// | ||
void Link::EnableBoundingBoxChecks( | ||
gz::sim::EntityComponentManager & _ecm, |
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.
we can omit gz::sim::
or sim::
since there are using namespace
directives above in the 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.
Addressed in 72e537a
include/gz/sim/Util.hh
Outdated
/// \param _sdfMesh Mesh SDF DOM. | ||
/// \return The AABB of the mesh in its local frame. | ||
GZ_SIM_VISIBLE math::AxisAlignedBox meshAxisAlignedBox( | ||
const sdf::Mesh _sdfMesh); |
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 made const &
?
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.
Oops, that was a typo that has been kept unintentionally, thanks for catching.
Addressed in 84e70e7
src/Util.cc
Outdated
@@ -989,6 +989,38 @@ const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf, | |||
return optimizedMesh; | |||
} | |||
|
|||
math::AxisAlignedBox meshAxisAlignedBox(sdf::Mesh _sdfMesh) |
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.
make this const &
?
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.
Oops.. Addressed in 84e70e7
test/integration/physics_system.cc
Outdated
EXPECT_GT(duckBbox.Max().Y(), 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.
remove empty line
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.
Amended 0595ea9 to address this
src/Util.cc
Outdated
@@ -989,6 +989,38 @@ const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf, | |||
return optimizedMesh; | |||
} | |||
|
|||
math::AxisAlignedBox meshAxisAlignedBox(sdf::Mesh _sdfMesh) |
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.
consider also returning std::optional
to indicate that the axis aligned box can not be computed
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.
Addressed in 84e70e7
src/systems/physics/Physics.cc
Outdated
gzdbg << "Attempting to get a bounding box, but the physics " | ||
<< "engine doesn't support feature " | ||
<< "[GetLinkBoundingBox]. Link bounding boxes will be " | ||
<< "computed from their collision shapes." << 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.
<< "computed from their collision shapes." << std::endl; | |
<< "computed from their collision shapes based on their " | |
<< "geometry properties in SDF." << 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.
Amended 0595ea9 to address this.
Signed-off-by: Gabriel Pacheco <[email protected]>
* Also fix `_sdfMesh` to be `const &` Signed-off-by: Gabriel Pacheco <[email protected]>
Signed-off-by: Gabriel Pacheco <[email protected]>
1fed07c
to
0595ea9
Compare
Currently there's a build error as it needs the new API from sdformat. So I'm waiting for gazebosim/sdformat#1547 to be merged first. We also need a new sdformat release afterwards in order to run CI in #2787 and make sure everything is green. We can only approve and merge a PR when the required CI checks are green. |
Yes, sure! I initially thought there might be a way to trigger the CI with dependent packages at specific branches, but then realized that the merge/release process is required, as you said. Besides the dependency that prevents the proper CI checks, though, there are still some unresolved threads here from your first pass review, are those solved? Regarding the sdformat PR, the CI is already green, and I believe all comments have been addressed. I've pinged the reviewers in gazebosim/sdformat#1547 (comment) recently, so I think we should be close to a merge. |
🎉 New feature
Follow-up of #2787
Summary
Computes the link bounding boxes for all link entities that have
components::AxisAlignedBox
present. The computation follows the same logic as the models bbox, but falls back to the SDF calculation introduced in #2787 in case the feature is not present for the selected physics plugin.Test it
Run the following integration test:
./build/gz-sim9/bin/INTEGRATION_physics_system --gtest_filter=*LinkBoundingBox*
It will load
bounding_boxes.sdf
world (see below) and perform link AABB checks while the models free-fall until reaching the ground.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.