From ff7ef87fa23e2a68f7dd03a124f58a77498fafad 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 b83ab64781..6ca478231f 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 6340e32dd0..bcc3f31985 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 8619d9e457..cfdf922db9 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);