Skip to content

Commit

Permalink
Parse thread scheduler priority parsing to the async handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Sep 17, 2024
1 parent 20550c4 commit 9180500
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<realtime_tools::AsyncFunctionHandler<return_type>>();
async_handler_->init(
[this](const rclcpp::Time & time, const rclcpp::Duration & period)
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<realtime_tools::AsyncFunctionHandler<return_type>>();
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<realtime_tools::AsyncFunctionHandler<return_type>>();
async_handler_->init(
[this](const rclcpp::Time & time, const rclcpp::Duration & period)
Expand All @@ -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);
Expand Down

0 comments on commit 9180500

Please sign in to comment.