ros2 / ros1_bridge

ROS 2 package that provides bidirectional communication between ROS 1 and ROS 2
Apache License 2.0
452 stars 288 forks source link

Building ROS bridge issue #329

Closed xander-m2k closed 3 years ago

xander-m2k commented 3 years ago

Bug report

Required Info:

Steps to reproduce issue

Install both debian packages for Noetic and Foxy: http://wiki.ros.org/noetic/Installation/Ubuntu and https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html Download the https://github.com/iirob/ros_opcua_communication repo and build a ROS1 workspace. (just catkin_make) Download the https://github.com/TechmanRobotInc/tmr_ros2 repo and build a ROS2 workspace. (just colcon build)

Use the ros1-bridge installation instructions (this repository) to source both environments and build the ros1 bridge.

Expected behavior

Should compile

Actual behavior

/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_1_to_2(controller_manager_msgs::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::msg::ControllerState_<std::allocator<void> >&)'
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_2_to_1(controller_manager_msgs::msg::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::ControllerState_<std::allocator<void> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/parameter_bridge.dir/build.make:368: parameter_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:252: CMakeFiles/parameter_bridge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_1_to_2(controller_manager_msgs::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::msg::ControllerState_<std::allocator<void> >&)'
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_2_to_1(controller_manager_msgs::msg::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::ControllerState_<std::allocator<void> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/static_bridge.dir/build.make:368: static_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:198: CMakeFiles/static_bridge.dir/all] Error 2
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_1_to_2(controller_manager_msgs::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::msg::ControllerState_<std::allocator<void> >&)'
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_2_to_1(controller_manager_msgs::msg::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::ControllerState_<std::allocator<void> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/dynamic_bridge.dir/build.make:368: dynamic_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:306: CMakeFiles/dynamic_bridge.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Additional information

I also tried excluding the tm_robot repo from the build, but I got the same error. The OPCUA library built before, so that should not be the problem.

xander-m2k commented 3 years ago

Reinstalling both ROS distros solved the problem

LoyVanBeek commented 3 years ago

Since reinstalling both ROS distros was a bit drastic :sweat_smile: , I simply removed the controller_manager_msgs from both my ROS Noetic and Foxy installs and could then compile successfully.

christianlandgraf commented 2 years ago

I'm struggling with the same error when trying to build the ros1_bridge from source. Do you know a more convenient way to avoid this issue? For example, excluding this message type during the build? It's messing up my workspaces quite a bit when trying to remove the packages...

LoyVanBeek commented 2 years ago

Have not found one, unfortunately. After the initial --force-cmake (or colcon equivalent, from top of my head) build, I could build fine without this flag for colcon and with controller_manager_msgs re-installed, which makes things a bit less painful.

likemountain commented 2 years ago

Hello, I am having the same error when building the ros1_bridge. @LoyVanBeek How did you remove and re-install controller_manager_msgs? Could you explain more detailed procedures to do this?

LoyVanBeek commented 2 years ago

It's embarrassingly simple and not a real fix at all:

  1. sudo apt remove ros-noetic-controller-manager-msgs
  2. Copy & paste all the pkgs that are now going to be uninstalled because they depend on the ros-noetic-controller-manager-msgs :cry:
  3. Build ros1_bridge as per instructions
  4. sudo apt install ros-noetic-controller-manager-msgs + the pkgs remembered from step 2. That is all there is to it.
LoyVanBeek commented 2 years ago

Alternatively, you can (of course, in hindsight) remove sudo apt remove ros-foxy-controller-manager-msgs and leave the noetic version in place. Which is better depens on your setup and which package has more dependents.

Still a workaround and not a real fix from me unfortunately.

awied1404 commented 2 years ago

I had the exact same setup/error and controller_manager_msgs installed in both ROS Distros. For me the solution was to just ignore the error because the binaries were built (don't know exactly why) and I could go on with the tutorials like described in the README and they all worked for me

LoyVanBeek commented 1 year ago

I think https://github.com/ros2/ros1_bridge/pull/382 is related to this problem. Not entirely because my PR does not fix this issue here, but the solution is somewhere around there...