方法一:
(注意:要在carto不报错之前停止构建地图)
1.停止地图构建
rosservice call /finish_trajectory 0
2.生成.pbstream文件
rosservice call /write_state "{filename: '<绝对路径>/***.pbstream' "
3.使用catro提供文件,将.pbstream文件转为.yaml和.pgm文件
rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=<绝对路径>/<地图名字> -pbstream_filename=<绝对路径>/<.pbstream名字> -resolution=0.05
方法二:
此方法可以在使用map_server加载地图中成功加载
由于carto保存地图格式和map_saver不一致,所以需要对源码进行修改,修改后地址
github地址:https://github.com/HaoQChen/map_server
将此包在工作空间下编译
然后运行:
rosrun map_server map_saver -f <绝对路径>/<地图名字>