寫在前面
以下内容主要來自 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位置 和 實際地圖中的位置 對應起來呢?
- 地圖的最右上角的像素為坐标(0,0),是以整個地圖都處于坐标系的第三象限
- 計算origin對應位置:對于
, 将origin: x=-132.9m y=-91.3m
的值分别除以分辨率 resolution(這裡是 0.05 米/像素),可以得出x=-2658 個像素,y為 -1826 個像素。然後從地圖的右上角(0,0)處,橫軸向左數2658個像素,縱軸向下數1826個像素,就是origin代表的在地圖中的位置。x,y
二、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