Skip to content

Commit

Permalink
Fix controller sorting issue while loading large number of controllers (
Browse files Browse the repository at this point in the history
#1180) (#1187)

(cherry picked from commit d68cc22)

Co-authored-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
  • Loading branch information
mergify[bot] and saikishor authored Dec 3, 2023
1 parent fbdc894 commit 08ef1e9
Show file tree
Hide file tree
Showing 2 changed files with 507 additions and 2 deletions.
13 changes: 11 additions & 2 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ controller_interface::return_type ControllerManager::configure_controller(
to = from;

// Reordering the controllers
std::sort(
std::stable_sort(
to.begin(), to.end(),
std::bind(
&ControllerManager::controller_sorting, this, std::placeholders::_1, std::placeholders::_2,
Expand Down Expand Up @@ -2461,7 +2461,16 @@ bool ControllerManager::controller_sorting(
{
// The case of the controllers that don't have any command interfaces. For instance,
// joint_state_broadcaster
return true;
// 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())
{
// If only the controller b is a broadcaster or non chainable type , then swap the controllers
return false;
}
else
{
Expand Down
Loading

0 comments on commit 08ef1e9

Please sign in to comment.