Skip to content

fix: detect rclcpp API differences via RCLCPP_VERSION_GTE#115

Merged
facontidavide merged 3 commits intomainfrom
fix/humble-typesupport-detection
Apr 21, 2026
Merged

fix: detect rclcpp API differences via RCLCPP_VERSION_GTE#115
facontidavide merged 3 commits intomainfrom
fix/humble-typesupport-detection

Conversation

@facontidavide
Copy link
Copy Markdown
Contributor

@facontidavide facontidavide commented Apr 21, 2026

Summary

Humble CI on main was failing because src/CMakeLists.txt gated the ROS_HUMBLE compile flag on $ENV{ROS_DISTRO} STREQUAL "humble", and that check did not match under action-ros-ci even though the same variable printed as humble from an adjacent message() call. Without ROS_HUMBLE, the Jazzy+ branch (rclcpp::get_message_typesupport_handle) was compiled, which does not exist in rclcpp 16.x.

Replace the whole scheme with compile-time checks against RCLCPP_VERSION_GTE(major, minor, patch) from <rclcpp/version.h>. That macro is emitted by rclcpp itself via ament_generate_version_header, so it is the authoritative version — independent of env vars and of the invoking shell.

Per-site thresholds

Site Change Threshold
typesupport_wrapper.cpp rclcpp::get_message_typesupport_handle (Jazzy rename) >= 28,0,0
generic_publisher.h rclcpp::PublisherBase 6-arg constructor + callbacks_ >= 17,0,0
dataload_ros2.cpp rosbag2 SerializedBagMessage::send_timestamp (Jazzy split) >= 28,0,0

As a side effect this also makes Iron compile — the previous layout unconditionally took the Jazzy path whenever ROS_HUMBLE wasn't defined.

Also drops the now-unused rosbag2_cpp/typesupport_helpers.hpp include (Humble's rclcpp exposes the same helper).

Rolling CI

Rolling's failure on the original run was unrelated — ModuleNotFoundError: No module named 'ament_package' at CMake configure time, an intermittent action-ros-ci@v0.4.6 flake on Ubuntu 24.04. It passed cleanly on this PR's first CI run.

Also included

  • docs: point README CI badges at the actual workflow files — the previous badge referenced a non-existent ros2.yaml workflow.

Test plan

  • Local Humble build: source /opt/ros/humble/setup.bash && colcon build --packages-select plotjuggler_ros → success.
  • CI: ROS2 Humble green on this PR.
  • CI: ROS2 Jazzy / Rolling remain green (they use the >=28 branches, unchanged behavior).

Commit 63e6e28 added a ROS_HUMBLE compile flag guarded by
`if("$ENV{ROS_DISTRO}" STREQUAL "humble")`, but in the GitHub Actions
build farm that check did not match even though ROS_DISTRO was "humble"
at configure time. As a result the Humble build compiled the Jazzy+
branch and failed with:

  'get_message_typesupport_handle' is not a member of 'rclcpp';
  did you mean 'get_typesupport_handle'?

Switch the detection to the rclcpp_VERSION variable populated by
find_package(rclcpp). Humble ships rclcpp 16.x (threshold <17); Jazzy
and newer ship 28.x+. This is deterministic and independent of the
invoking shell's environment.
The previous badge referenced a legacy `ros2.yaml` workflow that no
longer exists. Replace with badges for the current workflows:
ros-humble, ros-jazzy, ros-rolling, and pre-commit.
Relying on CMake `if("$ENV{ROS_DISTRO}" STREQUAL "humble")` to forward
a ROS_HUMBLE compile flag is brittle — it broke in the Humble CI
runner even though ROS_DISTRO printed as "humble". Move the
conditional compilation to the `RCLCPP_VERSION_GTE(major,minor,patch)`
preprocessor macro from `<rclcpp/version.h>`, which is the authoritative
version shipped by rclcpp itself via ament_generate_version_header.

Per-site thresholds now reflect when each API actually changed rather
than using a single rough ROS_HUMBLE flag:

- typesupport_wrapper.cpp: rclcpp::get_message_typesupport_handle was
  added in Jazzy (rclcpp 28). Use it at >=28 and fall back to the
  (still existing) rclcpp::get_typesupport_handle below. Humble's
  rclcpp has that name too, so the rosbag2_cpp/typesupport_helpers
  include is no longer needed.
- generic_publisher.h: the 6-arg rclcpp::PublisherBase constructor
  (callbacks + use_default_events) was introduced between Humble and
  Iron (rclcpp 17+). Guard the extra args and the callbacks_ member
  on RCLCPP_VERSION_GTE(17, 0, 0).
- dataload_ros2.cpp: rosbag2 SerializedBagMessage::time_stamp was
  split into recv_timestamp/send_timestamp in Jazzy; gate the new
  field name on >=28 too.

With everything moved to compile-time checks the `ROS_HUMBLE` compile
definition and its CMake detection are unnecessary and have been
removed from src/CMakeLists.txt.

As a side benefit this also makes Iron compile, since the old setup
unconditionally took the Jazzy path when ROS_HUMBLE wasn't defined.
@facontidavide facontidavide changed the title fix: detect Humble via rclcpp_VERSION, unbreaks Humble CI fix: detect rclcpp API differences via RCLCPP_VERSION_GTE Apr 21, 2026
@facontidavide facontidavide merged commit 9cb0b59 into main Apr 21, 2026
4 checks passed
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.

1 participant