www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/InflateObstaclesInAnOccupancyGridExample.m

    %% Inflate Obstacles in an Occupancy Grid
% This example shows how the inflate method performs probabilitistic inflation on
% obstacles to inflate their size and create a buffer zone for areas with
% a higher probability of obstacles.


%% 
% Create a 10m x 10m empty map. 
map = robotics.OccupancyGrid(10,10,10);  

%% 
% Update occupancy of world locations with specific values in |pvalues|.  
map = robotics.OccupancyGrid(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)  

%% 
% Inflate occupied areas by a given radius. Larger occupancy values are
% written over smaller values. You can copy your map beforehand to revert
% any unwanted changes.
savedMap = copy(map);
inflate(map,0.5)
figure
show(map)