(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Installing ROS Kinetic on the Raspberry Pi

Description: This instruction covers the installation of ROS Kinetic on the Raspberry Pi 2, 3, or 4 with Raspbian Jessie, Stretch, or Buster. However as final repositories are available now, today it is faster and easier to use Ubuntu Mate 16.04 (Xenial, download here) together with the standard ARM installation instructions here. An SD Card Image with Ubuntu 16.04 (LXDE) and ROS Kinetic installed can be downloaded here for the Raspberry Pi 3.

Keywords: RaspberryPi, Setup, Kinetic

Tutorial Level: BEGINNER


This tutorial explains how to install ROS Kinetic from source on the Raspberry Pi. The instructions follow roughly the source installation of Indigo. However, a few dependencies need to be accounted for Raspbian.

/!\ Note: If you're using the Raspberry Pi 2 or 3 it is faster and easier to use the standard ARM installation instructions here.

An SD Card Image with Ubuntu 16.04 and ROS Kinetic installed for Rapsberry Pi 3 can be downloaded here: https://downloads.ubiquityrobotics.com


These instructions assume that Raspbian is being used as the OS on the Raspberry Pi. The download page for current images of Raspbian is http://www.raspberrypi.org/downloads/.

Setup ROS Repositories

Raspbian Stretch:

Note: Instructions are similar to Jessie, but you must first install dirmngr:

$ sudo apt-get install dirmngr

Raspbian Buster:

Note: Instructions are same as Jessie unless mentioned otherwise

Raspbian Jessie:

$ 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://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

Now, make sure your Debian package index is up-to-date:

$ sudo apt-get update
$ sudo apt-get upgrade

Install Bootstrap Dependencies

Raspbian Jessie:

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

Initializing rosdep

$ sudo rosdep init
$ rosdep update


Now, we will download and build ROS Kinetic.

Create a catkin Workspace

In order to build the core packages, you will need a catkin workspace. Create one now:

$ mkdir -p ~/ros_catkin_ws
$ cd ~/ros_catkin_ws

Next we will want to fetch the core packages so we can build them. We will use wstool for this. Select the wstool command for the particular variant you want to install:

ROS-Comm: (recommended) ROS package, build, and communication libraries. No GUI tools.

  • $ rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall
    $ wstool init src kinetic-ros_comm-wet.rosinstall

Desktop: ROS, rqt, rviz, and robot-generic libraries

  • $ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-wet.rosinstall
    $ wstool init src kinetic-desktop-wet.rosinstall

This will add all of the catkin or wet packages in the given variant and then fetch the sources into the ~/ros_catkin_ws/src directory. The command will take a few minutes to download all of the core ROS packages into the src folder. The -j8 option downloads 8 packages in parallel.

So far, only these two variants have been tested on the Raspberry Pi in Kinetic; however, more are defined in REP 131 such as robot, perception, etc. Just change the package path to the one you want, e.g., for robot do:

$ rosinstall_generator robot --rosdistro kinetic --deps --wet-only --tar > kinetic-robot-wet.rosinstall
$ wstool init src kinetic-robot-wet.rosinstall

Please feel free to update these instructions as you test more variants.

If wstool init fails or is interrupted, you can resume the download by running:

wstool update -j4 -t src

Resolve Dependencies

Before you can build your catkin workspace, you need to make sure that you have all the required dependencies. We use the rosdep tool for this, however, a couple of dependencies are not available in the repositories. They must be manually built first.

Unavailable Dependencies

Compilation of collada_urdf will fail per this issue.

You can provide a compatible version of Assimp (Open Asset Import Library) to fix this link error:

mkdir -p ~/ros_catkin_ws/external_src
cd ~/ros_catkin_ws/external_src
wget http://sourceforge.net/projects/assimp/files/assimp-3.1/assimp-3.1.1_no_test_models.zip/download -O assimp-3.1.1_no_test_models.zip
unzip assimp-3.1.1_no_test_models.zip
cd assimp-3.1.1
cmake .
sudo make install

Note: If you have problems, you can skip collada_urdf using the following generator:

$ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --exclude collada_parser collada_urdf --tar > kinetic-desktop-wet.rosinstall

Resolving Dependencies with rosdep

The remaining dependencies should be resolved by running rosdep:

Raspbian Stretch:

$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:stretch

Raspbian Jessie:

$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:jessie

Raspbian Buster:

$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:buster

This will look at all of the packages in the src directory and find all of the dependencies they have. Then it will recursively install the dependencies.

The --from-paths option indicates we want to install the dependencies for an entire directory of packages, in this case src. The --ignore-src option indicates to rosdep that it shouldn't try to install any ROS packages in the src folder from the package manager, we don't need it to since we are building them ourselves. The --rosdistro option is required because we don't have a ROS environment setup yet, so we have to indicate to rosdep what version of ROS we are building for. Finally, the -y option indicates to rosdep that we don't want to be bothered by too many prompts from the package manager.

After a while rosdep will finish installing system dependencies and you can continue.

(rosdep may fail to install VTK6 if you have installed anything that requires VTK7, such as libpcl, from apt-get. Simply use sudo apt-get remove libvtk7-dev libvtk7-qt-dev to get rid of VTK7 related packages before calling rosdep again. Feel free to reinstall VTK7, and your other packages, right after rosdep finishes.)

Building the catkin Workspace

Once you have completed downloading the packages and have resolved the dependencies, you are ready to build the catkin packages.

Invoke catkin_make_isolated:

Note: On Raspbian Buster the compilation may fail with "'boost/tr1/unordered_set.hpp' file not found". This is because rospack version used in Kinetic is dependent on boost 1.58. To fix this error try installing boost 1.58 manually.

(note: the libboost 1.58 available through apt-get is not compatible with librosconsole when you are using GCC 8, the solution is to build boost 1.58 from source using GCC 8, or use a previous version of GCC for the entire build of ROS. Also almost all Kinetic ROS packages uses libboost 1.58 and fail to build with newer versions of libboost, please just keep using 1.58 for anything built within your catkin workspace)

(note: if you install libpcl later through apt-get, for use with rtabmap or other point-cloud packages, it will install the latest libboost 1.67 as a dependancy. Having both a manually installed libboost 1.58 in /usr/local/lib and automatically installed libboost 1.67 in /usr/lib will cause rtabmap to have runtime errors from CloudViewer.cpp. Thus it is recommended that the manually built libboost 1.58 is not actually installed, but instead simply pointed to by cmake's BOOST_INCLUDEDIR and BOOST_LIBRARYDIR, boost's build output actually shows you how.)

Raspbian Buster: gonzalocasas 's answer

$ sudo apt remove libboost1.67-dev
$ sudo apt autoremove
$ sudo apt install -y libboost1.58-dev libboost1.58-all-dev
$ sudo apt install -y g++-5 gcc-5
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
$ sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$ sudo update-alternatives --set cc /usr/bin/gcc
$ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$ sudo update-alternatives --set c++ /usr/bin/g++
$ sudo apt install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake

$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic

Note: This will install ROS in the equivalent file location to Ubuntu in /opt/ros/kinetic however you can modify this as you wish.

It is highly likely that the compilation will fail with an "internal compiler error" caused by memory exhaustion. A quick fix for this is to add swap space to the Pi and recompile. If the error persists try building with the -j2 option instead of the default -j4 option:

$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j2

CMake may have trouble finding FindEigen3.cmake. See this discussion for workarounds.

Now ROS should be installed! Remember to source the new installation:

$ source /opt/ros/kinetic/setup.bash

Or optionally source the setup.bash in the ~/.bashrc, so that ROS environment variables are automatically added to your bash session every time a new shell is launched:

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

Maintaining a Source Checkout

Updating the Workspace

See the Ubuntu source install instructions for steps on updating the ros_catkin_ws workspace. The same steps should apply to the Raspberry Pi.

Adding Released Packages

You may add additional packages to the installed ros workspace that have been released into the ros ecosystem. First, a new rosinstall file must be created including the new packages (Note, this can also be done at the initial install). For example, if we have installed ros_comm, but want to add ros_control and joystick_drivers, the command would be:

$ cd ~/ros_catkin_ws
$ rosinstall_generator ros_comm ros_control joystick_drivers --rosdistro kinetic --deps --wet-only --tar > kinetic-custom_ros.rosinstall

You may keep listing as many ROS packages as you'd like separated by spaces.

Next, update the workspace with wstool:

$ wstool merge -t src kinetic-custom_ros.rosinstall
$ wstool update -t src

After updating the workspace, you may want to run rosdep to install any new dependencies that are required:

Raspbian Jessie:

$ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y -r --os=debian:jessie

Raspbian Stretch:

$ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y -r --os=debian:stretch

Finally, now that the workspace is up to date and dependencies are satisfied, rebuild the workspace:

$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic

If the Raspberry Pi stalls due to an out-of-memory error, try adding the -j2 parameter option when rebuilding the workspace:

$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j2


Wiki: ROSberryPi/Installing ROS Kinetic on the Raspberry Pi (last edited 2020-05-05 22:48:58 by DmT)