目前机器人相关的构图定位大多模式是Cartographer + AMCL + MoveBase,而现在开始出现Cartographer + MoveBase,去掉AMCL,其定位功能,完全可由Cartographer提供,而且其精度还比AMCL好.
最近完成Cartographer的定位测试,记录相关操作步骤,供以后查看.
1.cartographer 官方提供的bag及测试用例,其雷达数据类型是sensor_msgs/MultiEchoLaserScan,而我们大多用的雷达是sensor_msgs/LaserScan,因此相关配置必须自己摸索修改.
2.生成地图
roslaunch cartographer_ros offline_backpack_2d.launch bag_filenames:=${HOME}/catkin_ws_cartographer/demo_bags/2020-07-04_dayang_1.bag
给定自己录制的bag,offline_backpack_2d.launch中变化为<arg name="configuration_basenames" default="revo_lds.lua"/>
(revo_lds.lua专为LaserScan类型配置)
3.纯定位
roslaunch cartographer_ros demo_backpack_2d_localization.launch \
load_state_filename:=${HOME}/catkin_ws_cartographer/demo_bags/2020-07-04_dayang_1.bag.pbstream \
bag_filename:=${HOME}/catkin_ws_cartographer/demo_bags/2020-07-04_dayang_1.bag
设置前面生成的地图,及要播放的bag文件,demo_backpack_2d_localization.launch文件需要修改:
<!--remap from="echoes" to="horizontal_laser_2d" /-->
<remap from="scan" to="scan" />
backpack_2d_localization.lua文件的引用修改为 include "revo_lds.lua"
4.注意自己雷达设置的坐标系(laser/base_laser/base_link等等).这样就可以跑了.