Main Content

occupancyMatrix

Convert occupancy grid to matrix

Description

mat = occupancyMatrix(map) returns occupancy values stored in the occupancy grid object as a matrix.

example

Examples

collapse all

Generate a random 2-D maze map.

map = mapMaze(2,MapSize=[10 10],MapResolution=1);
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.

Convert the binary occupancy map to occupancy values matrix.

occupancyMatrix(map)
ans = 10x10 logical array

   1   1   1   1   1   1   1   1   1   1
   1   0   0   0   0   0   0   0   0   1
   1   0   0   0   0   0   0   0   0   1
   1   1   1   1   1   1   1   0   0   1
   1   0   0   0   0   0   0   0   0   1
   1   0   0   0   0   0   0   0   0   1
   1   0   0   1   1   1   1   1   1   1
   1   0   0   0   0   0   0   0   0   1
   1   0   0   0   0   0   0   0   0   1
   1   1   1   1   1   1   1   1   1   1

Input Arguments

collapse all

Map representation, specified as a binaryOccupancyMap object. This object represents the environment of the robot. The object contains a matrix grid with binary values indicating obstacles as true (1) and free locations as false (0).

Output Arguments

collapse all

Occupancy values, returned as an h-by-w matrix, where h and w are defined by the two elements of the GridSize property of the occupancy grid object.

Data Types: double

Extended Capabilities

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

Version History

Introduced in R2016b