Installing ROS Melodic on Raspberry Pi 3B+ running Ubuntu MATE 18.04.2 (Bionic)

In this tutorial, you will learn how to configure your Raspberry Pi 3B+ board for running Ubuntu MATE 18.04.2 (codename Bionic) and the 12th ROS Distribution (codename Melodic). But we study robotics on this blog. We need ROS to read data from sensors and control motor drivers. So I have added the steps to install the Arduino IDE and rosserial to run ROS nodes on Arduino boards.

Considering Melodic a new ROS distribution, setting up the ROS environment is half of the battle. Not all the ROS packages available in Kinetic are migrated to Melodic.

My guess is that all the packages available in Kinetic will be migrated to Melodic since this distribution have long term support. If you want to start learning about ROS, I am pretty sure that all the packages you are going to use are already available in Melodic. Otherwise, if you think Melodic is not what you need at this moment, you can think of installing ROS Kinetic. In this tutorial, you can find all the steps to install ROS Kinetic on Raspberry Pi 3 and Ubuntu MATE 16.04.

Migrating a Kinetic package to Melodic needs some additional steps. The package has to be built from source (clone the package from GitHub to your catkin workspace) and checks for dependencies in the package.xml file of the migrated package.

Melodic comes with improvements including C++14 over C++11 in Kinetic, OpenCV support with a minimum version of 3.2, rviz and urdf changes. These four are just a part of all improvements from Melodic. All the improvements and the migration guide can be consulted here.

Because we’ve talked about the migrated packages, ROS gives us some insights about the list of available packages in Melodic. The list is here.

Ubuntu MATE (Bionic) installation

The idea of Linux and implicitly the Ubuntu MATE version is to customize it to your needs. The reason for the different versions is actually the packages that come with it.

For this installation and for other projects I run Ubuntu MATE and not Raspbian on Pi. Raspbian is a very good Raspberry Pi operating system but becomes a pain to install ROS and new packages. Using MATE consumes more resources than Raspbian, but in the end, everything works and I can use GPIO and the USB ports to control robots.

I work with MATE 16.04 and with MATE 18.04. If you’re trying to build robots, MATE has been just a platform to host different frameworks for running algorithms and has little impact on what we’re doing with Pi. If you’re using it for multimedia, definitely the last MATE version is impressive and comes with more utilities.

For this tutorial, I use a new Raspberry Pi 3B+, and the first step to make it useful is to install an Ubuntu MATE image.

Download the image archive from here. The image runs on Raspberry pi 2 B, 3 B and 3 B+.

Ubuntu Bionic Image

  1. Use a file archiver like 7-Zip to extract the image.
  2. Since I’m using Windows 10 to install the Ubuntu Image on a microSD card, I use Win32 disk imager to write the MATE image.

Insert the card into the Pi 3B + memory slot and power on the board. Since the Linux OS is not configured, at this point you will through a setup wizard. Select your preferred language, setting up the WiFi network, choose your region and configure your username. After a few minutes of running the first boot setup, you should run Ubuntu MATE 18.04.2 on your Pi 3 B +.

Info: In the first minutes of working, MATE (Bionic) displays an error and hide the menu button. This is probably one of the few known issues planned to be fixed with the next releases. To fix this issue, you have to reset the Panel. Right-click on the top menu bar and choose reset the panel.

The next step is to use ‘raspi-config’ to set up the interface option.
Open a shell terminal and type:

  1. sudo raspi-config
  2. navigate to ‘3 Interfacing Options’
  3. since I plan to use a camera and the GPIO pins, I enable these two options for future projects

Check the checkboxes to repositories to allow “restricted,” “universe,” and “multiverse.”

Before starting to install ROS Melodic, we have to be sure that the system allows us to install different repositories:
Step 1:Go to System -> Administration -> Software & Updates
Step 2:Check the checkboxes to repositories to allow “restricted,” “universe,” and “multiverse.”

ROS Melodic Installation

Installing Ubuntu MATE is only half of the puzzle. The installation of ROS Melodic is very similar to setting up any other ROS distribution. Of course, there are differences, and below I will explore all the steps to have a workable ROS Melodic on your Raspberry Pi 3B+.

The below steps to install ROS Melodic are based on the original guide from ROS.org.

