ElettraSciComp / witmotion_IMU_ros

ROS wrapper for the family of IMU sensor devices manufactured by Witmotion Ltd.
MIT License
27 stars 31 forks source link

CMake error trying to find_package(witmotion_ros REQUIRED) #39

Open TagirAbuziarov opened 3 months ago

TagirAbuziarov commented 3 months ago

I'm working with WT901 module using docker image of ROS2 Iron and witmotion_ros (ros2 branch). witmotion_ros package works fine but when I try to specify witmotion_ros package as a dependency of my custom package I get an CMake error:

root@dc29fda62103:/ros2_ws# colcon build --packages-select test_dep
Starting >>> test_dep
--- stderr: test_dep                         
CMake Error at /ros2_ws/install/witmotion_ros/share/witmotion_ros/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package):
  Found package configuration file:

    /ros2_ws/install/witmotion_ros/share/witmotion_ros/cmake/witmotion_rosConfig.cmake

  but it set witmotion_ros_FOUND to FALSE so package "witmotion_ros" is
  considered to be NOT FOUND.
Call Stack (most recent call first):
  /ros2_ws/install/witmotion_ros/share/witmotion_ros/cmake/witmotion_rosConfig.cmake:41 (include)
  CMakeLists.txt:10 (find_package)

CMake Error at CMakeLists.txt:10 (find_package):
  Found package configuration file:

    /ros2_ws/install/witmotion_ros/share/witmotion_ros/cmake/witmotion_rosConfig.cmake

  but it set witmotion_ros_FOUND to FALSE so package "witmotion_ros" is
  considered to be NOT FOUND.

---
Failed   <<< test_dep [3.56s, exited with code 1]

Summary: 0 packages finished [5.05s]
  1 package failed: test_dep
  1 package had stderr output: test_dep

How to reproduce:

  1. Run Docker ROS2 Iron image
  2. Create ROS2 workspace directory /ros2_ws and src directory:
    mkdir -p /ros2_ws/src
  3. Clone witmotion_ros (ros2 branch) following the README.md https://github.com/ElettraSciComp/witmotion_IMU_ros/tree/ros2
  4. Modify CMakeLists.txt so it can be built with ROS2 Iron (hardcoded humble and it can not find tf2_geometry_msgs)
    # (otherwise there will be fatal error:
    # tf2_geometry_msgs/tf2_geometry_msgs.hpp: No such file or directory)
    sed -i -e 's/include_directories(\/opt\/ros\/humble\/include\/tf2_geometry_msgs)/include_directories(\/opt\/ros\/iron\/include\/tf2_geometry_msgs)/' \
    /ros2_ws/src/witmotion_ros/CMakeLists.txt

    and build it

    colcon build --packages-select witmotion_ros
  5. Create custom package "test_dep" using witmotion as dependency:
    cd /ros2_ws/src && ros2 pkg create test_dep --dependencies witmotion_ros
  6. Build test_dep package
    cd /ros2_ws
    colcon build --packages-select test_dep
lolddohaja commented 3 months ago

I resolved the find_package(witmotion_ros REQUIRED) error by making necessary modifications to the CMakeLists.txt. This approach successfully addressed the issue without needing to refer to the changes in PR #40.

TagirAbuziarov commented 2 months ago

I still can reproduce the issue, using both original repo and PR #40 alternately with steps described above (except modifying CMakeLists.txt in step 4, it fixed). Am I doing something wrong?