Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achim-k committed Feb 23, 2024
1 parent 8ad8dd9 commit a1ec511
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ elseif("$ENV{ROS_VERSION}" STREQUAL "2")
ros2_foxglove_bridge/src/generic_client.cpp
)

# Check if the ROS_DISTRO is greater than iron and set a compile definition if that's the case.
string(COMPARE GREATER $ENV{ROS_DISTRO} "iron" ROS_DISTRO_GT_IRON)
if(ROS_DISTRO_GT_IRON)
target_compile_definitions(foxglove_bridge_component PRIVATE ROS_DISTRO_GT_IRON)
endif()
target_compile_definitions(foxglove_bridge_component
PRIVATE
RCLCPP_VERSION_MAJOR=${rclcpp_VERSION_MAJOR}
RCLCPP_VERSION_MINOR=${rclcpp_VERSION_MINOR}
RCLCPP_VERSION_PATCH=${rclcpp_VERSION_PATCH}
)

target_include_directories(foxglove_bridge_component
PUBLIC
Expand Down
17 changes: 16 additions & 1 deletion ros2_foxglove_bridge/src/generic_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@

#include <foxglove_bridge/generic_client.hpp>

/* True if the version of RCLCPP is at least major.minor.patch */
#define RCLCPP_VERSION_GTE(major, minor, patch) \
(major < RCLCPP_VERSION_MAJOR \
? true \
: major > RCLCPP_VERSION_MAJOR \
? false \
: minor < RCLCPP_VERSION_MINOR \
? true \
: minor > RCLCPP_VERSION_MINOR \
? false \
: patch < RCLCPP_VERSION_PATCH ? true \
: patch > RCLCPP_VERSION_PATCH ? false : true)

namespace {

// Copy of github.com/ros2/rclcpp/blob/33dae5d67/rclcpp/src/rclcpp/typesupport_helpers.cpp#L69-L92
Expand Down Expand Up @@ -123,7 +136,9 @@ GenericClient::GenericClient(rclcpp::node_interfaces::NodeBaseInterface* nodeBas
_typeIntrospectionHdl = (reinterpret_cast<decltype(get_ts)>(
_typeIntrospectionLib->get_symbol(typeinstrospection_symbol_name)))();

#ifdef ROS_DISTRO_GT_IRON
// get_typesupport_handle is deprecated since rclcpp 25.0.0
// (https://github.com/ros2/rclcpp/pull/2209)
#if RCLCPP_VERSION_GTE(25, 0, 0)
_requestTypeSupportHdl =
rclcpp::get_message_typesupport_handle(requestTypeName, TYPESUPPORT_LIB_NAME, *_typeSupportLib);
_responseTypeSupportHdl = rclcpp::get_message_typesupport_handle(
Expand Down

0 comments on commit a1ec511

Please sign in to comment.