%% Grid Coordinates from World Coordinate Inputs
% When setting occupancy locations, you can input the locations in either grid or world coordinates. However, based on the limits of the grid, the locations are set to the closest grid locations. Edges of the grid belong to the lower-left grid location.
% Show how locations are interpreted on the grid by creating an occupancy grid and setting points as occupied by obstacles. Then, plot the original input points over the map to show how they are interpreted. If any point within the grid cell is set as occupied, the entire grid cell is set as occupied.
% Create an occupancy grid map and set obstacle locations.

map = binaryOccupancyMap(10,10,5);
xy = [5 5; 4.3 4.4; 5.6 5.3];
setOccupancy(map,xy,1);

%
% Display the map, original points, and set the axes limits to zoom in. You can see how the edge points affect the entire grid location status.

show(map);
hold on
plot(xy(:,1),xy(:,2),'xr','MarkerSize', 20)
grid on
set(gca,'XTick',0:0.2:10,'YTick',0:0.2:10)
xlim([4 6])
ylim([4 6])

% Copyright 2012 The MathWorks, Inc.