From 61e85482015b2f94e241a58e646efe2241965453 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:38:43 +0100 Subject: [PATCH] Reformat with braces added (backport #1209) (#1306) * Reformat with braces added (#1209) (cherry picked from commit 562f36ddb615a70b54c71365393a8dc69508f52f) --------- Co-authored-by: Bence Magyar Co-authored-by: Dr. Denis --- controller_manager/src/controller_manager.cpp | 30 +++++++++++++++---- .../test/test_controller_manager_srvs.cpp | 9 +++++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 450a4780a2..f69b0ddb8e 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -156,7 +156,9 @@ std::vector get_following_controller_names( } // If the controller is not configured, return empty if (!(is_controller_active(controller_it->c) || is_controller_inactive(controller_it->c))) + { return following_controllers; + } const auto cmd_itfs = controller_it->c->command_interface_configuration().names; for (const auto & itf : cmd_itfs) { @@ -216,7 +218,10 @@ std::vector get_preceding_controller_names( for (const auto & ctrl : controllers) { // If the controller is not configured, then continue - if (!(is_controller_active(ctrl.c) || is_controller_inactive(ctrl.c))) continue; + if (!(is_controller_active(ctrl.c) || is_controller_inactive(ctrl.c))) + { + continue; + } auto cmd_itfs = ctrl.c->command_interface_configuration().names; for (const auto & itf : cmd_itfs) { @@ -2300,7 +2305,10 @@ bool ControllerManager::controller_sorting( if (!((is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) && (is_controller_active(ctrl_b.c) || is_controller_inactive(ctrl_b.c)))) { - if (is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) return true; + if (is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) + { + return true; + } return false; } @@ -2312,9 +2320,13 @@ bool ControllerManager::controller_sorting( // joint_state_broadcaster // If the controller b is also under the same condition, then maintain their initial order if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable()) + { return false; + } else + { return true; + } } else if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable()) { @@ -2324,12 +2336,17 @@ bool ControllerManager::controller_sorting( else { auto following_ctrls = get_following_controller_names(ctrl_a.info.name, controllers); - if (following_ctrls.empty()) return false; + if (following_ctrls.empty()) + { + return false; + } // If the ctrl_b is any of the following controllers of ctrl_a, then place ctrl_a before ctrl_b if ( std::find(following_ctrls.begin(), following_ctrls.end(), ctrl_b.info.name) != following_ctrls.end()) + { return true; + } else { auto ctrl_a_preceding_ctrls = get_preceding_controller_names(ctrl_a.info.name, controllers); @@ -2362,8 +2379,11 @@ bool ControllerManager::controller_sorting( // If there is no common parent, then they belong to 2 different sets auto following_ctrls_b = get_following_controller_names(ctrl_b.info.name, controllers); - if (following_ctrls_b.empty()) return true; - auto find_first_element = [&](const auto & controllers_list) + if (following_ctrls_b.empty()) + { + return true; + } + auto find_first_element = [&](const auto & controllers_list) -> int64_t { auto it = std::find_if( controllers.begin(), controllers.end(), diff --git a/controller_manager/test/test_controller_manager_srvs.cpp b/controller_manager/test/test_controller_manager_srvs.cpp index 30849a3ba3..1b86b04b9a 100644 --- a/controller_manager/test/test_controller_manager_srvs.cpp +++ b/controller_manager/test/test_controller_manager_srvs.cpp @@ -597,7 +597,9 @@ TEST_F(TestControllerManagerSrvs, list_sorted_chained_controllers) {TEST_CHAINED_CONTROLLER_4, TEST_CHAINED_CONTROLLER_3, TEST_CHAINED_CONTROLLER_5, TEST_CHAINED_CONTROLLER_2, TEST_CHAINED_CONTROLLER_1, test_controller::TEST_CONTROLLER_NAME}) + { cm_->configure_controller(controller); + } // get controller list after configure result = call_service_and_wait(*client, request, srv_executor); @@ -754,7 +756,9 @@ TEST_F(TestControllerManagerSrvs, list_sorted_complex_chained_controllers) {TEST_CHAINED_CONTROLLER_4, TEST_CHAINED_CONTROLLER_3, TEST_CHAINED_CONTROLLER_5, TEST_CHAINED_CONTROLLER_7, TEST_CHAINED_CONTROLLER_2, TEST_CHAINED_CONTROLLER_1, TEST_CHAINED_CONTROLLER_6, test_controller::TEST_CONTROLLER_NAME}) + { cm_->configure_controller(controller); + } // get controller list after configure result = call_service_and_wait(*client, request, srv_executor); @@ -968,7 +972,10 @@ TEST_F(TestControllerManagerSrvs, list_sorted_independent_chained_controllers) TEST_CHAINED_CONTROLLER_4, TEST_CONTROLLER_2, TEST_CHAINED_CONTROLLER_2, TEST_CHAINED_CONTROLLER_6, TEST_CHAINED_CONTROLLER_7, TEST_CHAINED_CONTROLLER_8}; - for (const auto & controller : ctrls_order) cm_->configure_controller(controller); + for (const auto & controller : ctrls_order) + { + cm_->configure_controller(controller); + } // get controller list after configure result = call_service_and_wait(*client, request, srv_executor);