RTAB-Map インストール メモ(Ubuntu)

RTAB-Mapとは、Kinectセンサー等を使って、
屋内の3Dモデルを作成できるオープンソースのソフトウェア。

http://introlab.github.io/rtabmap/
https://github.com/introlab/rtabmap/wiki/Tutorials
http://mohammedari.blogspot.jp/2015/01/kinect-360rtab-map3d.html

Kinect for Windows v2 + Ubuntu 14.04 で実行。
はじめはWindows 10でやろうとしたけど、対応してない的なことが書かれていたのでUbuntuにした。
もしかしたらWindows 10でも動くかもしれない。

Ubuntu

イントール手順のページを見ながら実行。
https://github.com/introlab/rtabmap/wiki/Installation#ubuntu

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
$ sudo apt-get update

$ sudo apt-get install libsqlite3-dev libpcl-1.7-all libopencv-dev
sudo apt-get install cmake


$ git clone https://github.com/introlab/rtabmap.git rtabmap
$ cd rtabmap/build
$ cmake ..
$ make -j4
$ sudo make install

sudo ldconfig
rtabmap

rtabmap: error while loading shared libraries: librtabmap_core.so.0.11: cannot open shared object file: No such file or directory

/usr/local/lib/x86_64-linux-gnu/librtabmap_core.so

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/x86_64-linux-gnu
rtabmap

で動いた。動いたけど、kinect v2は認識しない。
ツールバーキネクトっぽいアイコンから、
RGM-D camera > Kinect v2 > freenect2
を選ぼうとすると、灰色でDisabledになっている。

ldconfig

cd /etc/ld.so.conf.d/
sudo cp x86_64-linux-gnu.conf x86_64-linux-gnu.conf.20160512
vi x86_64-linux-gnu.conf
/usr/local/lib/x86_64-linux-gnu
を行末に追加

vi x86_64-linux-gnu.conf

libfreenect2

Kinect v2で動かすには、libfreenect2というものが必要らしい。

https://github.com/OpenKinect/libfreenect2#linux
の手順に沿ってインストール。
途中の
Install OpenCL (optional)
Install CUDA (optional, Nvidia only):
とかは省略。
CUDAは以前インストールしたかもしれない。

Set up udev rules for device access:

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

サンプルプログラム。

./bin/Protonect

サンプルプログラムを実行したら、kinectカメラの動画が表示された。 でも、RTAB-Mapからは認識できない..

You need to specify cmake -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2 for CMake based third-party application to find libfreenect2

rtabmapのcmake

cmake ..

--   BUILD_SHARED_LIBS =    ON
--   CMAKE_CXX_FLAGS =  -fmessage-length=0  -Wno-deprecated -fopenmp
--   With OpenCV 2 nonfree module (SIFT/SURF) = NO (not found, License: BSD)
--   With Freenect             = NO (libfreenect not found)
--   With OpenNI2              = NO (OpenNI2 not found)
--   With Freenect2            = NO (libfreenect2 not found)
--   With dc1394               = YES (License: LGPL)
--   With FlyCapture2/Triclops = NO (Point Grey SDK not found)
--   With TORO                 = YES (License: Creative Commons [Attribution-NonCommercial-ShareAlike])
--   With g2o                  = NO (g2o not found)
--   With GTSAM                = NO (GTSAM not found)
--   With VERTIGO              = YES (License: GPLv3)
--   With cvsba                = NO (cvsba not found)
--   With Qt4                  = YES (License: Open Source or Commercial)

vi CMakeLists.txt
196 FIND_PACKAGE(Freenect QUIET)

cmake .. -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2

--   BUILD_SHARED_LIBS =    ON
--   CMAKE_CXX_FLAGS =  -fmessage-length=0  -Wno-deprecated -fopenmp
--   With OpenCV 2 nonfree module (SIFT/SURF) = NO (not found, License: BSD)
--   With Freenect             = NO (libfreenect not found)
--   With OpenNI2              = NO (OpenNI2 not found)
--   With Freenect2            = YES (License: Apache v2 and/or GPLv2)
--   With dc1394               = YES (License: LGPL)
--   With FlyCapture2/Triclops = NO (Point Grey SDK not found)
--   With TORO                 = YES (License: Creative Commons [Attribution-NonCommercial-ShareAlike])
--   With g2o                  = NO (g2o not found)
--   With GTSAM                = NO (GTSAM not found)
--   With VERTIGO              = YES (License: GPLv3)
--   With cvsba                = NO (cvsba not found)
--   With Qt4                  = YES (License: Open Source or Commercial)

freenect2の置き場所はHOMEディレクトリの下ではない方が良いと思う。要修正。

make -j4
sudo make install

rtabmap

freenect2のためのldconfig

libfreenect2でもldconfigが必要なエラーが出た。
エラーメッセージをコピーし忘れた。↓的な。

rtabmap
rtabmap: error while loading shared libraries: librtabmap_core.so.0.11: cannot open shared object file: No such file or directory

/etc/ld.so.conf.d
$ sudo vi x86_64-linux-gnu.conf
/home/KUBOTTI_USERNAME/libfreenect2/build/lib

RTAB-Mapのキネクトっぽいアイコンから、
RGM-D camera > Kinect v2 > freenect2
が選べるようになった!

f:id:kubotti:20160512153205p:plain

以上、動作確認完了。