Skip to content

Fix controller activation crash on macOS (Fixes #604) (backport #2391) #2396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025
Merged
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
13 changes: 7 additions & 6 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool controller_name_compare(const controller_manager::ControllerSpec & a, const
* \return true if interface has a controller name as prefix, false otherwise.
*/
bool is_interface_a_chained_interface(
const std::string interface_name,
const std::string & interface_name,
const std::vector<controller_manager::ControllerSpec> & controllers,
controller_manager::ControllersListIterator & following_controller_it)
{
Expand Down Expand Up @@ -316,7 +316,7 @@ controller_interface::return_type evaluate_switch_result(
{
std::string list = std::accumulate(
std::next(deactivate_list.begin()), deactivate_list.end(), deactivate_list.front(),
[](std::string a, std::string b) { return a + " " + b; });
[](const std::string & a, const std::string & b) { return a + " " + b; });
const std::string info_msg =
fmt::format(FMT_COMPILE("Deactivated controllers: [ {} ]"), list);
message += "\n" + info_msg;
Expand All @@ -326,7 +326,7 @@ controller_interface::return_type evaluate_switch_result(
{
std::string list = std::accumulate(
std::next(activate_list.begin()), activate_list.end(), activate_list.front(),
[](std::string a, std::string b) { return a + " " + b; });
[](const std::string & a, const std::string & b) { return a + " " + b; });
const std::string info_msg =
fmt::format(FMT_COMPILE("Activated controllers: [ {} ]"), list);
message += "\n" + info_msg;
Expand Down Expand Up @@ -1183,7 +1183,7 @@ controller_interface::return_type ControllerManager::configure_controller(
{
std::string cmd_itfs_str = std::accumulate(
std::next(cmd_itfs.begin()), cmd_itfs.end(), cmd_itfs.front(),
[](std::string a, std::string b) { return a + ", " + b; });
[](const std::string & a, const std::string & b) { return a + ", " + b; });
RCLCPP_ERROR(
get_logger(),
"The command interfaces of the controller '%s' are not unique. Please make sure that the "
Expand All @@ -1197,7 +1197,7 @@ controller_interface::return_type ControllerManager::configure_controller(
{
std::string state_itfs_str = std::accumulate(
std::next(state_itfs.begin()), state_itfs.end(), state_itfs.front(),
[](std::string a, std::string b) { return a + ", " + b; });
[](const std::string & a, const std::string & b) { return a + ", " + b; });
RCLCPP_ERROR(
get_logger(),
"The state interfaces of the controller '%s' are not unique. Please make sure that the state "
Expand Down Expand Up @@ -1840,9 +1840,10 @@ controller_interface::return_type ControllerManager::switch_controller_cb(
switch_params_.timeout = timeout.to_chrono<std::chrono::nanoseconds>();
}
switch_params_.do_switch = true;

// wait until switch is finished
RCLCPP_DEBUG(get_logger(), "Requested atomic controller switch from realtime loop");
std::unique_lock<std::mutex> switch_params_guard(switch_params_.mutex, std::defer_lock);
std::unique_lock<std::mutex> switch_params_guard(switch_params_.mutex);
if (!switch_params_.cv.wait_for(
switch_params_guard, switch_params_.timeout, [this] { return !switch_params_.do_switch; }))
{
Expand Down
Loading