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 $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
    wget -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 -j2
    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
    cd ~/catkin_workspace/
    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.

4 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!

Leave a Reply

Required fields are marked *.