From 91805008ef5b11029b6455b37e85166fdde8e65a 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 337c2b5f43..a1e679e850 100644 --- a/hardware_interface/include/hardware_interface/actuator_interface.hpp +++ b/hardware_interface/include/hardware_interface/actuator_interface.hpp @@ -110,6 +110,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) @@ -126,7 +128,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 a31fca2222..04e09ff2d5 100644 --- a/hardware_interface/include/hardware_interface/sensor_interface.hpp +++ b/hardware_interface/include/hardware_interface/sensor_interface.hpp @@ -110,9 +110,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 8f444447a2..a57be99d65 100644 --- a/hardware_interface/include/hardware_interface/system_interface.hpp +++ b/hardware_interface/include/hardware_interface/system_interface.hpp @@ -112,6 +112,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) @@ -128,7 +130,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);