Skip to content

Commit

Permalink
refactor(system_error_monitor): hide error log in no-fault condition (a…
Browse files Browse the repository at this point in the history
…utowarefoundation#5522)

Signed-off-by: Takamasa Horibe <[email protected]>
  • Loading branch information
TakaHoribe authored Nov 9, 2023
1 parent 5797ee5 commit 63c1dd6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class AutowareErrorMonitor : public rclcpp::Node
bool canAutoRecovery() const;
bool isEmergencyHoldingRequired() const;

void loggingErrors(const autoware_auto_system_msgs::msg::HazardStatus & diag_array);

std::unique_ptr<tier4_autoware_utils::LoggerLevelConfigure> logger_configure_;
};

Expand Down
31 changes: 23 additions & 8 deletions system/system_error_monitor/src/system_error_monitor_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,9 @@ diagnostic_msgs::msg::DiagnosticArray convertHazardStatusToDiagnosticArray(
diag_array.status.push_back(decorateDiag(hazard_diag, "[Safe Fault]"));
}
for (const auto & hazard_diag : hazard_status.diag_latent_fault) {
const std::string logger_name = "system_error_monitor " + hazard_diag.name;
logThrottledNamed<DebugLevel::WARN>(
logger_name, clock, 5000, "[Latent Fault]: " + hazard_diag.message);

diag_array.status.push_back(decorateDiag(hazard_diag, "[Latent Fault]"));
}
for (const auto & hazard_diag : hazard_status.diag_single_point_fault) {
const std::string logger_name = "system_error_monitor " + hazard_diag.name;
logThrottledNamed<DebugLevel::ERROR>(
logger_name, clock, 5000, "[Single Point Fault]: " + hazard_diag.message);

diag_array.status.push_back(decorateDiag(hazard_diag, "[Single Point Fault]"));
}

Expand Down Expand Up @@ -688,6 +680,9 @@ void AutowareErrorMonitor::publishHazardStatus(
hazard_status_stamped.stamp = this->now();
hazard_status_stamped.status = hazard_status;
pub_hazard_status_->publish(hazard_status_stamped);

loggingErrors(hazard_status_stamped.status);

pub_diagnostics_err_->publish(
convertHazardStatusToDiagnosticArray(this->get_clock(), hazard_status_stamped.status));
}
Expand All @@ -703,3 +698,23 @@ bool AutowareErrorMonitor::onClearEmergencyService(

return true;
}

void AutowareErrorMonitor::loggingErrors(
const autoware_auto_system_msgs::msg::HazardStatus & hazard_status)
{
if (isInNoFaultCondition(*autoware_state_, *current_gate_mode_)) {
RCLCPP_DEBUG(get_logger(), "Autoware is in no-fault condition.");
return;
}

for (const auto & hazard_diag : hazard_status.diag_latent_fault) {
const std::string logger_name = "system_error_monitor " + hazard_diag.name;
logThrottledNamed<DebugLevel::WARN>(
logger_name, get_clock(), 5000, "[Latent Fault]: " + hazard_diag.message);
}
for (const auto & hazard_diag : hazard_status.diag_single_point_fault) {
const std::string logger_name = "system_error_monitor " + hazard_diag.name;
logThrottledNamed<DebugLevel::ERROR>(
logger_name, get_clock(), 5000, "[Single Point Fault]: " + hazard_diag.message);
}
}

0 comments on commit 63c1dd6

Please sign in to comment.