updateOccupancy
Update occupancy probability at locations
Description
updateOccupancy(
probabilistically integrates the observation values, map3D
,xyz
,obs
)obs
,
to each specified xyz
coordinate in the occupancyMap3D
object, map3D
.
Examples
Create and Export 3-D Occupancy Map
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
map3D
— 3-D occupancy map
occupancyMap3D
object
3-D occupancy map, specified as an occupancyMap3D
object.
xyz
— World coordinates
n-by-3 matrix
World coordinates, specified as an n-by-3 matrix of
[x y z]
points, where n is the
number of world coordinates.
obs
— Probability observation values
numeric scalar | logical scalar | n-by-1 column vector
Probability observation values, specified as a numeric or logical scalar,
or as an n-by-1 column vector with the same size as
xyz
.
obs
values can be from 0 to 1, but if
obs
is a logical array, the function uses the
default observation values of 0.7 (true
) and 0.4
(false
). If obs
is a numeric or
logical scalar, the value is applied to all coordinates in
xyz
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
updateOccupancy
does not support code generation using the packNGo
(MATLAB Coder) function if you set the packType
argument to "flat"
.
Version History
Introduced in R2019b
See Also
Classes
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)