ros学习(五):nav_msgs消息类型

一.nav_msgs/OccupancyGrid 消息类型

http://docs.ros.org/en/melodic/api/nav_msgs/html/msg/OccupancyGrid.htmlhttp://docs.ros.org/en/melodic/api/nav_msgs/html/msg/OccupancyGrid.html

# 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 消息类型

http://docs.ros.org/en/melodic/api/nav_msgs/html/msg/MapMetaData.htmlhttp://docs.ros.org/en/melodic/api/nav_msgs/html/msg/MapMetaData.html

# 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

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值