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 Ubuntu MATE 18.04.2 for Raspberry Pi 3B+
Download the image archive from here. The image runs on Raspberry pi 2 B, 3 B and 3 B+.

Ubuntu Bionic Image
- Use a file archiver like 7-Zip to extract the image.
- 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 +.
The next step is to use ‘raspi-config’ to set up the interface option.
Open a shell terminal and type:
- sudo raspi-config
- navigate to ‘3 Interfacing Options’
- 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.
1 2 3 4 5 6 7 8 9 | sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 sudo apt update sudo apt install ros-melodic-desktop-full sudo rosdep init rosdep update echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential |
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
1 2 | sudo apt-get update sudo apt-get install arduino arduino-core |
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:
1 2 3 4 | sudo apt-get update sudo apt-get install ros-melodic-rosserial-arduino sudo apt-get install ros-melodic-rosserial sudo usermod -a -G dialout YOUR_USER |
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
1 2 3 | cd sketchbook/libraries rm -rf ros_lib rosrun rosserial_arduino make_libraries.py . |
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.
I hope this tutorial helps you in learning ROS for robotics!
Hi
I have a raspberry pi 3B+ board and I need to work with ROS. Do you recommend me to install Ubuntu mate 18.04 and ROS Melodic? Does it work well like ROS for raspberry pi B models?
Hello Arvin,
Thank you for your comment. Pi 3B+ is compatible with Mate 18.04. ROS Melodic is the only one ROS version compatible with Mate 18.04. Considering the above, you can run on Pi 3B+ only this combination: Mate 18.04 and Melodic. In my opinion the performance is in the best case like ROS Kinetic + Mate 16.04 running on Pi 3B.
Hi from France
This tutorial is find and functional.
I’ll like to install Mate 16.04 but I don’t find the link to download Ubuntu Mate 16.04 for Raspberry PI.
Thank you and please continue your tutorials.
Christophe
Hello Christophe,
Thank you for comment. This tutorial is about installing Ubuntu MATE 18.04 and ROS Melodic on Raspberry Pi 3B+. If you want to install MATE 16.04 (download here), you have to use Raspberry Pi 3B and install ROS Kinetic. Here can find more details about how to install ROS Kinetic on Raspberry Pi 3B.
Hello Calin
I found the links but you can only download the Mate 18.04
I try on this one : http://cdimage.ubuntu.com/ubuntu/releases/
Bye
Really good work thank you!
I’m trying to setup ROS Melodic or Kinetic for the Pi 3 B+. Which one would be easier?
Hello Connor,
Thank you for your comment. If you’re trying to install ROS on Pi 3B+, you have only one option: ROS Melodic.
Hello Calin,
I have raspberry Pi3b+. I am new to working on ROS and raspberry pi. Why do we need to use Ubuntu Mate? Is it better than Debian Stretch? I have installed Debian Stretch on Raspberry pi. Could you help in providing the adv/ disadv of one over the other?
Hello Nalini,
thank you for your comment. It is about compatibility between – Raspberry Pi 3B+, Ubuntu Mate and ROS Melodic – and less about Mate vs Debian Stretch. Every operating systems has advantages and disadvantages. The idea is that ROS Melodic runs on Pi 3B+ only on Ubuntu Mate version 18.04.2.
Hello Calin,
Very good tutorial, I have few questions thou:
1. Why running raspberry pi 3B with Ubuntu Mate 18.04 and Melodic is not good choice?
2. Also I’ve encoutered a problem when upgrading all packages(sudo apt upgrade). Raspi rejected every SSH connection. Which was weird because it was active and enabled. Also it dissapeard from a raspi-config. Do you know maybe what might caused it?
Hello Dawid,
Thank you for your comment.
1. Maybe I don’t understood your question: Indeed, Ubuntu Mate 18.04 and Melodic is the right choice.
2. Yes, please install the SSH server on your Pi.
sudo apt install openssh-server
sudo systemctl enable ssh
And then restart your Pi.
Hello, this is a great tutorial. Have you been able to get the RaspiCamera to work with Melodic on Ubuntu Mate? I’m having some challenges with it as there doesn’t seem to be a supported Node app for melodic yet. Ubiquity Robotics built one for Kinetic which is available via apt but the source fails to compile on melodic. So as a workaround I have a USB Cam node app which seems to work ok though seems limited support.
Hello Psypher,
No, I didn’t try to use RaspiCamera with ROS Melodic.
I managed to make RPi camera work with Ubuntu 18.04 server on RPi 3 b+.
You can take a look at those notes: https://serge-m.github.io/ros-experience.html
Hi Calin.
Thanks for this tutorial. It’s very useful.
You should update the repository key.
This is the new key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
I found this information here: https://answers.ros.org/question/325039/apt-update-fails-cannot-install-pkgs-key-not-working/
Hi Teo,
Thank you for the new key.
Hello,
First, thank you for the tutorial it helps me a lot ! I followed all the tutorial in order to connect my mRanger (Makeblock) to a raspberry 3 B. When I connect the auriga board with an USB cable and ls -lh /dev/tty* I see /dev/ttyUSB0 appears (I have crw-rw-rw- 1 root dialout 188). I also enable serial and I2C, check “groups myusername” and dialout is here. but when I open the Arduino IDE the port setup is still greyed out. I saw you have an mRanger too, how can I do to connect my raspberry to the Auriga board ?
Thanks a lot
Hello Yorm,
Thank you for your comment.
Most probably you have an issue with the permissions for /dev/ttyACM*. This permission can be permanently solved by adding your user to the dialout group and change permission on serial port.
You can do this with:
Thanks for your response. Finally, I think my problem seemed to be link to a java problem (java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver error) but I didn’t succeed to resolve it. However, I remove the 2.1 arduino version installed thanks your tutorial and install the 1.8 version from the arduino.cc and that works !