From 35e32498cc0eb895b0716fea421f104c44ceee8b Mon Sep 17 00:00:00 2001 From: VX792 Date: Sun, 2 Apr 2023 21:26:14 +0200 Subject: [PATCH] start -> activate --- .../hardware_interface/async_components.hpp | 2 +- hardware_interface/src/resource_manager.cpp | 38 +++++++++++-------- .../test/joint_limits_urdf_test.cpp | 1 - 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/hardware_interface/include/hardware_interface/async_components.hpp b/hardware_interface/include/hardware_interface/async_components.hpp index acfbf4d42e..e4c89803c5 100644 --- a/hardware_interface/include/hardware_interface/async_components.hpp +++ b/hardware_interface/include/hardware_interface/async_components.hpp @@ -59,7 +59,7 @@ class AsyncComponentThread } } - void start() { write_and_read_ = std::thread(&AsyncComponentThread::write_and_read, this); } + void activate() { write_and_read_ = std::thread(&AsyncComponentThread::write_and_read, this); } void write_and_read() { diff --git a/hardware_interface/src/resource_manager.cpp b/hardware_interface/src/resource_manager.cpp index b24e9f540b..22a19cdf5d 100644 --- a/hardware_interface/src/resource_manager.cpp +++ b/hardware_interface/src/resource_manager.cpp @@ -305,6 +305,29 @@ class ResourceStorage if (result) { + if constexpr (std::is_same_v) + { + if (async_actuator_threads_.find(hardware.get_name()) != async_actuator_threads_.end()) + { + async_actuator_threads_.at(hardware.get_name()).activate(); + } + } + + if constexpr (std::is_same_v) + { + if (async_system_threads_.find(hardware.get_name()) != async_system_threads_.end()) + { + async_system_threads_.at(hardware.get_name()).activate(); + } + } + + if constexpr (std::is_same_v) + { + if (async_sensor_threads_.find(hardware.get_name()) != async_sensor_threads_.end()) + { + async_sensor_threads_.at(hardware.get_name()).activate(); + } + } // TODO(destogl): make all command interfaces available (currently are all available) } @@ -1304,21 +1327,6 @@ void ResourceManager::allocate_threads_for_async_components() std::forward_as_tuple(component, cm_update_rate_, clock_interface_)); } } - - for (auto & thread : resource_storage_->async_actuator_threads_) - { - thread.second.start(); - } - - for (auto & thread : resource_storage_->async_system_threads_) - { - thread.second.start(); - } - - for (auto & thread : resource_storage_->async_sensor_threads_) - { - thread.second.start(); - } } // BEGIN: private methods diff --git a/joint_limits_interface/test/joint_limits_urdf_test.cpp b/joint_limits_interface/test/joint_limits_urdf_test.cpp index 3914c2195a..1514803e27 100644 --- a/joint_limits_interface/test/joint_limits_urdf_test.cpp +++ b/joint_limits_interface/test/joint_limits_urdf_test.cpp @@ -20,7 +20,6 @@ #include - class JointLimitsUrdfTest : public ::testing::Test { public: