Main Content

world2grid

ワールド座標をグリッド インデックスに変換

説明

ij = world2grid(map,xy) は、ワールド座標 xy の配列を、グリッド インデックス ij[rows cols] 配列に変換します。

すべて折りたたむ

幅と高さが 10 メートルの空のバイナリ占有マップを作成します。

map = binaryOccupancyMap(10,10);

グリッド インデックスをワールド座標から取得します。

[xWorld,yWorld] = meshgrid(0:0.5:2);
ij = world2grid(map,[xWorld(:) yWorld(:)]);

10 m x 10 m の空のマップを作成します。

map = binaryOccupancyMap(10,10,10);

ワールド位置の占有を設定し、マップを表示します。

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)

Figure contains an axes object. The axes object with title Binary Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

占有位置を指定した半径でインフレートします。

inflate(map, 0.5)
figure
show(map)

Figure contains an axes object. The axes object with title Binary Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

ワールド位置からグリッド位置を取得します。

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

グリッド位置をフリー位置に設定します。

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

Figure contains an axes object. The axes object with title Binary Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

入力引数

すべて折りたたむ

地図表現。binaryOccupancyMap オブジェクトとして指定します。

ワールド座標。[x y] ペアの n 行 2 列の垂直配列として指定します。ここで、n はワールド座標の数です。

出力引数

すべて折りたたむ

グリッド インデックス。[rows cols] の形式で、[i j] ペアからなる n 行 2 列の垂直配列として指定します。ここで、n はグリッド位置の数です。

拡張機能

C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。

バージョン履歴

R2015a で導入