Main Content

setOccupancy

Set occupancy probability of locations

Description

setOccupancy(map3D,xyz,occval) assigns the occupancy values to each specified xyz coordinate in the 3-D occupancy map.

example

Examples

collapse all

Create an occupancyMap3D object.

map3D = occupancyMap3D;

Create a ground plane and set occupancy values to 0.

[xGround,yGround,zGround] = meshgrid(0:100,0:100,0);
xyzGround = [xGround(:) yGround(:) zGround(:)];
occval = 0;
setOccupancy(map3D,xyzGround,occval)

Create obstacles in specific world locations of the map.

[xBuilding1,yBuilding1,zBuilding1] = meshgrid(20:30,50:60,0:30);
[xBuilding2,yBuilding2,zBuilding2] = meshgrid(50:60,10:30,0:40);
[xBuilding3,yBuilding3,zBuilding3] = meshgrid(40:60,50:60,0:50);
[xBuilding4,yBuilding4,zBuilding4] = meshgrid(70:80,35:45,0:60);

xyzBuildings = [xBuilding1(:) yBuilding1(:) zBuilding1(:);...
                xBuilding2(:) yBuilding2(:) zBuilding2(:);...
                xBuilding3(:) yBuilding3(:) zBuilding3(:);...
                xBuilding4(:) yBuilding4(:) zBuilding4(:)];

Update the obstacles with new probability values and display the map.

obs = 0.65;
updateOccupancy(map3D,xyzBuildings,obs)
show(map3D)

Check if the map file named citymap.ot already exist in the current directory and delete it before creating the map file.

if exist("citymap.ot",'file')
    delete("citymap.ot")
end

Export the map as an octree file.

filePath = fullfile(pwd,"citymap.ot");
exportOccupancyMap3D(map3D,filePath)

Input Arguments

collapse all

3-D occupancy map, specified as an occupancyMap3D object.

World coordinates, specified as an n-by-3 matrix of [x y z] points, where n is the number of world coordinates.

Probability occupancy values, specified as a scalar or a column vector with the same length as xyz. A scalar input is applied to all coordinates in xyz.

Values close to 0 represent certainty that the cell is not occupied and obstacle-free.

Extended Capabilities

Version History

Introduced in R2019b