Skip to content

Commit

Permalink
feat(duplicated_node_checker): add duplicated node names to msg (auto…
Browse files Browse the repository at this point in the history
…warefoundation#5382)

* add duplicated node names to msg

Signed-off-by: kyoichi-sugahara <[email protected]>

* align with launcher repository

Signed-off-by: kyoichi-sugahara <[email protected]>

---------

Signed-off-by: kyoichi-sugahara <[email protected]>
  • Loading branch information
kyoichi-sugahara authored and shmpwk committed Nov 16, 2023
1 parent adad56a commit aafc0e8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/**:
ros__parameters:
update_rate: 10.0
add_duplicated_node_names_to_msg: false # if true, duplicated node names are added to msg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class DuplicatedNodeChecker : public rclcpp::Node

diagnostic_updater::Updater updater_{this};
rclcpp::TimerBase::SharedPtr timer_;
bool add_duplicated_node_names_to_msg_;
};
} // namespace duplicated_node_checker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ DuplicatedNodeChecker::DuplicatedNodeChecker(const rclcpp::NodeOptions & node_op
: Node("duplicated_node_checker", node_options)
{
double update_rate = declare_parameter<double>("update_rate");
add_duplicated_node_names_to_msg_ = declare_parameter<bool>("add_duplicated_node_names_to_msg");
updater_.setHardwareID("duplicated_node_checker");
updater_.add("duplicated_node_checker", this, &DuplicatedNodeChecker::produceDiagnostics);

Expand Down Expand Up @@ -63,8 +64,14 @@ void DuplicatedNodeChecker::produceDiagnostics(diagnostic_updater::DiagnosticSta
std::string msg;
int level;
if (identical_names.size() > 0) {
msg = "Error";
level = DiagnosticStatus::ERROR;
msg = "Error: Duplicated nodes detected";
if (add_duplicated_node_names_to_msg_) {
std::set<std::string> unique_identical_names(identical_names.begin(), identical_names.end());
for (const auto & name : unique_identical_names) {
msg += " " + name;
}
}
for (auto name : identical_names) {
stat.add("Duplicated Node Name", name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
/autoware/system/service_log_checker: { sf_at: "warn", lf_at: "none", spf_at: "none" }
/autoware/system/duplicated_node_checker: default
# /autoware/system/resource_monitoring: { sf_at: "warn", lf_at: "error", spf_at: "none" }
# /autoware/system/duplicated_node_checker: default

/autoware/vehicle/node_alive_monitoring: default

Expand Down

0 comments on commit aafc0e8

Please sign in to comment.