Command 1 and 2: These two commands set up the sources.list and the keyserver;
Command 3: This is a typical shell command before installing new packages in Linux. This should be run to make sure the Unix-like operating system package index is up-to-date;
Command 4: This command is the effective installation of ROS Melodic. This command installs the main ROS packages such as ROS, rqt, rviz and all the packages available in the Melodic distribution;
Command 5 and 6:rosdep is used to install system dependencies for source and is required to run some core components in ROS;
Command 7 and 8: Add the ROS environment variables to your bash session. This step is important when you run ROS commands in the shell terminal;
Command 9: Since we’re using Python to write ROS nodes, we must install the dependencies and other development tools;

Shell Terminal when you’re running roscore command

Next, we will test if the installation is successfull or not. The simplest test is to run the roscore and rostopic.

Open a shell terminal and type the command: roscore.
Open a new shell terminal and type rostopic list. You should see a list of two default ROS topics running on ROS Melodic.

The ROS Melodic packages list

Since ROS packages are hot subject on the new ROS Melodic, let’s try to check what packages are available. Open a new terminal and type: rospack list. You should see a long list of packages. All of these packages are already migrated to Melodic and ready to be used to build smart robots.

Find ROS packages tf and rviz

If you want to dig deep inside the package list available in ROS Melodic, you can search a certain ROS package using this shell command:rospack list-names | grep the_package_name.

Installing Arduino IDE

I prefer to use the classical Arduino IDE when I write Arduino sketchs. It is simple and easily supports the installation of Arduino compatible libraries.

Installing Arduino IDE on MATE is a very simple process. Once you have run the below two commands, the IDE is installed.

Arduino IDE installed: libraries, tools and examples

Command 1:The same useful command that should be run before installing any package;
Command 2:Install the Arduino IDE from the package repository via apt-get

At this point, the IDE can be seen in the MATE menu, but cannot be used to write ROS nodes. The serial communication between Arduino and Raspberry Pi is managed by the rosserial package. Next, you will see how to install the package.

Installing rosserial

rosserial is a ROS package that makes possible the communication between Arduino and Raspberry Pi. To install the package follows the below shell commands:

Command 2 and 3:Installing rosserial for Arduino;
Command 4:the dialout command is necessary to add the specified user to the group in order to obtain the necessary write permissions from the MATE system. If an Arduino board is connected to the computer via USB, then you need this write permission in order to send the code via the serial port.

At this point, we have installed the ros_lib. From now on, one step separates us to write ROS nodes on the Arduino. Besides rosserial, and the library called ros_lib, we need to copy the ros_lib into the Arduino build environment to enable Arduino programs to interact with ROS.

Install the ros_lib library

ros_lib installed in Arduino IDE

Command 1:Navigate to the Arduino build library directory.
Command 2:If exists, remove the ros_lib directory;
Command 3:Build the ros_lib library;

At this point, your system is ready to run ROS and is configured to communicate with Arduino boards via rosserial. In other words, from now on you can learn and experiment with your Raspberry Pi, Arduino, and the ROS framework.

Clone the microSD card

Clone the microSD card with Ubuntu MATE, ROS Melodic, rosserial and Arduino IDE

Don’t forget to clone the microSD card. This step is not required to set up and run ROS. This step is more about setting up your Raspberry Pi 3 B+ every time when you encounter big problems that cannot be solved.

Open Win32 Disk Imager, choose the disk partition to store the image and give it a name and the extension ‘.img’. Then press ‘Read’ button and wait for the program to create the image of the microSD card.

Summary

Today we learned how to set up an Ubuntu MATE 18.04.2 (Bionic) on the Raspberry Pi 3B+ machine for running ROS Melodic.

Raspberry Pi 3B+ is a development board and not a full-featured desktop computer. Running ROS nodes or computer vision application need a lot of processing power. Processing power that most certainly is not in the Pi and the idea of them.

Setting up all of this software is definitely daunting, especially for novice users. If you encountered any issues along the way, I highly encourage you to check that you didn’t skip any steps. If you are still stuck, please get in touch.

Share:

Related Posts

Don't Miss Out!

Get the latest news, tutorials, reviews and more direct to your inbox when you subscribe!