OctoMap

On this page 7

OctoMap is an open-source framework for probabilistic 3D occupancy mapping that represents the environment as an octree of voxels, each holding an estimate of whether the space is occupied, free or still unknown. In robotics perception, it turns noisy range measurements from LiDAR, depth cameras or stereo vision into a compact volumetric model that planners can query for collisions.

Unlike a raw point cloud, which only records where surfaces were hit, OctoMap also stores where the sensor saw free space. This distinction lets a robot separate explored empty regions from unexplored ones, which is essential for safe navigation, exploration and manipulation in cluttered three-dimensional scenes.

How OctoMap builds an occupancy octree

OctoMap builds its map by ray casting each sensor measurement from the sensor origin to the measured endpoint. Every voxel the ray passes through receives a miss update, and the voxel containing the endpoint receives a hit update. Repeating this for thousands of rays per scan gradually reveals both the surfaces and the empty space in front of them.

The space is organized as an octree: a cube is recursively split into eight children until the leaf size, called the resolution, is reached. Typical resolutions range from 2 to 10 centimeters for indoor robots and up to 20 centimeters or more for outdoor vehicles. Only regions that have been observed are allocated, so large unknown areas cost almost no memory.

Each leaf stores its occupancy as a log-odds value, which makes updates a simple addition instead of a multiplication of probabilities. The values are clamped between a minimum and maximum, so the map can still change when objects move, and neighboring leaves with identical stable states are pruned into their parent to compress the tree.

Key parameters of an OctoMap

The behavior of OctoMap is governed by a small set of sensor model parameters that trade responsiveness against stability. The values below are common defaults and typical tuning ranges.

ParameterTypical valueWhat it controls
Resolution0.05 mLeaf voxel size, memory and detail
Hit probability0.7How strongly a measured endpoint raises occupancy
Miss probability0.4How strongly a passing ray lowers occupancy
Clamping thresholds0.12 and 0.97Limits that keep the map adaptable
Occupancy threshold0.5Probability above which a voxel counts as occupied
Maximum range5 to 30 mCuts off distant and noisy measurements
Main OctoMap parameters and their effect

A higher hit probability makes obstacles appear quickly but also amplifies sensor noise and phantom obstacles. A narrower clamping range lets the map forget moved objects faster, at the price of more flicker in static regions.

OctoMap compared with other 3D representations

OctoMap is one of several ways to store 3D geometry, and the right choice depends on whether the task needs free-space knowledge, surface detail or fast distance queries. The comparison below places it among related perception data structures.

RepresentationStores free spaceMemory useBest suited for
OctoMapYes, probabilisticallyLow to moderateCollision checking and exploration
Point cloudNoHigh for large scenesRegistration and visualization
Dense voxel gridYesVery highSmall fixed workspaces
Signed distance fieldImplicitlyModerate to highGradient-based trajectory optimization
Elevation mapOnly below the surfaceLowGround robots on 2.5D terrain
OctoMap versus related map representations

A plain voxel grid allocates every cell up front, whereas OctoMap allocates only observed regions and merges uniform ones. Signed distance fields such as those built by Voxblox or nvblox provide distance-to-obstacle gradients that OctoMap does not offer directly, which matters for optimization-based planners.

Practical use in robot software

OctoMap is most often used as the collision environment for motion planning. In the ROS ecosystem, an octomap server node integrates registered point clouds into a map, and MoveIt can consume an OctoMap to keep manipulator trajectories away from unmodeled obstacles.

Correct results depend on an accurate sensor pose for every scan, usually supplied by SLAM, visual odometry or LiDAR odometry. The decision table below summarizes common configurations.

SituationRecommended settingReason
Tabletop manipulationResolution 1 to 2 cmGrasping needs fine geometry
Indoor mobile robotResolution 5 cm, range 5 mBalances detail and update rate
Outdoor drone mappingResolution 20 cm, range 30 mKeeps memory and CPU bounded
Dynamic scenes with peopleNarrow clamping rangeLets moved obstacles clear quickly
Choosing an OctoMap configuration

Maps can be saved in a compact binary format that keeps only occupied and free states, or in a full format that preserves the probabilities for later updates.

Limitations and common mistakes

OctoMap is robust and well understood, but several known limitations affect real deployments.

  • Ray casting is expensive: inserting dense depth images at full rate can saturate a CPU core, so clouds are usually downsampled first.
  • Pose drift corrupts the map: without loop closure, the same wall is mapped twice and free space is wrongly carved through obstacles.
  • Thin structures disappear when the resolution is coarser than wires, railings or chair legs.
  • No native semantics: classes such as person or door require semantic mapping extensions or separate layers.
  • Dynamic objects leave ghosts unless miss updates and clamping allow occupied cells to clear.

A frequent configuration mistake is mismatched coordinate frames, where point clouds are inserted in the sensor frame instead of the map frame and the resulting map smears as the robot moves. Another is treating unknown space as free during planning, which can send a robot straight into an unobserved obstacle; conservative planners therefore treat unknown voxels as occupied until the sensor has observed them.

In plain words

OctoMap is a way for a robot to keep a 3D memory of the space around it. Imagine dividing a room into many small boxes. For each box, the robot keeps a guess: is something there, is it empty, or has it not looked yet?

Big empty areas are stored as one large box instead of thousands of tiny ones. That keeps the memory small. The robot can then ask whether a path is clear before it moves.

A real-world example

A warehouse inspection drone carries a depth camera and flies between tall storage racks. Its software inserts each depth frame into an OctoMap at 10 cm resolution, using poses from a visual-inertial odometry module running at the same time.

As the drone advances, voxels between the camera and the rack faces become free, while the shelves and pallets become occupied. The path planner checks every candidate trajectory against the map and treats unknown voxels as obstacles, so the drone never flies into an aisle it has not yet seen. After a 20-minute flight, the saved map of the whole aisle occupies only a few megabytes and is reused for the next inspection route.