Skip to content

Commit

Permalink
feat: Add ROS 2 distribution-specific cv_bridge include guard
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejmajek committed Sep 15, 2024
1 parent 2a7f8ed commit e5a7898
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/perception/rai_whatisee/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# Determine ROS 2 distribution
if(DEFINED ENV{ROS_DISTRO})
if($ENV{ROS_DISTRO} STREQUAL "humble")
add_definitions(-DROS_DISTRO_HUMBLE)
elseif($ENV{ROS_DISTRO} STREQUAL "jazzy")
add_definitions(-DROS_DISTRO_JAZZY)
else()
message(WARNING "Unknown ROS 2 distribution: $ENV{ROS_DISTRO}. Defaulting to .hpp include.")
endif()
else()
message(WARNING "ROS_DISTRO environment variable not set. Defaulting to .hpp include.")
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
Expand Down
6 changes: 6 additions & 0 deletions src/perception/rai_whatisee/src/rai_whatisee_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if defined(ROS_DISTRO_HUMBLE)
#include <cv_bridge/cv_bridge.h>
#elif defined(ROS_DISTRO_JAZZY)
#include <cv_bridge/cv_bridge.hpp>
#else
#include <cv_bridge/cv_bridge.hpp> // Default to .hpp for future distributions
#endif

#include <mutex>
#include <opencv2/opencv.hpp>
Expand Down

0 comments on commit e5a7898

Please sign in to comment.