使用cartographer_ros(在线/离线)构建地图后保存地图的方法

1,安装cartographer

请看我写的这篇文章虽然我使用的是ubuntu18.04的melodic版本的ROS,但是ROS是兼容的,即你的ROS版本和系统和我的不同,也可以使用这篇文章的方法正确的安装。

2,使用cartographer构建号地图后怎么保存成yaml和png文件呢?

关于cartographer_ros的文档,官方有提供,请看这里

2.1 保存地图

  1. 当使用cartographer在线建图时,cartographer不知道什么时候结束,所以要先调用服务来关闭传感器数据的接收。
rosservice call /finish_trajectory 0
  1. 将当前地图信息的快照保存为后缀名为.pbstream
# Ask Cartographer to serialize its current state.
# (press tab to quickly expand the parameter syntax)
rosservice call /write_state "{filename: '<绝对路径存放地图信息>/<地图保存的名字>.pbstream', include_unfinished_submaps: 'true'}"
  1. 通过cartographer提供的ros包,将后缀名为.pbstream的地图信息,转化成ros地图信息
rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=<保存地图的绝对路径>/<地图命名> -pbstream_filename=<存放pbstream地图快照信息的绝对地址>/<filename>.pbstream -resolution=0.05

2.2 也可以尝试使用map_server保存地图

rosrun map_server map_saver map:=/<your map topic> -f <map_name>

不过保存cartographer的地图不是特别好,不推荐。

你可能感兴趣的:(algorithm,ROS的学习)