Create 3-D occupancy map
occupancyMap3D class stores a 3-D map and map information.
The map is stored as probabilistic values in an octree data
structure. The class handles arbitrary environments and expands its size
dynamically based on observation inputs. You can add observations as point clouds or as
specific xyz locations. These observations update the probability
values. Probabilistic values represent the occupancy of locations. The octree data
structure trims data appropriately to remain efficient both in memory and on
empty 3-D occupancy map with no observations and default property
omap = occupancyMap3D
specifies a map resolution in cells/meter and sets the
omap = occupancyMap3D(
creates an object with additional options specified by one or more
omap = occupancyMap3D(
Name,Value pair arguments. For example,
'FreeThreshold',0.25 sets the threshold to consider
cells obstacle-free as a probability value of 0.25. Enclose each property
name in quotes.
Resolution — Grid resolution
1 (default) | positive scalar
Grid resolution in cells per meter, specified as a scalar. Specify resolution on construction. Inserting observations with precisions higher than this value are rounded down and applied at this resolution.
FreeThreshold — Threshold to consider cells as obstacle-free
0.2 (default) | positive scalar
Threshold to consider cells as obstacle-free, specified as a positive scalar. Probability values below this threshold are considered obstacle-free.
OccupiedThreshold — Threshold to consider cells as occupied
0.65 (default) | positive scalar
Threshold to consider cells as occupied, specified as a positive scalar. Probability values above this threshold are considered occupied.
ProbabilitySaturation — Saturation limits on probability values
[0.001 0.999] (default) |
[min max] vector
Saturation limits on probability values, specified as a
max] vector. Values above or below these saturation values are
set to the
max values. This
property reduces oversaturating of cells when incorporating multiple
|Check if locations are free or occupied|
|Get occupancy probability of locations|
|Insert 3-D points or point cloud observation into map|
|Find intersection points of rays and occupied map cells|
|Set occupancy probability of locations|
|Show occupancy map|
|Update occupancy probability at locations|
Create 3-D Occupancy Map and Inflate Points
occupancyMap3D object stores obstacles in 3-D space, using sensor observations to map an environment. Create a map and add points from a point cloud to identify obstacles. Then inflate the obstacles in the map to ensure safe operating space around obstacles.
occupancyMap3D object with a map resolution of 10 cells/meter.
map3D = occupancyMap3D(10);
Define a set of 3-D points as an observation from a pose
[x y z qw qx qy qz]. This pose is for the sensor that observes these points and is centered on the origin. Define two sets of points to insert multiple observations.
pose = [ 0 0 0 1 0 0 0]; points = repmat((0:0.25:2)', 1, 3); points2 = [(0:0.25:2)' (2:-0.25:0)' (0:0.25:2)']; maxRange = 5;
Insert the first set of points using
insertPointCloud. The function uses the sensor pose and the given points to insert observations into the map. The colors displayed correlate to the height of the point only for illustrative purposes.
Insert the second set of points. The ray between the sensor pose (origin) and these points overlap points from the previous insertion. Therefore, the free space between the sensor and the new points are updated and marked as free space.
Inflate the map to add a buffer zone for safe operation around obstacles. Define the vehicle radius and safety distance and use the sum of these values to define the inflation radius for the map.
vehicleRadius = 0.2; safetyRadius = 0.3; inflationRadius = vehicleRadius + safetyRadius; inflate(map3D, inflationRadius); show(map3D)
Octree Data Structure
The octree data structure is a hierarchical structure used for subdivision of an environment into cubic volumes called voxels. For a given map volume, the space is recursively subdivided into eight voxels until achieving a desired map resolution (voxel size) is achieved. This subdivision can be represented as a tree, which stores probability values for locations in the map.
The probability values in the tree have a log-odds representation. Using this representation, locations easily recover from dynamic observations and numerical errors due to small probabilities are reduced. To remain efficient in memory, lower branches of the tree are pruned in the structure if they share the same occupancy values using this log-odds representation.
The class internally handles the organization of this data structure, including
the pruning of branches. Specify all observations as spatial coordinates when using
functions such as
insertPointCloud. Insertions into the tree, and navigation through
the tree, is determined based on the spatial coordinates and the resolution of the
 Hornung, Armin, Kai M. Wurm, Maren Bennewitz, Cyrill Stachniss, and Wolfram Burgard. "OctoMap: an efficient probabilistic 3D mapping framework based on octrees." Autonomous Robots, Vol. 34, No. 3, 2013, pp. 189–206.. doi:10.1007/s10514-012-9321-0.