How To Install ROS2 Humble Base On Raspberry Pi 4B (FULL INSTALL)
Learn how to install ros-humble-ros-base on Raspberry pi 4B running Ubuntu 22.04 LTS server
Last updated
Learn how to install ros-humble-ros-base on Raspberry pi 4B running Ubuntu 22.04 LTS server
Last updated
If you'll be building intelligent robotics applications, chances are you’ll want the power of ROS2 running on a compact, efficient platform like the Raspberry Pi 4B. This guide walks you through the complete process of setting up ROS2 Humble on on a Raspberry Pi running Ubuntu 22.04 Server — from the initial installation to configuring essential tools like colcon and rosdep. By the end, you'll be ready to develop and deploy robust robotics applications on this versatile microcomputer.
Let’s dive in and get your Pi humming with ROS2!
First ensure you have the Ubuntu 22.04 LTS server installed on the Raspberry Pi 4B (2GB, 4GB, or 8GB. The higher, the better)
Also, if you did headless installation, you should be able to communicate with the Pi from your Dev PC via SSH.
All we'll be doing in this tutorial assumes you are able to communicate with your Raspberry Pi 4B running Ubuntu 22.04 LTS server with SSH
Follow the instructions (step by step) to install ros-humble-ros-base (not desktop) on your Raspberry Pi.
This tutorial follows the official ROS humble installation documentation which can be found here
Set locale
Setup sources
Install ros2 humble (i.e ros-humble-ros-base)
Next, add the following command to the .bashrc
file to enable automatic sourcing of the ros humble environment and installed whenever you open a new terminal.
colcon is a build tool required to build your ROS2 packages created in your ros workspace
Install colcon
Setup colcon_cd
Setup colcon tab completion
With all the above added to the .bashrc
file, the colcon environment and functions will be automatically activated whenever you open a new terminal as well as automatic sourcing of the ros-humble environment.
To learn more about colcon check the link to its documentation here
you should see the following highlighted text (in the image below) at the bottom of your .bashrc
file. Run this command: sudo nano ~/.bashrc
rosdep is a dependency management utility that can work with packages and external libraries. It is a command line utility for identifying and installing dependencies to build or install a package.
It is most often invoked before before building a package with colcon. It will basiclally download and installing the necessary dependencies a specified in the package.xml
file so you don't have to manually install each dependencies again.
To learn more about rosdep check out its documentation here
Follow the instructions below to install rosdep:
In the root folder of your Raspberry Pi (i.e the home directory)
In the root folder of your Raspberry Pi (i.e the home directory), create a ros workspace folder. I would be using this workspace name - ros-robot-ws
- as seen in the image above.
change directory into the root ros workspace folder
build the ros workspace initially with colcon (while still in the root workspace folder)
you should now see three other folders - build, install, and log - apart from the src folder already created earlier. run ls
Let's setup automatic sourcing for the created workspace - ros-robot-ws
- in the .bashrc
file so that it is automatically sourced whenever you open a new terminal. Run this in terminal:
Open a new terminal (to auto source your ros2 environment and workspace) and cd into your ros workspace's src folder
Clone this ros2 helloworld cpp and python package
Change directory into the root ros workspace folder
Optionally, run rosdep to install the packge dependencies specified in the package's package.xml
file
Build the package with colcon
Open two seperate terminals. In one of the terminals, run:
In the other terminal, run:
On your Dev PC to which the Raspberry Pi is connected and communicating with (which also has ros humble desktop installed and ros workspace setup). Clone and build the helloworld package as you did on the Raspberry Pi above.
Source your workspace (if no automatic sourcing was setup)
Run on a terminal on your Dev PC
Run on a new terminal on the Raspberry Pi (to auto-source your ros2 environment and workspace):
If you would be using the Pi in ROS2 for navigation and some other high speed data transfer, install and use the Cyclone DDS in place of the default Fast DDS.