Skip to content

Update cv_bridge header suffix for new ROS2 versions - .h was deprecated - #3461

Merged
remibettan merged 2 commits into
realsenseai:ros2-developmentfrom
Gilaadb:cv_bridge_sufix_update
May 19, 2026
Merged

remibettan merged 2 commits into
realsenseai:ros2-developmentfrom
Gilaadb:cv_bridge_sufix_update

Conversation

@Gilaadb

@Gilaadb Gilaadb commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

No description provided.

remibettan
remibettan previously approved these changes Dec 15, 2025

@remibettan remibettan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@remibettan

Copy link
Copy Markdown
Collaborator

Sorry, I need to walk back my earlier approval — looking at this more carefully I see a few issues:

1. The distro macros (HUMBLE, IRON, GALACTIC, FOXY) are not defined anywhere in realsense2_rgbd_plugin. They are only set in realsense2_camera/CMakeLists.txt, not for this package. So on every distro the #else branch is taken and cv_bridge.hpp is always included — which means the build will now break on Foxy/Galactic (and older Humble), the exact distros the conditional was meant to protect.

2. realsense2_rgbd_plugin/src/ros_image_texture.cpp still has the bare #include <cv_bridge/cv_bridge.h>. Same package, same problem — so even on the newer distros this PR is meant to fix, the package still won't build.

3. It diverges from the existing pattern in the repo. realsense2_camera/include/base_realsense_node.h already solves this with a version-based guard:

#if defined(CV_BRDIGE_HAS_HPP)
#include <cv_bridge/cv_bridge.hpp>
#else
#include <cv_bridge/cv_bridge.h>
#endif

driven by realsense2_camera/CMakeLists.txt which checks cv_bridge_VERSION >= 3.3.0. That's the correct approach — it works regardless of distro name and matches the cv_bridge upstream guidance.

Suggested changes:

  • Apply the same fix to ros_image_texture.cpp.
  • Reuse the CV_BRDIGE_HAS_HPP pattern instead of hardcoded distro names — add the equivalent cv_bridge_VERSION check to realsense2_rgbd_plugin/CMakeLists.txt and use #if defined(CV_BRDIGE_HAS_HPP) in both files.

@remibettan
remibettan dismissed their stale review May 18, 2026 13:06

Dismissing on second look — issues identified in follow-up comment (undefined distro macros, ros_image_texture.cpp still uses cv_bridge.h, and diverges from the CV_BRDIGE_HAS_HPP pattern already used in realsense2_camera).

Gilaadb and others added 2 commits May 18, 2026 16:10
Replaces the GALACTIC/FOXY/HUMBLE/IRON conditional with the
CV_BRDIGE_HAS_HPP definition driven by cv_bridge_VERSION >= 3.3.0,
matching the pattern already used in realsense2_camera. The distro
macros were never defined for realsense2_rgbd_plugin, so the previous
guard always selected cv_bridge.hpp regardless of distro.

Also applies the same include guard to ros_image_texture.cpp, which
was still using the deprecated cv_bridge.h header unconditionally.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@remibettan
remibettan force-pushed the cv_bridge_sufix_update branch from bb0796a to c52cd44 Compare May 18, 2026 13:12
@remibettan
remibettan requested a review from Nir-Az May 18, 2026 13:15

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@remibettan
remibettan merged commit ac4b104 into realsenseai:ros2-development May 19, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants