Skip to content

Commit 61e8548

Browse files
mergify[bot]bmagyardestogl
authored
Reformat with braces added (backport #1209) (#1306)
* Reformat with braces added (#1209) (cherry picked from commit 562f36d) --------- Co-authored-by: Bence Magyar <[email protected]> Co-authored-by: Dr. Denis <[email protected]>
1 parent 350c2aa commit 61e8548

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ std::vector<std::string> get_following_controller_names(
156156
}
157157
// If the controller is not configured, return empty
158158
if (!(is_controller_active(controller_it->c) || is_controller_inactive(controller_it->c)))
159+
{
159160
return following_controllers;
161+
}
160162
const auto cmd_itfs = controller_it->c->command_interface_configuration().names;
161163
for (const auto & itf : cmd_itfs)
162164
{
@@ -216,7 +218,10 @@ std::vector<std::string> get_preceding_controller_names(
216218
for (const auto & ctrl : controllers)
217219
{
218220
// If the controller is not configured, then continue
219-
if (!(is_controller_active(ctrl.c) || is_controller_inactive(ctrl.c))) continue;
221+
if (!(is_controller_active(ctrl.c) || is_controller_inactive(ctrl.c)))
222+
{
223+
continue;
224+
}
220225
auto cmd_itfs = ctrl.c->command_interface_configuration().names;
221226
for (const auto & itf : cmd_itfs)
222227
{
@@ -2300,7 +2305,10 @@ bool ControllerManager::controller_sorting(
23002305
if (!((is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) &&
23012306
(is_controller_active(ctrl_b.c) || is_controller_inactive(ctrl_b.c))))
23022307
{
2303-
if (is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) return true;
2308+
if (is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c))
2309+
{
2310+
return true;
2311+
}
23042312
return false;
23052313
}
23062314

@@ -2312,9 +2320,13 @@ bool ControllerManager::controller_sorting(
23122320
// joint_state_broadcaster
23132321
// If the controller b is also under the same condition, then maintain their initial order
23142322
if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable())
2323+
{
23152324
return false;
2325+
}
23162326
else
2327+
{
23172328
return true;
2329+
}
23182330
}
23192331
else if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable())
23202332
{
@@ -2324,12 +2336,17 @@ bool ControllerManager::controller_sorting(
23242336
else
23252337
{
23262338
auto following_ctrls = get_following_controller_names(ctrl_a.info.name, controllers);
2327-
if (following_ctrls.empty()) return false;
2339+
if (following_ctrls.empty())
2340+
{
2341+
return false;
2342+
}
23282343
// If the ctrl_b is any of the following controllers of ctrl_a, then place ctrl_a before ctrl_b
23292344
if (
23302345
std::find(following_ctrls.begin(), following_ctrls.end(), ctrl_b.info.name) !=
23312346
following_ctrls.end())
2347+
{
23322348
return true;
2349+
}
23332350
else
23342351
{
23352352
auto ctrl_a_preceding_ctrls = get_preceding_controller_names(ctrl_a.info.name, controllers);
@@ -2362,8 +2379,11 @@ bool ControllerManager::controller_sorting(
23622379

23632380
// If there is no common parent, then they belong to 2 different sets
23642381
auto following_ctrls_b = get_following_controller_names(ctrl_b.info.name, controllers);
2365-
if (following_ctrls_b.empty()) return true;
2366-
auto find_first_element = [&](const auto & controllers_list)
2382+
if (following_ctrls_b.empty())
2383+
{
2384+
return true;
2385+
}
2386+
auto find_first_element = [&](const auto & controllers_list) -> int64_t
23672387
{
23682388
auto it = std::find_if(
23692389
controllers.begin(), controllers.end(),

controller_manager/test/test_controller_manager_srvs.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,9 @@ TEST_F(TestControllerManagerSrvs, list_sorted_chained_controllers)
597597
{TEST_CHAINED_CONTROLLER_4, TEST_CHAINED_CONTROLLER_3, TEST_CHAINED_CONTROLLER_5,
598598
TEST_CHAINED_CONTROLLER_2, TEST_CHAINED_CONTROLLER_1,
599599
test_controller::TEST_CONTROLLER_NAME})
600+
{
600601
cm_->configure_controller(controller);
602+
}
601603

602604
// get controller list after configure
603605
result = call_service_and_wait(*client, request, srv_executor);
@@ -754,7 +756,9 @@ TEST_F(TestControllerManagerSrvs, list_sorted_complex_chained_controllers)
754756
{TEST_CHAINED_CONTROLLER_4, TEST_CHAINED_CONTROLLER_3, TEST_CHAINED_CONTROLLER_5,
755757
TEST_CHAINED_CONTROLLER_7, TEST_CHAINED_CONTROLLER_2, TEST_CHAINED_CONTROLLER_1,
756758
TEST_CHAINED_CONTROLLER_6, test_controller::TEST_CONTROLLER_NAME})
759+
{
757760
cm_->configure_controller(controller);
761+
}
758762

759763
// get controller list after configure
760764
result = call_service_and_wait(*client, request, srv_executor);
@@ -968,7 +972,10 @@ TEST_F(TestControllerManagerSrvs, list_sorted_independent_chained_controllers)
968972
TEST_CHAINED_CONTROLLER_4, TEST_CONTROLLER_2,
969973
TEST_CHAINED_CONTROLLER_2, TEST_CHAINED_CONTROLLER_6,
970974
TEST_CHAINED_CONTROLLER_7, TEST_CHAINED_CONTROLLER_8};
971-
for (const auto & controller : ctrls_order) cm_->configure_controller(controller);
975+
for (const auto & controller : ctrls_order)
976+
{
977+
cm_->configure_controller(controller);
978+
}
972979

973980
// get controller list after configure
974981
result = call_service_and_wait(*client, request, srv_executor);

0 commit comments

Comments
 (0)