diff --git a/moveit_core/utils/src/robot_model_test_utils.cpp b/moveit_core/utils/src/robot_model_test_utils.cpp index b858a3d23a..2549355931 100644 --- a/moveit_core/utils/src/robot_model_test_utils.cpp +++ b/moveit_core/utils/src/robot_model_test_utils.cpp @@ -34,9 +34,26 @@ /* Author: Bryce Willey */ -#include - +// ament_index_cpp's get_package_share_directory API changed twice. +// Guard on ament_index_cpp's own version — not rclcpp — because the +// changes live in ament_index_cpp and its release cadence is independent +// of rclcpp's. +// 1.14+ (Rolling on Resolute): +// get_package_share_directory.hpp REMOVED, replaced with +// get_package_share_path.hpp exposing get_package_share_path(pkg) +// returning std::filesystem::path directly. +// 1.5+ (Jazzy 1.8.4, Kilted 1.11.4, Lyrical 1.13.3, Rolling-on-Noble 1.13.1): +// 2-arg out-param overload get_package_share_directory(pkg, path) +// available; the 1-arg form is deprecated starting in 1.13. +// Older (Humble 1.4.1): +// only the non-deprecated 1-arg get_package_share_directory(pkg) +// returning std::string is available. +#include +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) +#include +#else #include +#endif #include #include #include @@ -66,14 +83,14 @@ moveit::core::RobotModelPtr loadTestingRobotModel(const std::string& package_nam const std::string& urdf_relative_path, const std::string& srdf_relative_path) { -// For Rolling, L-turtle, and newer -#if RCLCPP_VERSION_GTE(30, 0, 0) - std::filesystem::path urdf_path; - ament_index_cpp::get_package_share_directory(package_name, urdf_path); - urdf_path /= urdf_relative_path; - std::filesystem::path srdf_path; - ament_index_cpp::get_package_share_directory(package_name, srdf_path); - srdf_path /= srdf_relative_path; +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) + const auto urdf_path = ament_index_cpp::get_package_share_path(package_name) / urdf_relative_path; + const auto srdf_path = ament_index_cpp::get_package_share_path(package_name) / srdf_relative_path; +#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0) + std::filesystem::path pkg_share; + ament_index_cpp::get_package_share_directory(package_name, pkg_share); + const auto urdf_path = pkg_share / urdf_relative_path; + const auto srdf_path = pkg_share / srdf_relative_path; #else const auto urdf_path = std::filesystem::path(ament_index_cpp::get_package_share_directory(package_name)) / urdf_relative_path; @@ -107,8 +124,9 @@ moveit::core::RobotModelPtr loadTestingRobotModel(const std::string& robot_name) urdf::ModelInterfaceSharedPtr loadModelInterface(const std::string& robot_name) { const std::string package_name = "moveit_resources_" + robot_name + "_description"; -// For Rolling, L-turtle, and newer -#if RCLCPP_VERSION_GTE(30, 0, 0) +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) + std::filesystem::path res_path = ament_index_cpp::get_package_share_path(package_name); +#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0) std::filesystem::path res_path; ament_index_cpp::get_package_share_directory(package_name, res_path); #else @@ -141,8 +159,9 @@ srdf::ModelSharedPtr loadSRDFModel(const std::string& robot_name) if (robot_name == "pr2") { const std::string package_name = "moveit_resources_" + robot_name + "_description"; -// For Rolling, L-turtle, and newer -#if RCLCPP_VERSION_GTE(30, 0, 0) +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) + std::filesystem::path res_path = ament_index_cpp::get_package_share_path(package_name); +#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0) std::filesystem::path res_path; ament_index_cpp::get_package_share_directory(package_name, res_path); #else @@ -153,8 +172,9 @@ srdf::ModelSharedPtr loadSRDFModel(const std::string& robot_name) else { const std::string package_name = "moveit_resources_" + robot_name + "_moveit_config"; -// For Rolling, L-turtle, and newer -#if RCLCPP_VERSION_GTE(30, 0, 0) +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) + std::filesystem::path res_path = ament_index_cpp::get_package_share_path(package_name); +#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0) std::filesystem::path res_path; ament_index_cpp::get_package_share_directory(package_name, res_path); #else diff --git a/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp b/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp index db0957e96f..45d6daf28d 100644 --- a/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp +++ b/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp @@ -34,13 +34,30 @@ /* Author: Ioan Sucan, Mathias Lüdtke, Dave Coleman */ -#include - // MoveIt #include #include #include +// ament_index_cpp's get_package_share_directory API changed twice. +// Guard on ament_index_cpp's own version — not rclcpp — because the +// changes live in ament_index_cpp and its release cadence is independent +// of rclcpp's. +// 1.14+ (Rolling on Resolute): +// get_package_share_directory.hpp REMOVED, replaced with +// get_package_share_path.hpp exposing get_package_share_path(pkg) +// returning std::filesystem::path directly. +// 1.5+ (Jazzy 1.8.4, Kilted 1.11.4, Lyrical 1.13.3, Rolling-on-Noble 1.13.1): +// 2-arg out-param overload get_package_share_directory(pkg, path) +// available; the 1-arg form is deprecated starting in 1.13. +// Older (Humble 1.4.1): +// only the non-deprecated 1-arg get_package_share_directory(pkg) +// returning std::string is available. +#include +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) +#include +#else #include +#endif #include #include @@ -222,8 +239,9 @@ bool RDFLoader::loadPkgFileToString(std::string& buffer, const std::string& pack std::filesystem::path path; try { -// For Rolling, L-turtle, and newer -#if RCLCPP_VERSION_GTE(30, 0, 0) +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) + path = ament_index_cpp::get_package_share_path(package_name); +#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0) ament_index_cpp::get_package_share_directory(package_name, path); #else path = ament_index_cpp::get_package_share_directory(package_name); diff --git a/moveit_setup_assistant/moveit_setup_framework/include/moveit_setup_framework/utilities.hpp b/moveit_setup_assistant/moveit_setup_framework/include/moveit_setup_framework/utilities.hpp index 6cc6967965..f0bedfd969 100644 --- a/moveit_setup_assistant/moveit_setup_framework/include/moveit_setup_framework/utilities.hpp +++ b/moveit_setup_assistant/moveit_setup_framework/include/moveit_setup_framework/utilities.hpp @@ -36,10 +36,27 @@ #pragma once -#include - #include +// ament_index_cpp's get_package_share_directory API changed twice. +// Guard on ament_index_cpp's own version — not rclcpp — because the +// changes live in ament_index_cpp and its release cadence is independent +// of rclcpp's. +// 1.14+ (Rolling on Resolute): +// get_package_share_directory.hpp REMOVED, replaced with +// get_package_share_path.hpp exposing get_package_share_path(pkg) +// returning std::filesystem::path directly. +// 1.5+ (Jazzy 1.8.4, Kilted 1.11.4, Lyrical 1.13.3, Rolling-on-Noble 1.13.1): +// 2-arg out-param overload get_package_share_directory(pkg, path) +// available; the 1-arg form is deprecated starting in 1.13. +// Older (Humble 1.4.1): +// only the non-deprecated 1-arg get_package_share_directory(pkg) +// returning std::string is available. +#include +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) +#include +#else #include +#endif #include #include #include @@ -54,8 +71,9 @@ inline std::filesystem::path getSharePath(const std::string& package_name) { try { -// For Rolling, L-turtle, and newer -#if RCLCPP_VERSION_GTE(30, 0, 0) +#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0) + return ament_index_cpp::get_package_share_path(package_name); +#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0) std::filesystem::path path; ament_index_cpp::get_package_share_directory(package_name, path); return path;