Skip to content

Commit 08ef1e9

Browse files
Fix controller sorting issue while loading large number of controllers (#1180) (#1187)
(cherry picked from commit d68cc22) Co-authored-by: Sai Kishor Kothakota <[email protected]>
1 parent fbdc894 commit 08ef1e9

File tree

2 files changed

+507
-2
lines changed

2 files changed

+507
-2
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ controller_interface::return_type ControllerManager::configure_controller(
780780
to = from;
781781

782782
// Reordering the controllers
783-
std::sort(
783+
std::stable_sort(
784784
to.begin(), to.end(),
785785
std::bind(
786786
&ControllerManager::controller_sorting, this, std::placeholders::_1, std::placeholders::_2,
@@ -2461,7 +2461,16 @@ bool ControllerManager::controller_sorting(
24612461
{
24622462
// The case of the controllers that don't have any command interfaces. For instance,
24632463
// joint_state_broadcaster
2464-
return true;
2464+
// If the controller b is also under the same condition, then maintain their initial order
2465+
if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable())
2466+
return false;
2467+
else
2468+
return true;
2469+
}
2470+
else if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable())
2471+
{
2472+
// If only the controller b is a broadcaster or non chainable type , then swap the controllers
2473+
return false;
24652474
}
24662475
else
24672476
{

0 commit comments

Comments
 (0)