gazebosim / gz-sim

Open source robotics simulator. The latest version of Gazebo.
https://gazebosim.org
Apache License 2.0
618 stars 251 forks source link

Support mesh optimization when using AttachMeshShapeFeature #2417

Closed iche033 closed 1 month ago

iche033 commented 1 month ago

πŸŽ‰ New feature

Summary

Add mesh optimization support in dartsim.

Dartsim uses AttachMeshShapeFeature for constructing meshes. It expects a common::Mesh to already be loaded and passed to it. So we need to optimize the mesh first in gz-sim (instead of doing mesh optimization inside gz-physics dartsim plugin). To support this, this PR adds logic to perform mesh optimization whenever a mesh is being loaded (e.g. via loadMesh here in physics system).

Test it

You can test with the cordless drill simplified mesh. Here's a cordless_drill.sdf test world

Launch gz-sim with the optimized mesh

gz sim -v 4 cordless_drill.sdf

and you should see a debug msg like this:

[Dbg] [Util.cc:918] Optimizing mesh (convex_decomposition): <home>/.gz/fuel/fuel.gazebosim.org/iche033/models/cordless drill simplified/3/meshes/cordless_drill.stl

Mesh collision visualization support is in https://github.com/gazebosim/gz-sim/pull/2352. I'll refactor that PR to use the new optimizeMesh function introduced here once this PR gets in.

Checklist

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.