Skip to content

Commit c588879

Browse files
authored
Fix controller activation crash on macOS (Fixes #604) (#2391)
1 parent ad47e2a commit c588879

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ bool controller_name_compare(const controller_manager::ControllerSpec & a, const
110110
* \return true if interface has a controller name as prefix, false otherwise.
111111
*/
112112
bool is_interface_a_chained_interface(
113-
const std::string interface_name,
113+
const std::string & interface_name,
114114
const std::vector<controller_manager::ControllerSpec> & controllers,
115115
controller_manager::ControllersListIterator & following_controller_it)
116116
{
@@ -316,7 +316,7 @@ controller_interface::return_type evaluate_switch_result(
316316
{
317317
std::string list = std::accumulate(
318318
std::next(deactivate_list.begin()), deactivate_list.end(), deactivate_list.front(),
319-
[](std::string a, std::string b) { return a + " " + b; });
319+
[](const std::string & a, const std::string & b) { return a + " " + b; });
320320
const std::string info_msg =
321321
fmt::format(FMT_COMPILE("Deactivated controllers: [ {} ]"), list);
322322
message += "\n" + info_msg;
@@ -326,7 +326,7 @@ controller_interface::return_type evaluate_switch_result(
326326
{
327327
std::string list = std::accumulate(
328328
std::next(activate_list.begin()), activate_list.end(), activate_list.front(),
329-
[](std::string a, std::string b) { return a + " " + b; });
329+
[](const std::string & a, const std::string & b) { return a + " " + b; });
330330
const std::string info_msg =
331331
fmt::format(FMT_COMPILE("Activated controllers: [ {} ]"), list);
332332
message += "\n" + info_msg;
@@ -1195,7 +1195,7 @@ controller_interface::return_type ControllerManager::configure_controller(
11951195
{
11961196
std::string cmd_itfs_str = std::accumulate(
11971197
std::next(cmd_itfs.begin()), cmd_itfs.end(), cmd_itfs.front(),
1198-
[](std::string a, std::string b) { return a + ", " + b; });
1198+
[](const std::string & a, const std::string & b) { return a + ", " + b; });
11991199
RCLCPP_ERROR(
12001200
get_logger(),
12011201
"The command interfaces of the controller '%s' are not unique. Please make sure that the "
@@ -1209,7 +1209,7 @@ controller_interface::return_type ControllerManager::configure_controller(
12091209
{
12101210
std::string state_itfs_str = std::accumulate(
12111211
std::next(state_itfs.begin()), state_itfs.end(), state_itfs.front(),
1212-
[](std::string a, std::string b) { return a + ", " + b; });
1212+
[](const std::string & a, const std::string & b) { return a + ", " + b; });
12131213
RCLCPP_ERROR(
12141214
get_logger(),
12151215
"The state interfaces of the controller '%s' are not unique. Please make sure that the state "
@@ -1852,9 +1852,10 @@ controller_interface::return_type ControllerManager::switch_controller_cb(
18521852
switch_params_.timeout = timeout.to_chrono<std::chrono::nanoseconds>();
18531853
}
18541854
switch_params_.do_switch = true;
1855+
18551856
// wait until switch is finished
18561857
RCLCPP_DEBUG(get_logger(), "Requested atomic controller switch from realtime loop");
1857-
std::unique_lock<std::mutex> switch_params_guard(switch_params_.mutex, std::defer_lock);
1858+
std::unique_lock<std::mutex> switch_params_guard(switch_params_.mutex);
18581859
if (!switch_params_.cv.wait_for(
18591860
switch_params_guard, switch_params_.timeout, [this] { return !switch_params_.do_switch; }))
18601861
{

0 commit comments

Comments
 (0)