grid_map::GridMap数据结构,坐标系及索引概述

grid_map::GridMap数据结构

主要的数据如下:
std::string frameId_; 坐标系名称;
std::unordered_map<std::string, Matrix> data_;每一层的地图数据,存放在一个Eigen的二维矩阵中;
Length length_; 将map的二维尺寸存放在一个Eigen二维向量中;
double resolution_; 栅格化表示地图的分辨率;
Position position_; 栅格地图几何中心在坐标系下的值;
Size size_;  栅格地图的x,y尺度(数量);

grid_map::GridMap坐标系

gridmap与cv::Mat坐标系

         |<----------- width --------------->|
         |                                   |
  -------|-----------------------------------|----> cols
   ^     |                ^                  |
   |     |              x |                  |
   |     |                |                  |
   |     |     y          |                  | 
 height  |    <-----------+---------------   | 
   |     |                | orig = position  | 
   |     |                |                  |
   |     |                |                  |
   v     |                                   |
  -------|-----------------------------------|
         |
         v
        rows

gridmap-坐标系(x,y) 与 图像cv::Mat的转换:
  其中,x,y为国际制单位;

  double offset_x_set = img_height/2;
  double offset_y_set = img_width/2;
  
  cv::Point2i output;
  output.y = -(x - map_center_x_value)/reslution + offset_x;
  output.x = -(y - map_center_y_value)/reslution + offset_y;

grid_map::GridMap索引

GridMap二维索引(i,j)与数据存储的关系:

按照二维矩阵的方式存储数据,行为i,列为j,存储数据如下:
    ------------------------------
    |(0,0)|(0,1)|     ...        |  
    |-----|----------------------|
    |(1,0)|(1,1)|     ...        |  
    |-----|-----|----------------|
    |     |           ...        |
    |-----|----------------------|
    |     |           ...        |
    ------------------------------

GridMap的索引(i,j)与图像cv::Mat所索引的关系:

GridMap与cv::Mat的数据索引顺序一致:
grid_map::Matrix& data = gridMap[layer];
cv::Mat imageMono;
data(i, j) =  imageMono.at<Type_>(i, j);

GridMap的索引(i,j)与OccupancyGrid的索引(idx)关系:

OccupancyGrid的参数width,height;
已知(i,j),求取idx:
ix = width - i - 1;
iy = height - j - 1;
idx = ix + iy * width;

已知idx,求取(i,j):
iy = idx / width;
ix = idx % width;
i = width - ix - 1;
j = height - iy - 1;
  • 4
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值