From 75c97d457d2624d607e2a804d336c4c9f03c1034 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 21 Apr 2026 16:44:11 +0200 Subject: [PATCH 1/3] fix: detect Humble via rclcpp_VERSION instead of ROS_DISTRO env var 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. --- src/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0bce0c4..0e19257 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,11 +45,10 @@ target_link_libraries( DataStreamROS2 commonROS) add_library( TopicPublisherROS2 SHARED TopicPublisherROS2/publisher_ros2.cpp) target_link_libraries( TopicPublisherROS2 commonROS) -message("AMENT_PREFIX_PATH = ${AMENT_PREFIX_PATH}") -message("ROS_DISTRO (env) = $ENV{ROS_DISTRO}") - -if("$ENV{ROS_DISTRO}" STREQUAL "humble") - message(STATUS "Detected Humble") +# rclcpp < 17 corresponds to Humble; newer distros expose the renamed +# typesupport helpers and rosbag2 message fields used in the #else branches. +if(rclcpp_VERSION VERSION_LESS "17") + message(STATUS "Detected Humble (rclcpp ${rclcpp_VERSION})") target_compile_definitions(DataLoadROS2 PUBLIC ROS_HUMBLE) target_compile_definitions(TopicPublisherROS2 PUBLIC ROS_HUMBLE) target_compile_definitions(commonROS PUBLIC ROS_HUMBLE) From 7f84ef59db08faab0938d1434438d5527d223ab1 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 21 Apr 2026 18:31:43 +0200 Subject: [PATCH 2/3] docs: point README CI badges at the actual workflow files 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. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f33ff5..01a5728 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -[![ros2](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros2.yaml/badge.svg)](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros2.yaml) +[![ROS2 Humble](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros-humble.yaml/badge.svg)](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros-humble.yaml) +[![ROS2 Jazzy](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros-jazzy.yaml/badge.svg)](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros-jazzy.yaml) +[![ROS2 Rolling](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros-rolling.yaml/badge.svg)](https://github.com/PlotJuggler/plotjuggler-ros-plugins/actions/workflows/ros-rolling.yaml) # ROS plugins for PlotJuggler From 5f1772734f67951374cd8efa5bef6c4f508ef8f4 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 21 Apr 2026 18:41:04 +0200 Subject: [PATCH 3/3] refactor: replace ROS_HUMBLE define with RCLCPP_VERSION_GTE checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ``, 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. --- src/CMakeLists.txt | 9 --------- src/DataLoadROS2/dataload_ros2.cpp | 10 ++++++---- src/TopicPublisherROS2/generic_publisher.h | 10 ++++++---- src/typesupport_wrapper.cpp | 21 +++++++-------------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e19257..8e08e4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,15 +45,6 @@ target_link_libraries( DataStreamROS2 commonROS) add_library( TopicPublisherROS2 SHARED TopicPublisherROS2/publisher_ros2.cpp) target_link_libraries( TopicPublisherROS2 commonROS) -# rclcpp < 17 corresponds to Humble; newer distros expose the renamed -# typesupport helpers and rosbag2 message fields used in the #else branches. -if(rclcpp_VERSION VERSION_LESS "17") - message(STATUS "Detected Humble (rclcpp ${rclcpp_VERSION})") - target_compile_definitions(DataLoadROS2 PUBLIC ROS_HUMBLE) - target_compile_definitions(TopicPublisherROS2 PUBLIC ROS_HUMBLE) - target_compile_definitions(commonROS PUBLIC ROS_HUMBLE) -endif() - ####################################################################### diff --git a/src/DataLoadROS2/dataload_ros2.cpp b/src/DataLoadROS2/dataload_ros2.cpp index 4c89d59..11fa54c 100644 --- a/src/DataLoadROS2/dataload_ros2.cpp +++ b/src/DataLoadROS2/dataload_ros2.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "dialog_select_ros_topics.h" @@ -188,11 +189,12 @@ bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info, PJ::PlotDataMapRef& continue; } -#ifdef ROS_HUMBLE - const double msg_timestamp = 1e-9 * double(msg->time_stamp); // nanoseconds to seconds -#else - // from jazzy and later + // rosbag2 split SerializedBagMessage::time_stamp into recv_timestamp / + // send_timestamp in Jazzy (rclcpp 28.x). +#if RCLCPP_VERSION_GTE(28, 0, 0) const double msg_timestamp = 1e-9 * double(msg->send_timestamp); // nanoseconds to seconds +#else + const double msg_timestamp = 1e-9 * double(msg->time_stamp); // nanoseconds to seconds #endif //------ progress dialog -------------- diff --git a/src/TopicPublisherROS2/generic_publisher.h b/src/TopicPublisherROS2/generic_publisher.h index 686b15a..eb231cc 100644 --- a/src/TopicPublisherROS2/generic_publisher.h +++ b/src/TopicPublisherROS2/generic_publisher.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "typesupport_wrapper.h" @@ -27,10 +28,11 @@ class GenericPublisher : public rclcpp::PublisherBase public: GenericPublisher(rclcpp::node_interfaces::NodeBaseInterface* node_base, const std::string& topic_name, const rosidl_message_type_support_t& type_support) -#ifdef ROS_HUMBLE - : rclcpp::PublisherBase(node_base, topic_name, type_support, rcl_publisher_get_default_options()) -#else + // The rclcpp::PublisherBase constructor grew event-callback parameters after Humble (rclcpp 16.x). +#if RCLCPP_VERSION_GTE(17, 0, 0) : rclcpp::PublisherBase(node_base, topic_name, type_support, rcl_publisher_get_default_options(), callbacks_, true) +#else + : rclcpp::PublisherBase(node_base, topic_name, type_support, rcl_publisher_get_default_options()) #endif { } @@ -56,7 +58,7 @@ class GenericPublisher : public rclcpp::PublisherBase return std::make_shared(node.get_node_base_interface().get(), topic_name, *type_support); } -#ifndef ROS_HUMBLE +#if RCLCPP_VERSION_GTE(17, 0, 0) rclcpp::PublisherEventCallbacks callbacks_; #endif }; diff --git a/src/typesupport_wrapper.cpp b/src/typesupport_wrapper.cpp index 82ebbea..3d01544 100644 --- a/src/typesupport_wrapper.cpp +++ b/src/typesupport_wrapper.cpp @@ -1,34 +1,27 @@ - - #include "typesupport_wrapper.h" -#include "rosidl_runtime_cpp/message_type_support_decl.hpp" -#ifdef ROS_HUMBLE -#include "rosbag2_cpp/typesupport_helpers.hpp" -#else #include "rclcpp/typesupport_helpers.hpp" -#endif +#include "rclcpp/version.h" +#include "rosidl_runtime_cpp/message_type_support_decl.hpp" namespace wrapper { std::shared_ptr get_typesupport_library(const std::string& type, const std::string& typesupport_identifier) { -#ifdef ROS_HUMBLE - return rosbag2_cpp::get_typesupport_library(type, typesupport_identifier); -#else return rclcpp::get_typesupport_library(type, typesupport_identifier); -#endif } const rosidl_message_type_support_t* get_message_typesupport_handle(const std::string& type, const std::string& typesupport_identifier, std::shared_ptr library) { -#ifdef ROS_HUMBLE - return rosbag2_cpp::get_typesupport_handle(type, typesupport_identifier, library); -#else + // rclcpp::get_message_typesupport_handle was introduced in Jazzy (rclcpp 28.x). + // On Humble/Iron the only name available is rclcpp::get_typesupport_handle. +#if RCLCPP_VERSION_GTE(28, 0, 0) return rclcpp::get_message_typesupport_handle(type, typesupport_identifier, *library); +#else + return rclcpp::get_typesupport_handle(type, typesupport_identifier, *library); #endif } } // namespace wrapper