Skip to content
Merged
Show file tree
Hide file tree
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 Nov 10, 2026
1bd1928
test(localization_util): split the SmartPoseBuffer without-logger tes…
sasakisasaki Nov 17, 2026
2f821ab
refactor(ndt_scan_matcher): move DiagnosticsReport into its own header
sasakisasaki Nov 6, 2026
2030fa4
refactor(ndt_scan_matcher): add ScanMatchDiagnostics for the scan mat…
sasakisasaki Nov 6, 2026
c80f84f
refactor(ndt_scan_matcher): report scan matching diagnostics through …
sasakisasaki Nov 6, 2026
ca76abf
refactor(ndt_scan_matcher): record best_particle_score where the alig…
sasakisasaki Nov 6, 2026
82bd4b1
style(pre-commit): autofix
pre-commit-ci[bot] Nov 18, 2026
63806e8
Merge branch 'main' into ndt-core/1-diagnostics-as-plain-data
sasakisasaki Nov 18, 2026
c0f5131
test(ndt_scan_matcher): mark the Arrange, Act and Assert steps in tes…
sasakisasaki Nov 18, 2026
a12b150
test(ndt_scan_matcher): name the keys omitted when the converged para…
sasakisasaki Nov 18, 2026
655aab9
bug: remove no effect `NOLINT`
sasakisasaki Nov 19, 2026
b76bff6
Merge branch 'main' into ndt-core/1-diagnostics-as-plain-data
sasakisasaki Nov 19, 2026
4cf6a4a
fix(test): check the detailed reason of `WARN` by intentional maximum…
sasakisasaki Nov 19, 2026
c75a4d4
fix(test): check `type` too for diag report
sasakisasaki Nov 19, 2026
c188bed
Merge branch 'main' into ndt-core/1-diagnostics-as-plain-data
sasakisasaki Nov 19, 2026
d820cd3
style(pre-commit): autofix
pre-commit-ci[bot] Nov 19, 2026
2484398
fix(test): assert the processed result via message too
sasakisasaki Nov 20, 2026
da5beeb
Merge branch 'ndt-core/1-diagnostics-as-plain-data' of github.com:sas…
sasakisasaki Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions localization/autoware_ndt_scan_matcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
src/ndt_scan_matcher_core.cpp
src/ndt_scan_matcher_helper.cpp
src/particle.cpp
src/scan_match_diagnostics.cpp
)

link_directories(${PCL_LIBRARY_DIRS})
Expand Down Expand Up @@ -116,6 +117,11 @@ if(BUILD_TESTING)
)
target_link_libraries(test_ndt_scan_matcher_helper ${PROJECT_NAME})

ament_auto_add_gtest(test_scan_match_diagnostics
test/test_scan_match_diagnostics.cpp
)
target_link_libraries(test_scan_match_diagnostics ${PROJECT_NAME})

# Unit tests for the map update module driven by an injected fake pcd loader (no ROS service).
ament_auto_add_gtest(test_map_update_module
test/test_map_update_module.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2026 Autoware Foundation

Copy link
Copy Markdown
Contributor Author

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

//
// 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_
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef AUTOWARE__NDT_SCAN_MATCHER__MAP_UPDATE_MODULE_HPP_
#define AUTOWARE__NDT_SCAN_MATCHER__MAP_UPDATE_MODULE_HPP_

#include "diagnostics_report.hpp"
#include "guarded.hpp"
#include "hyper_parameters.hpp"
#include "ndt_omp/multigrid_ndt_omp.h"
Expand All @@ -25,14 +26,12 @@

#include <pcl/point_types.h>

#include <cstdint>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <variant>
#include <vector>

namespace autoware::ndt_scan_matcher
Expand All @@ -57,43 +56,10 @@ class MapUpdateModule
using PcdLoaderFunction = std::function<GetDifferentialPointCloudMap::Response::ConstSharedPtr(
const GetDifferentialPointCloudMap::Request::SharedPtr &)>;

// Severity of a diagnostics update. Mirrors diagnostic_msgs::msg::DiagnosticStatus levels so
// this module needs 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 while updating the map: 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;
}
}
};
// Kept as member aliases so existing MapUpdateModule::Diagnostic* references keep working.
using DiagnosticLevel = autoware::ndt_scan_matcher::DiagnosticLevel;
using DiagnosticKeyValue = autoware::ndt_scan_matcher::DiagnosticKeyValue;
using DiagnosticsReport = autoware::ndt_scan_matcher::DiagnosticsReport;

// Result of a map update entry point: whether the NDT map changed, plus the diagnostics to
// report for this call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "hyper_parameters.hpp"
#include "map_update_module.hpp"
#include "ndt_omp/multigrid_ndt_omp.h"
#include "scan_match_diagnostics.hpp"

#include <autoware/agnocast_wrapper/node.hpp>
#include <autoware/agnocast_wrapper/tf2.hpp>
Expand Down Expand Up @@ -232,6 +233,7 @@ class NDTScanMatcher : public autoware::agnocast_wrapper::Node

std::atomic<bool> is_activated_;
std::unique_ptr<DiagnosticsInterface> diagnostics_scan_points_;
std::unique_ptr<ScanMatchDiagnostics> scan_match_diagnostics_;
std::unique_ptr<DiagnosticsInterface> diagnostics_initial_pose_;
std::unique_ptr<DiagnosticsInterface> diagnostics_regularization_pose_;
std::unique_ptr<DiagnosticsInterface> diagnostics_map_update_;
Expand Down
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_
Loading
Loading