构建栅格地图,要弄清楚坐标之间的关系。本篇根据代码,画出了坐标转换的关系。
如下图:
cartographer中的代码如下:
// Returns the index of the cell containing the 'point' which may be outside // the map, i.e., negative or too large indices that will return false for // Contains(). Eigen::Array2i GetCellIndex(const Eigen::Vector2f& point) const { // Index values are row major and the top left has Eigen::Array2i::Zero() // and contains (centered_max_x, centered_max_y). We need to flip and // rotate. return Eigen::Array2i( common::RoundToInt((max_.y() - point.y()) / resolution_ - 0.5), common::RoundToInt((max_.x() - point.x()) / resolution_ - 0.5)); } // Returns the center of the cell at 'cell_index'. Eigen::Vector2f GetCellCenter(const Eigen::Array2i cell_index) const { return {max_.x() - resolution() * (cell_index[1] + 0.5), max_.y() - resolution() * (cell_index[0] + 0.5)}; }
标签:index,cartographer,Array2i,Eigen,max,像素,cell,_.,坐标系 From: https://www.cnblogs.com/havain/p/17437431.html