rtabmap_ros---43

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rtabmap_ros---43相关的知识,希望对你有一定的参考价值。

一、前言

RTAB-Map (Real-Time Appearance-Based Mapping)是一种基于全局贝叶斯闭环检测的RGB-D Graph SLAM方法。它可以用kinect的深度信息结合kinect变

换得到的激光数据进行即时定位与建图(gmapping算法志只用到了kinect转换得到的激光数据,而把深度信息丢弃了)。
官网地址:http://introlab.github.io/rtabmap/
ROS下面安装请看:https://github.com/introlab/rtabmap_ros#rtabmap_ros
教程请看:https://github.com/introlab/rtabmap/wiki/Tutorials
在机器人上使用RTAB-Map:Setup RTAB-Map on Your Robot!

二、deb方式安装

嫌麻烦采用deb方式安装

Jade:   $ sudo apt-get install ros-jade-rtabmap-ros 
Indigo: $ sudo apt-get install ros-indigo-rtabmap-ros 
Hydro:  $ sudo apt-get install ros-hydro-rtabmap-ros 

三、源码安装

请看github上的安装说明:https://github.com/introlab/rtabmap_ros#rtabmap_ros
简单的安装方法是:
indigo:

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

hydro:

$ sudo apt-get install libsqlite3-dev libpcl-1.7-all ros-hydro-libfreenect ros-hydro-opencv2

然后下载RTAB-Map源码编译安装:

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

安装完之后插上Kinect在终端运行命令:

$ rtabmap

出现GUI,然后选择“File”——“New database”,再点击开始按键就可以出现图像了
技术分享

在catkin工作空间中安装RTAB-Map ros-pkg

$ cd ~/catkin_ws
$ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
$ catkin_make

1、安装可选的依赖项

(1)如果你需要用到SURF/SIFT那就装一下OpenCV
请看:http://blog.csdn.net/u013453604/article/details/49781771
由于cv-bridge依赖的是opencv2,所以装opencv3的话rtabmap_ros里面有些库会冲突,这里建议装opencv 2.4.11。
(2)安装g2o,这是在闭环检测中实现图优化的包
先安装依赖项

$ sudo apt-get install cmake libeigen3-dev libsuitesparse-dev

下载源码编译安装

$ cd 
$ git clone https://github.com/RainerKuemmerle/g2o.git
$ cd g2o/
$ mkdir build
$ cd build/
$ cmake ../
$ make

安装完之后库文件在/usr/local/lib,头文件在/usr/local/include/g2o
(3)安装其他依赖项Qt, PCL, dc1394, OpenNI, OpenNI2, Freenect, g2o, Costmap2d, Rviz, Octomap, CvBridge

$ sudo apt-get install libqt4-dev libpcl-1.7-all-dev libdc1394-22-dev ros-indigo-openni-launch ros-indigo-openni2-launch ros-indigo-freenect-launch ros-indigo-costmap-2d ros-indigo-octomap-ros ros-indigo-rviz ros-indigo-cv-bridge

如果按照github上的命令安装依赖项不成功就运行上述命令吧,其中opencv和g2o我是源码安装的,所以相对于github上的命令我这里把ros-indigo-g2o去掉了,把libdc1394-dev改成了libdc1394-22-dev
(4)安装GTSAM

GTSAM is a library of C++ classes that implement smoothing and mapping (SAM) in robotics and vision, using factor graphs and Bayes networks as the underlying computing paradigm rather than sparse matrices.

把gtsam包下载到某处进行编译安装:

$ cd software/
$ git clone https://bitbucket.org/gtborg/gtsam.git
$ cd gtsam
$ mkdir build
$ cd build
$ cmake ..
$ make check
$ make install

(5)安装cvsba

cvsba is an OpenCV wrapper for the well-known Sparse Bundle Adjustment library (sba) by M. Lourakis.

安装依赖项

$ sudo apt-get install liblapack-dev libf2c2-dev 

下载cvsba:http://sourceforge.net/projects/cvsba/files/latest/download?source=typ_redirect
解压得到cvsba-1.0.0文件夹,我把它放到~/software/文件夹下

$ cd ~/software/cvsba-1.0.0
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install 

安装完之后还要执行以下命令才可以让rtabmap_ros找到它

$ sudo mkdir /usr/local/lib/cmake/cvsba 
$ sudo mv /usr/local/lib/cmake/Findcvsba.cmake /usr/local/lib/cmake/cvsba/cvsbaConfig.cmake

(6)安装Freenect2

请看这里:https://github.com/OpenKinect/libfreenect2#debianubuntu-1404-perhaps-earlier

Driver for Kinect for Windows v2 (K4W2) devices (release and developer preview).

Note: libfreenect2 does not do anything for either Kinect for Windows v1 or Kinect for Xbox 360 sensors. Use libfreenect1 for those sensors.

This driver supports:

RGB image transfer
IR and depth image transfer
registration of RGB and depth images

先下载Freenect2源代码

$ cd ~/software
$ git clone https://github.com/OpenKinect/libfreenect2.git

安装依赖项

$ sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev

安装libusb

$ sudo apt-get install libusb-1.0-0-dev

注意libusb版本要大于1.0.20,否则编译freenect2的时候会报错:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LibUSB_LIBRARY
linked by target "freenect2" in directory /home/siat/libfreenect2

