Main Content

local2grid

Convert local coordinates to grid indices

Description

ijGrid = local2grid(map,xyLocal) converts local coordinates in the map to grid indices.

example

Examples

collapse all

Create an empty occupancy map with a width and height of 10 meters.

map = occupancyMap(10,10);

Get grid indices from local coordinates.

[xLocal,yLocal] = meshgrid(0:0.5:2);
ij = local2grid(map,[xLocal(:) yLocal(:)]);

Input Arguments

collapse all

Map representation, specified as a occupancyMap, mapLayer, multiLayerMap, or signedDistanceMap object.

Local coordinates, specified as an n-by-2 matrix of [x y] pairs, where n is the number of world coordinates.

Data Types: double

Output Arguments

collapse all

Grid positions, returned as an n-by-2 matrix of [i j] pairs in [row col] format, where n is the number of grid positions. The grid cell locations start at (1,1) and are counted from the top left corner of the grid.

Data Types: double

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2019b

expand all