TommyChangUMD / ros-humble-ros1-bridge-builder

Create a ros-humble-ros1-bridge package that can be used directly in ROS2 Humble
MIT License
59 stars 14 forks source link

ros-humble-ros1-bridge-builder

Create a "ros-humble-ros1-bridge" package that can be used directly within Ubuntu 22.02 ROS2 Humble. Both amd64 and arm64 architectures are supported.

How to create this builder docker images:

  git clone https://github.com/TommyChangUMD/ros-humble-ros1-bridge-builder.git
  cd ros-humble-ros1-bridge-builder

  # By default, ros-tutorals support will be built: (bridging the ros-humble-example-interfaces package)
  docker build . -t ros-humble-ros1-bridge-builder

Alternative builds:

  # **[OPTIONAL]** If you don't want to build ros-tutorals support:
  docker build . --build-arg ADD_ros_tutorials=0 -t ros-humble-ros1-bridge-builder

  # **[OPTIONAL]** If you want to build grid-map support:  (bridging the ros-humble-grid-map package)
  docker build . --build-arg ADD_grid_map=1 -t ros-humble-ros1-bridge-builder

  # **[OPTIONAL]** If you want to build an example custom message:
  docker build . --build-arg ADD_custom_msgs=1 -t ros-humble-ros1-bridge-builder

How to create ros-humble-ros1-bridge package:

0.) Start from the latest Ubuntu 22.04 ROS 2 Humble Desktop system, create the "ros-humble-ros1-bridge/" ROS2 package:

    cd ~/
    apt update; apt upgrade
    apt -y install ros-humble-desktop
    docker run --rm ros-humble-ros1-bridge-builder | tar xvzf -
    docker rmi ros-humble-ros1-bridge-builder

How to use ros-humble-ros1-bridge:

1.) First start a ROS1 Noetic docker and bring up a GUI terminal, something like:

  rocker --x11 --user --privileged \
         --volume /dev/shm /dev/shm --network=host -- ros:noetic-ros-base-focal \
         'bash -c "sudo apt update; sudo apt install -y ros-noetic-rospy-tutorials tilix; tilix"'

Tha docker image used above, ros:noetic-ros-base-focal, is multi-platform. It runs on amd64 (eg., Intel and AMD CPUs) or arm64 architecture (eg., Raspberry PI 4B and Nvidia Jetson Orin). Docker will automatically select the correct platform variant based on the host's architecture.

You may need to install rocker first:

  sudo apt install python3-rocker

2.) Then, start "roscore" inside the ROS1 Noetic docker container

  source /opt/ros/noetic/setup.bash
  roscore

3.) Now, from the Ubuntu 22.04 ROS2 Humble system, start the ros1 bridge node.

  source /opt/ros/humble/setup.bash
  source ~/ros-humble-ros1-bridge/install/local_setup.bash
  ros2 run ros1_bridge dynamic_bridge
  # or try:
  ros2 run ros1_bridge dynamic_bridge --bridge-all-topics

3.) Back to the ROS1 Noetic docker container, run in another terminal tab:

  source /opt/ros/noetic/setup.bash
  rosrun rospy_tutorials talker

4.) Finally, from the Ubuntu 22.04 ROS2 Humble system, run in another terminal tab:

  source /opt/ros/humble/setup.bash
  ros2 run demo_nodes_cpp listener

How to add custom message from ROS1 and ROS2 source code

See an step 6.3 and 7 in the Dockerfile for an example.

Also see the troubleshoot section.

How to make it work with ROS1 master running on a different machine?

  source /opt/ros/humble/setup.bash
  source ~/ros-humble-ros1-bridge/install/local_setup.bash
  ROS_MASTER_URI='http://192.168.1.208:11311' ros2 run ros1_bridge dynamic_bridge
  # Note, change "192.168.1.208" above to the IP address of your Noetic machine.

Troubleshoot

Fixing "[ERROR] Failed to contact master":

If you have Noetic and Humble running on two different machines and have already set the ROS_MASTER_URI environment variable, you should check the network to ensure that the Humble machine can reach the Noetic machine via port 11311.

$ nc -v -z 192.168.1.208 11311
# Connection to 192.168.1.208 11311 port [tcp/*] succeeded!

Checking tf2 message / service:

$ ros2 run ros1_bridge dynamic_bridge --print-pairs | grep -i tf2
  - 'tf2_msgs/msg/TF2Error' (ROS 2) <=> 'tf2_msgs/TF2Error' (ROS 1)
  - 'tf2_msgs/msg/TFMessage' (ROS 2) <=> 'tf2_msgs/TFMessage' (ROS 1)
  - 'tf2_msgs/msg/TFMessage' (ROS 2) <=> 'tf/tfMessage' (ROS 1)
  - 'tf2_msgs/srv/FrameGraph' (ROS 2) <=> 'tf2_msgs/FrameGraph' (ROS 1)

Checking AddTwoInts message / service:

Checking grid-map message / service:

Checking example custom message:

Now, run the bridge

$ source ~/ros-humble-ros1-bridge/install/local_setup.bash $ ros2 run ros1_bridge dynamic_bridge --print-pairs | grep -i PseudoGridMap

References