Main Content

checkOccupancy

Check if locations are free or occupied

Description

iOccval = checkOccupancy(map3D,xyz) returns an array of occupancy values specified at the xyz locations using the OccupiedThreshold and FreeThreshold properties of the input occupancyMap3D object. Each row is a separate xyz location in the map to check the occupancy of. Occupancy values can be obstacle-free (0), occupied (1), or unknown (–1).

example

Examples

collapse all

Import a 3-D occupancy map.

map3D = importOccupancyMap3D("citymap.ot")
map3D = 
  occupancyMap3D with properties:

    ProbabilitySaturation: [1.0000e-03 0.9990]
               Resolution: 1
        OccupiedThreshold: 0.6500
            FreeThreshold: 0.2000

Display the map.

show(map3D)

Figure contains an axes object. The axes object with title Occupancy Map, xlabel X [meters], ylabel Y [meters] contains an object of type patch.

Check the occupancy statuses of different locations and get their occupancy values.

iOccVal1 = checkOccupancy(map3D,[50 15 0])
iOccVal1 = 
0
OccVal1 = getOccupancy(map3D,[50 15 0])
OccVal1 = 
0.0019
iOccVal2 = checkOccupancy(map3D,[50 15 15])
iOccVal2 = 
1
OccVal2 = getOccupancy(map3D,[50 15 15])
OccVal2 = 
0.6500
iOccVal3 = checkOccupancy(map3D,[50 15 45])
iOccVal3 = 
-1
OccVal3 = getOccupancy(map3D,[50 15 45])
OccVal3 = 
0.5000

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.

Output Arguments

collapse all

Interpreted occupancy values, returned as a column vector with the same length as xyz.

Occupancy values can be obstacle-free (0), occupied (1), or unknown (–1). These values are determined from the actual probability values and the OccupiedThreshold and FreeThreshold properties of the map3D object.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2019b