Robot Operating System: Installation & Configuration on a Raspberry Pi with Ubuntu Server
Sebastian
Posted on February 21, 2022
There are plenty of options for developing a mobile robot. And even plentiful are the requirements that you might want to fulfill. An overall goal in all setups should be to get the most up-to-date software running, starting from the OS to the OS packages and the application libraries.
If you want to use ROS on a Raspberry Pi with the default obtain system Raspberry Pi OS, the installation is not a simple apt-get install
command. The reason: there is no precompiled version for the Raspberry Pi OS. Therefore, you will need to start a lengthy process that involves manual downloading and compilation of several packages. ROS suggests using an Ubuntu OS for operating, and I can only recommend following this because you will likely find support for questions about ROS in the context of Ubuntu. Therefore, I decided to use Ubuntu Server 20.04 as the operating system for my mobile robot.
This article is a complete guide about setup, configuration and auto-starting ROS on a Raspberry Pi running Ubuntu 20.04. You will learn how to add the ROS package sources, perform the installation, configure the default user so that it has the correct permissions, and finally how to autostart the ROS code node on your Raspberry Pi at runtime.
The technical context for this article is Ubuntu Server 20.04, ROS Noetic 1.15.11, and as the hardware either a Raspberry Pi 3 or 4. All instructions should work with newer OS and library versions as well.
This article originally appeared at my blog admantium.com.
Install ROS Noetic on Ubuntu Server
By considering the steps mentioned in the official documentation, and some minor modifications, the installation boils down to this:
- Bring your Raspberry Pi up-to-date, including the recent kernel:
sudo apt-get update
sudu apt-get upgrade
- Add the ROS package repository to your
sources.list
, and import the required keys.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
- Install the build essentials and the ROS core package
sudo apt-get update
sudo apt-get install build-essential cmake
sudo apt-get install ros-noetic-ros-base
If all went well, let’s test the installation by running the following two commands:
source /opt/ros/noetic/setup.bash
roscore
You should see the following output:
started roslaunch server http://omega:35395/
ros_comm version 1.15.13
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.13
If these steps were successful, you can continue with the next steps.
Set user Permissions
Assuming that you work with the default user pi
, and that you want to work with GPIO and I2X pins of the Raspberry Pi, we need to set specific access permissions.
Execute the following commands in a terminal:
sudo groupadd -f --system gpio
sudo usermod -a -G gpio pi
sudo usermod -a -G i2c pi
Setup a new ROS Package
To properly create ROS projects on your Raspberry Pi, follow these steps:
- Create a Catkin Workspace
mkdir ~/ros-noetic
cd ~/ros-noetic
- Create a ROS package inside the workspace
catkin_create_pkg cmd_vel_listener std_msg rospy --rosdistro noetic
Created file cmd_vel_listener/package.xml
Created file cmd_vel_listener/CMakeLists.txt
Created folder cmd_vel_listener/src
Successfully created files in /home/pi/catkin_ws/src/cmd_vel_listener. Please adjust the values in package.xml.
- Run the ROS compilation process
catkin_make
Base path: /home/pi/catkin_ws
Source space: /home/pi/catkin_ws/src
Build space: /home/pi/catkin_ws/build
Devel space: /home/pi/catkin_ws/devel
Install space: /home/pi/catkin_ws/install
####
#### Running command: "cmake /home/pi/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/pi/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/pi/catkin_ws/install -G Unix Makefiles" in "/home/pi/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/pi/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: False
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 4 packages in topological order:
-- ~~ - cmd_vel_listener
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
After this step, you are ready to go.
Conclusion
This short article showed the essential steps to install ROS on a Raspberry Pi running Ubuntu server. By using Ubuntu, you can use available Debian packages instead of compiling everything from scratch. Installation steps include a) updates sources list, b) add the required SSH keys, c) installing the packages. Afterwards, I showed how to set correct user permissions for interacting with the GPIOs and the I2C subsystem of the Raspberry Pi. Finally, I showed how to setup a ROS workspace in which you define your projects.
Posted on February 21, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
February 21, 2022