grid_map教程(初见)

一、安装

方法1:本人用的方法2

sudo apt-get install ros-kinetic-grid-map

方法2:需要先安装ROS

cd catkin_ws/src
git clone https://github.com/ethz-asl/grid_map.git
cd ../
catkin_make -DCMAKE_BUILD_TYPE=Release

二、功能介绍

1.octomap转化grid_map

grid_map::GridMapOctomapConverter::fromOctomap(const octomap::OcTree& octomap,
const std::string& layer, grid_map::GridMap& gridMap, const grid_map::Position3* minPoint = nullptr,  const grid_map::Position3* maxPoint = nullptr);

2.catkin_ws/src/grid_map/grid_map_core/include/grid_map_core/GridMap.hpp中有对grid_map的操作的定义。

void setFrameId(const std::string& frameId);
bool isDefaultStartIndex() const;
const std::vector<std::string>& getLayers() const;
...

3.grid_map在rviz中显示,需要转化成grid_map_msgs::GridMap

/*各类型的转化定义在catkin_ws/src/grid_map/grid_map_ros/include/grid_map_ros/
GridMapRosConverter.hpp中*/
grid_map::GridMapRosConverter::toMessage(const grid_map::GridMap& gridMap, grid_map_msgs::GridMap& message);
/*如果rviz中提示fixed frame map does not exist,按以下方式执行,my_frame改成自己的frameID,设置frameID的函数见2*/
catkin_make install
roscore
rosrun using_markers basic_shapes
rosrun tf static_transform_publisher 0.0 0.0 0.0 0.0 0.0 0.0 map my_frame 100 
rosrun rviz rviz
//也可以在launch文件中加入
<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0.0 0.0 0.0 0.0 0.0 0.0 map my_frame 100" />

三、备注

  • grid_map_demos有很多例子
  • 可视化可参考grid_map_visualization

你可能感兴趣的:(updating,ROS)