fix: detect rclcpp API differences via RCLCPP_VERSION_GTE#115
Merged
facontidavide merged 3 commits intomainfrom Apr 21, 2026
Merged
fix: detect rclcpp API differences via RCLCPP_VERSION_GTE#115facontidavide merged 3 commits intomainfrom
facontidavide merged 3 commits intomainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Humble CI on
mainwas failing becausesrc/CMakeLists.txtgated theROS_HUMBLEcompile flag on$ENV{ROS_DISTRO}STREQUAL "humble", and that check did not match underaction-ros-cieven though the same variable printed ashumblefrom an adjacentmessage()call. WithoutROS_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 viaament_generate_version_header, so it is the authoritative version — independent of env vars and of the invoking shell.Per-site thresholds
typesupport_wrapper.cpprclcpp::get_message_typesupport_handle(Jazzy rename)>= 28,0,0generic_publisher.hrclcpp::PublisherBase6-arg constructor +callbacks_>= 17,0,0dataload_ros2.cppSerializedBagMessage::send_timestamp(Jazzy split)>= 28,0,0As a side effect this also makes Iron compile — the previous layout unconditionally took the Jazzy path whenever
ROS_HUMBLEwasn't defined.Also drops the now-unused
rosbag2_cpp/typesupport_helpers.hppinclude (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 intermittentaction-ros-ci@v0.4.6flake 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-existentros2.yamlworkflow.Test plan
source /opt/ros/humble/setup.bash && colcon build --packages-select plotjuggler_ros→ success.>=28branches, unchanged behavior).