diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index bc629fd386..3c07ab265c 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -3393,6 +3393,10 @@ void ControllerManager::hardware_components_diagnostic_callback( const std::string & statistics_type_suffix, auto & diag_level, const auto & comp_info, const auto & params) { + if (!statistics) + { + return; + } const bool is_async = comp_info.is_async; const std::string periodicity_suffix = ".periodicity"; const std::string exec_time_suffix = ".execution_time"; @@ -3461,12 +3465,9 @@ void ControllerManager::hardware_components_diagnostic_callback( component_name, component_info.read_statistics, read_cycle_suffix, level, component_info, params_); // For components : {actuator and system} - if (component_info.write_statistics) - { - update_stats( - component_name, component_info.write_statistics, write_cycle_suffix, level, - component_info, params_); - } + update_stats( + component_name, component_info.write_statistics, write_cycle_suffix, level, component_info, + params_); } } diff --git a/hardware_interface/src/resource_manager.cpp b/hardware_interface/src/resource_manager.cpp index 0c816e9661..bc8f18ca0c 100644 --- a/hardware_interface/src/resource_manager.cpp +++ b/hardware_interface/src/resource_manager.cpp @@ -1774,11 +1774,14 @@ HardwareReadWriteStatus ResourceManager::read( ret_val = component.read(current_time, actual_period); } } - const auto & read_statistics_collector = component.get_read_statistics(); - hardware_component_info.read_statistics->execution_time.update_statistics( - read_statistics_collector.execution_time); - hardware_component_info.read_statistics->periodicity.update_statistics( - read_statistics_collector.periodicity); + if (hardware_component_info.read_statistics) + { + const auto & read_statistics_collector = component.get_read_statistics(); + hardware_component_info.read_statistics->execution_time.update_statistics( + read_statistics_collector.execution_time); + hardware_component_info.read_statistics->periodicity.update_statistics( + read_statistics_collector.periodicity); + } const auto component_group = component.get_group_name(); ret_val = resource_storage_->update_hardware_component_group_state(component_group, ret_val); @@ -1865,11 +1868,14 @@ HardwareReadWriteStatus ResourceManager::write( ret_val = component.write(current_time, actual_period); } } - const auto & write_statistics_collector = component.get_write_statistics(); - hardware_component_info.write_statistics->execution_time.update_statistics( - write_statistics_collector.execution_time); - hardware_component_info.write_statistics->periodicity.update_statistics( - write_statistics_collector.periodicity); + if (hardware_component_info.write_statistics) + { + const auto & write_statistics_collector = component.get_write_statistics(); + hardware_component_info.write_statistics->execution_time.update_statistics( + write_statistics_collector.execution_time); + hardware_component_info.write_statistics->periodicity.update_statistics( + write_statistics_collector.periodicity); + } const auto component_group = component.get_group_name(); ret_val = resource_storage_->update_hardware_component_group_state(component_group, ret_val);