diff --git a/clearpath_diagnostics/src/clearpath_diagnostic_updater.cpp b/clearpath_diagnostics/src/clearpath_diagnostic_updater.cpp index b0170291..c03d168c 100755 --- a/clearpath_diagnostics/src/clearpath_diagnostic_updater.cpp +++ b/clearpath_diagnostics/src/clearpath_diagnostic_updater.cpp @@ -732,6 +732,12 @@ void ClearpathDiagnosticUpdater::setup_topic_rate_diagnostics() template void ClearpathDiagnosticUpdater::add_rate_diagnostic( const std::string topic_name, const double rate) { + // Skip disabled topics (rate of 0 means the topic is not published) + if (rate == 0.0) { + RCLCPP_INFO(this->get_logger(), "Skipping diagnostic for %s (rate is 0)", topic_name.c_str()); + return; + } + // Store the rate so that it can be accessed via a pointer and is not deleted rates_.push_back(rate); diff --git a/clearpath_generator_common/clearpath_generator_common/param/platform.py b/clearpath_generator_common/clearpath_generator_common/param/platform.py index 7cdd47ca..a16395cf 100644 --- a/clearpath_generator_common/clearpath_generator_common/param/platform.py +++ b/clearpath_generator_common/clearpath_generator_common/param/platform.py @@ -656,9 +656,12 @@ def add_topic(self, sensor: BaseSensor, topic_key: str) -> None: :param sensor: The sensor object from which the topic info will be gotten :param topic_key: The key used to identify the topic to be monitored """ + rate = float(sensor.get_topic_rate(topic_key)) + if rate == 0.0: + return self.diag_dict[sensor.get_topic_name(topic_key, local=True)] = { 'type': sensor.get_topic_type(topic_key), - 'rate': float(sensor.get_topic_rate(topic_key)) + 'rate': rate } class FoxgloveBridgeParam(BaseParam):