Skip to content

Commit 865a596

Browse files
Fix controller activation crash on macOS (Fixes #604) (#2391) (#2396)
(cherry picked from commit c588879) Co-authored-by: Dhruv Patel <[email protected]>
1 parent a34ef90 commit 865a596

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;
@@ -1183,7 +1183,7 @@ controller_interface::return_type ControllerManager::configure_controller(
11831183
{
11841184
std::string cmd_itfs_str = std::accumulate(
11851185
std::next(cmd_itfs.begin()), cmd_itfs.end(), cmd_itfs.front(),
1186-
[](std::string a, std::string b) { return a + ", " + b; });
1186+
[](const std::string & a, const std::string & b) { return a + ", " + b; });
11871187
RCLCPP_ERROR(
11881188
get_logger(),
11891189
"The command interfaces of the controller '%s' are not unique. Please make sure that the "
@@ -1197,7 +1197,7 @@ controller_interface::return_type ControllerManager::configure_controller(
11971197
{
11981198
std::string state_itfs_str = std::accumulate(
11991199
std::next(state_itfs.begin()), state_itfs.end(), state_itfs.front(),
1200-
[](std::string a, std::string b) { return a + ", " + b; });
1200+
[](const std::string & a, const std::string & b) { return a + ", " + b; });
12011201
RCLCPP_ERROR(
12021202
get_logger(),
12031203
"The state interfaces of the controller '%s' are not unique. Please make sure that the state "
@@ -1840,9 +1840,10 @@ controller_interface::return_type ControllerManager::switch_controller_cb(
18401840
switch_params_.timeout = timeout.to_chrono<std::chrono::nanoseconds>();
18411841
}
18421842
switch_params_.do_switch = true;
1843+
18431844
// wait until switch is finished
18441845
RCLCPP_DEBUG(get_logger(), "Requested atomic controller switch from realtime loop");
1845-
std::unique_lock<std::mutex> switch_params_guard(switch_params_.mutex, std::defer_lock);
1846+
std::unique_lock<std::mutex> switch_params_guard(switch_params_.mutex);
18461847
if (!switch_params_.cv.wait_for(
18471848
switch_params_guard, switch_params_.timeout, [this] { return !switch_params_.do_switch; }))
18481849
{

0 commit comments

Comments
 (0)