Robotics StackExchange | Archived questions

ros1_bridge installation error "libros1_bridge.so: undefined reference to controller_manager_msgs"

Hello,

I am trying to install ros1_bridge inside a NUC. On this NUC I have installed: the Ubuntu 20.04.4 LTS OS; the ros-noetic-desktop-full of ROS1 Noetic; the ros-foxy-desktop and ros-foxy-ros-base of ROS2 Foxy.

I followed the steps of the ros1bridge repository (https://github.com/ros2/ros1bridge), both the foxy branch steps and the master branch steps. But, in both cases I got the same error when I compiled the ros1_bridge with the command:

colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure

These are all the steps I have followed.

First, in a Shell_1 I have compiled my ROS1 code:

source /opt/ros/noetic/setup.bash
cd ~/catkin_ws/
catkin build
source devel/setup.bash

Then, in a Shell_2 I compiled my ROS2 code:

source /opt/ros/foxy/setup.bash
cd ~/colcon_ws
colcon build --symlink-install
source install/setup.bash

In another terminal that does not have the ROS 1 environment sourced (Shell3), I have tried to install ros1bridge unsuccessfully by doing the following:

source /opt/ros/foxy/setup.bash    
mkdir -p ~/ros1_bridge/src
cd ~/ros1_bridge/src
git clone -b foxy https://github.com/ros2/ros1_bridge.git
cd ~/ros1_bridge
colcon build --symlink-install --packages-skip ros1_bridge

source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash
source /opt/ros/foxy/setup.bash
source ~/colcon_ws/install/setup.bash

colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure

And this is the error I get during compilation:

/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:451: parameter_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:314: 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:451: static_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:233: CMakeFiles/static_bridge.dir/all] Error 2
/usr/bin/ld: warning: libconsole_bridge.so.0.4, needed by /opt/ros/noetic/lib/libcpp_common.so, may conflict with libconsole_bridge.so.1.0
/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:451: dynamic_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:341: CMakeFiles/dynamic_bridge.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< ros1_bridge [8min 6s, exited with code 2]

Summary: 0 packages finished [8min 6s]
  1 package failed: ros1_bridge
  1 package had stderr output: ros1_bridge

I have tried to remove the packages ros-noetic-controller-manager-msgs and ros-foxy-controller-manager-msgs, and reinstall them again. But I still get the same error.

Do you know what I might be doing wrong, or what I might be wrong?

Thank you in advance for any help you can give me.

Asked by sanmool on 2022-08-10 07:28:38 UTC

Comments

Answers

Hello,

I finally got the compilation working. These are the steps I followed:

I deleted the ros1_bridge workspace:

rm -rf ~/ros1_bridge

Then, I uninstalled the ros controller-manager-msgs packages:

sudo apt remove ros-noetic-controller-manager-msgs
sudo apt remove ros-foxy-controller-manager-msgs
sudo apt purge ros-noetic-controller-manager-msgs
sudo apt purge ros-foxy-controller-manager-msgs

After that, I re-created the ros1_bridge workspace and again followed the installation steps from the repository (https://github.com/ros2/ros1_bridge).

source /opt/ros/foxy/setup.bash    
sudo apt update
mkdir -p ~/ros1_bridge_ws/src
cd ~/ros1_bridge_ws/src
git clone -b foxy https://github.com/ros2/ros1_bridge.git
cd ~/ros1_bridge_ws
colcon build --symlink-install --packages-skip ros1_bridge

source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash
source /opt/ros/foxy/setup.bash
source ~/colcon_ws/install/setup.bash

colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure

Once the compilation finished successfully, I reinstalled the ros controller-manager-msgs packages:

sudo apt update
sudo apt install ros-noetic-controller-manager-msgs
sudo apt install ros-foxy-controller-manager-msgs

Finally, I tested that the bridge worked!

Asked by sanmool on 2022-08-11 00:58:46 UTC

Comments