Skip to content

Geometry enhancements#2503

Open
dellaert wants to merge 5 commits intodevelopfrom
feature/geometry_enhancements
Open

Geometry enhancements#2503
dellaert wants to merge 5 commits intodevelopfrom
feature/geometry_enhancements

Conversation

@dellaert
Copy link
Copy Markdown
Member

@dellaert dellaert commented Apr 14, 2026

High-level changes

  • Modernized gtsam/base/numericalDerivative.h:

    • moved to generic callable-based derivative helpers
    • improved overload behavior for lambdas/free functions
    • added/organized Doxygen groups and explicit template-type requirements
    • removed stale/inaccurate template requirement wording
  • Geometry/runtime updates:

    • Gal3: added analytical LogmapDerivative(const TangentVector&) and routed LogmapDerivative(const Gal3&) through it
    • Quaternion traits: added GetDimension
    • SO3: small cleanup (inline ExpmapFunctor::expmap, corrected B comment)
    • Pose3: expanded implementation comments around Expmap
    • wrappers (geometry.i): exposed Similarity2::matrix() / Similarity3::matrix() and aligned DexpFunctor field constness
  • Test/style updates in geometry/navigation:

    • mechanically replaced std::function<...> var = ... with auto var = ... in test code
    • added [[maybe_unused]] only where required to satisfy -Werror

Validation

  • make -j6 check.geometry
  • make -j6 check.navigation

@dellaert dellaert marked this pull request as ready for review April 14, 2026 15:15
@dellaert dellaert requested a review from Copilot April 14, 2026 15:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR modernizes the numerical-derivative utilities to accept generic callables (improving overload/lambda handling) and updates several geometry components/wrappers alongside a broad mechanical cleanup of test lambdas/binds.

Changes:

  • Refactored gtsam/base/numericalDerivative.h to use callable-based helpers with clearer template requirements and improved overload resolution.
  • Added/updated geometry functionality and documentation (e.g., Gal3::LogmapDerivative analytical implementation, SO3 functor cleanup, quaternion trait dimension helper).
  • Updated many geometry/navigation tests to use auto instead of std::function, and adjusted wrappers to expose additional APIs / constness.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
gtsam/base/numericalDerivative.h Reworked numerical derivative API to accept generic callables and added stronger type/trait requirements.
gtsam/geometry/Gal3.h Added tangent-space LogmapDerivative declaration.
gtsam/geometry/Gal3.cpp Implemented analytical LogmapDerivative(xi) and routed LogmapDerivative(g) through it.
gtsam/geometry/Quaternion.h Added traits<QUATERNION_TYPE>::GetDimension.
gtsam/geometry/SO3.h Corrected B comment and inlined ExpmapFunctor::expmap().
gtsam/geometry/SO3.cpp Removed out-of-line ExpmapFunctor::expmap() definition after inlining.
gtsam/geometry/Pose3.cpp Expanded Expmap implementation comments/documentation pointers.
gtsam/geometry/geometry.i Made DexpFunctor::omega const and exposed Similarity2::matrix() / Similarity3::matrix() to wrappers.
gtsam/navigation/tests/testTangentPreintegration.cpp Replaced std::function wrappers with auto lambdas/binds.
gtsam/navigation/tests/testNavStateImuEKF.cpp Replaced std::function wrappers with auto lambdas.
gtsam/navigation/tests/testNavState.cpp Replaced std::function wrappers with auto, added [[maybe_unused]] in select cases.
gtsam/navigation/tests/testManifoldPreintegration.cpp Replaced std::function wrappers with auto lambdas/binds.
gtsam/navigation/tests/testImuFactor.cpp Replaced std::function wrapper with auto bind.
gtsam/navigation/tests/testImuBias.cpp Replaced std::function wrappers with auto binds.
gtsam/navigation/tests/testGal3ImuEKF.cpp Replaced std::function wrappers with auto lambdas.
gtsam/navigation/tests/testAHRSFactor.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testUnit3.cpp Replaced std::function wrappers with auto binds/lambdas.
gtsam/geometry/tests/testSimilarity3.cpp Replaced std::function with auto and simplified derivative wrappers.
gtsam/geometry/tests/testSimilarity2.cpp Replaced std::function with auto and simplified derivative wrappers.
gtsam/geometry/tests/testSOn.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testSO4.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testSO3.cpp Replaced std::function wrappers with auto lambdas and minor formatting cleanup.
gtsam/geometry/tests/testRot2.cpp Replaced std::function wrapper with auto lambda.
gtsam/geometry/tests/testPose3.cpp Replaced std::function wrappers with auto lambdas and minor formatting change.
gtsam/geometry/tests/testPose2.cpp Replaced std::function wrappers with auto lambdas and simplified proxy lambdas.
gtsam/geometry/tests/testPoint3.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testPinholePose.cpp Replaced std::function wrapper with auto bind in commented-out test block.
gtsam/geometry/tests/testPinholeCamera.cpp Replaced std::function wrappers with auto binds.
gtsam/geometry/tests/testOrientedPlane3.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testGal3.cpp Replaced std::function wrappers with auto lambdas and simplified wrappers.
gtsam/geometry/tests/testExtendedPose3.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testEssentialMatrix.cpp Replaced std::function wrappers with auto lambdas.
gtsam/geometry/tests/testCalibratedCamera.cpp Replaced std::function wrapper with auto bind.

