Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions moveit_core/utils/src/robot_model_test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,26 @@

/* Author: Bryce Willey */

#include <rclcpp/version.h>

// 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 <ament_index_cpp/version.h>
#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0)
#include <ament_index_cpp/get_package_share_path.hpp>
#else
#include <ament_index_cpp/get_package_share_directory.hpp>
#endif
#include <boost/algorithm/string_regex.hpp>
#include <filesystem>
#include <geometry_msgs/msg/pose.hpp>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 22 additions & 4 deletions moveit_ros/planning/rdf_loader/src/rdf_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,30 @@

/* Author: Ioan Sucan, Mathias Lüdtke, Dave Coleman */

#include <rclcpp/version.h>

// MoveIt
#include <moveit/rdf_loader/rdf_loader.hpp>
#include <std_msgs/msg/string.hpp>
#include <ament_index_cpp/get_package_prefix.hpp>
// 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 <ament_index_cpp/version.h>
#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0)
#include <ament_index_cpp/get_package_share_path.hpp>
#else
#include <ament_index_cpp/get_package_share_directory.hpp>
#endif
#include <moveit/utils/logger.hpp>

#include <rclcpp/duration.hpp>
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,27 @@

#pragma once

#include <rclcpp/version.h>

#include <ament_index_cpp/get_package_prefix.hpp>
// 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 <ament_index_cpp/version.h>
#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0)
#include <ament_index_cpp/get_package_share_path.hpp>
#else
#include <ament_index_cpp/get_package_share_directory.hpp>
#endif
#include <filesystem>
#include <string>
#include <tinyxml2.h>
Expand All @@ -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;
Expand Down
Loading