Getting Started with ROS on Raspberry Pi

December 20, 2021

The Robot Operating System (ROS) is an open-source robotics middleware suite. ROS is not a traditional operating system like Linux or macOS but a collection of software libraries and tools used to build robotic systems and applications. The current Long Term Service (LTS) version of ROS 1 is Noetic Ninjemys. It was released on May 23, 2020, by Open Robotics, the developer of ROS. It will be supported for five years until May 2025. However, in the future, all the official effort will be put into developing ROS 2, which is a major rewrite of the ROS framework.

ROS Noetic Ninjemys was developed for Ubuntu 20.04, so Ubuntu is the recommended Linux OS for installation. Note that Windows and Arch Linux support is still experimental and might not be fully functional. This tutorial explains how to install ROS Noetic Ninjemys from source on a Raspberry Pi. It’s not hard, but it will take a long time to compile everything, so grab a cup of coffee and a book to read while you wait for your machine to compile everything.

Step 1: Preparation of Raspberry Pi

ROS Noetic Ninjemys officially supports the Ubuntu Focal and Debian Buster operating systems. Since the Raspberry Pi OS is a Debian-based operating system, we need to ensure that the Raspberry Pi we’re using runs on Raspbian Buster. The latest version of Raspbian at the time of writing is Bullseye, so you’ll need to downgrade to Raspbian Buster if you’re using the latest version of Raspbian. You can download Raspbian Buster from the Raspberry Pi Foundation’s official Raspbian image archives.

Once the Raspberry Pi is up and running, we can check whether the latest drivers are installed with the following command.

sudo apt-get update

This command updates the list of available packages and their versions.

sudo apt-get upgrade

Once complete, you can reboot your Raspberry Pi by typing the following command.

sudo reboot

Step 2: Increasing Raspberry Pi Swap Memory

If you own a Raspberry Pi, you should know that the RAM has a limited capacity. This problem can be solved by simply enlarging the swap memory of the Raspberry Pi. This means that when all of the Raspberry Pi’s RAM is exhausted, it can start using the swap file as memory instead. Raspbian ships with a default swap file size of 100 MB, and in this case, we are simply increasing that to 2 GB.

Run the following command to stop the operating system from using the current swap file.

sudo dphys-swapfile swapoff

Next, we need to modify the swap file configuration file. We can open this file using nano by using the command below.

sudo nano /etc/dphys-swapfile

Within this config file, find the following line of text.


Now, set it to a size of 2 GB; make sure you have the said amount of space available on your SD card.


We can now re-initialize the Raspberry Pi’s swap file by running the command below.

sudo dphys-swapfile setup

To start the operating system with the new swap file, run the following command.

sudo dphys-swapfile swapon

You can now verify the amount of RAM and swap memory available by issuing the following command:

free -h

Step 3: Set Up ROS Repository on Raspberry Pi

We set up our machine to accept software from

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

If the command succeeds, you won’t see any output. However, you can double-check if the repo is added using the cat command:

cat /etc/apt/sources.list.d/ros-latest.list

You will see the following output:

deb buster main

Step 4: Set Up Official ROS Keys

Next, we will add the official ROS key to download authentic ROS Noetic Ninjemys packages to our Raspbian Buster.

curl -s | 
sudo apt-key add -

Step 5: Install Build Dependencies on Raspberry Pi

We are finally ready to install ROS Noetic Ninjemys on our Raspberry Pi. First, we make sure our Debian package index is up-to-date:

sudo apt update

Now pick how much ROS you would like to install.

  • Desktop-Full Install: Everything in Desktop plus 2D/3D simulators and perception packages.
  • Desktop Install: Everything in ROS-Base plus tools like rqt and rviz
  • ROS-Base (Bare Bones): ROS packaging, build, and communication libraries. No GUI tools.

There are even more packages available in ROS. You can always install a specific package directly. To find available packages, see ROS Index or use:

apt search ros-noetic

We will first install all dependencies:

sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake

Here, the dependencies include ROS-specific tools (rosdep, rosintall_generator, and ws_tool) and some essential build tools like make and cmake.

Step 6: Set Up ROS Dependency Sources

First, we initialize rosdep, which is a ROS tool for installing dependencies:

sudo rosdep init

Next, we run rosdep update to fetch package information from the repositories that are just initialized.

rosdep update

Step 7: Install ROS Dependencies

Before we begin, we will need to create a catkin workspace by:

mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws

Then we use rosinstall_generator to generate a list of ROS Noetic Ninjemys dependencies for different ROS Noetic Ninjemys variants, such as desktop-full, desktop, and ros_comm. I’ll go with installing desktop install here.

rosinstall_generator desktop --rosdistro noetic --deps --wet-only --tar > noetic-desktop-wet.rosinstall

Next, we will use the wstool to fetch all the remote repos:

wstool init src noetic-desktop-wet.rosinstall

The command will take a few minutes to download the core ROS packages into the src folder. If wstool init fails or is interrupted, you can resume the download by running:

wstool update -j8 -t src

Then before compiling the packages in the src folder, we install all system dependencies using rosdepinstall:

rosdep install -y --from-paths src --ignore-src --rosdistro noetic -r --os=debian:buster

Step 8: Compiling ROS Packages

Once it has completed downloading the packages and resolving the dependencies, you are ready to build the catkin packages.

sudo src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/noetic -j2 -DPYTHON_EXECUTABLE=/usr/bin/python3

It takes a long time to compile these packages so you can work on something else in the meantime. Once the packages have been compiled, you should see the following output:

<== Finished processing package [184 of 184]: 'xacro'

Step 9: Verify ROS Installation on Raspberry Pi

First, let’s source the bash.

echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Let’s try some ROS commands to ensure the installation has finished successfully. A simple way to check the functionality of ROS is to use the turtlesim simulator that is part of the ROS installation.

Open a new terminal and run the following command:


Start a new terminal prompt and run the below command in the terminal:

rosrun turtlesim turtlesim_node

Open up yet another terminal window. Run the following:

rosrun turtlesim turtle_teleop_key

Click the mouse in the last container window you created so that it has focus. Use the arrow keys to move the turtle around the screen. If everything goes right, you will obtain the following result on current terminal:

Press Ctrl-C to stop `roscore`, etc.

Congratulations! 🎉 We are done with the ROS installation!

rss facebook twitter github youtube mail spotify instagram linkedin google pinterest medium vimeo googlescholar