Skip to main content
Open In Colab Occupancy grid mapping builds a map from range measurements taken at known poses. It is the mapping half of SLAM. Localization estimates the pose given the map; occupancy grid mapping estimates the map given the poses (Thrun, Burgard and Fox, 2005, Chapter 9). Many SLAM systems also use it as their last step: they estimate the robot’s path first and then build a grid along that path for the planner. The last part of this section maps the same scans along an odometry path, which drifts.

The grid as a map

An occupancy grid divides the plane into square cells mim_i. A cell is occupied (mi=1m_i = 1) or free (mi=0m_i = 0). Given the measurements z1:tz_{1:t} and the poses s1:ts_{1:t}, we want the posterior p(m∣z1:t,s1:t).p(m \mid z_{1:t}, s_{1:t}). A grid of NN cells has 2N2^N possible maps. The posterior is therefore approximated by treating the cells as independent: p(m∣z1:t,s1:t)≈∏ip(mi∣z1:t,s1:t).p(m \mid z_{1:t}, s_{1:t}) \approx \prod_i p(m_i \mid z_{1:t}, s_{1:t}). Each cell is then a binary state that does not change over time, with its own Bayes filter.

Log-odds update

The filter stores the log-odds of occupancy, lt,i=log⁡p(mi=1∣z1:t,s1:t)1−p(mi=1∣z1:t,s1:t),l_{t,i} = \log \frac{p(m_i = 1 \mid z_{1:t}, s_{1:t})}{1 - p(m_i = 1 \mid z_{1:t}, s_{1:t})}, so that the Bayes update is a sum. Each cell covered by the measurement ztz_t is updated as lt,i=lt−1,i+log⁡p(mi=1∣zt,st)1−p(mi=1∣zt,st)−l0,l_{t,i} = l_{t-1,i} + \log \frac{p(m_i = 1 \mid z_t, s_t)}{1 - p(m_i = 1 \mid z_t, s_t)} - l_0, and the other cells keep their value. l0l_0 is the log-odds of the prior. The middle term is the inverse sensor model, the occupancy probability of the cell given only ztz_t and sts_t. The probability is recovered as p=1−1/(1+elt,i)p = 1 - 1/(1 + e^{l_{t,i}}). Summing log-odds also avoids the round-off of multiplying probabilities near 0 or 1 (Thrun, Burgard and Fox, 2005, Section 9.2).

Inverse sensor model for a range beam

Take a beam with measured range zz and a cell at distance dd along it:
  • d<z−α/2d < z - \alpha/2: the beam passed through the cell. Add lfree−l0l_{\text{free}} - l_0, with lfree<l0l_{\text{free}} < l_0.
  • ∣d−z∣≤α/2|d - z| \le \alpha/2: the beam ended in the cell. Add locc−l0l_{\text{occ}} - l_0, with locc>l0l_{\text{occ}} > l_0.
  • d>z+α/2d > z + \alpha/2: the cell is behind the hit point. No update.
α\alpha is the thickness of the surface region. A beam at maximum range hit nothing, so it frees its cells and occupies none. This is the inverse range sensor model of Section 9.2 for a lidar beam of negligible width. The code uses a 10 m by 6 m room, the same one as in the correspondence estimation section, a 2D lidar with 360 beams and an 8 m range, and 5 cm cells. It finds the cells a beam crosses by sampling the beam every half cell. Bresenham’s line algorithm walks the same cells exactly.
One scan from the middle of the room. A hit cell gets one occupied update, which gives it a probability of 0.70. Near the robot many beams cross each cell, and the cells become clearly free. Farther out a cell is crossed by one beam or none, so the free space is only slightly lighter than the prior and has gaps between the beams. Cells that no beam reached stay at the prior of 0.5. These include the shadows behind the box and the partition.
Output from cell 4

A map from the true path

The robot drives a loop around the room and scans every 0.4 m. Each scan is applied at its true pose.

A map from odometry

The odometry poses integrate the motion between consecutive true poses with small random errors and a heading bias of 0.3 degrees per step, as a slightly miscalibrated wheel would produce. The same scans are then mapped at the odometry poses.
Output from cell 7 With the true poses, the walls, the box and the partition are thin dark lines and the free space is uniformly light. Each cell was observed from many poses, and its probability is close to 0 or 1. With odometry, the pose error at the end of the loop is 1.06 m and 14.4 degrees. The odometry path (solid) moves away from the true path (dotted) as the heading error grows. Each scan is placed at a wrong pose, so the same wall is drawn several times at different positions and angles. The room is tilted, the outer walls are doubled and the box is smeared. The update uses the poses as given and cannot detect the error. To correct it, the poses have to be estimated from the scans, for example by aligning each scan with the map. The alignment needs correspondences between scan and map, covered in the next section. Estimating the poses and the map together is SLAM.

Limits of independent cells

The independence assumption fails for wide beams. A sonar cone returns one range for a whole sector, and the update marks every cell at that range as occupied, although only one of them produced the echo. Two overlapping cones can then disagree about the same cells. Section 9.4 of Probabilistic Robotics describes mapping with the forward sensor model, which keeps the dependencies between cells at a higher computational cost.

References

  • Thrun, S., Burgard, W., and Fox, D. (2005). Probabilistic Robotics. MIT Press.

Found an error on this page? Report an issue.