Repository navigation
refactor(ndt_scan_matcher): make scan matching diagnostics ROS-free
#1552
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
Merged
Motsu-san
merged 18 commits into
autowarefoundation:main
from
sasakisasaki:ndt-core/1-diagnostics-as-plain-data
Nov 20, 2026
+594
−125
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3cd4cde
feat(localization_util): allow SmartPoseBuffer without a logger
sasakisasaki 1bd1928
test(localization_util): split the SmartPoseBuffer without-logger tes…
sasakisasaki 2f821ab
refactor(ndt_scan_matcher): move DiagnosticsReport into its own header
sasakisasaki 2030fa4
refactor(ndt_scan_matcher): add ScanMatchDiagnostics for the scan mat…
sasakisasaki c80f84f
refactor(ndt_scan_matcher): report scan matching diagnostics through …
sasakisasaki ca76abf
refactor(ndt_scan_matcher): record best_particle_score where the alig…
sasakisasaki 82bd4b1
style(pre-commit): autofix
pre-commit-ci[bot] 63806e8
Merge branch 'main' into ndt-core/1-diagnostics-as-plain-data
sasakisasaki c0f5131
test(ndt_scan_matcher): mark the Arrange, Act and Assert steps in tes…
sasakisasaki a12b150
test(ndt_scan_matcher): name the keys omitted when the converged para…
sasakisasaki 655aab9
bug: remove no effect `NOLINT`
sasakisasaki b76bff6
Merge branch 'main' into ndt-core/1-diagnostics-as-plain-data
sasakisasaki 4cf6a4a
fix(test): check the detailed reason of `WARN` by intentional maximum…
sasakisasaki c75a4d4
fix(test): check `type` too for diag report
sasakisasaki c188bed
Merge branch 'main' into ndt-core/1-diagnostics-as-plain-data
sasakisasaki d820cd3
style(pre-commit): autofix
pre-commit-ci[bot] 2484398
fix(test): assert the processed result via message too
sasakisasaki da5beeb
Merge branch 'ndt-core/1-diagnostics-as-plain-data' of github.com:sas…
sasakisasaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
...zation/autoware_ndt_scan_matcher/include/autoware/ndt_scan_matcher/diagnostics_report.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Copyright 2026 Autoware Foundation | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef AUTOWARE__NDT_SCAN_MATCHER__DIAGNOSTICS_REPORT_HPP_ | ||
| #define AUTOWARE__NDT_SCAN_MATCHER__DIAGNOSTICS_REPORT_HPP_ | ||
|
|
||
| #include <cstdint> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <variant> | ||
| #include <vector> | ||
|
|
||
| namespace autoware::ndt_scan_matcher | ||
| { | ||
|
|
||
| // Severity of a diagnostics update. Mirrors diagnostic_msgs::msg::DiagnosticStatus levels so | ||
| // the core modules need no ROS diagnostics dependency. | ||
| enum class DiagnosticLevel : int8_t { OK = 0, WARN = 1, ERROR = 2, STALE = 3 }; | ||
|
|
||
| // A single diagnostic key/value. The value keeps its type so the ROS node can format it exactly | ||
| // the way DiagnosticsInterface would (e.g. bool as "True"/"False"). | ||
| struct DiagnosticKeyValue | ||
| { | ||
| std::string key; | ||
| std::variant<bool, int64_t, double, std::string> value; | ||
| }; | ||
|
|
||
| // Diagnostics accumulated by a core module: key/values plus an overall status (level + message). | ||
| // Returned to the ROS node, which forwards it to a DiagnosticsInterface. Plain data, kept ROS-free | ||
| // on purpose. | ||
| struct DiagnosticsReport | ||
| { | ||
| DiagnosticLevel level{DiagnosticLevel::OK}; | ||
| std::string message; | ||
| std::vector<DiagnosticKeyValue> key_values; | ||
|
|
||
| void add_key_value(DiagnosticKeyValue key_value) { key_values.push_back(std::move(key_value)); } | ||
|
|
||
| // Accumulates like DiagnosticsInterface: raises the level and appends the message. | ||
| void update_level_and_message(DiagnosticLevel new_level, const std::string & new_message) | ||
| { | ||
| if (static_cast<int8_t>(new_level) > static_cast<int8_t>(DiagnosticLevel::OK)) { | ||
| if (!message.empty()) { | ||
| message += "; "; | ||
| } | ||
| message += new_message; | ||
| } | ||
| if (static_cast<int8_t>(new_level) > static_cast<int8_t>(level)) { | ||
| level = new_level; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| } // namespace autoware::ndt_scan_matcher | ||
|
|
||
| #endif // AUTOWARE__NDT_SCAN_MATCHER__DIAGNOSTICS_REPORT_HPP_ | ||
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
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
66 changes: 66 additions & 0 deletions
66
...on/autoware_ndt_scan_matcher/include/autoware/ndt_scan_matcher/scan_match_diagnostics.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright 2026 Autoware Foundation | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef AUTOWARE__NDT_SCAN_MATCHER__SCAN_MATCH_DIAGNOSTICS_HPP_ | ||
| #define AUTOWARE__NDT_SCAN_MATCHER__SCAN_MATCH_DIAGNOSTICS_HPP_ | ||
|
|
||
| #include "diagnostics_report.hpp" | ||
|
|
||
| #include <vector> | ||
|
|
||
| namespace autoware::ndt_scan_matcher | ||
| { | ||
|
|
||
| struct ScanMatchDiagnosticsConfig | ||
| { | ||
| double initial_to_result_distance_tolerance_m; | ||
| double critical_upper_bound_exe_time_ms; | ||
| }; | ||
|
|
||
| // Values observed while matching one scan. The convergence verdicts (is_ok_*) are decided by the | ||
| // scan matching itself and are only reported here, never recomputed. | ||
| struct ScanMatchDiagnosticValues | ||
| { | ||
| int iteration_num{}; | ||
| int maximum_iterations{}; | ||
| bool is_ok_iteration_num{}; | ||
| int oscillation_num{}; | ||
| bool is_local_optimal_solution_oscillation{}; | ||
| float transform_probability{}; | ||
| float nearest_voxel_transformation_likelihood{}; | ||
| std::vector<float> transform_probability_array; | ||
| std::vector<float> nearest_voxel_transformation_likelihood_array; | ||
| // When false, the scan was rejected at this point and the fields below are not reported. | ||
| bool is_known_converged_param_type{true}; | ||
| double score{}; | ||
| double score_threshold{}; | ||
| bool is_ok_score{}; | ||
| double distance_initial_to_result{}; | ||
| float execution_time_ms{}; | ||
| }; | ||
|
|
||
| // Builds the scan matching part of the `scan_matching_status` diagnostics from the observed values. | ||
| class ScanMatchDiagnostics | ||
| { | ||
| public: | ||
| explicit ScanMatchDiagnostics(const ScanMatchDiagnosticsConfig & config); | ||
| [[nodiscard]] DiagnosticsReport make_report(const ScanMatchDiagnosticValues & values) const; | ||
|
|
||
| private: | ||
| ScanMatchDiagnosticsConfig config_; | ||
| }; | ||
|
|
||
| } // namespace autoware::ndt_scan_matcher | ||
|
|
||
| #endif // AUTOWARE__NDT_SCAN_MATCHER__SCAN_MATCH_DIAGNOSTICS_HPP_ |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[For PR Reviewers] This application code moved from here