Skip to content

resolute: complete ament_index_cpp::get_package_share_path migration#3705

Merged
nbbrooks merged 1 commit into
moveit:mainfrom
nbbrooks:update-get-package-share
Jul 9, 2026
Merged

resolute: complete ament_index_cpp::get_package_share_path migration#3705
nbbrooks merged 1 commit into
moveit:mainfrom
nbbrooks:update-get-package-share

Conversation

@nbbrooks

@nbbrooks nbbrooks commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Completes the ament_index_cpp::get_package_share_directoryget_package_share_path migration that #3703 started for Rolling. The current source has #if RCLCPP_VERSION_GTE(30, 0, 0) guards that hit the wrong branch on Rolling-on-Noble (deprecated call path) and outright fail to compile on Rolling-on-Resolute (missing header). Fixes both with a three-tier guard keyed on AMENT_INDEX_CPP_VERSION_GTE — the correct carrier package's version macro.

Background: what ament_index_cpp did

ament_index_cpp's get_package_share_directory API evolved in two steps:

Version Header API
≥ 1.14.0 (Rolling on Resolute) <ament_index_cpp/get_package_share_path.hpp> get_package_share_path(pkg) returns std::filesystem::path directly. Old header removed.
≥ 1.5.x (Jazzy, Kilted, Lyrical, Rolling-on-Noble) <ament_index_cpp/get_package_share_directory.hpp> Both forms: std::string get_package_share_directory(pkg) (deprecated in 1.13+) and void get_package_share_directory(pkg, std::filesystem::path& out) (non-deprecated).
older (Humble 1.4.1) <ament_index_cpp/get_package_share_directory.hpp> Only std::string get_package_share_directory(pkg). Not deprecated.

Version snapshot for the distros moveit2 currently supports (from apt-cache policy against packages.ros.org):

Distro ament_index_cpp Notes
Humble (jammy) 1.4.1 1-arg only
Jazzy (noble) 1.8.4 Both forms; neither deprecated
Kilted (noble) 1.11.4 Both forms; neither deprecated
Lyrical (resolute) 1.13.3 Both forms; 1-arg deprecated
Rolling on Noble (frozen moveit/moveit2:rolling-ci) 1.13.1 Both forms; 1-arg deprecated
Rolling on Resolute (current) 1.14.1 Only new API

What went wrong in #3703

#3703 added conditional branches like:

#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;
#else
  const auto urdf_path =
      std::filesystem::path(ament_index_cpp::get_package_share_directory(package_name)) / urdf_relative_path;
#endif

Two problems:

  1. Wrong carrier. RCLCPP_VERSION_GTE(30, 0, 0) guards on rclcpp's version, but the API change lives in ament_index_cpp. When Update deprecated usage of get_package_share without std::filesystem::path #3703 was written the two packages' versions happened to correlate; they've since drifted apart (see the version snapshot above).
  2. The #if branch's 2-arg call is real on 1.13.x but no longer exists on 1.14+. On the current Rolling-on-Resolute container, <ament_index_cpp/get_package_share_directory.hpp> doesn't exist at all — the header include itself fails.

Concretely, the current code fails on rolling-resolute with:

fatal error: ament_index_cpp/get_package_share_path.hpp: No such file or directory

(from an earlier iteration of this PR that guarded on a too-permissive threshold; the current version pins the header choice on 1.14+ so this specific error is gone.)

What this PR does

Three-tier guard, keyed on AMENT_INDEX_CPP_VERSION_GTE:

#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

// ... in the call site:
#if AMENT_INDEX_CPP_VERSION_GTE(1, 14, 0)
  const auto path = ament_index_cpp::get_package_share_path(pkg);
#elif AMENT_INDEX_CPP_VERSION_GTE(1, 5, 0)
  std::filesystem::path path;
  ament_index_cpp::get_package_share_directory(pkg, path);
#else
  const auto path = std::filesystem::path(ament_index_cpp::get_package_share_directory(pkg));
#endif

Why three tiers, not two:

  • 1.14+ branch uses the new get_package_share_path API. Required to compile on Rolling-on-Resolute where the old header is gone.
  • 1.5–1.13.x branch uses the non-deprecated 2-arg out-param form. This branch matters even though it's "old API" because Rolling-on-Noble (the frozen moveit/moveit2:rolling-ci container, ament_index_cpp 1.13.1) treats the 1-arg form as deprecated, and the rolling-ci + deprecation check job runs with -Werror=deprecated-declarations. Using the 2-arg form keeps that job green.
  • Sub-1.5 branch falls back to the only form Humble's 1.4.1 has.

Why guard on AMENT_INDEX_CPP_VERSION_GTE instead of RCLCPP_VERSION_GTE: the API rename lives in ament_index_cpp. Its release cadence is independent of rclcpp's. Using another package's version macro as a proxy silently misfires when the two packages' versions drift — exactly what happened in #3703 → this fix. Companion policy update in #3751 makes "guard on the feature-carrier package's version macro" the documented rule going forward.

Also drops the now-unused #include <rclcpp/version.h> in each file (added by #3703 for the guard we replaced).

