Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix controller sorting issue while loading large number of controllers (backport #1180) #1186

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,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 @@ -2292,7 +2292,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
Loading