From 82b9d41908bc8258d16ba33736bd295b54d8654b Mon Sep 17 00:00:00 2001 From: Dominik Authaler Date: Tue, 19 Aug 2025 07:18:41 +0000 Subject: [PATCH 1/5] use rclcpp type support helpers instead of rosbag2_cpp ones Signed-off-by: Dominik Authaler --- src/DataLoadROS2/dataload_ros2.cpp | 1 - src/TopicPublisherROS2/generic_publisher.h | 5 +++-- src/ros_parsers/ros2_parser.cpp | 22 +++++++++++----------- src/ros_parsers/ros2_parser.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/DataLoadROS2/dataload_ros2.cpp b/src/DataLoadROS2/dataload_ros2.cpp index 0e757d0..fc81340 100644 --- a/src/DataLoadROS2/dataload_ros2.cpp +++ b/src/DataLoadROS2/dataload_ros2.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/TopicPublisherROS2/generic_publisher.h b/src/TopicPublisherROS2/generic_publisher.h index ec80caf..69eedd6 100644 --- a/src/TopicPublisherROS2/generic_publisher.h +++ b/src/TopicPublisherROS2/generic_publisher.h @@ -48,8 +48,9 @@ class GenericPublisher : public rclcpp::PublisherBase static std::shared_ptr create(rclcpp::Node& node, const std::string& topic_name, const std::string& topic_type) { - auto library = std::move(rosbag2_cpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); - auto type_support = rosbag2_cpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", library); + + auto library = std::move(rclcpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); + auto type_support = rclcpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *library); return std::make_shared(node.get_node_base_interface().get(), topic_name, *type_support); } diff --git a/src/ros_parsers/ros2_parser.cpp b/src/ros_parsers/ros2_parser.cpp index 5c05427..cdcc9ba 100644 --- a/src/ros_parsers/ros2_parser.cpp +++ b/src/ros_parsers/ros2_parser.cpp @@ -41,11 +41,11 @@ std::string CreateSchema(const std::string& base_type) std::set secondary_types_pending; std::set secondary_types_done; - auto addTypeToSchema = [&](const std::string& type_name, bool add_header) { - auto introspection_library = - rosbag2_cpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - auto introspection_support = - rosbag2_cpp::get_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", introspection_library); + auto addTypeToSchema = [&](const std::string& type_name, bool add_header) + { + auto introspection_library = rclcpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); + auto introspection_support = rclcpp::get_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", + *introspection_library); if (add_header) { @@ -147,13 +147,13 @@ TopicInfo CreateTopicInfo(const std::string& topic_name, const std::string& type info.topic_name = topic_name; info.type = type_name; - info.introspection_library = rosbag2_cpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - info.introspection_support = rosbag2_cpp::get_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", - info.introspection_library); + info.introspection_library = rclcpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); + info.introspection_support = rclcpp::get_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", + *info.introspection_library); - auto identifier = rosidl_typesupport_cpp::typesupport_identifier; - info.support_library = rosbag2_cpp::get_typesupport_library(type_name, identifier); - info.type_support = rosbag2_cpp::get_typesupport_handle(type_name, identifier, info.support_library); + auto identifier = rosidl_typesupport_cpp::typesupport_identifier; + info.support_library = rclcpp::get_typesupport_library(type_name, identifier); + info.type_support = rclcpp::get_typesupport_handle(type_name, identifier, *info.support_library); info.has_header_stamp = TypeHasHeader(info.introspection_support); return info; diff --git a/src/ros_parsers/ros2_parser.h b/src/ros_parsers/ros2_parser.h index 4fcc021..dd4cd4e 100644 --- a/src/ros_parsers/ros2_parser.h +++ b/src/ros_parsers/ros2_parser.h @@ -3,7 +3,7 @@ #include "rclcpp/rclcpp.hpp" #include "rmw/rmw.h" #include "rmw/types.h" -#include "rosbag2_cpp/typesupport_helpers.hpp" +#include "rclcpp/typesupport_helpers.hpp" #include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" #include From d2f9e0d0fd2a4ba9d47f4a953ca1c7e3ad0cb563 Mon Sep 17 00:00:00 2001 From: Dominik Authaler Date: Tue, 19 Aug 2025 08:50:43 +0200 Subject: [PATCH 2/5] use rclcpp::get_message_typesupport_handle instead of deprecated rclcpp::get_typesupport_handle Signed-off-by: Dominik Authaler --- src/TopicPublisherROS2/generic_publisher.h | 2 +- src/ros_parsers/ros2_parser.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TopicPublisherROS2/generic_publisher.h b/src/TopicPublisherROS2/generic_publisher.h index 69eedd6..f68d5ae 100644 --- a/src/TopicPublisherROS2/generic_publisher.h +++ b/src/TopicPublisherROS2/generic_publisher.h @@ -50,7 +50,7 @@ class GenericPublisher : public rclcpp::PublisherBase { auto library = std::move(rclcpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); - auto type_support = rclcpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *library); + auto type_support = rclcpp::get_message_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *library); return std::make_shared(node.get_node_base_interface().get(), topic_name, *type_support); } diff --git a/src/ros_parsers/ros2_parser.cpp b/src/ros_parsers/ros2_parser.cpp index cdcc9ba..93bf047 100644 --- a/src/ros_parsers/ros2_parser.cpp +++ b/src/ros_parsers/ros2_parser.cpp @@ -44,8 +44,8 @@ std::string CreateSchema(const std::string& base_type) auto addTypeToSchema = [&](const std::string& type_name, bool add_header) { auto introspection_library = rclcpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - auto introspection_support = rclcpp::get_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", - *introspection_library); + auto introspection_support = rclcpp::get_message_typesupport_handle( + type_name, "rosidl_typesupport_introspection_cpp", *introspection_library); if (add_header) { @@ -148,12 +148,12 @@ TopicInfo CreateTopicInfo(const std::string& topic_name, const std::string& type info.type = type_name; info.introspection_library = rclcpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - info.introspection_support = rclcpp::get_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", - *info.introspection_library); + info.introspection_support = rclcpp::get_message_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", + *info.introspection_library); auto identifier = rosidl_typesupport_cpp::typesupport_identifier; info.support_library = rclcpp::get_typesupport_library(type_name, identifier); - info.type_support = rclcpp::get_typesupport_handle(type_name, identifier, *info.support_library); + info.type_support = rclcpp::get_message_typesupport_handle(type_name, identifier, *info.support_library); info.has_header_stamp = TypeHasHeader(info.introspection_support); return info; From 3d45f5020ae055bdb9296f6387fe3ca3279efab4 Mon Sep 17 00:00:00 2001 From: Dominik Authaler Date: Tue, 19 Aug 2025 08:51:48 +0200 Subject: [PATCH 3/5] fixed minor unused warnings Signed-off-by: Dominik Authaler --- src/DataLoadROS2/dataload_ros2.cpp | 1 - src/ros_parsers/ros2_parser.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/DataLoadROS2/dataload_ros2.cpp b/src/DataLoadROS2/dataload_ros2.cpp index fc81340..4c89d59 100644 --- a/src/DataLoadROS2/dataload_ros2.cpp +++ b/src/DataLoadROS2/dataload_ros2.cpp @@ -93,7 +93,6 @@ bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info, PJ::PlotDataMapRef& all_topics_qt.push_back({ QString::fromStdString(topic.name), QString::fromStdString(topic.type) }); topicTypesByName.emplace(topic.name, topic.type); - const auto& typesupport_identifier = rosidl_typesupport_cpp::typesupport_identifier; try { topics_info.emplace_back(CreateTopicInfo(topic.name, topic.type)); diff --git a/src/ros_parsers/ros2_parser.cpp b/src/ros_parsers/ros2_parser.cpp index 93bf047..2530020 100644 --- a/src/ros_parsers/ros2_parser.cpp +++ b/src/ros_parsers/ros2_parser.cpp @@ -35,7 +35,6 @@ bool TypeHasHeader(const rosidl_message_type_support_t* type_support) std::string CreateSchema(const std::string& base_type) { std::string schema; - using TypeSupport = rosidl_message_type_support_t; using namespace rosidl_typesupport_introspection_cpp; std::set secondary_types_pending; From 0c1710d17d1f667ff6e445fcd1c5a41af5644dcf Mon Sep 17 00:00:00 2001 From: Dominik Authaler Date: Thu, 8 Jan 2026 17:07:38 +0100 Subject: [PATCH 4/5] fix humble compatibility using typesupport wrapper Signed-off-by: Dominik Authaler --- src/CMakeLists.txt | 4 ++- src/TopicPublisherROS2/generic_publisher.h | 6 ++-- src/ros_parsers/ros2_parser.cpp | 18 ++++++------ src/ros_parsers/ros2_parser.h | 1 - src/typesupport_wrapper.cpp | 32 ++++++++++++++++++++++ src/typesupport_wrapper.h | 23 ++++++++++++++++ 6 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 src/typesupport_wrapper.cpp create mode 100644 src/typesupport_wrapper.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2db79a0..0bce0c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,13 +10,14 @@ QT5_WRAP_UI ( COMMON_UI_SRC add_library( commonROS STATIC - dialog_select_ros_topics.h + dialog_select_ros_topics.h dialog_select_ros_topics.cpp dialog_with_itemlist.h publisher_select_dialog.h parser_configuration.cpp parser_configuration.h ros_parsers/ros2_parser.cpp + typesupport_wrapper.cpp ${COMMON_UI_SRC} ) @@ -51,6 +52,7 @@ 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/TopicPublisherROS2/generic_publisher.h b/src/TopicPublisherROS2/generic_publisher.h index f68d5ae..d53a4b0 100644 --- a/src/TopicPublisherROS2/generic_publisher.h +++ b/src/TopicPublisherROS2/generic_publisher.h @@ -20,6 +20,8 @@ #include #include +#include "typesupport_wrapper.h" + class GenericPublisher : public rclcpp::PublisherBase { public: @@ -49,8 +51,8 @@ class GenericPublisher : public rclcpp::PublisherBase const std::string& topic_type) { - auto library = std::move(rclcpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); - auto type_support = rclcpp::get_message_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *library); + auto library = std::move(wrapper::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); + auto type_support = wrapper::get_message_typesupport_handle(topic_type, "rosidl_typesupport_cpp", library); return std::make_shared(node.get_node_base_interface().get(), topic_name, *type_support); } diff --git a/src/ros_parsers/ros2_parser.cpp b/src/ros_parsers/ros2_parser.cpp index 2530020..de64baf 100644 --- a/src/ros_parsers/ros2_parser.cpp +++ b/src/ros_parsers/ros2_parser.cpp @@ -10,6 +10,8 @@ #include #include +#include "typesupport_wrapper.h" + bool TypeHasHeader(const rosidl_message_type_support_t* type_support) { auto members = static_cast(type_support->data); @@ -42,9 +44,9 @@ std::string CreateSchema(const std::string& base_type) auto addTypeToSchema = [&](const std::string& type_name, bool add_header) { - auto introspection_library = rclcpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - auto introspection_support = rclcpp::get_message_typesupport_handle( - type_name, "rosidl_typesupport_introspection_cpp", *introspection_library); + auto introspection_library = wrapper::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); + auto introspection_support = wrapper::get_message_typesupport_handle( + type_name, "rosidl_typesupport_introspection_cpp", introspection_library); if (add_header) { @@ -146,13 +148,13 @@ TopicInfo CreateTopicInfo(const std::string& topic_name, const std::string& type info.topic_name = topic_name; info.type = type_name; - info.introspection_library = rclcpp::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - info.introspection_support = rclcpp::get_message_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", - *info.introspection_library); + info.introspection_library = wrapper::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); + info.introspection_support = wrapper::get_message_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", + info.introspection_library); auto identifier = rosidl_typesupport_cpp::typesupport_identifier; - info.support_library = rclcpp::get_typesupport_library(type_name, identifier); - info.type_support = rclcpp::get_message_typesupport_handle(type_name, identifier, *info.support_library); + info.support_library = wrapper::get_typesupport_library(type_name, identifier); + info.type_support = wrapper::get_message_typesupport_handle(type_name, identifier, info.support_library); info.has_header_stamp = TypeHasHeader(info.introspection_support); return info; diff --git a/src/ros_parsers/ros2_parser.h b/src/ros_parsers/ros2_parser.h index dd4cd4e..a32c8bd 100644 --- a/src/ros_parsers/ros2_parser.h +++ b/src/ros_parsers/ros2_parser.h @@ -3,7 +3,6 @@ #include "rclcpp/rclcpp.hpp" #include "rmw/rmw.h" #include "rmw/types.h" -#include "rclcpp/typesupport_helpers.hpp" #include "rosidl_typesupport_introspection_cpp/message_introspection.hpp" #include diff --git a/src/typesupport_wrapper.cpp b/src/typesupport_wrapper.cpp new file mode 100644 index 0000000..e204048 --- /dev/null +++ b/src/typesupport_wrapper.cpp @@ -0,0 +1,32 @@ + + +#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 + +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 + return rclcpp::get_message_typesupport_handle(type, typesupport_identifier, *library); + #endif + } +} diff --git a/src/typesupport_wrapper.h b/src/typesupport_wrapper.h new file mode 100644 index 0000000..ab83220 --- /dev/null +++ b/src/typesupport_wrapper.h @@ -0,0 +1,23 @@ +/* + * Wrappers to keep compatibility with all active ROS versions as of 01/2026 (Kilted, Jazzy, Humble). Dropping of + * this file should be reevaluated once Humble goes end of life (07/2027). + */ + +#ifndef TYPESUPPORT_WRAPPER_H +#define TYPESUPPORT_WRAPPER_H + +#include +#include "rcpputils/shared_library.hpp" +#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); + + const rosidl_message_type_support_t * + get_message_typesupport_handle(const std::string &type, + const std::string &typesupport_identifier, + std::shared_ptr library); +} + +#endif //TYPESUPPORT_WRAPPER_H From 0d56de9ab537881b629063353e2af1805166c712 Mon Sep 17 00:00:00 2001 From: Dominik Authaler Date: Fri, 9 Jan 2026 13:49:27 +0000 Subject: [PATCH 5/5] clang-format Signed-off-by: Dominik Authaler --- src/TopicPublisherROS2/generic_publisher.h | 5 +-- src/ros_parsers/ros2_parser.cpp | 9 ++--- src/typesupport_wrapper.cpp | 44 +++++++++++----------- src/typesupport_wrapper.h | 18 ++++----- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/TopicPublisherROS2/generic_publisher.h b/src/TopicPublisherROS2/generic_publisher.h index d53a4b0..686b15a 100644 --- a/src/TopicPublisherROS2/generic_publisher.h +++ b/src/TopicPublisherROS2/generic_publisher.h @@ -50,9 +50,8 @@ class GenericPublisher : public rclcpp::PublisherBase static std::shared_ptr create(rclcpp::Node& node, const std::string& topic_name, const std::string& topic_type) { - - auto library = std::move(wrapper::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); - auto type_support = wrapper::get_message_typesupport_handle(topic_type, "rosidl_typesupport_cpp", library); + auto library = std::move(wrapper::get_typesupport_library(topic_type, "rosidl_typesupport_cpp")); + auto type_support = wrapper::get_message_typesupport_handle(topic_type, "rosidl_typesupport_cpp", library); return std::make_shared(node.get_node_base_interface().get(), topic_name, *type_support); } diff --git a/src/ros_parsers/ros2_parser.cpp b/src/ros_parsers/ros2_parser.cpp index de64baf..d6ee8be 100644 --- a/src/ros_parsers/ros2_parser.cpp +++ b/src/ros_parsers/ros2_parser.cpp @@ -42,8 +42,7 @@ std::string CreateSchema(const std::string& base_type) std::set secondary_types_pending; std::set secondary_types_done; - auto addTypeToSchema = [&](const std::string& type_name, bool add_header) - { + auto addTypeToSchema = [&](const std::string& type_name, bool add_header) { auto introspection_library = wrapper::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); auto introspection_support = wrapper::get_message_typesupport_handle( type_name, "rosidl_typesupport_introspection_cpp", introspection_library); @@ -149,10 +148,10 @@ TopicInfo CreateTopicInfo(const std::string& topic_name, const std::string& type info.type = type_name; info.introspection_library = wrapper::get_typesupport_library(type_name, "rosidl_typesupport_introspection_cpp"); - info.introspection_support = wrapper::get_message_typesupport_handle(type_name, "rosidl_typesupport_introspection_cpp", - info.introspection_library); + info.introspection_support = wrapper::get_message_typesupport_handle( + type_name, "rosidl_typesupport_introspection_cpp", info.introspection_library); - auto identifier = rosidl_typesupport_cpp::typesupport_identifier; + auto identifier = rosidl_typesupport_cpp::typesupport_identifier; info.support_library = wrapper::get_typesupport_library(type_name, identifier); info.type_support = wrapper::get_message_typesupport_handle(type_name, identifier, info.support_library); diff --git a/src/typesupport_wrapper.cpp b/src/typesupport_wrapper.cpp index e204048..82ebbea 100644 --- a/src/typesupport_wrapper.cpp +++ b/src/typesupport_wrapper.cpp @@ -4,29 +4,31 @@ #include "rosidl_runtime_cpp/message_type_support_decl.hpp" #ifdef ROS_HUMBLE - #include "rosbag2_cpp/typesupport_helpers.hpp" +#include "rosbag2_cpp/typesupport_helpers.hpp" #else - #include "rclcpp/typesupport_helpers.hpp" +#include "rclcpp/typesupport_helpers.hpp" #endif -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 - } +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 - return rclcpp::get_message_typesupport_handle(type, typesupport_identifier, *library); - #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 + return rclcpp::get_message_typesupport_handle(type, typesupport_identifier, *library); +#endif } +} // namespace wrapper diff --git a/src/typesupport_wrapper.h b/src/typesupport_wrapper.h index ab83220..925f6cc 100644 --- a/src/typesupport_wrapper.h +++ b/src/typesupport_wrapper.h @@ -10,14 +10,14 @@ #include "rcpputils/shared_library.hpp" #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); +namespace wrapper +{ +std::shared_ptr get_typesupport_library(const std::string& type, + const std::string& typesupport_identifier); - const rosidl_message_type_support_t * - get_message_typesupport_handle(const std::string &type, - const std::string &typesupport_identifier, - std::shared_ptr library); -} +const rosidl_message_type_support_t* get_message_typesupport_handle(const std::string& type, + const std::string& typesupport_identifier, + std::shared_ptr library); +} // namespace wrapper -#endif //TYPESUPPORT_WRAPPER_H +#endif // TYPESUPPORT_WRAPPER_H