主要参考博客:https://blog.csdn.net/zhuoyueljl/article/details/78536996
https://hubpages.com/technology/Instructions-for-compiling-rgbdslam-v2-on-a-fresh-Ubuntu-1604-install-ros-kinetic-in-virtualbox
https://www.cnblogs.com/yuanlibin/p/8549416.html
1.因为上面提到的第一篇博客是rgbdslam跑不成功主要是因为pcl和g2o不兼容,所以是直接安装rgbdslam,跑不成功时再去安装其他需要的库.避免安装不合适了再去卸载.(首荐第一篇博客)
2.安装完成之后测试数据集包
(1)第一个终端:roscore
(2)第二个终端:rosbag play rgbd_dataset.bag (这个一定要是下载的数据集包.bag文件,否则运行时出错)
(3)第三个终端:roslaunch rgbdslam rgbdslam.launch
成功的话就可以出现rgbd slam重构的界面.
3.基于Kinect v2实时运行RGBDSLAMv2
(1)在rgbdslam_v2-kinetic的安装包里面的launch文件新建一个rgbdslam_kinect2.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="gicp"/> <!-- 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="ORB"/>-->
</node>
</launch>
在ros包里面写的.launch文件是不需要重新编译的可以直接运行
(2)最后基于Kinect v2的实时运行RGBDSLAMv2
第一个终端: roslaunch rgbdslam rgbdslam_kinect2.launch
第二个终端:roslaunch kinect2_bridge kinect2_bridge.launch
(一定要注意以上两个终端的执行顺序,否则运行不了)