From 898eb5a9009a48021ef813f9c51a995e7327e3e3 Mon Sep 17 00:00:00 2001 From: Tomoya Kimura Date: Thu, 11 Jul 2024 15:28:30 +0900 Subject: [PATCH] feat(duplicated_node_checker): add duplicate nodes to ignore (#7959) (#1410) * feat: add duplicate nodes to ignore * remove talker * newline * commments * pre-commit and sign * rviz->rviz2 --------- Signed-off-by: Dmitrii Koldaev Co-authored-by: Dmitrii Koldaev <39071246+dkoldaev@users.noreply.github.com> Co-authored-by: Dmitrii Koldaev --- .../config/duplicated_node_checker.param.yaml | 2 ++ .../duplicated_node_checker/duplicated_node_checker_core.hpp | 4 ++++ .../src/duplicated_node_checker_core.cpp | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/system/duplicated_node_checker/config/duplicated_node_checker.param.yaml b/system/duplicated_node_checker/config/duplicated_node_checker.param.yaml index 96dce7eb360e4..412c59e66e2c9 100644 --- a/system/duplicated_node_checker/config/duplicated_node_checker.param.yaml +++ b/system/duplicated_node_checker/config/duplicated_node_checker.param.yaml @@ -2,3 +2,5 @@ ros__parameters: update_rate: 10.0 add_duplicated_node_names_to_msg: true # if true, duplicated node names are added to msg + nodes_to_ignore: # List of nodes to ignore when checking for duplicates + - /rviz2 diff --git a/system/duplicated_node_checker/include/duplicated_node_checker/duplicated_node_checker_core.hpp b/system/duplicated_node_checker/include/duplicated_node_checker/duplicated_node_checker_core.hpp index 9d806754f3c20..66e125de666b7 100644 --- a/system/duplicated_node_checker/include/duplicated_node_checker/duplicated_node_checker_core.hpp +++ b/system/duplicated_node_checker/include/duplicated_node_checker/duplicated_node_checker_core.hpp @@ -33,6 +33,9 @@ class DuplicatedNodeChecker : public rclcpp::Node std::unordered_set unique_names; std::vector identical_names; for (auto name : input_name_lists) { + if (nodes_to_ignore_.count(name) != 0) { + continue; + } if (unique_names.find(name) != unique_names.end()) { identical_names.push_back(name); } else { @@ -49,6 +52,7 @@ class DuplicatedNodeChecker : public rclcpp::Node diagnostic_updater::Updater updater_{this}; rclcpp::TimerBase::SharedPtr timer_; bool add_duplicated_node_names_to_msg_; + std::unordered_set nodes_to_ignore_; }; } // namespace duplicated_node_checker diff --git a/system/duplicated_node_checker/src/duplicated_node_checker_core.cpp b/system/duplicated_node_checker/src/duplicated_node_checker_core.cpp index 384c8fdc46c5f..c9bc07cffde72 100644 --- a/system/duplicated_node_checker/src/duplicated_node_checker_core.cpp +++ b/system/duplicated_node_checker/src/duplicated_node_checker_core.cpp @@ -29,6 +29,11 @@ DuplicatedNodeChecker::DuplicatedNodeChecker(const rclcpp::NodeOptions & node_op { double update_rate = declare_parameter("update_rate"); add_duplicated_node_names_to_msg_ = declare_parameter("add_duplicated_node_names_to_msg"); + + std::vector nodes_to_ignore_vector = + declare_parameter>("nodes_to_ignore"); + nodes_to_ignore_.insert(nodes_to_ignore_vector.begin(), nodes_to_ignore_vector.end()); + updater_.setHardwareID("duplicated_node_checker"); updater_.add("duplicated_node_checker", this, &DuplicatedNodeChecker::produceDiagnostics);