robotology / yarp-devices-ros2

Plugins, devices and network wrappers for Yarp-ROS2 interoperation
http://www.yarp.it
9 stars 8 forks source link

Cannot build the devices with ROS 2 Iron #61

Open PasMarra opened 9 months ago

PasMarra commented 9 months ago

I am using ros2 iron on Ubuntu 22.04 and I am having difficulties to build the devices.

I am following the pure CMake-based installation instructions in https://github.com/robotology/yarp-devices-ros2#build-with-pure-cmake-commands.

The built stops with the following errors:

 62%] Linking CXX shared library ../../../lib/libyarp_control_msgs__rosidl_typesupport_introspection_cpp.so
[ 62%] Built target yarp_control_msgs__rosidl_typesupport_introspection_cpp
[ 62%] Built target yarp_control_msgs
[ 62%] Built target ament_cmake_python_copy_yarp_control_msgs
/usr/bin/python3.10: can't open file '/home/user/yarp-devices-ros2/build/ros2_interfaces_ws/src/yarp_control_msgs/ament_cmake_python/yarp_control_msgs/setup.py': [Errno 2] No such file or directory
gmake[2]: *** [ros2_interfaces_ws/src/yarp_control_msgs/CMakeFiles/ament_cmake_python_build_yarp_control_msgs_egg.dir/build.make:70: ros2_interfaces_ws/src/yarp_control_msgs/CMakeFiles/ament_cmake_python_build_yarp_control_msgs_egg] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:1482: ros2_interfaces_ws/src/yarp_control_msgs/CMakeFiles/ament_cmake_python_build_yarp_control_msgs_egg.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Is ros2 iron supported or should I use a different version of ros2? Or are the above errors due to something else?

Thank you

cc @elandini84 @randaz81

elandini84 commented 9 months ago

Hi @PasMarra, do you get, by any chance, an error message also from cmake?

xEnVrE commented 9 months ago

I think we also got the following errors at CMake-level:

CMake Error: Files to be generated by multiple different commands: "/home/user/yarp-devices-ros2/build/ament_cmake_environment_hooks/ament_prefix_path.dsv"
CMake Error: Files to be generated by multiple different commands: "/home/user/yarp-devices-ros2/build/ament_cmake_environment_hooks/library_path.dsv"

I have reproduced it again using also ros rolling. I am start thinking the problem might be due to CMake itself.

elandini84 commented 9 months ago

@xEnVrE thanks for the reply. I asked about cmake because I get the same exact error that you shown. The issue has definitely something to do with CMake because when I change the order in which the two ros2_interfaces_ws packages folders are added, the error that @PasMarra has shown is not triggered by yarp_control_msgs but by map2d_nws_ros2_msgs. I'll try to come up with a solution tomorrow.

Thanks again for opening this issue

xEnVrE commented 9 months ago

Thanks a lot, that means that, meanwhile, as we only need yarp_control_msgs, we can just disable the nav part and we should be able to continue?

elandini84 commented 9 months ago

That should work, yes.

traversaro commented 9 months ago

Possibily related to https://github.com/ament/ament_cmake/issues/460 .

traversaro commented 9 months ago

This is a regression related to https://github.com/ament/ament_cmake/pull/416, see also the related comment.

traversaro commented 9 months ago

I proposed a fix upstream in ROS 2 Iron in https://github.com/ament/ament_cmake/pull/484 . However, even if it is accepted it would take some time to have it released as a .deb package, so we may want to find a workaround in the meanwhile.

traversaro commented 9 months ago

@PasMarra @xEnVrE can you check if https://github.com/robotology/yarp-devices-ros2/pull/62 solves the problem? Remember to try it on a clean build, as otherwise the AMENT_CMAKE_ENVIRONMENT_PACKAGE_GENERATION option is already initialized to ON.

xEnVrE commented 9 months ago

@traversaro I can check if it works, just the time to setup the docker container and I'll let you know!

xEnVrE commented 9 months ago

Remember to try it on a clean build

Maybe it is a dumb question, is it ok if I remove the build folder of yarp-devices-ros2 to achieve that or do you mean something different ros2-wise?

If a standard build clean is what you meant, I have already tried it but I keep receiving the error:

-- Configuring done
CMake Error: Files to be generated by multiple different commands: "/home/user/yarp-devices-ros2/build/ament_cmake_environment_hooks/ament_prefix_path.dsv"
CMake Error: Files to be generated by multiple different commands: "/home/user/yarp-devices-ros2/build/ament_cmake_environment_hooks/library_path.dsv"
-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
traversaro commented 9 months ago

If a standard build clean is what you meant, I have already tried it but I keep receiving the error:

Yes, I mean removing the build directory (not make clean). It is strange you still get the problem, what is the output of (please run in the build directory):

cat CMakeCache.txt | grep AMENT_CMAKE_ENVIRONMENT_PACKAGE_GENERATION 
xEnVrE commented 9 months ago

What I did was

rm -rf build
mkdir build
cd build
cmake ../

Then I get the errors above.

The output of what you asked is then:

AMENT_CMAKE_ENVIRONMENT_PACKAGE_GENERATION:BOOL=ON
traversaro commented 9 months ago

Sorry, there was a stupid bug, can you try in a clean build updating after https://github.com/robotology/yarp-devices-ros2/pull/62/commits/10351e6a845641625766ffe6698ed4c0c1fcfe70 ?

xEnVrE commented 9 months ago

Considering the last change I get

-- Configuring done
CMake Error: Files to be generated by multiple different commands: "/home/user/yarp-devices-ros2/build/ament_cmake_environment_hooks/ament_prefix_path.dsv"
CMake Error: Files to be generated by multiple different commands: "/home/user/yarp-devices-ros2/build/ament_cmake_environment_hooks/library_path.dsv"
-- Generating done

and

cat CMakeCache.txt | grep AMENT_CMAKE_ENVIRONMENT_PACKAGE_GENERATION 
AMENT_CMAKE_ENVIRONMENT_PACKAGE_GENERATION:BOOL=OFF
traversaro commented 9 months ago

You are right, my environment was dirty. I played a bit but I could not find an easy workaround.

traversaro commented 9 months ago

The fix was merged upstream in https://github.com/ament/ament_cmake/pull/484. Looking at the history of iron syncs (see https://discourse.ros.org/tag/iron), I think we could expect the fix to land in .deb in a few weeks.

xEnVrE commented 9 months ago

Thanks for the update @traversaro

traversaro commented 8 months ago

The fix was merged upstream in ament/ament_cmake#484. Looking at the history of iron syncs (see https://discourse.ros.org/tag/iron), I think we could expect the fix to land in .deb in a few weeks.

Actually that was just a merge in rolling, the backport PR to iron got stuck: https://github.com/ament/ament_cmake/pull/487 .

traversaro commented 3 months ago

The fix was merged upstream in ament/ament_cmake#484. Looking at the history of iron syncs (see https://discourse.ros.org/tag/iron), I think we could expect the fix to land in .deb in a few weeks.

Actually that was just a merge in rolling, the backport PR to iron got stuck: ament/ament_cmake#487 .

The PR was merged, and it was released in February: https://github.com/ament/ament_cmake/commit/ff9a01f13ceacb381b99a8dec2eafa321b5f34f9 and https://discourse.ros.org/t/patch-release-4-and-new-packages-for-iron-irwini-2024-02-09/36006, I think we can safely close this issue.