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 Aug 6, 2024
1 parent 05d89f0 commit a162832
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 @@ -111,6 +111,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 @@ -127,7 +129,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 a162832

Please sign in to comment.