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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0bce0c4..8e08e4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,16 +45,6 @@ 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") - 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