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
Contents
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
Download the Raspbian “wheezy” image from the Raspberry Pi downloads page: http://www.raspberrypi.org/downloads. The chroot environment will not work on the February release, so download the December Release from http://downloads.raspberrypi.org/images/raspbian/2012-12-16-wheezy-raspbian/ if your want to use chroot
Instructions for how to create the SD card from the image: http://elinux.org/RPi_Easy_SD_Card_Setup
- Note: A 8GB SD card or larger is required to build the mobile and a 16GB SD card for the desktop variant.
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
$ echo "deb http://ros.raspbian.org/repo/ros/ wheezy main" >> /etc/apt/sources.list $ sudo apt-get update $ sudo apt-get upgrade
Install the core system dependencies:
$ sudo apt-get install build-essential python-yaml cmake subversion wget python-setuptools mercurial git-core libapr1-dev libaprutil1-dev libbz2-dev python-dev libgtest-dev python-paramiko libboost-all-dev liblog4cxx10-dev pkg-config python-empy swig python-nose lsb-release python-pip python-gtk2
Install ROS bootstrapping tools:
$ sudo easy_install wstool rospkg rosdep rosinstall_generator
ROS Installation
Start by building the core ROS packages.
First create the area in the directory that we will be using:
$ sudo mkdir -p /opt/ros/groovy/ros_catkin_ws
Next ensure rosdep has been initialized:
$ sudo rosdep init $ sudo rosdep update
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
$ rosinstall_generator --rosdistro groovy ros_comm > /tmp/groovy_ros_comm.ri $ sudo wstool init src -j1 /tmp/groovy_ros_comm.ri
Mobile Install: (Recommended) Includes robot_model and PCL, no OpenCV, no GUI
$ rosinstall_generator --rosdistro groovy mobile > /tmp/groovy_mobile.ri $ sudo wstool init src -j1 /tmp/groovy_mobile.ri
Desktop Install: ROS, rqt, rviz, and robot-generic libraries
$ rosinstall_generator --rosdistro groovy desktop > /tmp/groovy_desktop.ri $ sudo wstool init src -j1 /tmp/groovy_desktop.ri
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)
$ sudo swapoff /var/swap; sudo dd if=/dev/zero of=/var/swap bs=1024 count=2048k $ sudo mkswap /var/swap; sudo swapon /var/swap; sudo swapon -s
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
$ sudo rosdep install --from-paths src --ignore-src --rosdistro groovy -yr
--from-paths indicates that we want to install the dependencies for an entire directory of packages, in this case src.
--ignore-src indicates to rosdep that it shouldn't try to install any ROS packages in the src folder from the package manager.
--rosdistro is required because we don't have a ROS environment setup yet.
-y indicates to rosdep that we don't want to be bothered by too many prompts from the package manager.
After a while (and maybe some prompts for your password) rosdep will finish installing system dependencies and you can continue.
The above command will fail for 'desktop' and 'mobile' installations. This is because some of the dependencies were installed outside of apt which rosdep uses to verify the installation. Use the following command to identify these "missing" dependencies:
sudo rosdep check --from-paths src --ignore-src --rosdistro groovy
- Edit the package.xml file in each package that produced an error.
- Delete or comment out any lines where it checks for the "missing" dependencies.
- Use the above 'rosdep install ...' command and it should work fine.
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:
$ sudo ./src/catkin/bin/catkin_make_isolated --install --install-space /opt/ros/groovy
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:
$ source /opt/ros/groovy/setup.bash
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:
$ mkdir ~/ros_ws $ cd ~/ros_ws $ rosws init . /opt/ros/groovy/
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:
$ sudo apt-get install libsdl-image1.2-dev $ rosws merge http://packages.ros.org/web/rosinstall/generate/dry/raw/groovy/mobile $ rosws set laser_geometry git://github.com/ros-perception/laser_geometry.git --git --version=laser_pipeline-1.4
Desktop Install: ROS, rqt, rviz, and robot-generic libraries
$ rosws merge http://packages.ros.org/web/rosinstall/generate/dry/raw/groovy/desktop
Desktop-Full Install: 2d/3d simulators, navigation, robot models and several tutorial stacks
$ rosws merge http://packages.ros.org/web/rosinstall/generate/dry/raw/groovy/desktop-full
There are build errors in desktop-full (gazebo simulator) at the moment, so the desktop variant is suggested at this time. See: https://code.ros.org/trac/ros-pkg/ticket/5595
Now tell rosws to fetch the packages:
$ rosws update
Fix Broken Dependencies
https://github.com/ros-planning/navigation/issues/17
Remove the common_rosdeps dependency from each of the files listed by
grep -r common_rosdeps *
Build the ROS Stack
Once this is done fetching the stack you can source this workspace and then build the stack:
$ source ~/ros_ws/setup.bash $ rosmake -a
Install Optional Packages
Joystick Drivers
Prepare workspace:
$ sudo apt-get install libspnav-dev $ mkdir -p ~/catkin_ws/src $ touch ~/catkin_ws/src/.rosinstall
Add the following to ~/catkin_ws/src/.rosinstall
- tar: {local-name: wiimote, uri: 'https://github.com/ros-gbp/joystick_drivers-release/archive/release/wiimote/1.9.6.tar.gz', version: joystick_drivers-release-release-wiimote-1.9.6} - tar: {local-name: spacenav_node, uri: 'https://github.com/ros-gbp/joystick_drivers-release/archive/release/spacenav_node/1.9.6.tar.gz', version: joystick_drivers-release-release-spacenav_node-1.9.6} - tar: {local-name: joy, uri: 'https://github.com/ros-gbp/joystick_drivers-release/archive/release/joy/1.9.6.tar.gz', version: joystick_drivers-release-release-joy-1.9.6} - tar: {local-name: joystick_drivers, uri: 'https://github.com/ros-gbp/joystick_drivers-release/archive/release/joystick_drivers/1.9.6.tar.gz', version: joystick_drivers-release-release-joystick_drivers-1.9.6} - tar: {local-name: ps3joy, uri: 'https://github.com/ros-gbp/joystick_drivers-release/archive/release/ps3joy/1.9.6.tar.gz', version: joystick_drivers-release-release-ps3joy-1.9.6}
$ cd ~/catkin_ws/src $ wstool update $ cd ~/catkin_ws $ catkin_make $ source ~/catkin_ws/setup.bash
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!
sudo apt-get install libmongo-client-dev libmongo-client0 cd ~/catkin_ws/src wget https://bitbucket.org/ompl/ompl/downloads/omplapp-0.12.2-Source.tar.gz tar -xf omplapp* cd omplapp* ; cmake . ; make install wstool set libccd https://github.com/danfis/libccd.git --git -y wstool set fcl https://github.com/flexible-collision-library/fcl.git --git -y wstool set octomap https://github.com/OctoMap/octomap.git --git -y wstool set control_msgs https://github.com/ros-planning/control_msgs.git --git -y wstool set random_numbers https://github.com/ros-planning/random_numbers.git --git -y wstool set shape_tools https://github.com/ros-gbp/shape_tools-release.git --git -y wstool set eigen_stl_containers https://github.com/ros-gbp/eigen_stl_containers-release.git --git -y wstool set pr2_mechanism_msgs https://github.com/ros-gbp/pr2_mechanism_msgs-release.git --git -y wstool set geometric_shapes https://github.com/ros-planning/geometric_shapes.git --git -y wstool set octomap_msgs https://github.com/OctoMap/octomap_msgs.git --git -y wstool set warehouse_ros https://github.com/ros-planning/warehouse_ros.git --git -y wstool merge https://raw.github.com/ros-planning/moveit_docs/master/moveit.rosinstall wstool update cd libccd; cmake .; sudo make install; cd .. cd octomap; cmake .; sudo make install; cd .. cd fcl; cmake .; sudo make install; cd .. cd shape_tools; git checkout debian/groovy/shape_tools; cd .. cd eigen_stl_containers; git checkout release/eigen_stl_containers; cd .. cd pr2_mechanism_msgs; git checkout release/pr2_mechanism_msgs; cd .. cd ~/catkin_ws mkdir -p devel/include/octomap_msgs mkdir -p devel/include/eigen_stl_containers cp -r src/eigen_stl_containers/include/eigen_stl_containers/* devel/include/eigen_stl_containers cp -r eigen_stl_containers/include/eigen_stl_containers/ geometric_shapes/include cp src/octomap_msgs/include/octomap_msgs/conversions.h devel/include/octomap_msgs vi src/moveit_core/CMakeLists.txt remove fcl from find package catkin_make