一.建立rgbdslam_ws空间
$ cd ~/rgbdslam_ws/src
$ cd rgbdslam_ws
$ catkin_make
$ source devel/setup.bash
二.下载并安装PCL1.8 EIGEN3.0 G20
1.下载安装PCL1.8
$ cd ~/rgbdslam_vs/src
$ wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.0.tar.gz
$ tar -xvzf pcl-1.8.0.tar.gz
修改cmakelist.txt,在其第146行加入并保存
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
编译
$ cd ~/rgbdslam_ws/src/pcl-pcl-1.8.0
$ mkdir build
$ cd build
$ cmake ..
$ make VERBOSE=1
$ sudo make install
2.安装 EIGEN3.0和G2O
a.下载eigen3.0
$ cd rgbdslam_vs/src
$ wget http://bitbucket.org/eigen/eigen/get/3.2.10.tar.bz2
$ mkdir eigen
$ tar -xvjf 3.2.10.tar.bz2 -C eigen --strip-components 1
b.配置G2O
将G2O中CMakelistis.txt的251中的
SET(G2O_EIGEN3_INCLUDE ${EIGEN3_INCLUDE_DIR} CACHE PATH "Directory of Eigen3")
改为
SET(G2O_EIGEN3_INCLUDE "你的Eigen3的绝对路径" CACHE PATH "Directory of Eigen3")
安装G2O
$ cd rgbdslam_vs/src
$ git clone https://github.com/felixendres/g2o.git
$ cd ~/rgbdslam/src/g2o
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
3.安装opencv3.3.1(网上找教程)
4.安装RGBD-SLAM V2
$ cd ~/rgbdslam_ws/src
$ wget -q http://github.com/felixendres/rgbdslam_v2/archive/kinetic.zip
$ unzip -q kinetic.zip
$ cd ~/rgbdslam_ws/
$ rosdep update
$ rosdep install rgbdslam
catkin_make之前rgbdslam_v2包的cmakelists.txt文件下的第6行加入
add_compile_options(-std=c++11)
将rgbdslam_v2包下的cmakelist.txt文件的第79行
find_package(PCL 1.7 REQUIRED COMPONENTS common io)
改为
find_package(PCL 1.8 REQUIRED COMPONENTS common io)
编译RGBD-SLAM V2
注意:如果是在ARM环境下则需要进入rgbdslam-v2/external/siftgpu/makefile并注释第19行和第20行。ARM没有这些扩展的浮点指令。此外,在顶级目录的cmakelists.txt中取消第31行的注释。
$ cd rgbdslam_ws
$ catkin_make
5.添加rgbdslam_ws工作空间到.bashrc文件下
$ echo "source /home/XXXX/rgbdslam_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
6.测试数据集
打开第一个终端
$ roscore
打开第二个终端
$ rosbag play rgbd_dataset.bag
注意:修改rgbdslam.launch中13.14行的SIFTGPU为ORB
打开第三个终端
$ roslaunch rgbdslam rgbdslam.launch
打开kinetic v2
新建rgbdslam_kinect2.launch
打开一个终端
roslaunch kinect2_bridge kinect2_bridge.launch
注意:若出现failed to open Kinect V2 Access denied的错误,libfreenect2/platform/linux/udev/90-Kinect2.rules
文件复制到/etc/udev/rules.d/文件夹下
sudo cp ~/libfreenect2/platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
打开另一个终端
roslaunch rgbdslam rgbdslam_kinect2.launch
注意:打开终端后,执行source ~/rgbdslam_ws/devel/setup.bash,否则会报以下错误:
[rgbdslam_kinect2.launch] is neither a launch file in package [rgbdslam] nor is [rgbdslam] a launch file name
The traceback for the exception was written to the log file