Skip to content
Merged
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
8 changes: 4 additions & 4 deletions apriltag_detector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ find_package(rclcpp)
find_package(rclcpp_components)
find_package(sensor_msgs REQUIRED)

if(${cv_bridge_VERSION} VERSION_GREATER_EQUAL "4.0.0")
add_definitions(-DUSE_CV_BRIDGE_HPP)
endif()

if(${rclcpp_VERSION} VERSION_GREATER_EQUAL "28.0.0")
add_definitions(-DUSE_MATCHED_EVENTS)
endif()
Expand All @@ -43,6 +39,10 @@ if(${image_transport_VERSION} VERSION_GREATER_EQUAL "6.3.0")
add_definitions(-DIMAGE_TRANSPORT_USE_QOS)
endif()

if(${image_transport_VERSION} VERSION_GREATER_EQUAL "6.4.0")
add_definitions(-DIMAGE_TRANSPORT_USE_NODEINTERFACE)
endif()

#
# --------- header-only library
#
Expand Down
9 changes: 7 additions & 2 deletions apriltag_detector/src/detector_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.

#include <apriltag_detector/detector_component.hpp>
#ifdef USE_CV_BRIDGE_HPP
#if __has_include(<cv_bridge/cv_bridge.hpp>)
#include <cv_bridge/cv_bridge.hpp>
#else
#include <cv_bridge/cv_bridge.h>
Expand Down Expand Up @@ -109,7 +109,12 @@ void DetectorComponent::subscribe()
const auto profile = string_to_profile(image_qos_profile_);
image_sub_ = std::make_shared<image_transport::Subscriber>(
image_transport::create_subscription(
this, "image",
#ifdef IMAGE_TRANSPORT_USE_NODEINTERFACE
*this,
#else
this,
#endif
"image",
std::bind(&DetectorComponent::callback, this, std::placeholders::_1),
in_transport_, convert_profile(profile)));
is_subscribed_ = true;
Expand Down
9 changes: 5 additions & 4 deletions apriltag_draw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ set(ament_dependencies
${sensor_msgs_TARGETS}
${apriltag_msgs_TARGETS})

if(${cv_bridge_VERSION} VERSION_GREATER_EQUAL "4.0.0")
add_definitions(-DUSE_CV_BRIDGE_HPP)
endif()

if(${rclcpp_VERSION} VERSION_GREATER_EQUAL "28.0.0")
add_definitions(-DUSE_MATCHED_EVENTS)
endif()

if(${image_transport_VERSION} VERSION_GREATER_EQUAL "6.3.0")
add_definitions(-DIMAGE_TRANSPORT_USE_QOS)
endif()

if(${image_transport_VERSION} VERSION_GREATER_EQUAL "6.4.0")
add_definitions(-DIMAGE_TRANSPORT_USE_NODEINTERFACE)
endif()

#
# --------- composable node library (public)
#
Expand Down
23 changes: 19 additions & 4 deletions apriltag_draw/src/apriltag_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.

#include <apriltag_draw/apriltag_draw.hpp>
#ifdef USE_CV_BRIDGE_HPP
#if __has_include(<cv_bridge/cv_bridge.hpp>)
#include <cv_bridge/cv_bridge.hpp>
#else
#include <cv_bridge/cv_bridge.h>
Expand Down Expand Up @@ -121,10 +121,20 @@ ApriltagDraw::ApriltagDraw(const rclcpp::NodeOptions & options)
}
};
image_pub_ = image_transport::create_publisher(
this, "image_tags", convert_profile(rmw_qos_profile_default), pub_options);
#ifdef IMAGE_TRANSPORT_USE_NODEINTERFACE
*this,
#else
this,
#endif
"image_tags", convert_profile(rmw_qos_profile_default), pub_options);
#else
image_pub_ = image_transport::create_publisher(
this, "image_tags", convert_profile(rmw_qos_profile_default));
#ifdef IMAGE_TRANSPORT_USE_NODEINTERFACE
*this,
#else
this,
#endif
"image_tags", convert_profile(rmw_qos_profile_default));

// Since the early ROS2 image transport does not call back when
// subscribers come and go: must check by polling
Expand All @@ -149,7 +159,12 @@ void ApriltagDraw::subscribe()
std::bind(&ApriltagDraw::tagCallback, this, std::placeholders::_1));
image_sub_ = std::make_shared<image_transport::Subscriber>(
image_transport::create_subscription(
this, "image",
#ifdef IMAGE_TRANSPORT_USE_NODEINTERFACE
*this,
#else
this,
#endif
"image",
std::bind(&ApriltagDraw::imageCallback, this, std::placeholders::_1),
transport_, convert_profile(qos_profile_)));
is_subscribed_ = true;
Expand Down