如果libusb版本太低可以先卸载libusb-1.0-0-dev更新软件源重装libusb-1.0-0-dev,运行如下命令

$ sudo apt-get remove libusb-1.0-0-dev
$ sudo apt-add-repository ppa:floe/libusb 
$ sudo apt-get update 
$ sudo apt-get upgrade
$ sudo apt-get install libusb-1.0-0-dev

安装 GLFW3

$ sudo apt-get install libglfw3-dev

如果上面命令无效请使用下面命令:

$ cd libfreenect2/depends
$ sh install_ubuntu.sh
$ sudo dpkg -i libglfw3*_3.0.4-1_*.deb

安装OPENCL依赖

对于AMD GPU:
$ apt-get install opencl-headers
对于Nvidia GPU:(前提是你已经安装Nvidia驱动)
$ apt-get install opencl-headers
对于Intel GPU:
$ apt-get install beignet-dev
不行的话运行:
$ sudo apt-add-repository ppa:pmjdebruijn/beignet-testing

编译Freenect2

$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install # without sudo if cmake -DCMAKE_INSTALL_PREFIX=$HOME/...

运行测试

$ ./bin/Protonect

2、下载安装RTAB-Map

$ cd ~
$ git clone https://github.com/introlab/rtabmap.git rtabmap
$ cd rtabmap/build
$ cmake -DCMAKE_INSTALL_PREFIX=~/catkin_ws/devel ..
$ make -j4
$ make install

3、在catkin工作空间中安装RTAB-Map ros-pkg

$ cd ~/catkin_ws
$ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
$ catkin_make

4、更新版本

$ cd rtabmap
$ git pull origin master
$ cd build
$ make
$ make install

$ roscd rtabmap_ros
$ git pull origin master
$ cd ~/catkin_ws
$ catkin_make

四、遇到的报错

编译时遇到如下报错,最后发现是关于openni的库有问题,因为我用源码装过openni驱动,有可能是版本冲突了,其实根本没必要从源码安装, 可以从其他电脑上把usr/include下面的ni文件夹拷过来,我是重装了Ubuntu和ros indigo,然后按照前面简单的安装方法安装的,过程中自动安装了openni

[email protected]:~/rtabmap/build$ make -j4
[  7%] Built target rtabmap_utilite
[  7%] Built target uresourcegenerator
[  8%] Built target imagesJoiner
[  9%] Built target extractObject
[ 10%] Building CXX object corelib/src/CMakeFiles/rtabmap_core.dir/CameraThread.cpp.o
[ 10%] [ 11%] [ 12%] Building CXX object corelib/src/CMakeFiles/rtabmap_core.dir/CameraRGBD.cpp.o
Building CXX object corelib/src/CMakeFiles/rtabmap_core.dir/VisualWord.cpp.o
Building CXX object corelib/src/CMakeFiles/rtabmap_core.dir/EpipolarGeometry.cpp.o
In file included from /usr/include/ni/XnOS.h:27:0,
                 from /usr/include/pcl-1.7/pcl/io/openni_camera/openni.h:47,
                 from /usr/include/pcl-1.7/pcl/io/openni_camera/openni_depth_image.h:44,
                 from /home/siat/rtabmap/corelib/src/../include/rtabmap/core/CameraRGBD.h:37,
                 from /home/siat/rtabmap/corelib/src/CameraRGBD.cpp:28:
/usr/include/ni/XnPlatform.h:73:3: error: #error OpenNI Platform Abstraction Layer - Unsupported Platform!
  #error OpenNI Platform Abstraction Layer - Unsupported Platform!
   ^
.
.
.
In file included from /usr/include/pcl-1.7/pcl/io/openni_camera/openni.h:50:0,
                 from /usr/include/pcl-1.7/pcl/io/openni_camera/openni_depth_image.h:44,
                 from /home/siat/rtabmap/corelib/src/../include/rtabmap/core/CameraRGBD.h:37,
                 from /home/siat/rtabmap/corelib/src/CameraThread.cpp:31:
/usr/include/ni/XnCppWrapper.h:10045:76: error: macro "XN_VALIDATE_NEW" passed 4 arguments, but takes just 2
    XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
                                                                            ^
/usr/include/ni/XnCppWrapper.h:10104:75: error: macro "XN_VALIDATE_NEW" passed 4 arguments, but takes just 2
   XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
                                                                           ^
[ 13%] Building CXX object corelib/src/CMakeFiles/rtabmap_core.dir/VWDictionary.cpp.o
In file included from /usr/include/ni/XnStatusCodes.h:27:0,
                 from /usr/include/ni/XnMacros.h:27,
                 from /usr/include/ni/XnOS.h:28,
                 from /usr/include/pcl-1.7/pcl/io/openni_camera/openni.h:47,
                 from /usr/include/pcl-1.7/pcl/io/openni_camera/openni_depth_image.h:44,
                 from /home/siat/rtabmap/corelib/src/../include/rtabmap/core/CameraRGBD.h:37,
                 from /home/siat/rtabmap/corelib/src/CameraRGBD.cpp:28:
/usr/include/ni/XnStatus.h:33:9: error: ‘XnUInt32’ does not name a type
 typedef XnUInt32 XnStatus;

 


         ^

以上是关于rtabmap_ros---43的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数