From a35911567656811fefb81c1d80f8ed59dfb8ab52 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Mon, 28 Aug 2023 23:19:13 +0200 Subject: [PATCH 1/2] update list_chained_controllers_srv test with more assertions --- controller_manager/test/test_controller_manager_srvs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controller_manager/test/test_controller_manager_srvs.cpp b/controller_manager/test/test_controller_manager_srvs.cpp index 583480d494..7873adaacf 100644 --- a/controller_manager/test/test_controller_manager_srvs.cpp +++ b/controller_manager/test/test_controller_manager_srvs.cpp @@ -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"); @@ -300,6 +302,7 @@ TEST_F(TestControllerManagerSrvs, list_chained_controllers_srv) test_chainable_controller::TEST_CONTROLLER_NAME, result->controller[0].chain_connections[0].name); ASSERT_EQ(2u, result->controller[0].chain_connections[0].reference_interfaces.size()); + ASSERT_EQ("test_chainable_controller_name", result->controller[0].chain_connections[0].name); ASSERT_EQ("joint1/position", result->controller[0].chain_connections[0].reference_interfaces[0]); ASSERT_EQ("joint1/velocity", result->controller[0].chain_connections[0].reference_interfaces[1]); } From 7791c8661a3ecabe371694f35ec8a26f808f16f2 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Mon, 28 Aug 2023 23:20:07 +0200 Subject: [PATCH 2/2] use the controller reference interface info from resource manager instead --- controller_manager/src/controller_manager.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 062d813f0d..c13eb74a80 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -1639,11 +1639,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);