In this post we will install ROS Indigo on a Raspberry Pi 2, it is just a sequence of commands you should use to install this framework. Please refer to the official main page for futher informations.

ROS

ROS is a open source framework for robotic platform development. It is a meta-operating system for your robot. The aim of this framework is to take advantage of reliable robotic softwares already implemented and tested across the globe. This framework is a powerful tool and consists of a collection of libraries for obtaining, building, writing, and running code across multiple computers.

It provides services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality. It also provides tools that will simplify the task of creating complex and robust robot behavior.

  • Distributed Framework: ROS is a distributed framework that can run on multiple machines, so the computation of the robot can be divided over different machines. It can reduce the on board processing of the robot.
  • Languages: The ROS framework can be programmed using popular languages (such as Python, C++, and Lisp). The nodes can be written in any language and can communicate through ROS using topics, messages and services.
  • It’s free and Open Source: The source code is open. The core part of ROS is licensed under BSD license and it can be reused in commercial and closed source products.

Installation of ROS

We will assume that Raspbian OS is being used on the Raspberry Pi.

userk@meiji:~ $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu wheezy main" > /etc/apt/sources.list.d/ros-latest.list'
userk@meiji:~ $ wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
--2015-08-14 16:41:01--  https://raw.githubusercontent.com/ros/rosdistro/master/ros.key
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.31.17.133, 64:ff9b::b91f:1185
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.31.17.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1162 (1.1K) 
[application/octet-stream] Saving to: `STDOUT' 100%[======================================>] 1,162 --.-K/s in 0s 2015-08-14 16:41:09 (2.76 MB/s) - written to stdout [1162/1162] OK userk@meiji:~ $

Now update and upgrade.

userk@meiji:~ $ sudo apt-get update
userk@meiji:~ $ sudo apt-get upgrade

Let’s install dependencies

userk@meiji:~ $ sudo apt-get install python-pip python-setuptools python-yaml python-distribute python-docutils python-dateutil python-six
userk@meiji:~ $ sudo pip install rosdep rosinstall_generator wstool rosinstall

And initialize rosdep with the following command.

userk@meiji:~ $ sudo rosdep init
userk@meiji:~ $ rosdep update

Create a Catkin Workspace and download ROS

We will first create a ros directory in your home folder ther fetch the core packages.

userk@meiji:~ $ cd ~ && mkdir ros && cd ros
userk@meiji:~ $ rosinstall_generator ros_comm --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-ros_comm-wet.rosinstall
userk@meiji:~ $ wstool init src indigo-ros_comm-wet.rosinstall

Resolving dependencies
Before building our workspace we will use rosdep to install all required dependencies. Some of them are not available in the repositories and must be manually built.

Considering that we want to install the Ros_Comm variant, we will build the following package: libconsole-bridge-dev and liblz4-dev

Let’s create a directory to build all the required packages and install cmake and checkinstall.

userk@meiji:~ $  mkdir ~/ros/external_src
userk@meiji:~ $  sudo apt-get install checkinstall cmake
userk@meiji:~ $  sudo sh -c 'echo "deb-src http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi" >> /etc/apt/sources.list'
userk@meiji:~ $  sudo apt-get update

libconsole-bridge-dev:

userk@meiji:~ $  cd ~/ros/external_src
userk@meiji:~ $  sudo apt-get build-dep console-bridge
userk@meiji:~ $  apt-get source -b console-bridge
userk@meiji:~ $  sudo dpkg -i libconsole-bridge0.2_*.deb libconsole-bridge-dev_*.deb

liblz4-dev:

userk@meiji:~ $  cd ~/ros_catkin_ws/external_src
userk@meiji:~ $ sudo apt-get source -b lz4
userk@meiji:~ $  sudo dpkg -i liblz4-*.deb

The remaining dependencies should be resolved by running rosdep:

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

Building the catkin Workspace

We are now ready to build the catkin packages

userk@meiji:~ $  sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo

Help!!

  • If you got an error during last step, you might need to install:
     pi@tenzo ~/development/ros $ sudo apt-get install python-empy python2.7-dev libbz2-dev
  • If you run roscore and you get a command not found, source your setup.bash file
    userk@meiji: ~/development/ros $ roscore
    -bash: roscore: command not found
    

    Solution:

    userk@meiji: ~/development/ros $ source /opt/ros/indigo/setup.bash 
    userk@meiji: ~/development/ros $ roscore
    
  • If roscore keeps restarting after throwing an instance of ‘std::runtime_error’
    userk@meiji: ~/development/ros $  source /opt/ros/indigo/setup.bash
        roscore
        [...]
        setting /run_id to 04180ffe-50d0-11e5-ab19-74da3805302a
        process[rosout-1]: started with pid [3650]
        started core service [/rosout]
        terminate called after throwing an instance of 'std::runtime_error'
          what():  locale::facet::_S_create_c_locale name not valid
        [rosout-1] process has died [pid 3650, exit code -6, cmd /opt/ros/indigo/lib/rosout/rosout __name:=rosout __log:=/home/pi/.ros/log/04180ffe-50d0-11e5-ab19-74da3805302a/rosout-1.log].
        log file: /home/pi/.ros/log/04180ffe-50d0-11e5-ab19-74da3805302a/rosout-1*.log
        [rosout-1] restarting process
    

    Then your problem may be caused by your locale not properly set. See this answer.

    Just set the LANG, LANGUAGE, LC_MESSAGES and LC_ALL field in the locale file:

    userk@meiji: ~/development/ros $ sudo vim /etc/default/locale 
    LANG=en_GB.UTF-8
    LANGUAGE=C
    LC_MESSAGES=POSIX
    LC_ALL=C
    sudo reboot
    

    You could also run the graphical configuration with:

     sudo dpkg-reconfigure locales