Skip to content

Commit

Permalink
FIX: include deprecated header
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Jan 28, 2024
1 parent bb00c2e commit 1cbb441
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
39 changes: 39 additions & 0 deletions mola_input_rosbag2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,42 @@ mola_add_library(
mrpt-obs
mrpt-ros2bridge
)

# Credits: https://gist.github.com/jtanx/96ded5e050d5ee5b19804195ee5cf5f9
function(pad_string output str padchar length)
string(LENGTH "${str}" _strlen)
math(EXPR _strlen "${length} - ${_strlen}")

if(_strlen GREATER 0)
string(REPEAT ${padchar} ${_strlen} _pad)
string(PREPEND str ${_pad})
endif()

set(${output} "${str}" PARENT_SCOPE)
endfunction()

# 2 hex digits for each version part:
# For example: "0.5.1" => "0x000501"
macro(mrpt_version_to_hex VER TARGET_VAR_NAME)
string(REGEX MATCHALL "[0-9]+" __parts "${${VER}}")

if(__parts)
list(GET __parts 0 __VERSION_NUMBER_MAJOR)
list(GET __parts 1 __VERSION_NUMBER_MINOR)
list(GET __parts 2 __VERSION_NUMBER_PATCH)
pad_string(__VERSION_NUMBER_MAJOR ${__VERSION_NUMBER_MAJOR} "0" 2)
pad_string(__VERSION_NUMBER_MINOR ${__VERSION_NUMBER_MINOR} "0" 2)
pad_string(__VERSION_NUMBER_PATCH ${__VERSION_NUMBER_PATCH} "0" 2)
set(${TARGET_VAR_NAME} "0x${__VERSION_NUMBER_MAJOR}${__VERSION_NUMBER_MINOR}${__VERSION_NUMBER_PATCH}")
else()
set(${TARGET_VAR_NAME} "0x000")
endif()
endmacro()

# Convert package versions to hex so they can be used in preprocessor for wider
# versions compatibility of "one-source for all":
mrpt_version_to_hex(cv_bridge_VERSION cv_bridge_VERSION_HEX)

target_compile_definitions(${PROJECT_NAME} PRIVATE CV_BRIDGE_VERSION=${cv_bridge_VERSION_HEX})

message(STATUS "Found: cv_bridge_VERSION: ${cv_bridge_VERSION} (${cv_bridge_VERSION_HEX})")
5 changes: 5 additions & 0 deletions mola_input_rosbag2/src/Rosbag2Dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
#include <tf2/convert.h>
#include <tf2/exceptions.h>

#if CV_BRIDGE_VERSION < 0x030400
#include <cv_bridge/cv_bridge.h>
#else
#include <cv_bridge/cv_bridge.hpp>
#endif

#include <nav_msgs/msg/odometry.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/serialization.hpp>
Expand Down

0 comments on commit 1cbb441

Please sign in to comment.