world2grid
説明
例
占有マップのワールド座標をグリッド インデックスに変換
幅と高さが 10 メートルの空の占有マップを作成します。
map = occupancyMap(10,10);
グリッド インデックスをワールド座標から取得します。
[xWorld,yWorld] = meshgrid(0:0.5:2); ij = world2grid(map,[xWorld(:) yWorld(:)]);
占有マップの作成と変更
サイズが 10×10 メートルの空のマップを作成します。
map = occupancyMap(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]; pvalues = [0.2; 0.4; 0.6; 0.8; 1]; updateOccupancy(map,[x y],pvalues) figure show(map)
半径 0.5 m で占有領域をインフレートします。より大きな占有値が、より小さな値を上書きします。
inflate(map,0.5) figure show(map)
ワールド位置からグリッド位置を取得します。
ij = world2grid(map,[x y]);
グリッド位置の占有値を設定します。
setOccupancy(map,ij,ones(5,1),'grid')
figure
show(map)
入力引数
map
— 地図表現
occupancyMap
オブジェクト | mapLayer
オブジェクト | multiLayerMap
オブジェクト | signedDistanceMap
オブジェクト
地図表現。occupancyMap
、mapLayer
、multiLayerMap
、または signedDistanceMap
オブジェクトとして指定します。
xy
— ワールド座標
n 行 2 列の行列
ワールド座標。[x y]
ペアの n 行 2 列の行列として指定します。ここで、n はワールド座標の数です。
データ型: double
出力引数
ij
— グリッド インデックス
n 行 2 列の行列
グリッド インデックス。[row col]
の形式で、[i j]
ペアからなる n 行 2 列の行列として返されます。ここで、n はグリッド位置の数です。グリッド セルの位置は、グリッドの左上隅からカウントされます。
データ型: double
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
バージョン履歴
R2019b で導入R2023a: 符号付き距離マップのサポート
関数 world2grid
で、map
引数の新しい地図表現として signedDistanceMap
オブジェクトがサポートされるようになりました。
参考
オブジェクト
関数
トピック
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)