Install Ubuntu MATE 18.04 and ROS on Raspberry Pi 3 B+

In this tutorial I will show you how to install Ubuntu MATE 18.04 on a Raspberry Pi 3 B+ board. You’ll see how to configure everything step by step. We will use windows for flashing the Pi. We need 3 software:

  1. SD card Formatter
  2. Etcher
  3. 7-zip

The first thing to do is to use the SD Formatter tool and format your SD card:

The main supported OS for Raspberry Pi is Raspbian, an OS based on Debian, and adapted to the Raspberry Pi hardware. So, why would you want to use Ubuntu?

  • If you work with ROS (Robot Operating System), you know that the main supported OS is Ubuntu.
  • You may simply already use Ubuntu in your computer and some web servers, and you want to work on the Pi while keeping the same environment.

Download the Ubuntu MATE image for Raspberry Pi 3 B+

Choose “Raspberry Pi for aarch32 (ARMv7) computers”

and then select Bionic Beaver (name for Ubuntu 18.04 release).

You can now download an archive of the image (.xz extention).

Flash the image into a micro SD card

micro SD card requirements

Your micro SD card should also have at least 8GB of space. This is the bare minimum, I advise you take a bigger card (16 or 32GB).

Extract the Ubuntu MATE image

Warning: don’t flash the archive — .xz file, first you need to extract it!. To extract a .xz file, use:

  • 7-zip or a similar software on Windows. Right-click on the image > extract here.

Flash the image

Download Etcher and launch the software (no installation needed). Insert your micro SD card into your computer.

Then, all you need to do is select the image you just downloaded + extracted, and the SD card. Then, click on “Flash!” and wait a few minutes.

Even if the image size is much lower than the actual SD card size, don’t worry: when installing, the image will expand to take all the available space.

First steps with Ubuntu MATE 18.04 on Raspberry Pi 3 B+

Plug a screen with either the HDMI port, or the special port for Raspberry Pi compatible screens. Also plug a mouse and a keyboard. With that, you’ve got a complete computer!

You can now power on the Raspberry Pi 3 B+ with a micro USB charger (a phone charger is perfect for that).

The Raspberry Pi will boot.

Installation steps

  • Choose your language.
  • Choose your keyboard layout.
  • Connect to a Wi-Fi network (strongly recommended).
  • Choose your location.
  • Choose whether you want to login automatically or not.
  • Wait for the configuration and installation process. This might take a while. The system may also reboot.

Once the installation done and the Pi has reboot (do it manually if it didn’t), you might want to upgrade the Ubuntu packages on the system, because they won’t be up to date.

Open a terminal (to do that: click on the menu > type “terminal” and choose “MATE terminal”). On the terminal execute the following commands — might also take a long time:

$ sudo apt-get update
$ sudo apt autoremove
$ sudo apt upgrade
$ sudo reboot

Activate ssh

On the Pi open a terminal and type:

$ sudo apt install openssh-server
$ sudo systemctl enable ssh.service
$ sudo systemctl start ssh.service
$ sudo dpkg-reconfigure openssh-server

First we install openssh-server (it’s surely already installed, in this case you’ll just have a message saying so), and then we enable the ssh service (from systemd), so every time the Raspberry Pi 3 B+ boots it will launch the ssh server. Running dpkg-reconfigure will fix an error where you’d have a connection refused on the client, when trying to connect to the server.

Now you need to test if ssh is working correctly. To do that, your computer and Raspberry Pi 3 B+ must be connected to the same Wi-Fi network.

In a Raspberry Pi to know its IP address on the network, type in terminal

$ hostname -I

Installing ROS melodic

Step1 : Go to System -> Administration -> Software & Updates

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

Software and Updates

Step3 : Setup your sources. List

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

Step4 : Setup your keys

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

Step5 : To be sure that your Ubuntu Mate package index is up to date, type the following command

sudo apt update

Step6 : Install ros-melodic-desktop-full

sudo apt install ros-melodic-desktop-full

Step7 : Initialize dependicies and rosdep

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essentialsudo apt install python-rosdep
sudo rosdep init
rosdep update

Step8 : Setting up the ROS environment variables

echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc