Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 0 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

#######################################################################


Expand Down
10 changes: 6 additions & 4 deletions src/DataLoadROS2/dataload_ros2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <rosbag2_cpp/types/introspection_message.hpp>
#include <unordered_map>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/version.h>
#include <rmw/rmw.h>

#include "dialog_select_ros_topics.h"
Expand Down Expand Up @@ -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 --------------
Expand Down
10 changes: 6 additions & 4 deletions src/TopicPublisherROS2/generic_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/publisher_base.hpp>
#include <rclcpp/version.h>

#include "typesupport_wrapper.h"

Expand All @@ -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
{
}
Expand All @@ -56,7 +58,7 @@ class GenericPublisher : public rclcpp::PublisherBase
return std::make_shared<GenericPublisher>(node.get_node_base_interface().get(), topic_name, *type_support);
}

#ifndef ROS_HUMBLE
#if RCLCPP_VERSION_GTE(17, 0, 0)
rclcpp::PublisherEventCallbacks callbacks_;
#endif
};
Expand Down
21 changes: 7 additions & 14 deletions src/typesupport_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -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<rcpputils::SharedLibrary> 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<rcpputils::SharedLibrary> 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
Loading