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

Physics System populates link bounding boxes #2821

Draft
wants to merge 11 commits into
base: gz-sim9
Choose a base branch
from

Conversation

gabrielfpacheco
Copy link
Contributor

@gabrielfpacheco gabrielfpacheco commented Mar 12, 2025

🎉 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.

image

Note: after the previous PR is merged, this PR will rebase to gz-sim9 and be marked as ready to review

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

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.

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]>
Copy link
Contributor

@iche033 iche033 left a 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,
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 72e537a

/// \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);
Copy link
Contributor

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 &?

Copy link
Contributor Author

@gabrielfpacheco gabrielfpacheco Mar 17, 2025

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

make this const &?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops.. Addressed in 84e70e7

EXPECT_GT(duckBbox.Max().Y(), 0);
}


Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 84e70e7

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<< "computed from their collision shapes." << std::endl;
<< "computed from their collision shapes based on their "
<< "geometry properties in SDF." << std::endl;

Copy link
Contributor Author

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.

@iche033 iche033 added the needs upstream release Blocked by a release of an upstream library label Mar 14, 2025
@gabrielfpacheco gabrielfpacheco force-pushed the gp-link_aabb_physics_system branch from 1fed07c to 0595ea9 Compare March 14, 2025 20:52
@gabrielfpacheco
Copy link
Contributor Author

@iche033, I believe I addressed all your comments. If you agree with the proposed changes, could you please approve #2787 before? I would like to rebase this PR after the previous one is merged so that it focuses only on the physics system changes.

@iche033
Copy link
Contributor

iche033 commented Mar 26, 2025

@iche033, I believe I addressed all your comments. If you agree with the proposed changes, could you please approve #2787 before? I would like to rebase this PR after the previous one is merged so that it focuses only on the physics system changes.

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.

@gabrielfpacheco
Copy link
Contributor Author

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic needs upstream release Blocked by a release of an upstream library
Projects
Status: Inbox
Development

Successfully merging this pull request may close these issues.

2 participants