Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

411 University St, Seattle, USA

engitech@oceanthemes.net

+1 -800-456-478-23

English How To
Installing ROS on a Raspberry Pi 4

Installing ROS Noetic on a Headless Raspberry Pi 4 with Ubuntu 20.04

The Raspberry Pi 4 is powerful enough to make it interesting for robotics use. In order to simplify development, it would be great to run a current ROS installation on this little board. Unfortunately, the official installation instructions advises you to use Ubuntu with ROS Kinetic.

Initially I really wanted to use Raspberry Pi OS for my robot setup, since it is a lot more popular than Ubuntu for the Pi. But unfortunately the ROS installation process for Raspberry Pi OS is ugly. You can’t simply use apt-get to download ROS and its many available packages, you need to build them from source. Since this is a hassle, I changed my mind and now I’m using Ubuntu 20.04 with ROS Noetic on a Raspberry Pi 4. In this post I’ll tell you (and future me) how to get it working.

Step 1: Setup Ubuntu on your Pi

Installing Raspberry Pi OS in a headless mode is easy: Just take the Raspberry Pi imager software, press CTRL+SHIFT+X, setup WiFi and ssh, flash the image and boot your Pi. You can then connect to it via SSH. Unfortunately, on Ubuntu things are not that easy:

At first, we need to download the the Ubuntu OS for the Raspberry Pi. This process is very easy since Raspberry Pi has published the Raspberry Pi Imager software, because you can simply select the OS version and just press go. For this installation, I am using the Ubuntu Server 20.04.03 LTS (RPI 3/4/400). This image can be found in the menu “Other general purpose OS > Ubuntu”. Please make sure to use the same OS version, since ROS Noetic does not work with other Ubuntu versions.

Select Ubuntu Server 20.04.03 LTS (RPI 3/4/400)
Configure Networking

It is important that you do this before booting the image for the first time, since the file is applied only once during first boot.

In order to connect your robot to your network, you have to configure it first. This can be done directly on the SD card. Just insert the card into your PC (Windows / Linux works) and edit the file “network-config” in the SD card’s root directory.

There are already some examples present, but for a basic WiFi and Ethernet connection with DHCP support, add the following content to the file:

version: 2
ethernets:
  eth0:
    dhcp4: true
    optional: true
wifis:
  wlan0:
    dhcp4: true
    optional: true
    access-points:
      "YOUR_SSID_HERE":
        password: "YOUR_PASSWORD_HERE"

You just need to insert your own WLAN SSID and password here.

Save the file and eject your SD card from your PC. You are now ready to boot the image with networking support. It should show up in your router:

Hint: For me, it took two boots for this to work. So if your Pi does not show up on your network, just try rebooting it after a while.

Connect via SSH

Since we installed Ubuntu Server as operating system, SSH is enabled by default. Therefore, in order to connect to your PI, just open a SSH connection with the following default credentials:

  • User: ubuntu
  • Password: ubuntu
  • Hostname: ubuntu
  • Port: 22

On the first login, you are forced to change your password. Enter the current password (= ubuntu) and then you must enter a new password (twice).

Settings for use in a robotics environment

Ubuntu Server is designed for systems which are running 24/7 with networking always connected. Since we are going to be using this Ubuntu instance for our robot, it might be interesting to disable some things.

The first thing that comes to mind are the unattended updates. We really don’t want our Raspberry Pi to update itself automatically in our robot, since this might break our software. Additionally, there is a risk that the power is cut during the update process (e.g. battery empty) and the update fails. In this case, our robot wouldn’t be able to recover.

Disabling unattended upgrades

Luckily, it is very easy to disable unattended upgrades. Just use the following command:

sudo apt remove unattended-upgrades

Now your system won’t upgrade automatically. You can still update packages manually by running:

sudo apt update
sudo apt upgrade

Step 2: Installing ROS Noetic

Now we are running an Ubuntu 20.04 installation on our Raspberry Pi and we’re able to connect to it using SSH. This allows us to install ROS Noetic just like on any other Ubuntu based system:

Getting the Package

In order to install the ROS package, we need to add the ROS repository to our system. This is done using the following commands:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

Then you can install ROS using the following commands to install the ROS base system without GUI tools:

sudo apt update
sudo apt install ros-noetic-ros-base

Author

Clemens

Entrepreneur, Loves Software Engineering, Hardware Design, Robots and Open Source.

Leave a comment

Your email address will not be published.