Testing ROS Bridge on the TurtleBot3

ROS Bridge

Table of Contents


Overview

Introduction

My name is Salvatore and I am a Development Engineer at 株式会社Rist.

About this article

This article is meant to be a quick and direct introduction to the ROS Bridge, based on the official documentation.
This is the first article of a series related to my work at Rist.

About me

Present

Joined Rist in February 2020, currently part of the Development Team.
Responsible for Robotics R&D, and among other things, primarily working on the following topics:

  • Robot design, control, motion, perception and manipulation.
  • Image analysis, recognition and classification.
  • AI algorithms design and implementation.
  • UI/UX design and implementation.

Background

Graduated cum laude with a master's degree in Computer Science Engineering for Intelligent Systems at University of Palermo, Italy, presenting a Thesis in Robotics on a Brain-Computer Interface Framework.
Previously graduated with the grade of 110/110 in Computer Science Engineering, presenting a Thesis in Artificial Intelligence / Latent Semantic Analysis.


ROS Bridge

What is ROS Bridge

The ROS Bridge is a ROS 2 package that makes possible to seamlessly exchange messages between ROS 1 and ROS 2, on shared topics. Once executed, the bridge taps on both ROS 1 and ROS 2 topics and, by default, establishes a communication bridge between the existing topics which bear the same name.
It is also possible to establish a bridge for any existing topics, regardless of their concurrent status in both environments.

Why it is needed

Currently, the ROS 2 core packages are still undergoing heavy development, and most of the third-party packages are still relying on ROS 1.
Therefore, by using the ROS Bridge, it is possible to make use of those packages that are still not natively running on ROS 2.


Installation

ROS 2 machine

As previously stated, the ROS Bridge is a ROS 2 package, and it is available in the official repositories.
In order to run the ROS Bridge, the machine running ROS 2 is required to also run a functional ROS 1 environment.

Environment

HW: Raspberry Pi 3 Model B+
(used as the computational unit for TurtleBot3 Burger/Waffle Pi)

SoftwareVersion
OSUbuntu 18.04.4 LTS (Bionic Beaver)
PythonPython 2.7.17 (Default)
 Python 3.6.9
ROSROS 1 (Melodic)
 ROS 2 (Dashing)

For information on setting up a ROS 2 Dashing environment on a machine running Ubuntu, refer to the official documentation.

  • To proceed with the Bridge installation, execute:
$ sudo apt install ros-dashing-ros1-bridge

Bash

I have slightly customised the Bash configuration file, adding an automatic IP recognition and a convenient alias for sourcing the ROS environments.

  • Add the following lines at the end of the ~/.bashrc file:
# ROS
ROS_MASTER_IP=192.168.0.100  # Ip of the ROS 1 master machine
WIFI_INTERFACE=$(iw dev | awk '$1=="Interface"{print $2}')
WIFI_IP=$(/sbin/ip -o -4 addr list $WIFI_INTERFACE | head -1 | awk '{print $4}' | cut -d/ -f1)
export TB3_MODEL=burger
export TURTLEBOT3_MODEL=${TB3_MODEL}

# ROS1
export ROS_IP=$WIFI_IP
export ROS_HOSTNAME=$WIFI_IP
export ROS_MASTER_URI=http://$ROS_MASTER_IP:11311
alias source-ros1='source /opt/ros/melodic/setup.bash'

# ROS2
alias source-ros2='source /opt/ros/dashing/setup.bash; source ~/turtlebot3_ws/install/setup.bash; export ROS_DOMAIN_ID=30 #TURTLEBOT3'

Note: In order to retrieve the interface name, the iw package must be present in the system.
If it is not already available, proceed with its installation:

$ sudo apt install iw

ROS 1 machine

The use of the ROS Bridge is completely transparent to the ROS 1 machine, therefore the machine running ROS 1 is required to only be configured to run a ROS 1 environment and its ROS 1 related packages.

Environment

HW: Desktop PC

SoftwareVersion
OSUbuntu 18.04.4 LTS (Bionic Beaver)
PythonPython 2.7.17
 Python 3.6.9 (Default)
ROSROS 1 (Melodic)

For information on setting up a ROS 1 Melodic environment on a machine running Ubuntu, refer to the official documentation.

Bash

  • Similarly, add the following lines at the end of the ~/.bashrc file:
# ROS
WIFI_INTERFACE=$(iw dev | awk '$1=="Interface"{print $2}')
WIFI_IP=$(/sbin/ip -o -4 addr list $WIFI_INTERFACE | head -1 | awk '{print $4}' | cut -d/ -f1)
export TB3_MODEL=burger
export TURTLEBOT3_MODEL=${TB3_MODEL}

# ROS1
export ROS_IP=$WIFI_IP
export ROS_HOSTNAME=$WIFI_IP
export ROS_MASTER_URI=http://$WIFI_IP:11311
alias source-ros1='source /opt/ros/melodic/setup.bash > /dev/null && source ~/catkin_ws/devel/setup.bash > /dev/null'

Running the demo example

To verify the successful installation of the Bridge, it is possible to run a simple talker/listener example between the machine running ROS 1 and the machine running ROS 2, and vice versa.

ROS 2 machine

  • Install the demo examples:
$ sudo apt install ros-dashing-demo-nodes-py

Shell 1: bridge

  • Launch the bridge:
$ . /opt/ros/melodic/setup.bash
$ . /opt/ros/dashing/setup.bash
$ ros2 run ros1_bridge dynamic_bridge

Shell 2: listener

  • Launch the listener:
