ROS2 cartographer 保存地图

1. 结束构图,停止接收新数据

ros2 service call /finish_trajectory cartographer_ros_msgs/srv/FinishTrajectory "{trajectory_id: 0}"

 其中服务类型可以tab出来,服务的格式可以使用如下命令查看

ros2 interface show cartographer_ros_msgs/srv/FinishTrajectory.srv

 2. 序列化保存其当前状态

ros2 service call /write_state cartographer_ros_msgs/srv/WriteState "{filename: '/home/develop/bags/mymap.pbstream'}"

 3. 将pbstream转换为pgm和yaml

在cartographer_pbstream_to_ros_map文件目录下执行:

./cartographer_pbstream_to_ros_map -map_filestem=${HOME}/bags/mymap -pbstream_filename=${HOME}/bags/mymap.pbstream -resolution=0.05

这样地图已经保存成功了。

posted @ 2021-01-22 21:23  白菜菜白  阅读(2544)  评论(0编辑  收藏  举报