diff --git a/realtime_tools/CMakeLists.txt b/realtime_tools/CMakeLists.txt index a9d48f70..4bb0d30a 100644 --- a/realtime_tools/CMakeLists.txt +++ b/realtime_tools/CMakeLists.txt @@ -21,6 +21,7 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS rclcpp_action Threads rcpputils + fmt ) find_package(ament_cmake REQUIRED) @@ -42,7 +43,13 @@ target_include_directories(realtime_tools PUBLIC $ $ ) -target_link_libraries(realtime_tools PUBLIC rclcpp::rclcpp rclcpp_action::rclcpp_action rcpputils::rcpputils Threads::Threads Boost::boost) +target_link_libraries(realtime_tools PUBLIC + rclcpp::rclcpp + rclcpp_action::rclcpp_action + rcpputils::rcpputils + Threads::Threads + Boost::boost + fmt::fmt) if(UNIX AND NOT APPLE) target_link_libraries(realtime_tools PUBLIC cap) endif() @@ -66,6 +73,7 @@ if(BUILD_TESTING) find_package(lifecycle_msgs REQUIRED) find_package(rclcpp_lifecycle REQUIRED) find_package(test_msgs REQUIRED) + find_package(fmt REQUIRED) ament_add_gmock(thread_priority_tests test/thread_priority_tests.cpp) target_link_libraries(thread_priority_tests thread_priority) @@ -98,7 +106,8 @@ if(BUILD_TESTING) realtime_tools thread_priority ${lifecycle_msgs_TARGETS} - rclcpp_lifecycle::rclcpp_lifecycle) + rclcpp_lifecycle::rclcpp_lifecycle + fmt::fmt) if(NOT WIN32) ament_add_gmock(realtime_mutex_tests test/realtime_mutex_tests.cpp) diff --git a/realtime_tools/include/realtime_tools/async_function_handler.hpp b/realtime_tools/include/realtime_tools/async_function_handler.hpp index d815c109..030c6607 100644 --- a/realtime_tools/include/realtime_tools/async_function_handler.hpp +++ b/realtime_tools/include/realtime_tools/async_function_handler.hpp @@ -17,6 +17,8 @@ #ifndef REALTIME_TOOLS__ASYNC_FUNCTION_HANDLER_HPP_ #define REALTIME_TOOLS__ASYNC_FUNCTION_HANDLER_HPP_ +#include +#include #include #include #include @@ -568,9 +570,13 @@ class AsyncFunctionHandler params_.logger, !affinity_result.first, "Could not set CPU affinity for the async worker thread. Error: %s", affinity_result.second.c_str()); + + std::string cores_list_print = + fmt::format("[{}]", fmt::join(params_.cpu_affinity_cores, ", ")); + RCLCPP_WARN_EXPRESSION( params_.logger, affinity_result.first, - "Async worker thread is successfully pinned to the requested CPU cores!"); + "Async worker thread successfully pinned to Cores: %s", cores_list_print.c_str()); } if (!params_.thread_name.empty()) { const auto rename_result = realtime_tools::set_current_thread_name(params_.thread_name); diff --git a/realtime_tools/package.xml b/realtime_tools/package.xml index 8b2eea74..d107a8ee 100644 --- a/realtime_tools/package.xml +++ b/realtime_tools/package.xml @@ -25,6 +25,7 @@ rclcpp rclcpp_action libcap-dev + fmt ament_cmake_gmock lifecycle_msgs