$ . /opt/ros/dashing/setup.bash
$ ros2 run demo_nodes_py listener

ROS 1 machine

  • Install the demo examples:
$ sudo apt install ros-melodic-rospy-tutorials

Shell 1: roscore

  • Launch roscore:
$ . /opt/ros/melodic/setup.bash
$ roscore

Shell 2: talker

  • Launch the talker:
$ . /opt/ros/melodic/setup.bash
$ rosrun rospy_tutorials talker

Terminals

Screenshot from 2020-07-28 13-50-45.png

Switching roles

To switch the roles of the two machines, it is also possible to run the listener on the ROS 1 machine and the talker on the ROS 2 machine.

ROS 2 machine: talker

  • Launch the talker:
$ ros2 run demo_nodes_py talker

ROS 1 machine: listener

  • Launch the listener:
$ rosrun rospy_tutorials listener

Verify the USB camera stream

ROS 2 machine

  • Install the image_tools package:
    This package will allow the ROS 2 machine to use a regular USB camera to produce a stream of frames of specified dimensions on a chosen topic.
$ sudo apt install ros-dashing-image-tools

Shell 1: bridge

  • Launch the bridge:
$ . /opt/ros/melodic/setup.bash
$ . /opt/ros/dashing/setup.bash
$ ros2 run ros1_bridge dynamic_bridge

Shell 2: cam2image

  • Obtain the camera stream:
$ . /opt/ros/dashing/setup.bash
$ ros2 run image_tools cam2image -s 0 -x 320 -y 240 -t /image_raw
  • For more information about the usage of the available parameters:
$ ros2 run image_tools cam2image -h

ROS 1 machine

Shell 1: roscore

  • Launch roscore:
$ . /opt/ros/melodic/setup.bash
$ roscore

Shell 2: rqt_image_view

  • Verify the camera stream:
$ . /opt/ros/melodic/setup.bash
$ rqt_image_view /image_raw

Terminals

Screenshot from 2020-07-28 14-01-52.png

References


Master’s Degree project added

Added the following pages:

  • UniPA BCI Framework project page:
    an Advanced Brain-Computer Interface framework which includes many novel features.

Edited parent and other reference pages accordingly.


Brief introduction to the Master's Degree Thesis:

  • The UniPA BCI Framework is an augmented framework based on the P300 paradigm and allows a user to select individual actions to be performed by a robot or, in the more classic configuration, to spell a sequence of symbols.
  • The framework takes advantage of additional developed modules, which perform the acquisition of eye gaze coordinates and biometric signals.
  • The use of such modules allows to achieve a combined response which does not only take in account the response of a traditional BCI system based on the P300 paradigm, but it also considers useful information, such as the user visual focus and her level of engagement with the system, providing a more robust and effective global response.

Kyoto: A map of places to visit

I thought to share a map of Kyoto points of interest I created some time ago. It mostly contains locations of temples, but it also includes other places I found interesting to visit.

The map is dinamically linked from my google account, so whenever I'll add more places, they will automatically appear on this post as well. I realise that, for an easier reading of the map, I should change the pin appearance depending on the type of location pinned on the map, but this is something I'll try to do later, if I find some spare time.
(more…)


Comments issue and New theme

I have just discovered that there have been some issues in leaving comments which were, apparently, related to the fact that I was still using an outdated theme on the latest WordPress release. I'm not sure how long this problem has been around, my apologies for the trouble.

I'm temporarily using this new theme, and although I don't particularly like it, it's still better than a theme that doesn't let people leave comments at all.
It's still a bit messy, but it'll do for now.

More configuration guides for the Raspberry Pi are on my to-do list since quite some time by now. I'll put them up once I'll be more free.


Raspberry Pi – VPN Server

Connecting from the University network, I often incur into a very annoying issue, that of blocked ports. I have therefore decided to configure a personal VPN (Virtual Private Network) server where to connect to from university and have true freedom of access to whichever service I would need to use.
(more…)


Raspberry Pi – Webcam streaming

Now it's time to make my old Creative Live! Cam Vista IM (VF0260) Webcam work on the RasPi, I also tried a new Logitech C270 HD Webcam and they both work flawlessly out of the box.
I have tried three softwares for the webcam, which I previously tested on my desktop machine running Fedora and I wanted to try them also on the Pi. These are:

  • fswebcam
  • motion
  • mjpeg-streamer

Let's now have a look at them.
(more…)


Raspberry Pi – Firmware and Updates

Now that the system is installed on the SD card and the ssh service has been configured properly, we're going to take care of the system and firmware updates; few words have to be said about the system partitioning scheme.
The Raspbian installation consist of two partitions: the fat16 boot partition, that contains the firmware needed to the Pi to boot, and the ext4 system partition.
(more…)


Raspberry Pi – SSH and static IP

By the time I received my RasPi, I didn't have an usb keyboard yet, so my first concern was about how to use it without the keyboard from the very first boot. It wasn't clear whether the ssh daemon would be active by default or not, and I've also got to know that for some distributions, or even among different updates of the same distribution, its default state changed over time.
I found out that in Raspbian, ssh is installed by default but it's not configured to start up automatically since the first boot.
(more…)


Raspberry Pi – Preparing the SD card

Download the image:

First step would of course be that to choose and install a linux distribution on the SD card.
I'm personally a RedHat/Fedora user since quite some time but I thought, for the RasPi, to give Debian a go. I decided to install Raspbian “wheezy”, an optimised version of Debian for the Raspberry Pi, and it comes with LXDE as default desktop environment, for those who care about it.
You can download the image from the RaspberryPi Downloads page.
(more…)