Skip to content

Fix GeometryModel::collisionPairMapping not updated on removeGeometryObject - #2937

Open
benjiiDELPECH wants to merge 3 commits into
stack-of-tasks:develfrom
benjiiDELPECH:fix/2846-collision-pair-mapping
Open

Fix GeometryModel::collisionPairMapping not updated on removeGeometryObject#2937
benjiiDELPECH wants to merge 3 commits into
stack-of-tasks:develfrom
benjiiDELPECH:fix/2846-collision-pair-mapping

Conversation

@benjiiDELPECH

Copy link
Copy Markdown

Summary

GeometryModel::removeGeometryObject correctly removed and reindexed collisionPairs when a GeometryObject was deleted, but left collisionPairMapping untouched — wrong size (still ngeoms+1) and stale pair indices that could point past the end of the shrunk collisionPairs vector.

This rebuilds collisionPairMapping in the same pass that already walks collisionPairs to erase/reindex the surviving pairs, so it stays in sync with both the new object count and the renumbered pair list — no extra pass needed.

Closes #2846.

Test plan

  • Added BOOST_CHECK_EQUAL on collisionPairMapping.rows()/cols() vs ngeoms in test_simple_boxes, after the existing removeGeometryObject call.
  • Verified the new assertions fail without the fix (3 != 2) and pass with it — confirmed locally via ctest -R pinocchio-test-cpp-geometry-algorithms.

…Object

removeGeometryObject() correctly removed and reindexed collisionPairs
when a GeometryObject was deleted, but left collisionPairMapping
untouched: wrong size (still ngeoms+1) and stale pair indices that
could point past the end of the shrunk collisionPairs vector.

Rebuild collisionPairMapping in the same pass that already walks
collisionPairs to erase/reindex the surviving pairs, so it stays in
sync with both the new object count and the renumbered pair list.

Add regression coverage in test_simple_boxes checking that
collisionPairMapping.rows()/cols() match ngeoms after removal.

Fixes stack-of-tasks#2846

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 Hi,
This is a reminder message to assign an extra build label to this Pull Request if needed.
By default, this PR will be build with minimal build options (URDF support and Python bindings)
The possible extra labels are:

  • build_collision (build Pinocchio with coal support)
  • build_casadi (build Pinocchio with CasADi support)
  • build_autodiff (build Pinocchio with CppAD support)
  • build_codegen (build Pinocchio with CppADCodeGen support)
  • build_extra (build Pinocchio with extra algorithms)
  • build_mpfr (build Pinocchio with Boost.Multiprecision support)
  • build_sdf (build Pinocchio with SDF parser)
  • build_accelerate (build Pinocchio with APPLE Accelerate framework support)
  • build_all (build Pinocchio with ALL the options stated above)

Thanks.
The Pinocchio development team.

@jcarpent jcarpent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good to me overall
Thanks @benjiiDELPECH for this nice PR.

Could you add a test to check the content of collisionPairMapping?

Best,
Justin

@benjiiDELPECH

Copy link
Copy Markdown
Author

Done, thanks for the review!

Requested by @jcarpent: the existing regression check only compared
collisionPairMapping.rows()/cols() to ngeoms, which passes even if the
matrix content is wrong. Assert both symmetric entries of the
surviving pair and the still-empty diagonal after removal.
@benjiiDELPECH
benjiiDELPECH force-pushed the fix/2846-collision-pair-mapping branch from 7e9b470 to 583f4c4 Compare August 23, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: collisionPairMapping of a GeometryModel is not updated when removeGeometryObject is called

2 participants