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
  • Loading branch information
saikishor authored Dec 3, 2023
1 parent 587dffb commit d68cc22
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 @@ -777,7 +777,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 @@ -2453,7 +2453,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 d68cc22

Please sign in to comment.