Installing Ubuntu(18.04 LTS) on Raspberry Pi 4 with ROS Melodic and RealSense D435 + RTAB-Map


I thought of writing this article because I had to face a lot of problems when configuring the Intel RealSense D435 camera to work in a ROS environment on top of Raspberry Pi 4.

As of December 2021 the only official Ubuntu desktop version that supports Raspberry Pi 4 is Ubuntu 20.10. However since my target is to use Raspberry Pi 4 in a ROS-related application, I can not use this option as ROS versions are only supported in LTS versions. (Ex: 16.04, 18.04, 20.04). Therefore my only option is to install Ubuntu Server on Raspberry pi 4 and then install a suitable desktop version on top of that and then install RealSense drivers. But the problem here is when I do this, some of the hardware of the Raspberry Pi 4 board is not accessible because the ubuntu-desktop version is not properly configured to work on a Raspberry Pi 4 board making the RealSense D435 camera fail.

However, I managed to properly install the RealSense D435 camera and RTAB-Map on Raspberry Pi 4 and use it in my final year research project. So the steps I followed are briefed below.




Install Ubuntu 18.04 Desktop on Raspberry Pi 4

The first thing would be to download Ubuntu 18.04 server image for the Raspberry Pi 4 from this link — https://cdimage.ubuntu.com/releases/18.04/release/.(ubuntu-18.04.5-preinstalled-server-arm64+raspi4.img.xz)

Then burn it to a SD card (storage greater than 32GB is recommended) using the Raspberry Pi imager.

Burning Ubuntu 18.04 Server image into Raspberry pi 4 using Raspberry pi imager

Then connect a mouse, keyboard, and a display to your raspberry pi 4 and power the board after inserting the SD card.

After that, you have to add your network information to the Raspberry Pi 4 in order to connect to the internet. Refer to the following tutorial to do that.

Now it is time to install Ubuntu Desktop GUI on top of the Ubuntu server. You can easily do that by entering the following command in the command line.

sudo apt install ubuntu-desktop

This will take some time. Once the installation is completed, reboot the Raspberry pi 4. Now you will see the beautiful Ubuntu GUI on your monitor.




Install ROS Melodic

The next step is installing ROS Melodic. To do that please follow the tutorial below which is mentioned in ROS wiki.

Then type the following commands to update and install the dependencies and tools which are required before moving into RealSense related installations.

sudo apt-get update

sudo apt-get install automake libtool vim cmake libusb-1.0–0-dev libx11-dev xorg-dev libglu1-mesa-dev




Install RealSense related dependencies

Follow the below step-by-step approach in order to build the required drivers and packages which are required for the proper operation of the RealSense D435 camera.

NOTE: However, you might have to install some additional dependencies while you go through the above approach. For your convenience, I will mention some tips and commands under the relevant sub-topics in case if you face any issues. (Sub-topics are ordered in the same order as the above approach)

Pre-install requirements

When increasing the SWAP size, you have to type CONF_SWAP_SIZE=2048 in /etc/dphys-swapfile and then press ZZ to exit from the vi editor.

Installation — install protobuf

Before following the steps under install protobuf section, first install Python3-pip and utils using the following commands.

sudo apt install python3-pip

sudo pip3 install utils

Installation — install libtbb-dev

Before following the steps under install libtbb-dev, first add an armhf architecture using the following command.

sudo dpkg — add-architecture armhf




Installing RealSense ROS wrapper

To install the RealSense ROS wrapper please follow the below instructions.

sudo apt-get install ros-melodic-ddynamice-reconfigure

Then create a catkin workspace and clone and build the following package.




Enabling SSH

Additionally, if you want to enable SSH on your Raspberry pi 4, please follow the below guide by enabling the SSH through raspi-config.

Then from your remote laptop/ computer type ssh ubuntu@{ip_address} in order to access the Raspberry pi 4 through SSH.




Installing RTAB-Map

Finally, if someone is planning to use RTAB-Map with RealSense d435, you can follow the instructions mentioned below in order to install RTAB-Map in your Raspberry Pi4.

sudo apt-get install ros-melodic-rtabmap

sudo apt-get install ros-melodic-move-base

sudo apt-get install ros-move-base-msgs

Then clone and build the rtabmap-ros package into your catkin workspace from the following link.

That’s it. Now you can build maps using RTAB-Map with RealSense D435 camera on your Raspberry Pi 4.