The grid as a map
An occupancy grid divides the plane into square cells . A cell is occupied () or free (). The map is assumed static: nothing in the room moves while the robot maps it. Given the measurements and the poses , we want the posterior The actions do not appear, because the poses are given. A grid of cells has possible maps, far too many to store a probability for each. The standard algorithm therefore keeps only one marginal per cell and treats the cells as independent: This is a modeling choice, and it loses information. A LIDAR return at range means that the first occupied cell along the beam is at and that every cell before it is free. That is one statement about a group of cells, and a product of marginals cannot represent it. Neighboring beams of one scan, and scans taken from nearby poses, see the same surfaces, so their evidence is correlated. The update below counts each of them as independent. The factorized grid is an approximation even for a LIDAR with very thin beams, and the last part of this section returns to the errors this approximation causes. After the factorization, each cell is a binary state with its own Bayes filter. Because the map is static, the motion model of each filter is the identity. The prediction step leaves the belief unchanged and only the measurement update remains.Log-odds update
Apply Bayes rule to one cell and separate the newest measurement from the older ones: where normalizes. Two assumptions simplify the right side. The new pose alone carries no information about the map, so , the previous posterior. Given and , the measurement is treated as independent of the earlier measurements: The factorization loses accuracy in the second assumption. The scan depends on the whole map, not on alone, and the earlier scans carry information about the other cells. Treating the approximation as exact is what makes correlated scans count as independent evidence. Bayes rule then turns the measurement model into the inverse sensor model , the occupancy probability of the cell given only the current scan: using once more. After substitution, the posterior still contains and , which are hard to compute. Write the same expression for and divide one by the other. The normalizers cancel and the odds multiply: The filter therefore stores the log-odds of occupancy, and the product becomes a sum: Every cell starts at . The middle term is the inverse sensor model in log-odds form. It is a posterior, so it already contains the prior , and subtracting removes that second copy. The subtraction is correct only if the inverse model was built with the same prior that the grid starts from. For a cell about which the scan carries no information, the inverse model equals the prior, so its update is zero. The probability is recovered as . Thrun, Burgard and Fox (2005) derive this update for a general binary state in Section 4.1.4 and apply it to grids in Section 9.2. Adding log-odds also avoids the round-off of multiplying probabilities near 0 or 1.Inverse sensor model for a range beam
A LIDAR scan is a list of beams, , where is the range measured by beam at bearing in the sensor frame. A beam that hits nothing reports the maximum range . The inverse model below follows Table 9.2 of Thrun, Burgard and Fox (2005). For each cell, compute the range and bearing of its center from the robot at , and let be the beam whose bearing is closest to . Then:- If and , the beam ended in the cell, and .
- Otherwise, if , the beam passed through the cell, and .
- Otherwise the cell lies behind the return or beyond . The scan carries no information about it, and the model returns the prior.
A map from the true path
The robot drives a loop around the room and scans every 0.4 m. It turns in place at each corner, and at the end it turns back to its starting heading, so the last pose equals the first. Each scan is applied at its true pose.A map from wheel odometry
Odometry estimates the poses by integrating wheel encoder readings. The robot here has two wheels 0.16 m apart. Each motion between two true poses is split into a turn in place, a straight drive and a second turn, as in the odometry motion model (Thrun, Burgard and Fox, 2005, Section 5.4). For each part, the code computes how far each wheel rolled. The right encoder reports 0.2 percent more distance than the wheel rolls, as it would if the right wheel were slightly smaller than the radius the software assumes. Both readings also get a little noise. Integrating these readings gives the odometry path, and the same scans are then mapped at the odometry poses.Limits of independent cells
The map from the true poses looks right, but the independent-cell approximation behind it has two shortcomings. Each cell is updated as if alone, so the map cannot express that a return means “the first occupied cell along this beam is near ”. The update also counts every scan as new evidence, although consecutive scans see the same walls from almost the same pose. That is why the free space reached the clipping bound: 58 scans of the same room are worth far less than 58 independent measurements. The first problem is visible with wide beams. A sonar cone returns one range for a whole sector, and the inverse model marks every cell at that range as occupied, although only one of them produced the echo. Two overlapping cones can then give conflicting evidence about the same cells. The update resolves the conflict by counting how often each kind of evidence arrived, even when one map would explain both readings. For example, when a sonar passes an open door, the door tends to appear closed in the map (Thrun, Burgard and Fox, 2005, Section 9.4). Section 9.4 of the book replaces the inverse model with the forward model and searches for the single most probable map: The search starts from an empty map and flips one cell at a time whenever the flip raises this score. Each likelihood term scores the whole map, so a sonar return is explained by any occupied cell in its cone, and the search can settle on one map that explains overlapping cones together. The result is a single map, with no occupancy probability per cell, so the remaining uncertainty is lost. The search is a batch computation that keeps all the data in memory, it can stop at a local maximum, and it cannot run incrementally while the robot drives.Occupancy grids in practice
Occupancy grids remain a basic map representation in mobile robot navigation. ROS 2 Nav2 plans and controls on costmaps, which are grids built from layers (Nav2 documentation). The static layer holds the map, received from a SLAM package or from the map server. Nav2 recommends SLAM Toolbox for building that map, and its localizer, AMCL, estimates the robot’s pose in the same map. The obstacle layer updates the grid from a 2D LIDAR or a depth camera while the robot drives. It marks the cells where returns land and, when clearing is turned on, clears the cells along each ray. Those are the occupied and free cases of the inverse sensor model above. The documentation describes the obstacle layer only as marking and clearing, with no probabilities, so the costmap holds costs rather than log-odds. An inflation layer adds cost around obstacles so that paths keep a margin from them, and the planner and the controller each read their own costmap, a global one and a local one. OctoMap applies the same filter in 3D (Hornung et al., 2013). It stores the log-odds of each voxel in an octree, which merges uniform regions into larger nodes and keeps the map compact, and it keeps free, occupied and unknown space apart. Its default sensor model is the one used in this section: a voxel at a return gets an inverse model of 0.7, and a voxel the ray passes through gets 0.4. It also clamps the log-odds, by default between probabilities 0.12 and 0.97, for the same reasons as the clipping above. Autonomous cars use the same kind of grid. A bird’s-eye view (BEV) is a top-down grid on the ground plane around the vehicle, laid out like a 2D occupancy grid. A driving stack projects LIDAR returns into it, or uses a network that transforms the images of several cameras into it, and then labels each cell, for example as drivable road or as an obstacle. Tesla extended this to 3D. At the CVPR 2022 Workshop on Autonomous Driving it presented occupancy networks, which take the images of all eight cameras and predict whether each voxel around the car is occupied (Elluswamy, 2022). In the terms of this section, the network is a learned inverse sensor model, and the grid it fills is the map that collision avoidance runs on.References
- Elluswamy, A. (2022). Keynote, Workshop on Autonomous Driving, CVPR 2022. Video.
- Hornung, A., Wurm, K. M., Bennewitz, M., Stachniss, C., and Burgard, W. (2013). OctoMap: An efficient probabilistic 3D mapping framework based on octrees. Autonomous Robots. Project page.
- Nav2 documentation. Costmap 2D, obstacle layer, mapping and localization.
- Thrun, S., Burgard, W., and Fox, D. (2005). Probabilistic Robotics. MIT Press.
Found an error on this page? Report an issue.

