Repository navigation
feat(autoware_ndt_scan_matcher): load the NDT implementation as a pluginlib backend - #1527
Merged
Merged
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
3 tasks done
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
from
November 9, 2026 19:53
36742b5 to
28dce94
Compare
xmfcx
changed the base branch from
refactor/ndt-omp-snake-case-api
to
refactor/ndt-omp-package
November 9, 2026 19:53
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/ndt-backend-interface #1527 +/- ##
==============================================================
- Coverage 72.59% 72.51% -0.08%
==============================================================
Files 500 505 +5
Lines 27778 28045 +267
Branches 13128 13140 +12
==============================================================
+ Hits 20165 20337 +172
- Misses 7531 7605 +74
- Partials 82 103 +21
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
from
November 9, 2026 20:50
28dce94 to
a37836b
Compare
xmfcx
changed the base branch from
refactor/ndt-omp-package
to
feat/ndt-backend-interface
November 9, 2026 20:50
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
2 times, most recently
from
November 9, 2026 22:02
bb7568c to
fdbd149
Compare
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
6 times, most recently
from
November 10, 2026 03:18
c5895d6 to
7613292
Compare
xmfcx
marked this pull request as ready for review
November 10, 2026 04:29
xmfcx
requested review from
Motsu-san,
TaikiYamada4 and
YamatoAndo
as code owners
November 10, 2026 04:29
This was referenced Nov 23, 2026
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
from
November 23, 2026 14:27
7613292 to
f6dc2f2
Compare
Base automatically changed from
feat/ndt-backend-interface
to
refactor/ndt-omp-snake-case-api
November 23, 2026 14:27
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
from
November 23, 2026 14:43
f6dc2f2 to
a982e19
Compare
xmfcx
changed the base branch from
refactor/ndt-omp-snake-case-api
to
feat/ndt-backend-interface
November 23, 2026 14:43
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
2 times, most recently
from
November 23, 2026 17:42
018049b to
169fa3e
Compare
…ginlib backend The node now does its NDT computations through the interface NdtBackend from autoware_ndt_scan_matcher_common. It loads the backend with pluginlib, by the name in the parameter ndt.backend. Other packages can add backends without a change to the node. - The backend "ndt_omp" is a thin wrapper of ndt_omp in a plain library of this package, so that no library links it. It converts between the types of the interface and the types of ndt_omp. - The node loads backends through one pluginlib class loader that is never destroyed. So a backend library stays loaded until the process ends, and the clones of a backend stay valid. The node loads the backend before it creates its interfaces. - The copy constructor and the copy assignment of the NDT object become clone(), and the new empty NDT of a full map rebuild becomes clone_empty(). After a rebuild, need_rebuild becomes false only after the copy to the secondary NDT exists. - The covariance estimation uses the interface and is now part of the node library. ndt.backend has no default value in the code, as the parameter guideline requires. Without the parameter, the node stops with a message that names the parameter and the line to add. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
…ackend Add a characterization test for a parameter file without ndt.backend. An override without a value in the test harness now removes that parameter of the yaml. Remove const from the LogSpy of the loader test, because class_loader changes it through log(). Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
xmfcx
force-pushed
the
feat/ndt-backend-plugin
branch
from
November 23, 2026 17:45
169fa3e to
4bdcb68
Compare
mitsudome-r
approved these changes
Nov 24, 2026
YamatoAndo
approved these changes
Nov 24, 2026
5 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The node now does its NDT computations through the interface
autoware::ndt_scan_matcher::NdtBackendfromautoware_ndt_scan_matcher_common. It loads the backend with pluginlib, by the name in the parameterndt.backend. The only backend isndt_omp, a thin wrapper of ndt_omp. Other packages can add backends without a change to the node.What changes:
src/omp_ndt_backend.hpp/.cpp: the backendndt_omp, in the plain libraryautoware_ndt_scan_matcher_omp_backend, registered inplugins.xml. It converts between the types of the interface and the types of ndt_omp. The vectors of the result move, so the conversion copies no large data.ndt_backend_loader.hpp/.cpp:load_ndt_backend(). It uses onepluginlib::ClassLoaderthat is never destroyed, so a backend library stays loaded until the process ends. An exception from the constructor of a backend gets the name of the backend. The loader is in its own source file, because the pluginlib headers makendt_scan_matcher_core.cpp(the longest compile of the package) 3.6 s slower.initialize()of the backend in a message with the name of the backend. The copy constructor and the copy assignment becomeclone(), andnew NdtTypewithset_params()becomesclone_empty(). The calls happen at the same places and under the same locks as before.estimate_covariance.cpp) moves from the ndt_omp library into the node library, because it now uses the interface.Before and after:
Related links
Parent Issue:
This PR builds on the rename of the ndt_omp methods (merged) and on the parameter and the interface PRs below it in the stack:
Discussion and benchmark:
How was this PR tested?
New and changed tests:
test_omp_ndt_backend(4 tests): thendt_ompbackend gives the same results as ndt_omp called directly, for every field of the result and for the three score functions. It compares with and without a regularization pose. Its copies are independent, andclone_empty()keeps all six parameters.test_ndt_backend_loader(5 tests): pluginlib loadsndt_omp, the backend library is still loaded and a clone works after the instance from pluginlib is gone, and an unknown name throws with the list of the declared backends. The test also expects that class_loader gives no warning about a library that it cannot unload. So it fails if the loader is destroyed while the instance from pluginlib exists. It cannot find a loader that is destroyed while only a clone exists, because the library stays loaded in the test process in that case too.test_map_update_module: the backend comes from pluginlib. A new test runs a rebuild and then an update of the secondary NDT, which usesclone_empty()andclone().initialize()of the second one throws, and the third one was built with another allocator of Eigen.test_ndt_backend_loaderexpects the name of the backend in the message for the first one, and the message that names the possible causes for the third one.ndt.backend, a backend whoseinitialize()throws, and a parameter file withoutndt.backendmake the node constructor throw. The first test expects the name of the backend in the message, the second one the name and the cause, and the third one the line to add to the parameter file. In the test harness, an override without a value removes that parameter of the parameter file.The run results are in the Verification block at the end.
Notes for reviewers
ndt.backendhas no default value in the code, as the parameter guideline requires. Merge order: the parameter PR (feat(autoware_ndt_scan_matcher): add the ndt.backend parameter #1533 above) merges first, then the sync-params PR in autoware_launch merges, and only then this PR. Merging this PR also merges every PR below it, so do not merge the whole stack in one step before the sync-params PR has merged.autoware_ndt_scan_matcher_omp_backendis a plainadd_library(), notament_auto_add_library(). ament_auto exports every library thatament_auto_add_library()adds and links it into the later libraries and tests of the package. The node library usesNO_TARGET_LINK_LIBRARIES, so it does not link ndt_omp either.readelf -dshows noNEEDEDentry for ndt_omp or the backend library in the node library.src/ndt_backend_loader.cpp).clone()andclone_empty()make instances withstd::make_sharedin the backend library, so the library must stay loaded while any instance exists.need_rebuildnow becomesfalseonly after the copy exists.NdtResult::hessian: if a step has the length 0 or is not a number, ndt_omp returns before it stores the hessian, so the result holds the hessian of the alignment before. This PR does not change it, and a comment inomp_ndt_backend.cppstates it.ndt_ompbackend stay in this package, and only the interface is in a new package. Earlier decisions rejected anautoware_-prefixed ndt_omp package, and third parties include the ndt_omp headers:autoware_ndt_scan_matcher)): move header files fromincludetosrc" #880Interface changes
C++ interface
ndt_omp/estimate_covariance.hpp:estimate_xy_covariance_by_multi_ndt()andestimate_xy_covariance_by_multi_ndt_score()takeautoware::ndt_scan_matcher::NdtResultandNdtBackend &.propose_poses_to_search()takesautoware::ndt_scan_matcher::NdtResult.ResultOfMultiNdtCovarianceEstimation::ndt_resultsholdsautoware::ndt_scan_matcher::NdtResult. Code that calls these functions with the ndt_omp types must change.hyper_parameters.hpp:HyperParameters::ndtisautoware::ndt_scan_matcher::NdtParams, andHyperParameters::ndt_backendis new.MapUpdateModule::NdtTypeisNdtBackend, andMapUpdateModule::NdtPtrTypeisNdtBackend::SharedPtr.ndt_backend_loader.hppwith the functionload_ndt_backend().hyper_parameters.hpp,map_update_module.hpp,ndt_scan_matcher_core.hppandndt_omp/estimate_covariance.hppno longer includemultigrid_ndt_omp.h. Code that got the ndt_omp types through these headers must include it.multigrid_ndt_ompno longer contains the covariance estimation. It is in the node library.ROS parameters
ndt.backend. The parameter PR below this one added it to the parameter file. Without it, the node stops with this message:The parameter 'ndt.backend' is not set. Add the line `backend: "ndt_omp"` under `ndt:` in the parameter file of autoware_ndt_scan_matcher.Effects on system behavior
With the
ndt_ompbackend, the node computes the same results with the same code. A parameter file withoutndt.backend(for example, a private copy of the file) now makes the node stop at startup, until it gets this one line.AI usage
AI usage: Written with Claude Code. I set the design, the requirements and the PR structure. Claude Code wrote the code, the tests and this description.
Self-review: A review with a clean context read the full diff of this PR against its base branch, the three files with rebase conflicts, and the ndt_omp code behind the wrapper. Three rounds ran: two on the code and one on this description. The first round found no correctness bug and two small items: no test for the message of a missing
ndt.backend, and aconsttest object that a callback changes. Both are fixed, and the description has the corrections from the third round.Verification: On Jazzy, the two packages build after the rebase on the diagnostics change, and `colcon test-result` reports 185 results with 0 failures. The rosbag comparison, the runtime and the build times are from the version before that rebase.
Build and tests
Jazzy, x86_64, an incremental build in the local workspace, this PR at
169fa3eb. The current head4bdcb683has the same files: GitHub rebased it onmainafter the rename PR merged. The dependencies came from a local workspace install.colcon build --symlink-install --packages-select autoware_ndt_scan_matcher_common autoware_ndt_scan_matcher --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=--coverage:Summary: 2 packages finished [49.7s].colcon test --packages-select autoware_ndt_scan_matcher_common autoware_ndt_scan_matcher --event-handlers console_cohesion-, thencolcon test-result --test-result-base build/<package>for each package:Summary: 23 tests, 0 errors, 0 failures, 4 skippedandSummary: 162 tests, 0 errors, 0 failures, 48 skipped. All skipped results are cppcheck results.MissingBackendParameterThrowsAtConstruction.autoware_ndt_scan_matcher_common, printedSummary: 185 tests, 0 errors, 0 failures, 52 skipped.ENABLE_AGNOCAST=1. The characterization tests do not run in an agnocast build.Node start with a missing or wrong
ndt.backendros2 run autoware_ndt_scan_matcher autoware_ndt_scan_matcher_node --ros-args --params-file <file>, on the pushed head018049bff, without the fix commit of the interface PR and without the last commit of this PR:backendin the file:The parameter 'ndt.backend' is not set. Add the line ...-p ndt.backend:=3:InvalidParameterTypeException-p 'ndt.backend:=""':Failed to load the NDT backend ''. ... Declared types are ndt_ompComparison with
mainOn the version before the rebase on the diagnostics change. It did not run again after that rebase.
mainand this stack in two overlay workspaces, Release, on the sample rosbag (Ryzen 9 5900X).mainfor every scan that both sides recorded (283 or 284 of 284 in each run). In two runs, one side recorded one scan fewer: oncemainand once this stack.mainand 3.60 to 3.76 ms with this stack.autoware_ndt_scan_matcheronmain. The CPU time (user and system) is 116.8 s against 103.1 s. Thendt_ompbackend library compiles in parallel with the node library.ndt_scan_matcher_core.cpp, that file took 3.6 s longer to compile. So the loader is in its own source file.Other backends
On the version before the rebase on the diagnostics change.
-mavxdoes not load (see the interface PR below this one).ndt_cuda_autoware_backend, a wrapper of about 180 lines) implements the interface without a change to the interface or to the node. In open loop on the sample rosbag with a tiled map, the node with this backend takes a median of 0.40 ms per scan, against 3.75 ms withndt_omp. The largest position difference tondt_ompis 1.2 cm.CI
On this head
4bdcb683:clang-tidy-diffpasses on Humble and Jazzy.codecov/projectfails, andcodecov/patchpasses.pre-commit-optionalfails on two dead links inlocalization/autoware_pose_initializer/README.md, which this PR does not touch.