From 1bf11573df02e71c689da2f47c1987ebeb2a030b Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Cordero Date: Thu, 18 Dec 2025 11:23:15 +0100 Subject: [PATCH 1/2] Updated deprecated ament_index_cpp API Signed-off-by: Alejandro Hernandez Cordero --- rclcpp/src/rclcpp/typesupport_helpers.cpp | 16 ++++++++-------- rclcpp_components/src/component_manager.cpp | 12 ++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/rclcpp/src/rclcpp/typesupport_helpers.cpp b/rclcpp/src/rclcpp/typesupport_helpers.cpp index 22e3cebea6..07d4104b7e 100644 --- a/rclcpp/src/rclcpp/typesupport_helpers.cpp +++ b/rclcpp/src/rclcpp/typesupport_helpers.cpp @@ -123,27 +123,27 @@ std::string get_typesupport_library_path( { const char * dynamic_library_folder; #ifdef _WIN32 - dynamic_library_folder = "/bin/"; + dynamic_library_folder = "bin"; #elif __APPLE__ - dynamic_library_folder = "/lib/"; + dynamic_library_folder = "lib"; #else - dynamic_library_folder = "/lib/"; + dynamic_library_folder = "lib"; #endif - std::string package_prefix; + std::filesystem::path package_prefix; try { - package_prefix = ament_index_cpp::get_package_prefix(package_name); + ament_index_cpp::get_package_prefix(package_name, package_prefix); } catch (ament_index_cpp::PackageNotFoundError & e) { throw std::runtime_error(e.what()); } const std::string library_path = rcpputils::path_for_library( - package_prefix + dynamic_library_folder, + (package_prefix / dynamic_library_folder).string(), package_name + "__" + typesupport_identifier); if (library_path.empty()) { throw std::runtime_error( - "Typesupport library for " + package_name + " does not exist in '" + package_prefix + - "'."); + "Typesupport library for " + package_name + " does not exist in '" + + package_prefix.string() + "'."); } return library_path; } diff --git a/rclcpp_components/src/component_manager.cpp b/rclcpp_components/src/component_manager.cpp index 20cb61be7a..73d14da2fe 100644 --- a/rclcpp_components/src/component_manager.cpp +++ b/rclcpp_components/src/component_manager.cpp @@ -93,17 +93,13 @@ std::vector ComponentManager::get_component_resources( const std::string & package_name, const std::string & resource_index) const { - std::string content; - std::string base_path; - if ( - !ament_index_cpp::get_resource( - resource_index, package_name, content, &base_path)) - { + auto result = ament_index_cpp::get_resource(resource_index, package_name); + if (result.first == std::nullopt) { throw ComponentManagerException("Could not find requested resource in ament index"); } std::vector resources; - std::vector lines = rcpputils::split(content, '\n', true); + std::vector lines = rcpputils::split(result.second, '\n', true); for (const auto & line : lines) { std::vector parts = rcpputils::split(line, ';'); if (parts.size() != 2) { @@ -112,7 +108,7 @@ ComponentManager::get_component_resources( std::filesystem::path library_path = parts[1]; if (!library_path.is_absolute()) { - library_path = (base_path / library_path); + library_path = (result.first.value() / library_path); } resources.push_back({parts[0], library_path.string()}); } From 402fcbf34230c8104b2b5277de3c4b5fa412a3b1 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Cordero Date: Fri, 19 Dec 2025 22:23:00 +0100 Subject: [PATCH 2/2] updated API Signed-off-by: Alejandro Hernandez Cordero --- rclcpp_components/src/component_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rclcpp_components/src/component_manager.cpp b/rclcpp_components/src/component_manager.cpp index 73d14da2fe..ac2df6d812 100644 --- a/rclcpp_components/src/component_manager.cpp +++ b/rclcpp_components/src/component_manager.cpp @@ -94,12 +94,12 @@ ComponentManager::get_component_resources( const std::string & package_name, const std::string & resource_index) const { auto result = ament_index_cpp::get_resource(resource_index, package_name); - if (result.first == std::nullopt) { + if (result.resourcePath == std::nullopt) { throw ComponentManagerException("Could not find requested resource in ament index"); } std::vector resources; - std::vector lines = rcpputils::split(result.second, '\n', true); + std::vector lines = rcpputils::split(result.contents, '\n', true); for (const auto & line : lines) { std::vector parts = rcpputils::split(line, ';'); if (parts.size() != 2) { @@ -108,7 +108,7 @@ ComponentManager::get_component_resources( std::filesystem::path library_path = parts[1]; if (!library_path.is_absolute()) { - library_path = (result.first.value() / library_path); + library_path = (result.resourcePath.value() / library_path); } resources.push_back({parts[0], library_path.string()}); }