Ubuntu16.04 ros Kinect v2下运行RGBD-SLAM_v2

由于跑RGBDSLAM2,安装时候遇到好多问题,经过查询得到解决,希望对大家有所帮助

1.安装ROS

可参考官网http://wiki.ros.org/kinetic/Installation/Ubuntu

2.kinectv2相机的标定

参考https://blog.csdn.net/qq_33835307/article/details/81272377

3.创建catkin 工作空间存放项目

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ../
catkin_make

cd ~/catkin_ws/src
git clone https://github.com/felixendres/rgbdslam_v2

注意此版本CMakelists是基于的pcl1.7,我们要改成1.8,否则编译好之后运行会崩溃。

4.g2o安装

安装依赖

sudo apt-get install cmake libeigen3-dev libsuitesparse-dev libqt4-dev qt4-qmake libqglviewer-dev qt5-qmake

g2o地址: https://github.com/felixendres/g2o,下载完后:

进行cmake 编译,如下

mkdir build
cd build
cmake ..
make
sudo make install

5.pcl 安装

pcl1.8地址:https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.0.tar.gz

进入解压的pcl-pcl-1.8.0目录,打开终端

gedit CMakeLists.txt

找到地第146行(在endif()下面),添加下面一段话

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

 在pcl-pcl-1.8.0目录下,cmake 编译:

mkdir build
cd build
cmake ..
make
sudo make install

6.编译rgbdslam

  特别注意是:将在项目的cmakelsits文件中将pcl1.7改成1.8,还有在文件中加入

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

7.算法测试

  开启kienctv_2相机

roslaunch kinect2_bridge kinect2_bridge.launch

注意https://blog.csdn.net/zhuoyueljl/article/details/78536996(g20与pcl冲突解决)

该项目的作者开源的时候只有kinect1,本实战使用的是kinect2,需要单独建立launch文件,来启动程序,在launch文件下,建立rgbdslam_kinect2.launch

里面内容如下:

<!-- This file shows the most important parameters in their default settings,
     to make them easily available for beginners.

     The openni driver has to be started seperately, e.g. with "roslaunch openni_launch openni.launch" -->
<launch> 
<node pkg="rgbdslam" type="rgbdslam" name="rgbdslam" cwd="node" required="true" output="screen"> 

<!-- Input data settings-->
 <param name="config/topic_image_mono"              value="/kinect2/qhd/image_color_rect"/> 
<param name="config/camera_info_topic"             value="/kinect2/qhd/camera_info"/>
 <param name="config/topic_image_depth"             value="/kinect2/qhd/image_depth_rect"/> 
<param name="config/topic_points"                  value=""/> <!--if empty, poincloud will be reconstructed from image and depth --> 

<!-- These are the default values of some important parameters --> 
<param name="config/feature_extractor_type"        value="ORB"/><!-- also available: SIFT, SIFTGPU, SURF, SURF128 (extended SURF), ORB. --> 
<param name="config/feature_detector_type"         value="ORB"/><!-- also available: SIFT, SURF, GFTT (good features to track), ORB. --> 
<param name="config/detector_grid_resolution"      value="3"/><!-- detect on a 3x3 grid (to spread ORB keypoints and parallelize SIFT and SURF) --> 
<param name="config/optimizer_skip_step"           value="15"/><!-- optimize only every n-th frame -->
 <param name="config/cloud_creation_skip_step"      value="2"/>

<!-- subsample the images' pixels (in both, width and height), when creating the cloud (and therefore reduce memory consumption) -->
 <param name="config/backend_solver"                value="csparse"/><!-- pcg is faster and good for continuous online optimization, cholmod and csparse are better for offline optimization (without good initial guess)--> <param name="config/pose_relative_to"              value="first"/><!-- optimize only a subset of the graph: "largest_loop" = Everything from the earliest matched frame to the current one. Use "first" to optimize the full graph, "inaffected" to optimize only the frames that were matched (not those inbetween for loops) --> 
<param name="config/maximum_depth"           value="2"/> <param name="config/subscriber_queue_size"         value="20"/> 
<param name="config/min_sampled_candidates"        value="30"/><!-- Frame-to-frame comparisons to random frames (big loop closures) -->
 <param name="config/predecessor_candidates"        value="20"/><!-- Frame-to-frame comparisons to sequential frames--> 
<param name="config/neighbor_candidates"           value="20"/><!-- Frame-to-frame comparisons to graph neighbor frames--> 
<param name="config/ransac_iterations"             value="140"/> 
<param name="config/g2o_transformation_refinement"           value="1"/> 
<param name="config/icp_method"           value="icp"/> <!-- icp, gicp ... --> <!--
<param name="config/max_rotation_degree"           value="20"/>
<param name="config/max_translation_meter"           value="0.5"/>

<param name="config/min_matches"           value="30"/>   

<param name="config/min_translation_meter"           value="0.05"/>
<param name="config/min_rotation_degree"           value="3"/>
<param name="config/g2o_transformation_refinement"           value="2"/>
<param name="config/min_rotation_degree"           value="10"/>

<param name="config/matcher_type"         value="SIFTGPU"/>
 --> 
</node> 
</launch>

启动命令行如此下:

roslaunch rgbdslam rgbdslam_kinect2.launch 

运行截图:(本人实力抢镜)

8 硬件实验

本人实验平台为turtlebot2,参考大神的博客https://blog.csdn.net/weixin_43540678/article/details/84031363

运行命令行机器启动:

1.将电脑连接设备,打开设备开关
2.roslaunch rgbdslam openni+rgbdslam.launch,开启程序直到画面出现,再执行3
3.roslaunch turtlebot_bringup minimal.launch,启动底座
4.roslaunch turtlebot_teleop keyboard_teleop.launch,启动遥控

 参考

1.https://blog.csdn.net/weixin_43540678/article/details/84031363

2.https://blog.csdn.net/zhuoyueljl/article/details/78536996(g20与pcl冲突解决)

3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值