Test plan

  • Full source-build of moveit2 + downstream on ubuntu:resolute + ROS Rolling (ros2-testing apt) — all three files' downstream packages build cleanly; the rolling-resolute build path exercises the 1.14+ branch.
  • rolling-ci + ccov (Rolling on Noble, ament_index_cpp 1.13.1, no -Werror on deprecations) — exercises the 1.5–1.13.x branch.
  • rolling-ci + deprecation check (same container, -Werror=deprecated-declarations) — exercises the 1.5–1.13.x branch, confirms the 2-arg form doesn't trigger deprecation.
  • humble-ci, jazzy-ci — exercise the sub-1.5 and 1.5+ branches respectively.

@codecov

codecov Bot commented Mar 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.28%. Comparing base (4a766fd) to head (7c2646e).

Files with missing lines Patch % Lines
moveit_core/utils/src/robot_model_test_utils.cpp 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3705      +/-   ##
==========================================
+ Coverage   46.23%   46.28%   +0.06%     
==========================================
  Files         726      726              
  Lines       59512    59506       -6     
  Branches     7622     7624       +2     
==========================================
+ Hits        27509    27538      +29     
+ Misses      31836    31801      -35     
  Partials      167      167              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread moveit_core/utils/src/robot_model_test_utils.cpp Outdated
@nbbrooks nbbrooks marked this pull request as draft March 16, 2026 05:11
@nbbrooks nbbrooks force-pushed the update-get-package-share branch from 8189640 to a521b04 Compare July 9, 2026 19:25
@nbbrooks nbbrooks changed the title DUPLICATE Update deprecated usage of get_package_share resolute: complete ament_index_cpp::get_package_share_path migration Jul 9, 2026
@nbbrooks nbbrooks marked this pull request as ready for review July 9, 2026 19:29
@nbbrooks nbbrooks force-pushed the update-get-package-share branch 3 times, most recently from 562ec8b to 0c83916 Compare July 9, 2026 20:57
nbbrooks added a commit to nbbrooks/moveit2 that referenced this pull request Jul 9, 2026
…macro

The §1.1 draft advised guarding C++ divergence on RCLCPP_VERSION_GTE
as a general distro proxy. That's fragile: every ROS 2 package has
its own version macro and its own release cadence, so RCLCPP_VERSION
only proxies for another package's feature when their versions happen
to move in lockstep.

Concrete failure moveit#3703moveit#3705: `ament_index_cpp` renamed
`get_package_share_directory.hpp` → `get_package_share_path.hpp` in
1.14. Rolling's `rclcpp` had already been at ≥ 30 for months before
that, so a `RCLCPP_VERSION_GTE(30, 0, 0)` guard triggered on
Rolling-on-Noble containers that still shipped ament_index_cpp 1.13.1
— referencing a header that didn't exist yet. The guard was doing
nothing useful in the Noble era, then quietly discriminating wrong
across the Noble→Resolute transition.

Changes:

- §1.1 rewritten to advise guarding on the actual feature-carrier
  package's version macro (`AMENT_INDEX_CPP_VERSION_GTE`,
  `TF2_VERSION_GTE`, `RCLCPP_VERSION_GTE` for genuine rclcpp changes).
  Adds a "picking the threshold" checklist, a version snapshot for
  the frozen `rolling-ci` container vs. current Rolling, and
  moveit#3703moveit#3705 as the canonical example.
- §1.5 adds a reviewer checklist item: verify the threshold matches
  the upstream release, and verify the guard uses the correct package's
  macro.
- New Topic 3 section "Auditing existing version guards when Rolling
  changes base OS" — a concrete grep-and-audit procedure for the
  CI-matrix PR that adopts each new Rolling base.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…lling

ament_index_cpp evolved its API in two steps, and the RCLCPP_VERSION_GTE(30, 0, 0)
guards added in moveit#3703 hit the wrong branch on Rolling-on-Noble (where
the header still exists but the 1-arg form is now deprecated) and
outright fail to compile on Rolling-on-Resolute (where the header no
longer exists at all).

Guard on ament_index_cpp's own version macro — three tiers:

  1.14+ (Rolling on Resolute)
    <ament_index_cpp/get_package_share_path.hpp> replaced the old
    header, exposing get_package_share_path(pkg) which returns
    std::filesystem::path directly.

  1.5+ (Jazzy 1.8.4, Kilted 1.11.4, Lyrical 1.13.3, Rolling-on-Noble 1.13.1)
    Old header still present; use the 2-arg out-param overload
    get_package_share_directory(pkg, path) which is non-deprecated
    (matters for the -Werror=deprecated-declarations job on
    Rolling-on-Noble where the 1-arg form is deprecated).

  older (Humble 1.4.1)
    Only the 1-arg get_package_share_directory(pkg) returning
    std::string is available; wrap in std::filesystem::path().

Guarding on ament_index_cpp's own version (rather than rclcpp's) is
important because the two packages release independently — the API
change lives in ament_index_cpp, and using RCLCPP_VERSION as a proxy
misfires when Rolling's rclcpp advances without a corresponding
ament_index_cpp bump (as happened in moveit#3703 → this fix).

Drops the now-unused `#include <rclcpp/version.h>` in each file (added
by moveit#3703 for the guard we replaced).

Verified with a full source-build of moveit2 + downstream against
`ubuntu:resolute` + ROS Rolling (`ros2-testing` apt).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@nbbrooks nbbrooks force-pushed the update-get-package-share branch from 0c83916 to 7c2646e Compare July 9, 2026 22:29
@nbbrooks nbbrooks merged commit 2fb8492 into moveit:main Jul 9, 2026
10 of 12 checks passed
@github-project-automation github-project-automation Bot moved this to ✅ Done in MoveIt Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants