How to Install ROS Kinetic on Raspberry Pi 3 running Raspbian Stretch Lite

I want to control an autonomous robot with a Raspberry Pi 3 board and ROS Kinetic. The Pi 3 will be connected to another Linux PC used for monitoring and control settings. The setup for computers are in this article.

Due to the lack of Pi resources in terms of processor and memory, I’m forced to use resources more efficiently. The first step is to install on Pi an operating system like Raspbian Stretch Lite. The interaction with this system is done through type commands. It doesn’t have GUI and other software included with the Desktop version. Theoretically speaking, it is a perfect operating system if you want to not stress the Pi board with too many tasks that you do not need anyway.

The system will use the Raspberry Pi board as the master while the PC is the slave. This configuration means to run the Roscore on the robot instead on the remote PC. The PC is used to see the message that coming from Pi or send some manual correction back to the robot.

I installed the ROS Kinetic version with no GUI tools on the Raspbian Stretch Lite and I put all the steps below.

  • Step 1: Download and install Raspbian Stretch Lite
    The installation steps for Raspberry Lite are described here.
  • Step 2:Connect via SSH to Pi and run the below commands:

    sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

    wget http://packages.ros.org/ros.key -O – | sudo apt-key add –

    sudo apt-get update

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

    sudo apt install dirmngr

    sudo rosdep init

    rosdep update

    rosinstall_generator ros_comm –rosdistro kinetic –deps –wet-only –tar > kinetic-ros_comm-wet.rosinstall

    wstool init src kinetic-ros_comm-wet.rosinstall

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

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

    (thanks CaJU and Bruce W)

    source /opt/ros/kinetic/setup.bash

    echo ‘source /opt/ros/kinetic/setup.bash’ >> ~/.bashrc

    mkdir -p ~/catkin_workspace/src

    cd catkin_workspace/src

    catkin_init_workspace

    cd ~/catkin_workspace/

    catkin_make

    source ~/catkin_workspace/devel/setup.bash

    echo ‘source ~/catkin_workspace/devel/setup.bash’ >> ~/.bashrc

    export | grep ROS

  • Step 3 (optional): The installation process takes several hours and sincerely, I don’t want to repeat the installation too soon. I decide to clone the memory card as soon as I finished the initial installation. Here are the steps needed to clone the memory card.

You can find additional information here and here.

7 comments » Write a comment

  1. I am getting my Raspberry Pi freezed when I used this command:
    sudo ./src/catkin/bin/catkin_make_isolated –install -DCMAKE_BUILD_TYPE=Release –install-space /opt/ros/kinetic -j2
    Specifically it freezes while installing the “roscpp” package.

    • Hi! Maybe you could try to remove the “-j2” at the end of the command. It is written to run the order in two threads, what is faster, but sometimes the raspberrys have problems executing commands in multiple threads.

      • On mine, if you don’t explicitly set to single core it uses 4 cores. So use “-j1” instead of “-j2” at the end of the command.

        I’ve also read that you can deal with this by upping the swap space to 2GB. I did both, but the swap space was not needed. With 2 cores, the memory usage went up to 100%. I’ve read that’s because of deadlocks waiting for memory.

  2. So I’ve spent the past few weeks trying to research how to get ROS Melodic on a Raspberry Pi 3 B+ with Raspbian Lite (Stretch). It seems following your instructions and replacing kinetic with melodic actually did the trick!

  3. Hi
    I am following above steps.
    However after i run ‘wstool init src kinetic-ros_comm-wet.rosinstall’, i get below fether failures.
    Can you suggest a way to solve it?
    Exception caught during install: Error processing ‘genmsg’ : [genmsg] Checkout of https://github.com/ros-gbp/genmsg-release/archive/release/kinetic/genmsg/0.5.11-0.tar.gz version genmsg-release-release-kinetic-genmsg-0.5.11-0 into /home/pi/src/genmsg failed.
    Error processing ‘ros_comm/rosmaster’ : [ros_comm/rosmaster] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/kinetic/rosmaster/1.12.14-0.tar.gz version ros_comm-release-release-kinetic-rosmaster-1.12.14-0 into /home/pi/src/ros_comm/rosmaster failed.
    Error processing ‘ros_comm/rosmsg’ : [ros_comm/rosmsg] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/kinetic/rosmsg/1.12.14-0.tar.gz version ros_comm-release-release-kinetic-rosmsg-1.12.14-0 into /home/pi/src/ros_comm/rosmsg failed.
    Error processing ‘ros_comm/roswtf’ : [ros_comm/roswtf] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/kinetic/roswtf/1.12.14-0.tar.gz version ros_comm-release-release-kinetic-roswtf-1.12.14-0 into /home/pi/src/ros_comm/roswtf failed.

    ERROR in config: Error processing ‘genmsg’ : [genmsg] Checkout of https://github.com/ros-gbp/genmsg-release/archive/release/kinetic/genmsg/0.5.11-0.tar.gz version genmsg-release-release-kinetic-genmsg-0.5.11-0 into /home/pi/src/genmsg failed.
    Error processing ‘ros_comm/rosmaster’ : [ros_comm/rosmaster] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/kinetic/rosmaster/1.12.14-0.tar.gz version ros_comm-release-release-kinetic-rosmaster-1.12.14-0 into /home/pi/src/ros_comm/rosmaster failed.
    Error processing ‘ros_comm/rosmsg’ : [ros_comm/rosmsg] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/kinetic/rosmsg/1.12.14-0.tar.gz version ros_comm-release-release-kinetic-rosmsg-1.12.14-0 into /home/pi/src/ros_comm/rosmsg failed.
    Error processing ‘ros_comm/roswtf’ : [ros_comm/roswtf] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/kinetic/roswtf/1.12.14-0.tar.gz version ros_comm-release-release-kinetic-roswtf-1.12.14-0 into /home/pi/src/ros_comm/roswtf failed.

    Thanks in advance

  4. Argh got so close to the end! I’m trying to install ROS on RPi3 running Stretch Lite but when running ‘rosdep install’ (10th command) I get an error that some packages/stacks could not have their rosdep keys resolved to system dependencies, for instance:

    genlisp: no definition of [genmsg] for OS [debian]
    rosbag: No definition of [roscpp] for OS [debian]
    rostest: No definition of [rosmaster] for OS [debian]

    Subsequently, the command after that gave errors due to the missing packages. Any advice?

Leave a Reply

Required fields are marked *.