[Documentation] [TitleIndex] [WordIndex

Installing on Raspberry PI/Raspbian from source

Install from source requires that you download and compile the source code on your own. Beware it will take days to compile the desktop package if you do not set up a chroot environment and you will have to fix a few things described in the respective section. You can also download a compressed image of the mobile package combined with the perception variant including OpenCV, PCL and other goodies from here http://goo.gl/FjGKb

Install Raspbian

You have the choice of compiling ROS directly on the the Raspberry Pi hardware or in a chroot on a machine of your choice. Compiling a working ROS system on the Raspberry Pi Hardware will likely take days to complete. A chroot (similar to a virtual machine) will be able to utilize the resources of the host machine and will compile many times faster. Choose your own adventure:

SD Card install

chroot

If you want to build ROS from source and plan to build more than the ROS Comm stack, it is recommended to setup a chroot environment on another system. This will only work on Linux or a VirtualBox running Linux.

It will allow you to compile with more memory and multiple cores which makes it much faster than a native compilation on the Raspberry Pi. To set up chroot, you will need qemu which will emulate the raspi.

$ sudo apt-get install qemu qemu-user qemu-user-static parted gparted kpartx

Now you can either copy the SD card to your computer using dd or you can mount it in the USB drive. If you only have the image file on your harddrive and want to expand the size, check out this guide: groovy/Installation/Linaro/Source

It will also tell you how to mount it if you dd-ed the image to your hard drive. If you used the Raspbian image from december and called it raspi.img, you can use the following mount http://pastebin.com/WA0phHXZ and umount script http://pastebin.com/FZrbbrZ0 After the first mount, you will need to copy one file. The second time, the script will work fine.

$ sudo cp /usr/bin/qemu-arm-static /mnt/usr/bin/
$ sudo chroot /mnt

If you did not dd it to the hard drive, it will probably be already mounted and you can just replace raspi.img with the correct mount point. You will also not need to mount it with an offset. Once that has been tried, this wiki will be updated.

From now on you can exchange every "j1" you see in this tutorial with a number corresponding to the amount of cores in your computer.

chroot will automatically log you in as root, so do not you sudo as described in this tutorial. If you do not want be logged in as root, you can switch to the regular user by typing

su pi

Two users experienced a known cmake issue (race condition) with qemu that causes it to hang during build. Others have built successfully without issue however.

Install Dependencies

Add the Raspbian repo to /etc/apt/sources.list

Install the core system dependencies:

Install ROS bootstrapping tools:

ROS Installation

Start by building the core ROS packages.

First create the area in the directory that we will be using:

Next ensure rosdep has been initialized:

ROS is in the process of converting to a new build system, catkin, but not all of the packages have been converted and the two build systems cannot be used simultaneously. Therefore it is necessary to build the core ROS packages first (catkin packages) and then the rest.

Create a catkin Workspace

In order to build the core packages, navigate to the catkin workspace

$ cd /opt/ros/groovy/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: (Bare Bones) ROS package, build, and communication libraries. No GUI tools, no OpenCV or PCL

Mobile Install: (Recommended) Includes robot_model and PCL, no OpenCV, no GUI

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

This will add almost all of the catkin or wet packages in the given variant and then fetch the sources into the /opt/ros/groovy/ros_catkin_ws/src directory. The command will take a few minutes to download all of the core ROS packages into the src folder. Since the Raspberry Pi is single core we use the -j1 for a single package at a time.

In addition to the 3 variants above, more are defined in REP 131 such as robot, perception, etc. You can also combine variants by merging another variant into the existing package. If you initialized the workspace with the mobile variant, you could add the perception variant by:

$ cd src
$ rosinstall_generator --rosdistro groovy perception > /tmp/groovy_perception.ri
$ wstool merge /tmp/groovy_perception.ri
$ wstool update
$ cd ..

Increase Swap

If you are building the ROS-Comm package or set up a chroot environment skip this step. For all desktop packages, the SRAM is not big enough, so we need to increase the swap file (Hopefully your SD card has enough capacity)

Resolving Dependencies

Depending on what packages you want to build, you will need to install some libraries by hand

camera_calibration_parser

This package will require yaml-cpp to be installed. Do not install the latest version from source, use this prebuilt binary

$ sudo apt-get install libyaml-cpp-dev

OpenCV2

If you added a variant which includes opencv2, you want to remove it from the src folder and install it using prebuilt binaries.

$ sudo apt-get install libopencv-dev
$ rm -rf src/opencv2

Openni

If you want to use PCL with Openni, you will also need to install it before compiling PCL

$ sudo apt-get install libopenni-dev

PCL

You will need to use the PCL provided by ROS, unfortunately PCL will not compile, so do the following changes:

Edit src/pcl/cmake/pcl_find_sse.cmake and replace '-march=native' from line 10 with '-march=armv6 -mfloat-abi=hard -mfpu=vfp'.

Edit src/pcl/io/include/pcl/io/ply/byte_order.h and define PLY_LITTLE_ENDIAN, right after it checks if it was already defined on line (69?).

Collada

If you want to use any collada package (included in both the 'desktop' and 'moblie' installations), you will need to install collada-dom from source http://sourceforge.net/projects/collada-dom/files/latest/download

$ sudo apt-get install libxml2-dev

$ mkdir /opt/ros/collada
$ cd /opt/ros/collada
  {download the collada source from the above link and put it in this directory}
$ tar -xf collada*; rm collada*tgz; cd collada*; mkdir build; cd build
$ cmake .. ; make -j1; sudo make install

Collada requires assimp. There is something wrong with the ASSIMP binary, so you also need to compile it from source http://sourceforge.net/projects/assimp/files/assimp-3.0

$ mkdir /opt/ros/assimp
$ cd /opt/ros/assimp
  {download the assmip source zip from the above link and put it in this directory}
$ unzip assimp*; rm assimp*zip*; cd assimp*; mkdir build; cd build
$ cmake ..; make -j1; sudo make install

Modify CMakeLists.txt in collada_urdf to default to ASSIMP version 3 by replacing "set(IS_ASSIMP3 0)" at line 36(?) with :

  set(IS_ASSIMP3 1)
  add_definitions(-DIS_ASSIMP3)

Remaining Dependencies

After a while (and maybe some prompts for your password) rosdep will finish installing system dependencies and you can continue.


Build the Catkin Workspace

Now you are ready to build the catkin packages. We will use the catkin_make_isolated command because there are both catkin and plain cmake packages in the base install, when developing on your catkin only workspaces you should use catkin/commands/catkin_make.

Invoke catkin_make_isolated:

Note: The default catkin installation location would be ~/ros_catkin_ws/install_isolated, if you would like to install some where else then you can do this by adding the --install-space /opt/ros/groovy argument to your catkin_make_isolated call.

For usage on a robot without Raspbain, it is recommended to install compiled code into /opt/ros/groovy just as the Raspbain packages would do. It is also possible to install elsewhere (e.g. /usr), but it is not recommended unless you really know what you are doing.

Please see REP 122: Filesystem Hierarchy Layout for more detailed documentation on how the installed files are placed.

Note: In the above command we are running the catkin_make_isolated command from the catkin source folder because it has not been installed yet, once installed it can be called directly.

Now the packages should have been installed to /opt/ros/groovy or to wherever you specified with the --install-space argument. If you look in that directory you will see that a setup.bash file have been generated. To utilize the things installed there simply source that file. Lets do that now before building the rest of ROS:

Build the rosbuild Packages

Now that you have the catkin ROS packages built and sourced, you can build any of the packages and stacks using the rosbuild build system.

Create a rosbuild workspace

Note: You do not need to do this part of the installation for the ROS-Comm: (Bare Bones) variant as it does not contain any rosbuild packages in it.

Like with building catkin packages, it is convenient to build rosbuild packages in a workspace. Lets create a ROS workspace using rosws:

Note that we are pointing the ROS workspace to the catkin install location that we built in the previous step. This allows the ROS workspace to always source the catkin install location environment before you use the ROS workspace.

Download ROS Stacks

Now we need to get the dry (rosbuild) components of the variant you chose before. Use the corresponding command for your variant to do this:

Mobile Install:

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

Desktop-Full Install: 2d/3d simulators, navigation, robot models and several tutorial stacks

Now tell rosws to fetch the packages:

Fix Broken Dependencies

https://github.com/ros-planning/navigation/issues/17

Remove the common_rosdeps dependency from each of the files listed by

Build the ROS Stack

Once this is done fetching the stack you can source this workspace and then build the stack:

Install Optional Packages

Joystick Drivers

Prepare workspace:

Add the following to ~/catkin_ws/src/.rosinstall

Install MoveIt!

In Groovy, arm-navigation was replaced by MoveIt! which is not released yet, but here is what you need to do to install it on your Raspberry. !Not done yet!


2024-11-23 14:39