Skip to content
Open
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 src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)

Expand Down Expand Up @@ -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()

#######################################################################
Expand Down
2 changes: 0 additions & 2 deletions src/DataLoadROS2/dataload_ros2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <rosidl_typesupport_introspection_cpp/message_introspection.hpp>
#include <rosidl_typesupport_introspection_cpp/field_types.hpp>
#include <rosidl_typesupport_cpp/identifier.hpp>
#include <rosbag2_cpp/typesupport_helpers.hpp>
#include <rosbag2_cpp/types/introspection_message.hpp>
#include <unordered_map>
#include <rclcpp/rclcpp.hpp>
Expand Down Expand Up @@ -94,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));
Expand Down
6 changes: 4 additions & 2 deletions src/TopicPublisherROS2/generic_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/publisher_base.hpp>

#include "typesupport_wrapper.h"

class GenericPublisher : public rclcpp::PublisherBase
{
public:
Expand Down Expand Up @@ -48,8 +50,8 @@ class GenericPublisher : public rclcpp::PublisherBase
static std::shared_ptr<GenericPublisher> 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(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<GenericPublisher>(node.get_node_base_interface().get(), topic_name, *type_support);
}
Expand Down
20 changes: 10 additions & 10 deletions src/ros_parsers/ros2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <rosidl_typesupport_introspection_cpp/identifier.hpp>
#include <fmt/core.h>

#include "typesupport_wrapper.h"

bool TypeHasHeader(const rosidl_message_type_support_t* type_support)
{
auto members = static_cast<const rosidl_typesupport_introspection_cpp::MessageMembers*>(type_support->data);
Expand All @@ -35,17 +37,15 @@ 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<std::string> secondary_types_pending;
std::set<std::string> 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 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)
{
Expand Down Expand Up @@ -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 = 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 = rosbag2_cpp::get_typesupport_library(type_name, identifier);
info.type_support = rosbag2_cpp::get_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;
Expand Down
1 change: 0 additions & 1 deletion src/ros_parsers/ros2_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "rclcpp/rclcpp.hpp"
#include "rmw/rmw.h"
#include "rmw/types.h"
#include "rosbag2_cpp/typesupport_helpers.hpp"
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"

#include <PlotJuggler/plotdata.h>
Expand Down
34 changes: 34 additions & 0 deletions src/typesupport_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


#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<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
return rclcpp::get_message_typesupport_handle(type, typesupport_identifier, *library);
#endif
}
} // namespace wrapper
23 changes: 23 additions & 0 deletions src/typesupport_wrapper.h
Original file line number Diff line number Diff line change
@@ -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 <memory>
#include "rcpputils/shared_library.hpp"
#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);

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);
} // namespace wrapper

#endif // TYPESUPPORT_WRAPPER_H