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:
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+
First you have to download the OS image. Go to the download page of the Ubuntu MATE website.
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
Make sure you get a class 10 micro SD card. You can see the class of the card when you buy it. The class is related to the writing speed. As your SD card will serve as the complete OS for your Raspberry Pi 3 B+, you want something that is fast enough.
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
OK, you have a micro SD card. Now you need to flash the image into this card.
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
To flash the image I recommend you use the open source Etcher software. This is a very handy multi-platform software for flashing SD cards.
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+
Once the micro SD card is flashed with the image, remove it from your computer and insert it into your 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.
Basically on the first boot you’ll just have to follow standard Ubuntu installation instructions:
- 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
Once all the previous steps are done, basically one of the first things you want to do is to activate ssh, so you can control your Raspberry Pi 3B+ from your own computer, without an extra screen and keyboard.
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
Now our Pi is working perfectly as a Ubuntu computer.
Step1 : Go to System -> Administration -> Software & Updates
Step2 : Check the checkboxes to repositories to allow “restricted,” “universe,” and “multiverse.”
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
Step8 : Setting up the ROS environment variables
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc