数据预处理(17)_对cartographer或gmapping生成的.pgm地图作分割

一般来说,gmapping是一种增量式的建图方法,一般用于小场景的地图构建,而大场景的地图构建方法一般选择基于图优化的方法,代表有cartographer,通过开源的算法得到地图后,但是对于移动机器人在大场景下的定位有一个问题:启动定位,一次性加载地图并完成代价计算相当耗时,这时就需要作地图分割,根据里程计推算或者GPS的定位完成分块加载地图。

1.将.pgm地图转为.png格式

这里用了Ubuntu下的KolourPaint软件进行转换,理想的方式还是需要自己用代码实现。这里先展示一下由.pgm转换后的.png图片,看不出变化,只是编码方式不同而已。
在这里插入图片描述对应的yaml文件如下:

image: map_2020307.png
resolution: 0.025000
origin: [-27.400000, -27.400000, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196

2.分割的目标

由gmapping生成的地图包含一张.png格式的栅格地图及对应的.yaml配置文件,将全局栅格地图划分成边长为10m的正方形,按列优顺序生成子图。每个子图命名为"i_j.png“,其中i表示列数,j表示行数。

3.需要注意的几点

1)分割的边长(m)/地图分辨率(m/pixel)=子图边长对应像素(pixel)
行/列方向上子图的个数=地图的大小(pixel)/子图边长对应的像素(pixel)
3)原全局地图(.png)要想转换为多个子图,必须有一个中间地图。因为在完成行列方向上子图个数计算时时这样的:

width_num_=ceil(map_.cols/double(submap_size_));
height_num_=ceil(map_.cols/double(submap_size_));

也即是取整计算,那么按照这个方式还原回原来的栅格地图,大小是不一样的,因此需要重新考虑地图占据、空闲以及未知状态的定义。方法可以参考map_server。
4)如3)所说,地图的大小变化了,那么相应的地图原点也需要重新计算。

4.最终的分割结果

在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
FAILED: CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DGFLAGS_IS_A_DLL=0 -I../cartographer -I. -I../ -isystem /usr/include/eigen3 -isystem /usr/include/lua5.2 -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -std=gnu++11 -MD -MT CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -MF CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o.d -o CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -c ../cartographer/transform/timestamped_transform_test.cc In file included from ../cartographer/transform/timestamped_transform_test.cc:17: ../cartographer/transform/timestamped_transform.h:21:10: fatal error: cartographer/transform/proto/timestamped_transform.pb.h: No such file or directory 21 | #include "cartographer/transform/proto/timestamped_transform.pb.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. [44/380] Building CXX object CMakeFiles/cartographer.sensor.internal.voxel_filter_test.dir/cartographer/sensor/internal/voxel_filter_test.cc.o
07-23
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值