Skip to content

Commit

Permalink
Revert "change diag message"
Browse files Browse the repository at this point in the history
This reverts commit dff01ce.
  • Loading branch information
asa-naki committed Sep 4, 2023
1 parent 44f4235 commit af77a3a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ void AutowareStateMonitorNode::checkTopicStatus(
std::lock_guard<std::mutex> lock(lock_state_input_);
const auto & topic_stats = state_input_.topic_stats;

std::string msg;
// OK
for (const auto & topic_config : topic_stats.ok_list) {
if (topic_config.module != module_name) {
continue;
}
msg = "OK";

stat.add(fmt::format("{} status", topic_config.name), "OK");
}

Expand All @@ -68,7 +67,7 @@ void AutowareStateMonitorNode::checkTopicStatus(
}

stat.add(fmt::format("{} status", topic_config.name), "Not Received");
msg = "Error(Not Received)";

level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
}

Expand All @@ -86,7 +85,6 @@ void AutowareStateMonitorNode::checkTopicStatus(
stat.addf(fmt::format("{} warn_rate", name), "%.2f [Hz]", topic_config.warn_rate);
stat.addf(fmt::format("{} measured_rate", name), "%.2f [Hz]", topic_rate);

msg = "Warn";
level = diagnostic_msgs::msg::DiagnosticStatus::WARN;
}

Expand All @@ -105,19 +103,18 @@ void AutowareStateMonitorNode::checkTopicStatus(
stat.addf(fmt::format("{} checked_time", name), "%.2f [s]", topic_stats.checked_time.seconds());
stat.addf(fmt::format("{} last_received_time", name), "%.2f [s]", last_received_time.seconds());

msg = "Error(Timeout)";
level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
}

// // Create message
// std::string msg;
// if (level == diagnostic_msgs::msg::DiagnosticStatus::OK) {
// msg = "OK";
// } else if (level == diagnostic_msgs::msg::DiagnosticStatus::WARN) {
// msg = "Warn";
// } else if (level == diagnostic_msgs::msg::DiagnosticStatus::ERROR) {
// msg = "Error";
// }
// Create message
std::string msg;
if (level == diagnostic_msgs::msg::DiagnosticStatus::OK) {
msg = "OK";
} else if (level == diagnostic_msgs::msg::DiagnosticStatus::WARN) {
msg = "Warn";
} else if (level == diagnostic_msgs::msg::DiagnosticStatus::ERROR) {
msg = "Error";
}

stat.summary(level, msg);
}
Expand All @@ -129,7 +126,7 @@ void AutowareStateMonitorNode::checkTFStatus(

std::lock_guard<std::mutex> lock(lock_state_input_);
const auto & tf_stats = state_input_.tf_stats;
std::string msg;

// OK
for (const auto & tf_config : tf_stats.ok_list) {
if (tf_config.module != module_name) {
Expand All @@ -138,7 +135,6 @@ void AutowareStateMonitorNode::checkTFStatus(

const auto name = fmt::format("{}2{}", tf_config.from, tf_config.to);
stat.add(fmt::format("{} status", name), "OK");
msg="OK";
}

// Check tf received
Expand All @@ -151,7 +147,6 @@ void AutowareStateMonitorNode::checkTFStatus(
stat.add(fmt::format("{} status", name), "Not Received");

level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
msg="Error(Not Received)";
}

// Check tf timeout
Expand All @@ -170,18 +165,17 @@ void AutowareStateMonitorNode::checkTFStatus(
stat.addf(fmt::format("{} last_received_time", name), "%.2f [s]", last_received_time.seconds());

level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
msg="Error(TimeOut)";
}

// Create message
// std::string msg;
// if (level == diagnostic_msgs::msg::DiagnosticStatus::OK) {
// msg = "OK";
// } else if (level == diagnostic_msgs::msg::DiagnosticStatus::WARN) {
// msg = "Warn";
// } else if (level == diagnostic_msgs::msg::DiagnosticStatus::ERROR) {
// msg = "Error";
// }
std::string msg;
if (level == diagnostic_msgs::msg::DiagnosticStatus::OK) {
msg = "OK";
} else if (level == diagnostic_msgs::msg::DiagnosticStatus::WARN) {
msg = "Warn";
} else if (level == diagnostic_msgs::msg::DiagnosticStatus::ERROR) {
msg = "Error";
}

stat.summary(level, msg);
}
16 changes: 10 additions & 6 deletions system/topic_state_monitor/src/topic_state_monitor_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,22 @@ void TopicStateMonitorNode::checkTopicStatus(diagnostic_updater::DiagnosticStatu
stat.addf("topic", "%s", param_.topic.c_str());

// Judge level
std::string msg;
int8_t level = DiagnosticStatus::OK;
if (topic_status == TopicStatus::Ok) {
level = DiagnosticStatus::OK;
stat.add("status", "OK");
msg = "OK";
} else if (topic_status == TopicStatus::NotReceived) {
level = DiagnosticStatus::ERROR;
stat.add("status", "NotReceived");
msg = "Error(NotReceived)";
} else if (topic_status == TopicStatus::WarnRate) {
level = DiagnosticStatus::WARN;
stat.add("status", "WarnRate");
msg = "Warn";
} else if (topic_status == TopicStatus::ErrorRate) {
level = DiagnosticStatus::ERROR;
stat.add("status", "ErrorRate");
msg = "Error(ErrorRate)";
} else if (topic_status == TopicStatus::Timeout) {
level = DiagnosticStatus::ERROR;
stat.add("status", "Timeout");
msg = "Error(Timeout)";
}

// Add key-value
Expand All @@ -155,6 +149,16 @@ void TopicStateMonitorNode::checkTopicStatus(diagnostic_updater::DiagnosticStatu
stat.addf("now", "%.2f [s]", this->now().seconds());
stat.addf("last_message_time", "%.2f [s]", last_message_time.seconds());

// Create message
std::string msg;
if (level == DiagnosticStatus::OK) {
msg = "OK";
} else if (level == DiagnosticStatus::WARN) {
msg = "Warn";
} else if (level == DiagnosticStatus::ERROR) {
msg = "Error";
}

// Add summary
stat.summary(level, msg);
}
Expand Down

0 comments on commit af77a3a

Please sign in to comment.