From 48c31afbb6850844b837a6cf072641cce1b2b211 Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Thu, 21 Dec 2023 14:10:21 +0100 Subject: [PATCH] Aggregator: publish diagnostics_toplevel_state immediately on every degradation --- diagnostic_aggregator/src/aggregator.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/diagnostic_aggregator/src/aggregator.cpp b/diagnostic_aggregator/src/aggregator.cpp index d9576c737..e17ef0364 100644 --- a/diagnostic_aggregator/src/aggregator.cpp +++ b/diagnostic_aggregator/src/aggregator.cpp @@ -156,14 +156,13 @@ void Aggregator::diagCallback(const DiagnosticArray::SharedPtr diag_msg) for (auto j = 0u; j < diag_msg->status.size(); ++j) { analyzed = false; - const bool top_level_state_transition_to_error = - (last_top_level_state_ != DiagnosticStatus::ERROR) && - (diag_msg->status[j].level == DiagnosticStatus::ERROR); + const bool top_level_state_degradation = (last_top_level_state_ < diag_msg->status[j].level); - if (critical_ && top_level_state_transition_to_error) { + if (critical_ && top_level_state_degradation) { RCLCPP_DEBUG( - logger_, "Received error message: %s, publishing error immediately", + logger_, "Received degrated message: %s, publishing immediately", diag_msg->status[j].name.c_str()); + DiagnosticStatus diag_toplevel_state; diag_toplevel_state.name = "toplevel_state_critical"; diag_toplevel_state.level = diag_msg->status[j].level;