首先按照前篇文章实现Kinect V2的驱动安装
https://blog.****.net/qq_41906592/article/details/112231524?spm=1001.2014.3001.5501
1.安装Rtabmap_ROS
sudo apt-get install ros-kinetic-rtabmap-ros
2.运行测试
(1)启动kinect
roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true
出现下面的显示说明运行成功。
(2)执行tf
rosrun tf static_transform_publisher 0 0 0 -1.5707963267948966 0 -1.5707963267948966 camera_link kinect2_link 100
(3)启动rtabmap
分别对应sd/qhd/hd三种清晰度,分别为640*480/960*540/1920*1080
sd对应的是红外镜头kinect2_ir_optical_frame
qhd和hd对应的彩色镜头kinect2_rgb_optical_frame
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" rgb_topic:=/kinect2/sd/image_color_rect depth_topic:=/kinect2/sd/image_depth_rect camera_info_topic:=/kinect2/sd/camera_info
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" rgb_topic:=/kinect2/qhd/image_color_rect depth_topic:=/kinect2/qhd/image_depth_rect camera_info_topic:=/kinect2/qhd/camera_info
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" rgb_topic:=/kinect2/qhd(hd)/image_color_rect depth_topic:=/kinect2/qhd(hd)/image_depth_rect camera_info_topic:=/kinect2/qhd(hd)/camera_info
(4)使用rviz
rosrun rviz rviz
当Rviz打开以后,将Fixed Frame更改为kinect2_link,点击Add按钮添加PointCloud2,展开PointCloud2后,将Topic改为/kinect2/sd/points就可以看到点云信息。
(5)3D点云地图的保存
rosrun pcl_ros pointcloud_to_pcd input:=/rtabmap/cloud_map