diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index 73e06dc33..a6f93459a 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,14 @@ 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) + 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); +#endif #else throw RuntimeError("Using attribute [ros_pkg] in , but this library was " "compiled without ROS support. Recompile the BehaviorTree.CPP "