open-rmf / rmf_obstacle

Packages that infer the presence of obstacles from sensor inputs.
Apache License 2.0
6 stars 10 forks source link

[Other issue]: CMake error when building rmf_obstacle_ros2 #27

Closed Jerrybaoyilei closed 6 months ago

Jerrybaoyilei commented 6 months ago

Before proceeding, is there an existing issue or discussion for this?

Description

Setup: Ubuntu 22.04, ROS 2 Humble

Hi @Yadunund , I am trying to build (with colcon build) and run the rmf_obstacle_ros2 package, but I ran into a series of CMake Errors shown below.

I have cloned rmf_demos package into my Ubuntu 22.04 machine, and also cloned the rmf_obstacle_detector_laserscan and rmf_obstacle_ros2 as sibling folders of rmf_demos. rmf_demos has been running fine.

Below is a reference for the current file structure:

- rmf_ws
  - src
    - rmf_demos
    - rmf_traffic_ros2
    - rmf_obstacle_ros2
    - rmf_obstacle_detector_laserscan

I double checked that lane_blocker is part of rmf_obstacle_ros2. I also ran ros2 pkg prefix rmf_traffic_ros2 and it points to the rmf_traffic_ros2's installation in the install folder (which is a sibling of the src folder)

Below are the errors shown in the terminal:

CMake Error at CMakeLists.txt:73 (add_library):
  Target "lane_blocker" links to target
  "rmf_traffic_ros2::rmf_traffic_schedule" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?

CMake Error at CMakeLists.txt:73 (add_library):
  Target "lane_blocker" links to target
  "rmf_traffic_ros2::rmf_traffic_schedule_monitor" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

CMake Error at CMakeLists.txt:73 (add_library):
  Target "lane_blocker" links to target
  "rmf_traffic_ros2::rmf_traffic_blockade" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?

CMake Error at CMakeLists.txt:73 (add_library):
  Target "lane_blocker" links to target
  "rmf_traffic_ros2::update_participant" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?

CMake Generate step failed.  Build files cannot be regenerated correctly.
Yadunund commented 6 months ago

ROS 2 Humble is not supported. Please try with Iron or Rolling.

Yadunund commented 6 months ago

Setup: Ubuntu 22.04, ROS 2 Humble

Could you clarify if you're building Open-RMF from source and if so, which branches you have checked out?

My previous comment assumed that you have Open-RMF Humble binaries installed and you're building rmf_obstacle on main with the Open-RMF humble binaries sourced.

If you want to use ROS 2 Humble to build rmf_obstacle packages on main, you will need to also build all of Open-RMF packages with their main branches checked out.

Jerrybaoyilei commented 6 months ago

Hi @Yadunund, I am building Open-RMF from binaries, not from source. Your assumption in the previous comments are correct.

In "you will need to also build all of Open-RMF packages with their main branches checked out", which packages are you referring to? Only rmf_traffic_ros2 and rmf_obstacle, or including some other packages?

Also, does building rmf_demos from source (but still with ROS 2 Humble) make a difference? Or if it's better to remove ROS 2 Humble, install ROS 2 Iron, and then install the corresponding version of rmf_demos for ROS 2 Iron?

Thank you!

Jerrybaoyilei commented 6 months ago

Hi @Yadunund , I modified the CMakeLists.txt file and added set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /opt/ros/humble /home/jbao/boston_office_ws/src/rmf_ros2/rmf_traffic_ros2) to force colcon build to build the rmf_traffic_ros2 that I cloned from the rmf_ros2 repo, instead of the one that was installed system-wide in /opt/ros/humble. The previous errors are gone, but a new error related to lane_blocker has occured. Is this related to what you mentioned about "ROS 2 Humble is not supported"? I've pasted the error message below. Thank you!

In file included from /home/jbao/boston_office_ws/src/rmf_obstacle/rmf_obstacle_ros2/src/lane_blocker/LaneBlocker.hpp:35,
                 from /home/jbao/boston_office_ws/src/rmf_obstacle/rmf_obstacle_ros2/src/lane_blocker/LaneBlocker.cpp:19:
