www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/GetOccupancyValuesAndCheckOccupancyStatusExample.m
%% Get Occupancy Values and Check Occupancy Status % Access occupancy values and check their % occupancy status based on the occupied and free thresholds of the % |OccupancyGrid| object. %% % Create a matrix and populate it with values. Use this matrix to create an occupancy % grid. p = 0.5*ones(20,20); p(11:20,11:20) = 0.75*ones(10,10); map = robotics.OccupancyGrid(p,10); %% % Get the occupancy of different locations and check their occupancy statuses. % The occupancy status returns 0 for free space and 1 for occupied space. % Unknown values return -1. pocc = getOccupancy(map,[1.5 1]) occupied = checkOccupancy(map,[1.5 1]) pocc2 = getOccupancy(map,[5 5],'grid') occupied2 = checkOccupancy(map,[5 5],'grid')