一.nav_msgs/OccupancyGrid 消息类型
# This represents a 2-D grid map, in which each cell represents the probability of
# occupancy.
#代表一个2D栅格地图,其中每一个小格是占据的概率
Header header
#MetaData for the map #2D栅格地图的图元
MapMetaData info
# The map data, in row-major order, starting with (0,0). Occupancy
# probabilities are in the range [0,100]. Unknown is -1.
#0~100,占据的概率从小到大,其中-1是未知
int8[] data
data数组中元素为不同值,在rviz中显示时为不同颜色,这篇博文是将颜色与data数组里元素值的对应关系进行了探索:https://blog.csdn.net/sunqin_csdn/article/details/106676725
karto$ rosmsg info nav_msgs/OccupancyGrid
std_msgs/Header header
uint32 seq
time stamp
string frame_id
nav_msgs/MapMetaData info
time map_load_time
float32 resolution
uint32 width
uint32 height
geometry_msgs/Pose origin
geometry_msgs/Point position
float64 x
float64 y
float64 z
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w
int8[] data
对应的c++头文件 为:
#include "nav_msgs/OccupancyGrid.h"
二、nav_msgs/MapMetaData 消息类型
# This hold basic information about the characterists of the OccupancyGrid
# 它包括占据栅格特征的基本信息
# The time at which the map was loaded #地图加载的时间
time map_load_time
# The map resolution [m/cell] #分辨率,每一小格的尺寸,小格的长宽应该是一致的,单位为m
float32 resolution
# Map width [cells] #地图宽度,多少个小格
uint32 width
# Map height [cells] #地图高度
uint32 height
# The origin of the map [m, m, rad]. This is the real-world pose of the
# cell (0,0) in the map.
# map地图的原点,是map地图的(0,0)点在真实世界中的姿态
# 注:栅格地图原点为其左下角,且坐标系中:右为x轴正向,上为y轴正向
geometry_msgs/Pose origin
karto$ rosmsg info nav_msgs/MapMetaData
time map_load_time
float32 resolution
uint32 width
uint32 height
geometry_msgs/Pose origin
geometry_msgs/Point position
float64 x
float64 y
float64 z
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w
当初始化地图的部分参数如下时,可以看出地图的方向和坐标系/velo_link一致,可以通过/velo_link的坐标方向来找到地图的坐标方向;且栅格地图原点为其左下角,其标系中:右为x轴正向,上为y轴正向
map_.header.frame_id="/velo_link";
// map_.header.frame_id="camera_init";
map_.header.stamp = ros::Time::now();
map_.info.resolution = resolution; // float32
map_.info.width = map_width_inc; // uint32
map_.info.height = map_height_inc; // uint32
map_.info.origin.orientation.x = 0.0;
map_.info.origin.orientation.y = 0.0;
map_.info.origin.orientation.z = 0.0;
map_.info.origin.orientation.w = 1.0;
@meng