|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 Indigo on the Raspberry PiDescription: This instruction covers the installation of ROS Indigo on the original Raspberry Pi with Raspbian.
Keywords: RaspberryPi, Setup, Indigo
Tutorial Level: BEGINNER
- Maintaining a Source Checkout
This tutorial explains how to install ROS Indigo 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 it is faster and easier to use the standard ARM installation instructions here
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
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu wheezy main" > /etc/apt/sources.list.d/ros-latest.list' $ wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu jessie main" > /etc/apt/sources.list.d/ros-latest.list' $ wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
Now, make sure your Debian package index is up-to-date:
$ sudo apt-get update $ sudo apt-get upgrade
Install Bootstrap Dependencies
$ sudo apt-get install python-pip python-setuptools python-yaml python-argparse python-distribute python-docutils python-dateutil python-six $ sudo pip install rosdep rosinstall_generator wstool rosinstall
$ sudo apt-get install python-pip python-setuptools python-yaml python-distribute python-docutils python-dateutil python-six $ sudo pip install rosdep rosinstall_generator wstool rosinstall
$ sudo rosdep init $ rosdep update
Now, we will download and build ROS Indigo.
Create a catkin Workspace
In order to build the core packages, you will need a catkin workspace. Create one now:
$ mkdir ~/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 indigo --deps --wet-only --exclude roslisp --tar > indigo-ros_comm-wet.rosinstall $ wstool init src indigo-ros_comm-wet.rosinstall
$ rosinstall_generator desktop --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-desktop-wet.rosinstall $ wstool init src indigo-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.
Note: The roslisp package is excluded in these generators because the dependency sbcl is not available in the Raspbian repositories. Building sbcl from source may be possible but is not tested.
So far, only these two variants have been tested on the Raspberry Pi in Indigo; 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 indigo --deps --wet-only --tar > indigo-robot-wet.rosinstall $ wstool init src indigo-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 -t src
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.
Following packages are not available for Raspbian:
Raspbian Wheezy: libconsole-bridge-dev, liburdfdom-headers-dev, liburdfdom-dev, liblz4-dev, collada-dom-dev
Raspbian Jessie: collada-dom-dev
The following packages are needed for each ROS variant:
Ros_Comm: libconsole-bridge-dev, liblz4-dev
Desktop: libconsole-bridge-dev, liblz4-dev, liburdfdom-headers-dev, liburdfdom-dev, collada-dom-dev
The required packages can be built from source in a new directory:
$ mkdir ~/ros_catkin_ws/external_src $ sudo apt-get install checkinstall cmake $ sudo sh -c 'echo "deb-src http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi" >> /etc/apt/sources.list' $ sudo apt-get update
$ cd ~/ros_catkin_ws/external_src $ sudo apt-get build-dep console-bridge $ apt-get source -b console-bridge $ sudo dpkg -i libconsole-bridge0.2*.deb libconsole-bridge-dev_*.deb
If you see an error complaining about the option '-std=c++11' then follow these steps to upgrade to gcc 4.7+
sudo apt-get install g++-4.7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7 sudo update-alternatives --config gcc
$ cd ~/ros_catkin_ws/external_src $ apt-get source -b lz4 $ sudo dpkg -i liblz4-*.deb
$ cd ~/ros_catkin_ws/external_src $ git clone https://github.com/ros/urdfdom_headers.git $ cd urdfdom_headers $ git reset --hard 76da8dc $ cmake . $ sudo checkinstall make install
When check-install asks for any changes, the name (2) needs to change from "urdfdom-headers" to "liburdfdom-headers-dev" otherwise the rosdep install wont find it.
- Note: recent version of urdfdom_headers are incompatible with the ROS Indigo because of changes from using Boost shared pointers to C++11 shared pointers. '76da8dc' is the commit hash for the version just prior to the shared pointer change.
$ cd ~/ros_catkin_ws/external_src $ sudo apt-get install libboost-test-dev libtinyxml-dev $ git clone https://github.com/ros/urdfdom.git $ cd urdfdom $ cmake . $ sudo checkinstall make install
- When check-install asks for any changes, the name (2) needs to change from "urdfdom" to "liburdfdom-dev" otherwise the rosdep install wont find it.
$ cd ~/ros_catkin_ws/external_src $ wget https://github.com/assimp/assimp/archive/v3.3.1.zip $ unzip v3.3.1.zip $ rm v3.3.1.zip $ cd ~/ros_catkin_ws/external_src/assimp-3.3.1 $ cmake . -DCMAKE_BUILD_TYPE=Release -DASSIMP_BUILD_TESTS=False $ sudo checkinstall make install
- When check-install asks for any changes, the name (2) needs to change from "assimp" to "libassimp-dev" otherwise the rosdep install wont find it.
$ cd ~/ros_catkin_ws/external_src $ sudo apt-get install libboost-filesystem-dev libxml2-dev $ wget http://downloads.sourceforge.net/project/collada-dom/Collada%20DOM/Collada%20DOM%202.4/collada-dom-2.4.0.tgz $ tar -xzf collada-dom-2.4.0.tgz $ cd collada-dom-2.4.0 $ cmake . $ sudo checkinstall make install
- When check-install asks for any changes, the name (2) needs to change from "collada-dom" to "collada-dom-dev" otherwise the rosdep install wont find it.
Note: If you don't want to compile Collada but would like to install the desktop variant, use the following generator:
$ rosinstall_generator desktop --rosdistro indigo --deps --wet-only --exclude roslisp collada_parser collada_urdf --tar > indigo-desktop-wet.rosinstall
Resolving Dependencies with rosdep
The remaining dependencies should be resolved by running rosdep:
$ cd ~/ros_catkin_ws $ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:wheezy
$ cd ~/ros_catkin_ws $ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie
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.
Note: Rosdep may report that python-rosdep, python-catkin-pkg, python-rospkg, and python-rosdistro failed to install; however, you can ignore this error because they have already been installed with pip.
Building the catkin Workspace
Once you have completed downloading the packages and have resolved the dependencies, you are ready to build the catkin packages.
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo
Note: This will install ROS in the equivalent file location to Ubuntu in /opt/ros/indigo however you can modify this as you wish.
For rviz, you will also have to apply this patch.
Should the compilation fail with an "internal compiler error", it may be because you're out of memory. 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/indigo -j2
Now ROS should be installed! Remember to source the new installation:
$ source /opt/ros/indigo/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/indigo/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 indigo --deps --wet-only --exclude roslisp --tar > indigo-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 indigo-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:
$ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:wheezy
$ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie
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/indigo