/opt/ros/humble/include/tf2_ros/tf2_ros/message_filter.h: In instantiation of ‘void tf2_ros::MessageFilter<M, BufferT>::add(const MEvent&) [with M = rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> >; BufferT = tf2_ros::Buffer; tf2_ros::MessageFilter<M, BufferT>::MEvent = message_filters::MessageEvent<const rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> > >]’:
/opt/ros/humble/include/tf2_ros/tf2_ros/message_filter.h:603:8:   required from ‘void tf2_ros::MessageFilter<M, BufferT>::incomingMessage(const message_filters::MessageEvent<const M>&) [with M = rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> >; BufferT = tf2_ros::Buffer]’
/opt/ros/humble/include/tf2_ros/tf2_ros/message_filter.h:265:46:   required from ‘void tf2_ros::MessageFilter<M, BufferT>::connectInput(F&) [with F = message_filters::Subscriber<rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> > >; M = rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> >; BufferT = tf2_ros::Buffer]’
/home/jbao/boston_office_ws/src/rmf_obstacle/rmf_obstacle_ros2/src/lane_blocker/LaneBlocker.cpp:224:38:   required from here
/opt/ros/humble/include/tf2_ros/tf2_ros/message_filter.h:365:60: error: ‘value’ is not a member of ‘message_filters::message_traits::FrameId<rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> >, void>’
  365 |     std::string frame_id = stripSlash(mt::FrameId<M>::value(*message));
      |                                       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:24,
                 from /opt/ros/humble/include/rclcpp/rclcpp/client.hpp:40,
                 from /opt/ros/humble/include/rclcpp/rclcpp/callback_group.hpp:24,
                 from /opt/ros/humble/include/rclcpp/rclcpp/any_executable.hpp:20,
                 from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategy.hpp:25,
                 from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategies.hpp:18,
                 from /opt/ros/humble/include/rclcpp/rclcpp/executor_options.hpp:20,
                 from /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:37,
                 from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25,
                 from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21,
                 from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155,
                 from /home/jbao/boston_office_ws/src/rmf_obstacle/rmf_obstacle_ros2/src/lane_blocker/LaneBlocker.hpp:21,
                 from /home/jbao/boston_office_ws/src/rmf_obstacle/rmf_obstacle_ros2/src/lane_blocker/LaneBlocker.cpp:19:
