swri-robotics / marti_common

Common utility functions for MARTI
BSD 3-Clause "New" or "Revised" License
53 stars 62 forks source link

Issue Compiling swri_image_util Package in ROS2 Galactic #728

Closed marcusvinicius178 closed 8 months ago

marcusvinicius178 commented 8 months ago

Hello,

I am currently working with the marti_common repository, specifically with the swri_image_util package in a ROS2 Galactic environment (the packages are used by this tutorial https://navigation.ros.org/tutorials/docs/navigation2_with_gps.html).

I need a local source installation since using binary I cannot switch the QoS of swri_transform_util origin initialization from RELIABLE to BEST_EFFORT to match the publisher of the GPS plugin on /gps/fix topic which is BEST_EFFORT. So the mapviz and transform won't work with binary installation (at least for Galactic).

That being said, I am encountering a compilation issue that I haven't been able to resolve.

Environment:

ROS2 Galactic Repository: marti_common, branch ros2-devel

Issue Description:

While trying to compile the swri_image_util package, I am consistently facing linker errors related to OpenCV functions, such as cv::line, cv::rectangle, and others. These errors suggest that the OpenCV libraries are not being properly linked.

Steps to Reproduce:

Clone the marti_common repository from the ros2-devel branch. Attempt to build the package using colcon build --symlink-install --packages-select swri_image_util. Error Output: The error output indicates undefined references to several OpenCV functions, e.g.,

/usr/bin/ld: libswri_image_util.so: undefined reference tocv::line(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)'`

I have verified that other packages in the same workspace that use OpenCV are compiling correctly ( I mean I was able to compile all packages from the marti_common repo, except the swri_image_util). I have tried modifying the CMakeLists.txt to adjust the order of linked libraries and ensure that all necessary OpenCV components are included.

A test script using the same OpenCV functions compiles and runs successfully, suggesting that the OpenCV installation is functional.

CMakeLists.txt: I have attached my CMakeLists.txt for reference: CMakeLists.txt

Given the above, it seems like there might be an issue specific to the swri_image_util package's configuration or compatibility with ROS2 Galactic.

REQUEST

I would appreciate any guidance or suggestions on how to resolve these compilation issues. Additionally, I noticed that the replace_colors_node has not been ported from ROS 1 yet due to extensive changes in ROS parameters. Could this be related to the issue I am experiencing? If there are specific modifications needed for ROS Galactic, could you please advise?

Thank you for your time and help.

marcusvinicius178 commented 8 months ago

Well, I have "fixed" this just cloning the repo for ros2 galactic and using just the swri_image_util from the galactic tag along with the other swri packages for the ros2-devel branch which I had in my workspace:

https://github.com/swri-robotics/marti_common/tree/galactic-eol

I am unsure what changed in the code or CMakeLists.txt ...but it worked...