准备工作 rbgdslam_v2 按照github ,实验环境Ubuntu 16.04, ROS kinetic
如果你电脑安装PCL版本是1.7,那么请直接跳到错误1,如果你也不知道有没有,或者版本多少,那么就跟着我的博客走下去吧。
git clone https://github.com/felixendres/rgbdslam_v2.git
cd rgbdslam_v2
source install.sh
接着会提示
This script puts all code into ‘/home/damon/Code’. Edit this script to change the location.
Press enter to continue, Ctrl-C to cancel
按着步骤走编译出来的东西会被放在~/Code/rgbdslam_catkin_ws 这时候
source ~/Code/rgbdslam_catkin_ws/devel/setup.bash
到这里,rgbdslam_v2已经安装成功 运行,跑数据 首先得下载数据集,tum数据集地址在这里可能会下载比较慢,可以找找镜像或者百度云. 错误1 直接运行 roslaunch rgbdslam rgbdslam.launch 会报错
ROS_MASTER_URI=http://localhost:11311
process[rgbdslam-1]: started with pid [22155]
================================================================================REQUIRED process [rgbdslam-1] has died!
process has died [pid 22155, exit code -11, cmd /home/damon/Code/rgbdslam_catkin_ws/devel/lib/rgbdslam/rgbdslam __name:=rgbdslam __log:=/home/damon/.ros/log/adfdfee8-22d1-11ea-9524-02428408a590/rgbdslam-1.log].
log file: /home/damon/.ros/log/adfdfee8-22d1-11ea-9524-02428408a590/rgbdslam-1*.log
Initiating shutdown!
================================================================================
[rgbdslam-1] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
查资料提示PCL与g2o不兼容导致,下载pcl1.8版本替换系统的1.7 解决办法如下:
cd 到某个路径,存放pcl
wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.0.tar.gz
tar -zxvf pcl-1.8.0.tar.gz
cd pcl-pcl-1.8.0/
vim CMakeLists.txt
在146行加插入 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
mkdir build&&cd build
cmake ..
make VERBOSE=1 -j8 # 需要等待很久
sudo make install
接下来做以下操作:
- 修改rgbdslam_v2的 :修改第 79 行:find_package(PCL 1.7 REQUIRED COMPONENTS common io) 为 find_package(PCL 1.8 REQUIRED COMPONENTS common io)
- 修改 /opt/ros/kinetic/share/pcl_ros/cmake/pcl_rosConfig.cmake文件,将所有/usr/lib/x86_64-linux/libpcl开头的内容改成/usr/local/lib/libpcl
- 修改完成之后重新source install.sh 编译一下
再次运行
roslaunch rgbdslam rgbdslam.launch
会出现以下界面(这就说明你已经安装成功了): 运行 RGB-D 数据集 RGB-D 数据集 使用 rgbd_dataset_freiburg1_xyz.bag 修改 /home/用户名/Code/rgbdslam_catkin_ws/src/rgbdslam/launch文件下 rgbdslam.launch 中的 图像topic
<param name="config/topic_image_mono" value="/camera/rgb/image_color"/>
<param name="config/topic_image_depth" value="/camera/depth/image"/>
roscore & rosbag play rgbd_dataset_freiburg1_rpy.bag
roslaunch rgbdslam rgbdslam.launch
结果 RGB-D 相机 RGB-D 相机 使用 realsense-d435i 修改 /home/用户名/Code/rgbdslam_catkin_ws/src/rgbdslam/launch文件下 rgbdslam.launch 中的 图像topic
<!-- Input data settings-->
<param name="config/topic_image_mono" value="/camera/color/image_raw"/>
<param name="config/topic_image_depth" value="/camera/depth/image_rect_raw"/>
<!--param name="config/topic_image_mono" value="/camera/rgb/image_color"/>
<param name="config/topic_image_depth" value="/camera/depth/image "/-->
<!-- remap to realsense -->
<remap from="/camera/depth/camera_info" to="/camera/aligned_depth_to_color/camera_info"/>
<remap from="/camera/depth/image" to="/camera/aligned_depth_to_color/image_raw"/>
<remap from="/camera/rgb/camera_info" to="/camera/color/camera_info"/>
<remap from="/camera/rgb/image_color" to="/camera/color/image_raw"/>
<!-- lack of topic /cortex_marker_array & /imu -->
运行
roslaunch rgbdslam rgbdslam.launch
roslaunch realsense2_camera rs_rgbd.launch
RGBD-SLAM使用kinetic v2
如果是使用Kinetic V2 获取深度图像信息的话(先正常安装Kinetic V2 在ROS下正常使用的方法:Ubuntu16.04 ROS安装kinect2并获取骨骼数据+配置kinect2_tracker 链接:https://blog.csdn.net/qq_42145185/article/details/103955937) 然后在/home/用户名/Code/rgbdslam_catkin_ws/src/rgbdslam/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="SIFTGPU"/><!-- also available: SIFT, SIFTGPU, SURF, SURF128 (extended SURF), ORB. -->
<param name="config/feature_detector_type" value="SIFTGPU"/><!-- 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="SIFTGPU"/>
-->
</node>
</launch>
打开一个终端
roslaunch kinect2_bridge kinect2_bridge.launch
打开另一个终端
roslaunch rgbdslam rgbdslam_kinect2.launch