@github-actions
Copy link
Copy Markdown

timeSFMBAL benchmark

  • Head: 98717ce7884d1d52b3f4cf26cc0f15e7173dbdcf
  • Base: 80b623cb314de815d827450a7227d7a908aa1662
Runner Metric Base (s) Head (s) Delta (s) Change
linux-arm64-tbbOFF timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalCholesky 9.857587 9.370473 -0.487114 -4.94%
linux-arm64-tbbOFF timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalSolver 13.026214 12.608730 -0.417484 -3.20%
linux-arm64-tbbON timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalCholesky 5.575654 5.288979 -0.286675 -5.14%
linux-arm64-tbbON timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalSolver 9.621873 9.428447 -0.193427 -2.01%
linux-x64-tbbOFF timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalCholesky 13.428854 10.788892 -2.639962 -19.66%
linux-x64-tbbOFF timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalSolver 20.850131 15.655774 -5.194357 -24.91%
linux-x64-tbbON timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalCholesky 8.551609 6.536196 -2.015413 -23.57%
linux-x64-tbbON timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalSolver 17.434086 12.825639 -4.608447 -26.43%
macos-arm64-tbbOFF timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalCholesky 31.619532 51.824226 +20.204694 +63.90%
macos-arm64-tbbOFF timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalSolver 19.525952 31.393976 +11.868025 +60.78%
macos-arm64-tbbON timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalCholesky 48.723703 79.520933 +30.797230 +63.21%
macos-arm64-tbbON timeSFMBAL/dubrovnik-135-90642-pre.txt/MultifrontalSolver 25.664973 40.850945 +15.185972 +59.17%

Worker runs

Role Runner SHA Conclusion
head linux-x64 98717ce7884d1d52b3f4cf26cc0f15e7173dbdcf success
base linux-x64 80b623cb314de815d827450a7227d7a908aa1662 success
head linux-arm64 98717ce7884d1d52b3f4cf26cc0f15e7173dbdcf success
base linux-arm64 80b623cb314de815d827450a7227d7a908aa1662 success
head macos-arm64 98717ce7884d1d52b3f4cf26cc0f15e7173dbdcf success
base macos-arm64 80b623cb314de815d827450a7227d7a908aa1662 success


/// Rodrigues formula
Matrix3 expmap() const;
Matrix3 expmap() const { return I_3x3 + A * W + B * WW; }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

non inline implementation should not be in the header

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will it not be automatically inlined? That’s what I’ve been told. All CI passes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It will be a ODR violation

@dellaert dellaert requested a review from ProfFan April 15, 2026 01:40
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.

3 participants