Occupancy Grid Mapping
Published:
Besides state estimation or localization, which provide a robot with knowledge of where it is, it’s equally important for a mobile robot to perceive its surrounding and form a knowledge of where is occupied, that’s where mapping comes in. This note covers a fundamental mapping algorithm, occupancy grid mapping.
Problem Statement
In occupancy grid mapping, a map is discretized into different cells, where each cell is a binary random variable that models the occupancy, and is the probability of a cell being occupied. The map is assumed to be static. The goal is to find the belief , where is the observation and is the state of the robot.
Two assumptions are made for tractability
- The robot state are known.
- The occupancy of individual cells are independent, and thus
At each timestep , the sensor performs some measurement and provide the information of whether a cell is believed to be occupied or not, in terms of , which is known as the inverse sensor model.

One simple inverse sensor model is shown in the figure above. Consider a laser beam range sensor that provides the reading , where and are the range and bearing of the -th beam. For grid , let and be the range and bearing of the grid as observed from the current robot pose , and be the beam going through that gird. Based on the relation of a grid’s position relative to the robot, we have three different cases:
- If or , then return , the sensor has no information about this grid.
- Else if and , then return , the sensor think the grid is occupied.
- Else if and , then return , the sensor think the grid is free.
where is a sensor-specific parameter representing the maximum detectable range, is the grid size and is the width of each beam.
Mapping Algorithm
Following the Bayes filtering framework, a general algorithm can be derived for the occupancy grid mapping [2]. Starting from equation 1,
Further notice that the map is independent of the robot state , we obtain
Similarly, for the negation
Compute the ratio of equation (2) and (3), we get
Then, change to log odds form by defining
and the product chain turns into a sum
Bayes Inference using Conjugate Prior
The previous section derived an equation for updating the belief of the map under the Bayes framework, however, it lacks the notion of uncertainty (i.e., how confident we are about the map). With the notion of conjugate prior, a proper selection of the underlying distribution function for can both simplifies the updating rule and provide a closed form formula for uncertainty.
Recall that from Bayes rule
Bernoulli Likelihood and Beta Prior
First consider the case where the occupancy of a grid is binary, i.e., . Let be the unknown occupancy probability. From the inverse sensor model described above, we know that each sensor measurement provide a binary result, denoted as , where
Then, the likelihood is modeled as a Bernoulli with parameter , i.e.,
Furthermore, if we model the prior as a Beta distribution, i.e.,
where is the beta function.
Then, it follows from the Bayes rule that the posterior is
which still follows a Beta distribution, , where
In this case, we call beta distribution the conjugate prior for the Bernoulli likelihood.
Conjugate Distribution and Conjugate Prior [2]
- If the posterior distributions are in the same probability distribution family as the prior probability distribution, the prior and posterior are then called conjugate distributions.
- The prior is called a conjugate prior for the likelihood function.
Note that the choice of modeling the prior as a Beta distribution here is an algebraic convenience, which provides a closed-form expression for the posterior. Then the mean and covariance can be easily obtained
<figure id="32b45435-6ef1-80d4-abf7-d3e0db4a4e80" class="equation" data-notion-equation="\begin{align*} \mathbb{E}[\theta_i]=\frac{\alpha_i}{\alpha_i + \beta_i} && \text{and} && \mathbb{V}[\theta_i]=\frac{\alpha_i\beta_i}{\left(\alpha_i+\beta_i\right)^2\left(\alpha_i+\beta_i+1\right)}

