Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion off_highway_can/include/off_highway_can/receiver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class Receiver : public rclcpp::Node
const bool use_fd_{false};
/// Use J1939 protocol, defaults to false if J1939 protocol handling is not implemented for sensor
bool use_j1939_{false};
/// Store the timeout status
bool is_timeout_{false};

private:
/**
Expand Down Expand Up @@ -175,7 +177,6 @@ class Receiver : public rclcpp::Node
/// information
Messages messages_;


double timeout_;
double watchdog_frequency_;
};
Expand Down
9 changes: 4 additions & 5 deletions off_highway_can/src/receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ void Receiver::stop()

void Receiver::callback_watchdog()
{
if ((now() - last_message_received_).seconds() > timeout_) {
is_timeout_ = (now() - last_message_received_).seconds() > timeout_;
if (is_timeout_) {
RCLCPP_WARN(get_logger(), "Timeout of watchdog for receiving node %s", get_name());
force_diag_update();
last_message_received_ = now();
Expand Down Expand Up @@ -110,11 +111,9 @@ void Receiver::diagnostics(diagnostic_updater::DiagnosticStatusWrapper & stat) c
{
using diagnostic_msgs::msg::DiagnosticStatus;

bool timeout = (now() - last_message_received_).seconds() > timeout_;
stat.add("Timeout", is_timeout_);

stat.add("Timeout", timeout);

if (timeout) {
if (is_timeout_) {
stat.summary(DiagnosticStatus::ERROR, "Error");
} else {
stat.summary(DiagnosticStatus::OK, "Ok");
Expand Down
4 changes: 2 additions & 2 deletions off_highway_general_purpose_radar/src/receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void Receiver::manage_targets()

void Receiver::publish_targets()
{
if (pub_targets_->get_subscription_count() == 0) {
if (pub_targets_->get_subscription_count() == 0 || is_timeout_) {
return;
}

Expand All @@ -247,7 +247,7 @@ void Receiver::publish_targets()

void Receiver::publish_pcl()
{
if (pub_targets_pcl_->get_subscription_count() == 0) {
if (pub_targets_pcl_->get_subscription_count() == 0 || is_timeout_) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions off_highway_radar/src/receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void Receiver::manage_objects()

void Receiver::publish_objects()
{
if (pub_objects_->get_subscription_count() == 0) {
if (pub_objects_->get_subscription_count() == 0 || is_timeout_) {
return;
}

Expand All @@ -241,7 +241,7 @@ void Receiver::publish_objects()

void Receiver::publish_pcl()
{
if (pub_objects_pcl_->get_subscription_count() == 0) {
if (pub_objects_pcl_->get_subscription_count() == 0 || is_timeout_) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions off_highway_uss/src/receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void Receiver::manage_and_publish_objects()

void Receiver::publish_objects()
{
if (pub_objects_->get_subscription_count() == 0) {
if (pub_objects_->get_subscription_count() == 0 || is_timeout_) {
return;
}

Expand All @@ -290,7 +290,7 @@ void Receiver::publish_objects()

void Receiver::publish_pcl()
{
if (pub_objects_pcl_->get_subscription_count() == 0) {
if (pub_objects_pcl_->get_subscription_count() == 0 || is_timeout_) {
return;
}

Expand Down