%% Insert Laser Scans into Binary Occupancy Map
% Create an empty binary occupancy grid map.

map = binaryOccupancyMap(10,10,20);

% Input pose of the vehicle, ranges, angles, and the maximum range of the laser scan.

pose = [5,5,0];
ranges = 3*ones(100,1);
angles = linspace(-pi/2,pi/2,100);
maxrange = 20;

% Create a lidarScan object with the specified ranges and angles.

scan = lidarScan(ranges,angles);

% Insert the laser scan data into the occupancy map.

insertRay(map,pose,scan,maxrange);

% Show the map to see the results of inserting the laser scan.

show(map)

% Check the occupancy of the spot directly in front of the vehicle.

getOccupancy(map,[8 5])

% Copyright 2019 The MathWorks, Inc.