はじめに
Raspberry pi 2(Raspbian Jessie)にROS indigo(ROS-Desktop)をインストールする方法が
日本語ではなかったので、まとめました。
rqtやrvizが使えた方がデバッグで圧倒的に便利なので、おすすめです。
Raspberry pi 3でも、Raspbian Jessieなら同様の方法でインストールできると思います。
リンク
ROSのリポジトリを設定、認証キーを追加
$ 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 -
aptのパッケージインデックスを更新
$ sudo apt-get update
$ sudo apt-get upgrade
ROSビルド(ROS-Comm)に必要なパッケージをインストール
$ 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
ROSビルド(ROS-Desktop)に必要なパッケージをインストール
$ sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-devl
rosdepを初期化する
$ sudo rosdep init
$ rosdep update
$ mkdir ~/ros_catkin_ws
$ cd ~/ros_catkin_ws
rosinstallでdesktopを選択する
$ rosinstall_generator desktop --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-desktop-wet.rosinstall
$ wstool init src indigo-desktop-wet.rosinstall
ROSビルド(ROS-Desktop)に必要なパッケージをソースビルドする
- desktopは、libconsole-bridge-dev, liblz4-dev, liburdfdom-headers-dev, liburdfdom-dev, collada-dom-devのソースビルドが必要
- ソースビルド用にexternal_srcディレクトリを用意する
$ 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
libconsole-bridge-devをビルドする
$ 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
liblz4-devをビルドする
$ cd ~/ros_catkin_ws/external_src
$ apt-get source -b lz4
$ sudo dpkg -i liblz4-*.deb
liburdfdom-headers-devをビルドする
$ cd ~/ros_catkin_ws/external_src
$ git clone https://github.com/ros/urdfdom_headers.git
$ cd urdfdom_headers
$ cmake .
$ sudo checkinstall make install
checkinstallコマンド後に、以下の設定画面となる。
0 - Maintainer: [ root@raspberrypi ]
1 - Summary: [ Package created with checkinstall 1.6.2 ]
2 - Name: [ urdfdom-headers ]
3 - Version: [ 20150804 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ armhf ]
8 - Source location: [ urdfdom_headers ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ urdfdom-headers ]
12 - Conflicts: [ ]
13 - Replaces: [ ]
Enter a number to change any of them or press ENTER to continue:
2番のNameをurdfdom_headersからliburdfdom-headers-devに変更する。
2 を入力してEnter、liburdfdom-headers-dev と入力する。
再度確認の設定が表示されたら Enterで進む。
liburdfdom-devをビルドする
$ 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
checkinstallコマンド後に、以下の設定画面となる。
0 - Maintainer: [ root@raspberrypi ]
1 - Summary: [ Package created with checkinstall 1.6.2 ]
2 - Name: [ urdfdom ]
3 - Version: [ 20150804 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ armhf ]
8 - Source location: [ urdfdom ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ urdfdom ]
12 - Conflicts: [ ]
13 - Replaces: [ ]
Enter a number to change any of them or press ENTER to continue:
2番のNameをurdfdomからliburdfdom-devに変更する。
2 を入力してEnter、次に liburdfdom-dev と入力する。
再度確認の設定が表示されたら Enterで進む。
$ 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
checkinstallコマンド後に、以下の設定画面となる。
0 - Maintainer: [ root@raspberrypi ]
1 - Summary: [ Package created with checkinstall 1.6.2 ]
2 - Name: [ collada-dom ]
3 - Version: [ 2.4.0 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ armhf ]
8 - Source location: [ collada-dom-2.4.0 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ collada-dom ]
12 - Conflicts: [ ]
13 - Replaces: [ ]
Enter a number to change any of them or press ENTER to continue:
2番のNameをcollada-domからcollada-dom-devに変更する。
2 を入力してEnterを押し、次に collada-dom-dev と入力する。
再度確認の設定が表示されたら Enterで進む。
Re: [ros-sig-embedded] Re: Install ROS on Linaro (gumstix, pandaboard)
の添付ファイル(0001-fixed-arm-build.patch)をダウンロードし、パッチを当てる。
$ cd ~/ros_catkin_ws/src/robot_model/collada_urdf/
$ patch -p1 < ~/0001-fixed-arm-build.patch
rvizのコードをARMビルド用に一部変更する。
Unable to compile rviz on ubuntu armhfを参考に、mesh_loader.cppに+で表記した行を追加する。この変更をしないとrvizのビルドが通らない。
$ nano ~/ros_catkin_ws/src/rviz/src/rviz/mesh_loader.cpp
#include <assimp/aiPostProcess.h>
#include <assimp/IOStream.h>
#include <assimp/IOSystem.h>
#endif
+ # ifdef __arm__ // fix for ARM build
+ #include <strings.h>
+ bool Assimp::IOSystem::ComparePaths(const char *p1, const char *p2) const
+ {
+ return !::strcasecmp(p1, p2);
+ }
+ # endif
ROSビルド用にスワップメモリを拡張する
$ vi sudo raspi-config
-> 8. Advanced Option を選択
-> A3 Memory Split
-> GPU のメモリを 16MByte に設定
-> 下矢印キーで Finish を選択
-> Yes でreboot
$ sudo service dphys-swapfile stop
$ sudo nano /etc/dphys-swapfile
#CONF_SWAPSIZE=100
CONF_SWAPSIZE=1024
$ sudo service dphys-swapfile start
ROS依存関係の解消
$ cd ~/ros_catkin_ws
$ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie
ROSのビルドを実行する
- 注意:ビルド完了まで数時間かかる。(スワップメモリを使用することもあり)
- -j4オプションだと途中でエラーになるので、初めから-j2オプションで行う。
- 上記まで手続きをこなしていれば、下記のrvizのビルドエラー以外は通る。
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo -j2
rvizで以下のビルドエラーが出た場合は個別でビルドする。
Makefile:123: recipe for target 'all' failed
make: *** [all] Error 2
<== Failed to process package 'rviz':
Command '['/opt/ros/indigo/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2
Reproduce this error by running:
==> cd /home/jorg/ros_catkin_ws/build_isolated/rviz && /opt/ros/indigo/env.sh make -j4 -l4
Command failed, exiting.
$ cd ~/ros_catkin_ws/build_isolated/rviz
$ sudo make -j2
$ cd ~/ros_catkin_ws
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo
ROSビルド結果を反映させる
- --install-spaceオプションで/opt/ros/indigo/にインストールしているので、そこのsetup.bashでビルドを反映させる。
- source /opt/ros/indigo/setup.bashを.bashrcにも記述することで起動毎に自動反映できる。
$ source /opt/ros/indigo/setup.bash
$ echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
ROS(roscore)を実行し、動作確認する
$ roscore
- 以下がエラーなしで立ち上がればROSのビルド完了!
... logging to /home/pi/.ros/log/9781754e-3a9d-11e5-8b98-b827ebe98f3c/roslaunch-raspberrypi-11718.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://raspberrypi:42226/
ros_comm version 1.11.19
SUMMARY
========
PARAMETERS
* /rosdistro: indigo
* /rosversion: 1.11.19
NODES
auto-starting new master
process[master]: started with pid [11735]
ROS_MASTER_URI=http://raspberrypi:11311/
setting /run_id to 9781754e-3a9d-11e5-8b98-b827ebe98f3c
process[rosout-1]: started with pid [11748]
started core service [/rosout]
Raspbian Jessieで、roscore,rqt,rvizを立ち上げたスクリーンショット
- roscoreを起動、picameraのimage_topicを配信、rqt/rvizをリアルタイム表示している。
- 実際に動いてます!
リンク
参考文献
Installing ROS Indigo on the Raspberry Pi
Raspberry piにROS indigoをインストールする
http://jorgbosman.eu
CMake is not able to find BOOST libraries
Re: [ros-sig-embedded] Re: Install ROS on Linaro (gumstix, pandaboard)
Raspberry Pi でビルドがこんな感じで失敗したときの対処