之前做的2D LiDAR的实验中,大多采用gmapping,本博文试试采用cartographer。对于cartographer方法,相比起gmapping,其多了IMU以及回环检测。有了回环检测后,可以避免odom的累积误差,故此,较为适合用于大面积地图的构建。
cartographer采用的是主流的SLAM框架,也就是特征提取、闭环检测、后端优化的三段式。由一定数量的LaserScan组成一个submap子图,一系列的submap子图构成了全局地图。用LaserScan构建submap的短时间过程累计误差不大,但是用submap构建全局地图的长时间过程就会存在很大的累计误差,所以需要利用闭环检测来修正这些submap的位置,闭环检测的基本单元是submap,闭环检测采用scan_match策略。cartographer的重点内容就是融合多传感器数据(odometry、IMU、LaserScan等)的submap子图创建以及用于闭环检测的scan_match策略的实现。
目录
Cartographer的配置
首先安装依赖包
sudo apt-get install ros-melodic-cartographer*
然后对于运行的SLAM launch加入参数指定SLAM方法即可
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
直接运行仿真时会报错(https://blog.csdn.net/c417469898/article/details/117365197)
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
错误如下:
sensor_bridge.cc:126] Check failed: sensor_to_tracking->translation().norm() < 1e-5 The IMU frame must be colocated with the tracking frame. Transforming linear acceleration into the tracking frame will otherwise be imprecise.
这是gazebo_ros_imu的一个bug
解决方法1
运行slam时候,添加参数指定仿真用配置文件
configuration_basename:=turtlebot3_lds_2d_gazebo.lua
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer configuration_basename:=turtlebot3_lds_2d_gazebo.lua
运行键盘
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
实验
接下来看看实验的效果以及跟gmapping的对比:对于他们两者,一个是基于图优化框架的SLAM,一个基于滤波框架的SLAM(gmapping)。
从上图可以看出。对于但机器人而言,gmapping与Cartographer好像差别并不是很大。但是对于multi robot map merge而言,就差别比较大了。类似的设置,类似的距离下,多机器人地图融合若采用Cartographer,其建图的效果会很差。但是理论上,map merge这个包仅仅是把栅格地图作为输入,不应该受到SLAM方法的影响吖~~~
参考资料
https://www.cnblogs.com/hiram-zhang/archive/2019/02/21/10415865.html