Get occupancy value of locations
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;
lidarScan object with the specified ranges and angles.
scan = lidarScan(ranges,angles);
Insert the laser scan data into the occupancy map.
Show the map to see the results of inserting the laser scan.
Check the occupancy of the spot directly in front of the vehicle.
ans = logical 1
Access occupancy values and check their occupancy status based on the occupied and free thresholds of the
Create a matrix and populate it with values. Use this matrix to create an occupancy map.
p = zeros(20,20); p(11:20,11:20) = ones(10,10); map = binaryOccupancyMap(p,10); show(map)
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');
map— Map representation
Map representation, specified as a
binaryOccupancyMap object. This object represents the
environment of the vehicle.
xy— Coordinates in the map
Coordinates in the map, specified as an n-by-2 matrix of
y] pairs, where n is the number of
coordinates. Coordinates can be world or local coordinates depending on the
ij— Grid locations in the map
Grid locations in the map, specified as an n-by-2 matrix of
j] pairs, where n is the number of
locations. Grid locations are given as
bottomLeft— Location of output matrix in world or local
Location of bottom left corner of output matrix in world or local coordinates,
specified as a two-element vector,
[xCoord yCoord]. Location is in
world or local coordinates based on syntax.
matSize— Output matrix size
Output matrix size, specified as a two-element vector,
[gridRow gridCol]. The size is in world
coordinates, local coordinates, or grid indices based on syntax.
topLeft— Location of grid
Location of top left corner of grid, specified as a two-element vector,