天天看点

【ROS学习】-map.yaml 文件内容解析

写在前面

以下内容主要来自 ROS wiki 官网 map_server:https://wiki.ros.org/map_server

一、yaml格式

image: testmap.png
resolution: 0.1
origin: [0.0, 0.0, 0.0]
occupied_thresh: 0.65
free_thresh: 0.196
negate: 0
           

参数解析:

  • image: 地图文件的路径,可以是绝对路径,也可以是相对路径
  • resolution: 地图的分辨率, 米/像素
  • origin: 地图左下角像素对应的 2D 位姿(x,y,yaw), 这里的yaw是逆时针方向旋转的(yaw=0 表示没有旋转)。目前系统中的很多部分会忽略yaw值。
  • occupied_thresh: 占用概率大于这个阈值的的像素,会被认为是完全占用。
  • free_thresh: 占用概率小于这个阈值的的像素,会被认为是完全自由。
  • negate: 是否颠倒 白/黑 、自由/占用 的意义(阈值的解释不受影响)

可选参数:

  • mode: 有三个值可选:trinary, scale, raw 。默认值是 trinary ,更多细节请参考下一节的 具体的解释

举例

image: map.pgm
resolution: 0.050000
origin: [-132.900000, -91.300000, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
           

这里 origin 是相对于机器人建图时的初始位置的,单位是m,以建图起点作为参考点,origin 的值是地图左下角那个像素所对应的坐标。

那怎样将origin位置 和 实际地图中的位置 对应起来呢?

  1. 地图的最右上角的像素为坐标(0,0),所以整个地图都处于坐标系的第三象限
  2. 计算origin对应位置:对于

    origin: x=-132.9m y=-91.3m

    , 将

    x,y

    的值分别除以分辨率 resolution(这里是 0.05 米/像素),可以得出x=-2658 个像素,y为 -1826 个像素。然后从地图的右上角(0,0)处,横轴向左数2658个像素,纵轴向下数1826个像素,就是origin代表的在地图中的位置。

二、ROS wiki 原文

1.2 YAML format

The YAML format is best explained with a simple, complete example:

image: testmap.png
resolution: 0.1
origin: [0.0, 0.0, 0.0]
occupied_thresh: 0.65
free_thresh: 0.196
negate: 0
Required fields:
           
  • image : Path to the image file containing the occupancy data; can be absolute, or relative to the location of the YAML file
  • resolution : Resolution of the map, meters / pixel
  • origin : The 2-D pose of the lower-left pixel in the map, as (x, y, yaw), with yaw as counterclockwise rotation (yaw=0 means no rotation). Many parts of the system currently ignore yaw.
  • occupied_thresh : Pixels with occupancy probability greater than this threshold are considered completely occupied.
  • free_thresh : Pixels with occupancy probability less than this threshold are considered completely free.
  • negate : Whether the white/black free/occupied semantics should be reversed (interpretation of thresholds is unaffected)

Optional parameter:

  • mode : Can have one of three values: trinary, scale, or raw. Trinary is the default. More information on how this changes the value interpretation is in the next section.

1.3 Value Interpretation

参考链接:

[1] map_server : https://wiki.ros.org/map_server

[2] ros中如何根据map.yaml和tf数据确定地图中机器人的位置 https://blog.csdn.net/sunyoop/article/details/79965673