Skip to content

Commit

Permalink
feat(duplicated_node_checker): add duplicate nodes to ignore (autowar…
Browse files Browse the repository at this point in the history
…efoundation#7959) (#1410)

* feat: add duplicate nodes to ignore



* remove talker



* newline



* commments



* pre-commit and sign



* rviz->rviz2



---------

Signed-off-by: Dmitrii Koldaev <[email protected]>
Co-authored-by: Dmitrii Koldaev <[email protected]>
Co-authored-by: Dmitrii Koldaev <[email protected]>
  • Loading branch information
3 people authored Jul 11, 2024
1 parent 58ddfa8 commit 898eb5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class DuplicatedNodeChecker : public rclcpp::Node
std::unordered_set<std::string> unique_names;
std::vector<std::string> 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 {
Expand All @@ -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<std::string> nodes_to_ignore_;
};
} // namespace duplicated_node_checker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ DuplicatedNodeChecker::DuplicatedNodeChecker(const rclcpp::NodeOptions & node_op
{
double update_rate = declare_parameter<double>("update_rate");
add_duplicated_node_names_to_msg_ = declare_parameter<bool>("add_duplicated_node_names_to_msg");

std::vector<std::string> nodes_to_ignore_vector =
declare_parameter<std::vector<std::string>>("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);

Expand Down

0 comments on commit 898eb5a

Please sign in to comment.