From ade6056c2ccadd9ff395920f1a28165c5d644b06 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Sat, 16 Sep 2023 21:10:56 +0200 Subject: [PATCH] Fix multiple calls to export reference interfaces (#1108) (cherry picked from commit af1052537558450f57f0e647448be21399d283af) # Conflicts: # controller_manager/test/test_controller_manager_srvs.cpp --- controller_manager/src/controller_manager.cpp | 14 ++++++++++---- .../test/test_controller_manager_srvs.cpp | 12 +++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 9f9b836f55..69af65961e 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -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); diff --git a/controller_manager/test/test_controller_manager_srvs.cpp b/controller_manager/test/test_controller_manager_srvs.cpp index adb227d6fe..034d2c6832 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"); @@ -298,10 +300,18 @@ TEST_F(TestControllerManagerSrvs, list_chained_controllers_srv) ASSERT_EQ(result->controller[1].claimed_interfaces.size(), 3u); ASSERT_EQ( test_chainable_controller::TEST_CONTROLLER_NAME, +<<<<<<< HEAD result->controller[1].chain_connections[0].name); ASSERT_EQ(2u, result->controller[1].chain_connections[0].reference_interfaces.size()); ASSERT_EQ("joint1/position", result->controller[1].chain_connections[0].reference_interfaces[0]); ASSERT_EQ("joint1/velocity", result->controller[1].chain_connections[0].reference_interfaces[1]); +======= + 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]); +>>>>>>> af10525 (Fix multiple calls to export reference interfaces (#1108)) } TEST_F(TestControllerManagerSrvs, reload_controller_libraries_srv)