From f6a2d15fea2acc3e3b550bef90539a904a96bed2 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Tue, 6 Aug 2024 10:11:13 +0200 Subject: [PATCH] Parse thread scheduler priority parsing to the async handlers --- .../include/hardware_interface/actuator_interface.hpp | 5 ++++- .../include/hardware_interface/sensor_interface.hpp | 5 ++++- .../include/hardware_interface/system_interface.hpp | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hardware_interface/include/hardware_interface/actuator_interface.hpp b/hardware_interface/include/hardware_interface/actuator_interface.hpp index 771207d832..cf42506125 100644 --- a/hardware_interface/include/hardware_interface/actuator_interface.hpp +++ b/hardware_interface/include/hardware_interface/actuator_interface.hpp @@ -114,6 +114,8 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod info_ = hardware_info; if (info_.is_async) { + RCLCPP_INFO_STREAM( + get_logger(), "Starting async handler with scheduler priority: " << info_.thread_priority); async_handler_ = std::make_unique>(); async_handler_->init( [this](const rclcpp::Time & time, const rclcpp::Duration & period) @@ -130,7 +132,8 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod next_trigger_ = TriggerType::READ; return ret; } - }); + }, + info_.thread_priority); async_handler_->start_thread(); } return on_init(hardware_info); diff --git a/hardware_interface/include/hardware_interface/sensor_interface.hpp b/hardware_interface/include/hardware_interface/sensor_interface.hpp index 04108a3f24..36604d1f77 100644 --- a/hardware_interface/include/hardware_interface/sensor_interface.hpp +++ b/hardware_interface/include/hardware_interface/sensor_interface.hpp @@ -114,9 +114,12 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI info_ = hardware_info; if (info_.is_async) { + RCLCPP_INFO_STREAM( + get_logger(), "Starting async handler with scheduler priority: " << info_.thread_priority); read_async_handler_ = std::make_unique>(); read_async_handler_->init( - std::bind(&SensorInterface::read, this, std::placeholders::_1, std::placeholders::_2)); + std::bind(&SensorInterface::read, this, std::placeholders::_1, std::placeholders::_2), + info_.thread_priority); read_async_handler_->start_thread(); } return on_init(hardware_info); diff --git a/hardware_interface/include/hardware_interface/system_interface.hpp b/hardware_interface/include/hardware_interface/system_interface.hpp index 09768e4d56..89fd8d0f8b 100644 --- a/hardware_interface/include/hardware_interface/system_interface.hpp +++ b/hardware_interface/include/hardware_interface/system_interface.hpp @@ -117,6 +117,8 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI info_ = hardware_info; if (info_.is_async) { + RCLCPP_INFO_STREAM( + get_logger(), "Starting async handler with scheduler priority: " << info_.thread_priority); async_handler_ = std::make_unique>(); async_handler_->init( [this](const rclcpp::Time & time, const rclcpp::Duration & period) @@ -133,7 +135,8 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI next_trigger_ = TriggerType::READ; return ret; } - }); + }, + info_.thread_priority); async_handler_->start_thread(); } return on_init(hardware_info);