/opt/ros/humble/include/tf2_ros/tf2_ros/message_filter.h:411:9: error: ‘value’ is not a member of ‘message_filters::message_traits::FrameId<rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> >, void>’
  411 |         TF2_ROS_MESSAGEFILTER_DEBUG(
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [CMakeFiles/lane_blocker.dir/build.make:90: CMakeFiles/lane_blocker.dir/src/lane_blocker/LaneBlocker.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:184: CMakeFiles/lane_blocker.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< rmf_obstacle_ros2 [10.6s, exited with code 2]
Yadunund commented 6 months ago

To clarify, there are two sets of binaries

  1. ROS 2 binaries
  2. Open-RMF binaries

If you're really keen on building everything with ROS 2 Humble binaries, you will need to build

Hence, I recommend relying on Iron binaries of ROS 2 and Open-RMF. Or Iron binaries of ROS 2 and build all of Open-RMF including this repo from source with ROS 2 Iron binaries sourced. rosdep will install all necessary dependencies.

Jerrybaoyilei commented 6 months ago

Sounds good. I will try Iron and report back if there are still errors. Thank you for the reply!

Jerrybaoyilei commented 6 months ago

Hi @Yadunund , I've installed the Iron binaries of ROS 2 and Open-RMF. However, when I tried colcon build, I am still having a similar error for building rmf_obstacle_ros2 as when I was using the Humble binaries of ROS 2 and Open-RMF. The error is: /opt/ros/iron/include/tf2_ros/tf2_ros/message_filter.h:365:60: error: ‘value’ is not a member of ‘message_filters::message_traits::FrameId<rmf_obstacle_msgs::msg::Obstacles_<std::allocator<void> >, void>’

Yadunund commented 6 months ago

Ah that's strange. I assume you opened a new terminal to source Iron and build the workspace? Did you do a clean build, ie run rm -rf build/ install/ log/ before running colcon build?

Could you share the version of tf2_ros binary installed by running dpkg -l | grep ros-iron-tf2-ros. Mine is 0.31.5.

Kindly also share the latest installation steps you followed to setup the workspace that you're building.

Jerrybaoyilei commented 6 months ago

Hi @Yadunund , yes I opened a new terminal, sourced iron (the sourcing code was actually added to bash script so it does it every time I open a new terminal window). I also tried the clean build by manually deleting the build, install, and log folders before running colcon build.

An update after I tried to solve this problem earlier today: since Obstacle.msg is part of rmf_obstacle_msgs, I downloaded the source code of rmf_obstacle_msgs (main branch) from here.

I also added find_package(rmf_obstacle_msgs REQUIRED PATHS /home/jbao/ NO_DEFAULT_PATH) to CMakeLists.txt of rmf_obstacle_detector_laserscan and rmf_obstacle_ros2, so that these two packages should look for rmf_obstacle_msgs at this path (where I have the source code) instead of the default ROS path (i.e., /opt/ros/iron).

After a clean build, I now ran into this following error:

CMake Error at CMakeLists.txt:50 (find_package):
  Could not find a package configuration file provided by "rmf_obstacle_msgs"
  with any of the following names:

    rmf_obstacle_msgsConfig.cmake
    rmf_obstacle_msgs-config.cmake

  Add the installation prefix of "rmf_obstacle_msgs" to CMAKE_PREFIX_PATH or
  set "rmf_obstacle_msgs_DIR" to a directory containing one of the above
  files.  If "rmf_obstacle_msgs" provides a separate development package or
  SDK, be sure it has been installed.

I have checked that rmf_obstacle_msgsConfig.cmake exists in install/rmf_obstacle_msgs/share/rmf_obstacle_msgs/cmake. I have added set(CMAKE_PREFIX_PATH "/home/jbao/iron_migration_ws/install/rmf_obstacle_msgs/share/rmf_obstacle_msgs/cmake" ${CMAKE_PREFIX_PATH}) to CMakeLists.txt of rmf_obstacle_ros2, then deleted the build, install, and log folders, and then build, but this new error persists.

I don't have the linux machine with me at home, but I will check the version of tf2_ros tomorrow morning (I do have a 12 hour time difference, which makes this conversation move slowly, and apologies for that)

For installation, I uninstalled ROS 2 Humble following the official documentation of ROS 2 Iron.

I then installed ROS 2 Iron following the same official documentation.

I uninstalled rmf by running sudo apt purge ros-humble-rmf* && sudo apt autoremove. When installing rmf, I followed this page and went with binary install. Branch I used is 2.1.2 (i.e., I ran git clone https://github.com/open-rmf/rmf_demos.git -b 2.1.2).

Afterwards, I downloaded source code (didn't use git clone) of rmf_obstacle from here, under the main branch. I downloaded the source code of rmf_traffic_ros2 from here, also under the main branch. Also had to install backward_ros myself since that was missing when I tried to build these additional packages.

Jerrybaoyilei commented 6 months ago

Hi @Yadunund , I also have 0.31.5 for tf2_ros version

Jerrybaoyilei commented 6 months ago

Hi @Yadunund , I fixed it. I will try running the obstacle packages, and if I run into something during that, I will comment. Thank you!

Yadunund commented 6 months ago

May I ask what the issue was?

Jerrybaoyilei commented 6 months ago

Hi @Yadunund , of course, it was a mistake from my side. I didn't correctly set CMAKE_PREFIX_PATH to the installation prefix of rmf_obstacles_msgs in the CMakeLists.txt files for rmf_obstacle_ros2 and rmf_obstacle_detector_laserscan. Threfore, colcon build couldn't find rmf_obstacle_msgsConfig.cmake file.

In summary, while using Iron binaries of both ROS 2 and rmf, I also downloaded rmf_traffic_ros2 and rmf_obstacle_msgs in main branch (which come from rmf_ros2 and rmf_internal_msgs repositories, respectively). I also downloaded backward_ros from its repo. I put these additional packages inside rmf_demos, as sibling packages to other rmf_demos packages like rmf_demos_maps.

Jerrybaoyilei commented 6 months ago

@Yadunund also a follow up question. After the colcon build succeeded, I tried to run rmf_obstacle_detector_laserscan and rmf_obstacle_ros2. I also configured and activated the laserscan node.

However, I realized that when I configured the LiDAR model according to the gazebo tutorials, I don't think there is a part about sending LaserScan message to /laser/scan topic. I followed https://classic.gazebosim.org/tutorials?tut=guided_i1#Intro

Is there a tutorial that I missed, which talk about sending LaserScan message generated by LiDAR scanners to ROS topics?

Yadunund commented 6 months ago

Btw i've updated the binary package for rmf_obstacle_msgs on Iron such that it includes the new header field. https://github.com/ros/rosdistro/pull/40403 It should be released later this week so doing an apt update && apt upgrade will get you the latest version. Then you only need to build rmf_obstacle from source. Everything else can be binary. But if you're developing new features or fixes, its best to work with source versions of all Open-RMF packages.

However, I realized that when I configured the LiDAR model according to the gazebo tutorials, I don't think there is a part about sending LaserScan message to /laser/scan topic. I followed https://classic.gazebosim.org/tutorials?tut=guided_i1#Intro

You'll need to run the ros-gz bridge that converts gz topics to ROS 2 topics. There are examples here

Jerrybaoyilei commented 6 months ago

@Yadunund sounds good! Thank you for all the work! I will try with the suggested bridge. My understanding is I can use this bridge to convert the /gazebo/default/velodyne/top/sensor/scan topic to the /laser/scan ROS 2 topic, right?

Also may I ask what is causing the incompatibility issue between ROS 2 Humble binary & rmf Humble binary and rmf_obstacle_detector packages? Is it because the Humble versions of rmf_obstacle_msgs, rmf_traffic_ros2, and rmf_internal_msgs are incompatible with rmf_obstacle_detector packages?

I am asking because I have some modifications to rmf packages in Humble branch that I realize are different in Iron branch and/or main branch. If I only need to use the main branch version of some but not all rmf packages to go around the incompatibility issue, that would be great. Thanks!