Skip to content

Commit

Permalink
ros2: Fix cv_bridge and tf2_geometry_msgs header for Jazzy
Browse files Browse the repository at this point in the history
  • Loading branch information
benthie authored and saierd committed Oct 28, 2024
1 parent 4996c71 commit f21eee5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
13 changes: 13 additions & 0 deletions ensenso_camera/include/ensenso_camera/ros2/cv_bridge/cv_bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#ifdef ROS2
// We use the deprecated .h header instead of .hpp, because the latter is not available for foxy and humble.
// TODO Use .hpp header as soon as we do not support foxy and humble anymore
#ifdef ROS2_JAZZY
#include <cv_bridge/cv_bridge.hpp>
#else
#include <cv_bridge/cv_bridge.h>
#endif
#else
#include <cv_bridge/cv_bridge.h>
#endif
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#pragma once

#ifdef ROS2
// We use the deprecated .h header instead of .hpp, because the latter is not available for foxy
// TODO Use .hpp header as soon as we do not support foxy anymore
// We use the deprecated .h header instead of .hpp, because the latter is not available for foxy and humble
// TODO Use .hpp header as soon as we do not support foxy and humble anymore
#ifdef ROS2_JAZZY
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
#else
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#endif
#else
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#endif
2 changes: 1 addition & 1 deletion ensenso_camera/src/image_utilities.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Do not change the order of this block. Otherwise getBinaryData with CV::mat overload will not be recognized
#include <cv_bridge/cv_bridge.h>
#include "ensenso_camera/ros2/cv_bridge/cv_bridge.h"
#include "ensenso_camera/image_utilities.h"

#include "ensenso_camera/conversion.h"
Expand Down
2 changes: 1 addition & 1 deletion ensenso_camera/src/texture_point_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Make sure cv_bridge is imported before image_transport. Otherwise
// getBinaryData with CV::mat overload will not be recognized.
#include <cv_bridge/cv_bridge.h>
#include "ensenso_camera/ros2/cv_bridge/cv_bridge.h"

#include "ensenso_camera/ros2/core.h"
#include "ensenso_camera/ros2/image_transport.h"
Expand Down
6 changes: 6 additions & 0 deletions ensenso_camera2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ if(NOT CMAKE_CXX_STANDARD)
endif()

add_compile_definitions(ROS2)
if(DEFINED ENV{ROS_DISTRO})
if($ENV{ROS_DISTRO} STREQUAL "jazzy")
add_compile_definitions(ROS2_JAZZY)
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down

0 comments on commit f21eee5

Please sign in to comment.