Installing on Raspberry PI/Raspbian from source



Installing on Raspberry PI/Raspbian from http://wiki.ros.org/groovy/Installation/Raspbian/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

  • $ 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

 
 

 

  

 

   

  

 

 

   

 
  
  

ROS在ARM上的编译

ROS(robot operaring system)作为移动机器人软件架构,近几年得到了越来越广泛的应用,但是大部分应用是基于X86架构的处理器,怎么样将这么强大的工具和应用极为广泛的ARM处理器结合在一起,是现在很多开发者急于解决的问题。我作为ROS的初学者最近也尝试了一把ROS 的ARM移植,纠结了四五天,不过最后还是成功了。

      虽然现在针对非X86架构的处理器产生了一些ROS的应用方案,比如eros(http://www.ros.org/wiki/eros)、rosserial(http://www.ros.org/wiki/rosserial等方式,后者是针对Arduino的,前者玩了几天,没搞清楚是怎么用的,所以上网各处搜索,也在ROS的群里问了一些人,最近正好群里也有人成功在MK802 III上成功编译了ROS源码,所以直接在目标机上编译源码这个原始的方式,虽然效率较低,但是应该是行的通的。

       移植环境:

       PC:Ubuntu 12.04

            ARM处理器:Cortex-A9

       ARM操作系统:Ubuntu12.04

       ROS版本:groovy

       编译流程:

     整体的编译流程全部按照官网的教程进行(http://www.ros.org/wiki/groovy/Installation/Source)。

       1、安装工具软件

        启动ARM板中的ubuntu操作系统,使用串口与电脑连接,通过ssh使得PC机可以与ARM板进行远程控制,然后就可以在PC机上控制ARM板中的代码编译了。

        首先是按照教程上说的:

sudo apt-get install python-rosdep python-wstool build-essential
        但是在ARM的ubuntu源中没有python-rosdep和python-wstool这两个包,这两个包的安装可以按照fuerte的编译说明进行(http://www.ros.org/wiki/fuerte/Installation/Ubuntu/Source):

         安装easy_install:(http://blog.csdn.net/chosen0ne/article/details/7210745

wget http://peak.telecommunity.com/dist/ez_setup.py 
python ez_setup.py

         利用easy_install安装pip:(http://www.ros.org/wiki/ROS/Installation/EasyInstallConfig

sudo easy_install pip
             然后安装以下的包:http://www.ros.org/wiki/fuerte/Installation/Ubuntu/Source

sudo pip install -U rosdep
sudo pip install -U rosinstall
sudo pip install -U rospkg
              安装python-wstool:

pip install -U wstool
                redep初始化:

sudo rosdep init
rosdep update
        2、下载源码

        创建文件夹:

mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws
        下载代码,我是用的是最小包ros-common:

wstool init src -j8 http://packages.ros.org/web/rosinstall/generate/raw/groovy/ros_comm
         传说春运抢票搞垮了github,一开始怎么都连接不上github的服务器,尝试了一天,才在茫茫抢票热潮中把代码下了下来。

         3、编译源码

          按照教程上说的进行依赖包的安装:

rosdep install --from-paths src --ignore-src --rosdistro groovy -y 
         然后应该还需要安装cmake(我之前就已经安装好了,不知道是不是应该在这一步)。我是从官网下载的源码(http://www.cmake.org/),然后在ARM上编译的。安装方法参考链接(http://hi.baidu.com/phpbooker/item/38ca262ed599d10c73863e05),ARM上编译太慢了,用了将近一个小时,不知道可不可以在PC上交叉编译,不做深究了。

         接下来就是最重要的过程了——编译。这个过程是痛苦而漫长的,ARM板的主频慢,编译一次代码需要20分钟左右,而且每次出错总是在编译了好长时间之后,各种依赖的包需要安装。如果现在进行编译,肯定会出现一大堆错误,可以根据这些错误进行一步步的处理,基本都是所依赖的包没有安装。其中最重要的就是boost库的包。因为ROS中很多的代码是使用C++写的,都使用了boost静态库,所以必须在ARM中的ubuntu系统中安装boost库。boost库是我纠结时间最长的一个问题,我使用了各种各样的方法进行安装:

(1)直接apt-get安装

(2)下载源码在PC机上交叉编译然后放到ARM中

(3)直接下载官方针对ARM架构已经编译好的deb包进行安装(https://launchpad.net/ubuntu/+source/boost1.46/1.46.1-7ubuntu3/+build/3060825

          至于boost库的版本,我也尝试过很多,从1.40到1.52,最后还是第三种方法靠谱,前两种方法安装完成后在编译过程中总是会报错说找不到boost中的某个库。打开上面的链接,会有一个boost库的列表:

        我是把上面的包全部一个一个下载安装了,基本也是相互依赖的。安装过程中可能还是会有一些其他依赖的包,都可一使用pip或者easy_install进行安装。

         到现在为止,终于可以开始编译、安装了:

./src/catkin/bin/catkin_make_isolated --install --install-space /opt/ros/groovy
         如果一切正常,而是分钟后就汇编一安装结束了。

         添加环境路径:

source /opt/ros/groovy/setup.bash

echo "export ROS_PACKAGE_PATH=~/ros_workspace:$ROS_PACKAGE_PATH" >> ~/.bashrc
echo "export ROS_WORKSPACE=~/ros_workspace" >> ~/.bashrc
. ~/.bashrc
        终于安装完成了,在终端中输入“roscore”,看一下是否正常运行了。在这一步,我这里出现了一个错误:

what():  locale::facet::_S_create_c_locale name not valid
        后来使用google解决了(http://cruisever.blog.163.com/blog/static/786117572010817112310741/),加入:

export LC_ALL="C"
         终于可以正常运行了。进行了简单的talker和listener的测试,一切正常,虽然运行着实有点慢,但是初步移植应该完成了,后面应该还有更多问题等着我的。


PS:

(1)我也尝试过fuerte版本的ROS编译,但是在编译到90%的时候报错,我google了一下,好像是说ARM的内存不足了,我用的ARM板的内存是512MB,如果哪位有解决方法,请不吝指教。

(2)上面所写的过程中可能有一些包的安装遗漏了,基本使用easy_install和pip都可以安装,有一些Python包不能安装的,可以从网上下载deb包进行安装。

(3)本人还是初学者,如果有什么不对的读放,还请高手多多指教

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值