From 67d6e30f32b0d4b4e9df9dd807c0cb51df5ab85c Mon Sep 17 00:00:00 2001 From: mini-1235 Date: Mon, 13 Jul 2026 09:43:04 +0000 Subject: [PATCH 1/2] Fix package share path API for newer ament_index_cpp --- src/xml_parsing.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index 73e06dc33..68a8f3dd5 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -50,8 +50,13 @@ #include #ifdef USING_ROS2 +#include "ament_index_cpp/version.h" +#if AMENT_INDEX_CPP_VERSION_GTE(1, 13, 2) +#include +#else #include #endif +#endif #include "behaviortree_cpp/blackboard.h" #include "behaviortree_cpp/tree_node.h" @@ -397,8 +402,13 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes) { std::string ros_pkg_path; // NOLINT(misc-const-correctness) #if defined USING_ROS2 +#if AMENT_INDEX_CPP_VERSION_GTE(1, 13, 2) + ros_pkg_path = ament_index_cpp::get_package_share_path(ros_pkg_relative_path) + .string(); +#else ros_pkg_path = ament_index_cpp::get_package_share_directory(ros_pkg_relative_path); +#endif #else throw RuntimeError("Using attribute [ros_pkg] in , but this library was " "compiled without ROS support. Recompile the BehaviorTree.CPP " From 63673e7338dfd1b5a0dc509e44eb65bd491f9c0f Mon Sep 17 00:00:00 2001 From: mini-1235 Date: Mon, 13 Jul 2026 09:48:55 +0000 Subject: [PATCH 2/2] Style: format package share path update --- src/xml_parsing.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index 68a8f3dd5..a6f93459a 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -403,8 +403,9 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes) std::string ros_pkg_path; // NOLINT(misc-const-correctness) #if defined USING_ROS2 #if AMENT_INDEX_CPP_VERSION_GTE(1, 13, 2) - ros_pkg_path = ament_index_cpp::get_package_share_path(ros_pkg_relative_path) - .string(); + std::filesystem::path pkg_share_dir = + ament_index_cpp::get_package_share_path(ros_pkg_relative_path); + ros_pkg_path = pkg_share_dir.string(); #else ros_pkg_path = ament_index_cpp::get_package_share_directory(ros_pkg_relative_path);