Main Content

二进制挑选

创建occupancy grid with binary values

Description

二进制挑选创建一个二维占用地图对象,您可以用来表示和可视化机器人工作区,包括障碍。传感器数据和位置估计的集成创造了障碍物的近似位置的空间表示。

占用网格用于机器人技术算法,例如路径计划。它们还用于映射应用程序,例如查找无碰撞路径,进行避免碰撞并计算本地化。您可以修改占用网格以适合您的特定应用程序。

Each cell in the occupancy grid has a value representing the occupancy status of that cell. An occupied location is represented astrue (1)自由位置表示为false (0)

这目的keeps track of three reference frames: world, local, and, grid. The world frame origin is defined byGridLocationinworld,,,,which defines the bottom-left corner of the map relative to the world frame. TheLocalOriginInWorld属性指定本地框架相对于世界框架的原点的位置。索引的第一个网格位置(1,1)begins in the top-left corner of the grid.

笔记

This object was previously namedrobotics.BinaryOccupancyGrid

创建

Description

例子

map = binaryOccupancyMapcreates a 2-D binary occupancy grid with a width and height of 10m. The default grid resolution is one cell per meter.

例子

map = binaryoccupancymap(width,,,,高度creates a 2-D binary occupancy grid representing a work space ofwidth高度in meters. The default grid resolution is one cell per meter.

map = binaryoccupancymap(width,,,,高度,,,,解析度Resolution属性以每米的单元格方式指定。这map is in world coordinates by default.

map = binaryoccupancymap(行,cols,解析度,“网格”)创建一个大小的2D二元占用网格(rows,,,,科尔斯)。

例子

map = binaryoccupancymap(pcreates a grid from the values in matrixp。这size of the grid matches the size of the matrix, with each cell value interpreted from its location in the matrix.pcontains any numeric or logical type with zeros (0) and ones (1).

map = binaryoccupancymap(p,,,,解析度creates a map from a matrix with theResolution属性以每米的单元格方式指定。

map = binaryoccupancymap(sourcemapcreates an object using values from another二进制挑选目的。

map = binaryoccupancymap(sourcemap,,,,解析度creates an object using values from another二进制挑选对象,但重新示例矩阵具有指定的分辨率。

Input Arguments

expand all

Map width, specified as a positive scalar in meters.

地图高度,,,,specified as a positive scalar in meters.

Map grid values, specified as a matrix.

占用图对象,,,,specified as a二进制挑选目的。

特性

expand all

This property is read-only.

Number of rows and columns in grid, stored as a two-element horizontal vector of the form[行科尔斯]

This property is read-only.

网格分辨率,以每米的单元格中的标量存储。

This property is read-only.

Minimum and maximum values ofX- 本地框架中的坐标,作为形式的两元素水平向量存储[min max]。本地框架由LocalOriginInWorld财产。

This property is read-only.

Minimum and maximum values ofy- 本地框架中的坐标,作为形式的两元素水平向量存储[min max]。本地框架由LocalOriginInWorld财产。

This property is read-only.

Minimum and maximum values ofX- 世界框架中的坐标,作为形式的两元素水平向量存储[min max]。这se values indicate the world range of theX- 网格中的坐标。

This property is read-only.

Minimum and maximum values ofy- 坐标,,,,stored as a two-element vector of the form[min max]。这se values indicate the world range of they- 网格中的坐标。

bottom-l的位置eft corner of the grid in world coordinates, specified as a two-element vector,[XGRID YGRID]

本地框架在世界坐标中的位置,指定为两元素向量,[Xlocal Ylocal]。使用movefunction to shift the local frame as your vehicle moves.

bottom-l的位置eft corner of the grid in local coordinates, specified as a two-element vector,[Xlocal Ylocal]

Default value for unspecified map locations including areas outside the map, specified as0or1

Object Functions

校验 检查位置的占用值
getOccupancy 获得位置的占用价值
grid2local Convert grid indices to local coordinates
grid2world 将网格索引转换为世界坐标
inflate 充气每个被占用的网格位置
insertRay Insert ray from laser scan observation
local2grid Convert local coordinates to grid indices
local2world 将本地坐标转换为世界坐标
move Move map in world frame
占领 Convert occupancy grid to matrix
射线广播 沿射线计算单元格指数
rayIntersection Find intersection points of rays and occupied map cells
Setoccupancy 设定位置的占用价值
节目 显示占用网格值
Syncwith Sync map with overlapping map
world2grid Convert world coordinates to grid indices
world2local 将世界坐标转换为本地坐标

Examples

collapse all

创建a 10m x 10m empty map.

map = binaryoccupancymap(10,10,10);

Set occupancy of world locations and show map.

X= [1.2; 2.3; 3.4; 4.5; 5.6]; y = [5.0; 4.0; 3.0; 2.0; 1.0]; setOccupancy(map, [x y], ones(5,1)) figure show(map)

图包含一个轴对象。带有标题二进制占用网格的轴对象包含类型图像的对象。

充气占用的位置占据给定半径。

膨胀(地图,0.5)图显示(地图)

图包含一个轴对象。带有标题二进制占用网格的轴对象包含类型图像的对象。

Get grid locations from world locations.

ij = world2grid(map, [x y]);

将网格位置设置为自由位置。

Setoccupancy(map, ij, zeros(5,1),'grid')figure show(map)

图包含一个轴对象。带有标题二进制占用网格的轴对象包含类型图像的对象。

此示例显示了如何将图像转换为二进制占用网格,用于使用映射和路径计划。

导入图像。

图像= imread('imagemap.png');

Convert to grayscale and then black and white image based on given threshold value.

grayimage = rgb2gray(image); bwimage = grayimage < 0.5;

Use black and white image as matrix input for binary occupancy grid.

grid = binaryoccupancymap(bwimage);展示(网格)

图包含一个轴对象。带有标题二进制占用网格的轴对象包含类型图像的对象。

This example shows how to convert a.pgmfile into a二进制挑选对象用于MATLAB。

Import image usingimread。图像很大,应裁剪到相关区域。

图像= imread('playpen_map.pgm');ImageCropped =图像(750:1250,750:1250);Imshow(想象中)

图包含一个轴对象。轴对象包含类型图像的对象。

Unknown areas (gray) should be removed and treated as free space. Create a logical matrix based on a threshold. Depending on your image, this value could be different. Occupied space should be set as 1 (white in image).

imageBW = imageCropped < 100; imshow(imageBW)

图包含一个轴对象。轴对象包含类型图像的对象。

创建二进制挑选使用调整后的地图图像对象。

map = binaryoccupancymap(imageBW); show(map)

图包含一个轴对象。带有标题二进制占用网格的轴对象包含类型图像的对象。

扩展功能

版本历史记录

Introduced in R2015a

expand all

Behavior change in future release

也可以看看