Skip to content

Commit

Permalink
Fix multiple calls to export reference interfaces (backport #1108) (#…
Browse files Browse the repository at this point in the history
…1114)

* Fix multiple calls to export reference interfaces (#1108)

(cherry picked from commit af10525)

# Conflicts:
#	controller_manager/test/test_controller_manager_srvs.cpp

* Apply suggestions from code review

Co-authored-by: Sai Kishor Kothakota <[email protected]>

---------

Co-authored-by: Sai Kishor Kothakota <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
  • Loading branch information
3 people authored Sep 21, 2023
1 parent ee9c06d commit 1e73a8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,11 +1317,17 @@ void ControllerManager::list_controllers_srv_cb(
}
}
// check reference interfaces only if controller is inactive or active
auto references = controllers[i].c->export_reference_interfaces();
controller_state.reference_interfaces.reserve(references.size());
for (const auto & reference : references)
if (controllers[i].c->is_chainable())
{
controller_state.reference_interfaces.push_back(reference.get_interface_name());
auto references =
resource_manager_->get_controller_reference_interface_names(controllers[i].info.name);
controller_state.reference_interfaces.reserve(references.size());
for (const auto & reference : references)
{
const std::string prefix_name = controllers[i].c->get_node()->get_name();
const std::string interface_name = reference.substr(prefix_name.size() + 1);
controller_state.reference_interfaces.push_back(interface_name);
}
}
}
response->controller.push_back(controller_state);
Expand Down
4 changes: 3 additions & 1 deletion controller_manager/test/test_controller_manager_srvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ TEST_F(TestControllerManagerSrvs, list_chained_controllers_srv)
ASSERT_EQ(result->controller[0].is_chainable, true);
ASSERT_EQ(result->controller[0].is_chained, false);
ASSERT_EQ(result->controller[0].reference_interfaces.size(), 2u);
;
ASSERT_EQ("joint1/position", result->controller[0].reference_interfaces[0]);
ASSERT_EQ("joint1/velocity", result->controller[0].reference_interfaces[1]);

ASSERT_EQ(result->controller[0].chain_connections.size(), 0u);
// check test controller
ASSERT_EQ(result->controller[1].state, "inactive");
Expand Down

0 comments on commit 1e73a8f

Please sign in to comment.