Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions controller_interface/src/controller_interface_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ return_type ControllerInterfaceBase::init(
auto_declare<int>("update_rate", static_cast<int>(params.controller_manager_update_rate));
auto_declare<bool>("is_async", false);
auto_declare<int>("thread_priority", -100);

auto_declare<int>("async_parameters.thread_priority", 50);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For others, this is added in #3481, so ignore it here!

auto_declare<std::string>("async_parameters.scheduling_policy", "synchronized");
auto_declare<std::vector<int64_t>>("async_parameters.cpu_affinity", std::vector<int64_t>());
auto_declare<int>("async_parameters.execution_rate", impl_->ctrl_itf_params_.update_rate);
auto_declare<bool>("async_parameters.wait_until_initial_trigger", true);
auto_declare<bool>("async_parameters.print_warnings", true);
auto_declare<std::string>("async_parameters.thread_name", "");

}
catch (const std::exception & e)
{
Expand Down Expand Up @@ -258,6 +267,9 @@ const rclcpp_lifecycle::State & ControllerInterfaceBase::configure()
"instead.");
}
async_params.initialize(impl_->node_, "async_parameters.");
if (async_params.thread_name.empty()) {
async_params.thread_name = get_node()->get_name();
}
if (async_params.scheduling_policy == realtime_tools::AsyncSchedulingPolicy::DETACHED)
{
RCLCPP_ERROR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ struct HardwareAsyncParams
std::vector<int> cpu_affinity_cores = {};
/// Whether to print warnings when the async thread doesn't meet its deadline
bool print_warnings = true;
/// Custom name for the async worker thread
std::string thread_name = "";
};

/// This structure stores information about hardware defined in a robot's URDF.
Expand Down
6 changes: 6 additions & 0 deletions hardware_interface/src/component_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ constexpr const auto kThreadPriorityAttribute = "thread_priority";
constexpr const auto kAffinityCoresAttribute = "affinity";
constexpr const auto kSchedulingPolicyAttribute = "scheduling_policy";
constexpr const auto kPrintWarningsAttribute = "print_warnings";
constexpr const auto kThreadNameAttribute = "thread_name";

} // namespace

Expand Down Expand Up @@ -766,6 +767,11 @@ HardwareInfo parse_resource_from_xml(
hardware.async_params.scheduling_policy =
to_lower_case(get_attribute_value(async_it, kSchedulingPolicyAttribute, kAsyncTag));
}
if (async_it->FindAttribute(kThreadNameAttribute))
{
hardware.async_params.thread_name =
get_attribute_value(async_it, kThreadNameAttribute, kAsyncTag);
}
if (async_it->FindAttribute(kThreadPriorityAttribute))
{
hardware.async_params.thread_priority = parse_thread_priority_attribute(async_it);
Expand Down
5 changes: 5 additions & 0 deletions hardware_interface/src/hardware_component_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ CallbackReturn HardwareComponentInterface::init(
async_thread_params.logger = get_logger();
async_thread_params.exec_rate = params.hardware_info.rw_rate;
async_thread_params.print_warnings = info_.async_params.print_warnings;
if (!info_.async_params.thread_name.empty()) {
async_thread_params.thread_name = info_.async_params.thread_name;
} else {
async_thread_params.thread_name = info_.name;
}
RCLCPP_INFO(
get_logger(), "Starting async handler with scheduler priority: %d and policy : %s",
info_.async_params.thread_priority,
Expand Down
Loading