ROS Integration#

Most of the Ignition libraries use Ignition Transport to exchange data between different software components. This tutorial details how to interface with ROS, enabling the ability to use tools such as Rviz for robot or sensor visualization.

Important: The packages documented here used to have the ros1_ prefix instead of ros_. Please update your code accordingly in order to avoid adverse effects.

ros_ign_bridge to the rescue#

ros_ign_bridge provides a network bridge which enables the exchange of messages between ROS 1 and Ignition Transport. Its support is limited to only certain message types. Please, read this README to verify if your message type is supported by the bridge.

How to install ros_ign_bridge#

Binary install#

Citadel binaries are available for ROS Noetic and Foxy. Check out the table on ros_ign for other combinations.

For example, to install on Noetic use:

sudo apt install ros-noetic-ros-ign

Source install#

See the prerequisites and install section of the bridge documentation. This tutorial requires Ubuntu Bionic or newer.

Assuming that you have ROS Melodic, you can install all dependencies with:

sudo apt install ros-melodic-desktop ros-melodic-rqt-image-view libignition-common3-dev libignition-transport8-dev libignition-msgs5-dev

Run the bridge and exchange images#

In this example, we’re going to generate Ignition Transport images using Gazebo, that will be converted into ROS 1 images, and visualized with rqt_viewer.

First we start a ROS 1 roscore:

# Shell A:
. /opt/ros/melodic/setup.bash
roscore

Then we start Gazebo.

# Shell B:
ign gazebo -r camera_sensor.sdf
# if you don't see the camera image in the Image Display and it stays grey, press the orange refresh button

Gazebo should be running and publishing images over the /camera topic. Let’s verify it:

# Shell C:
ign topic -l | grep "^/camera"
/camera

Then we start the parameter bridge with the previous topic. To run the bridge:

# Shell D:
. /opt/ros/melodic/setup.bash
# If installed from source, make sure you've sourced the ros-ign packages too
rosrun ros_ign_bridge parameter_bridge /camera@sensor_msgs/Image@ignition.msgs.Image

Now we start the ROS 1 GUI:

# Shell E:
. /opt/ros/melodic/setup.bash
sudo apt-get install ros-melodic-rqt-image-view
rqt_image_view /camera

You should see the current images in rqt_image_view which are coming from Gazebo (published as Ignition Msgs over Ignition Transport).

The screenshot shows all the shell windows and their expected content (it was taken using ROS Melodic):

Ignition Transport images and ROS 1 rqt