Chapter 13

Robot Localization

The filtering algorithms developed in Chapter 11 and Chapter 12 provide general tools for estimating the state of a dynamical system from noisy measurements. In mobile robotics, one of the most important instances of this general problem is localization: estimating a robot’s pose with respect to a map of the environment.

In this chapter, we specialize the Bayesian filtering framework to the robot localization problem. We begin in Section 13.1 with a taxonomy that organizes different localization scenarios—pose tracking versus global localization, static versus dynamic environments, active versus passive sensing, and single-robot versus multi-robot settings. This taxonomy provides a mental model for the kinds of problems that arise in practice.

In Section 13.2, we then express localization formally as a Bayesian filtering problem in which the state is the robot pose and the map is an additional, known variable that influences both motion and measurements. This leads to map-aware state transition and measurement models, which we discuss in Section 13.3.

Building on this formulation, in Section 13.4 we introduce Markov localization, a general Bayes filter for estimating a robot’s pose that explicitly incorporates a map. Markov localization is conceptually clean but rarely implemented directly; instead, it serves as a reference from which more specialized algorithms are derived.

We then present two specializations of Markov localization. In Section 13.5, we develop an EKF localization algorithm for feature-based maps that are well suited to pose tracking with moderate uncertainty. Finally, in Section 13.6 we introduce Monte Carlo Localization (MCL), a particle filter–based method that can handle global localization and strongly multimodal beliefs. Along the way, we discuss data association and practical considerations that arise in map-based localization.

13.1 A Taxonomy of Robot Localization Problems

Table 13.1: A taxonomy of robot localization problems along four key axes.
Axis Representative cases Typical algorithmic implications
Initial pose Pose tracking (local), global localization, kidnapped robot Tracking often amenable to unimodal Gaussian filters; global and kidnapped scenarios typically require non-parametric, multimodal beliefs (e.g., particle filters).
Environment Static, slowly varying, strongly dynamic Static maps simplify modeling; dynamic elements motivate robust measurement models and possibly explicit dynamic object tracking.
Action selection Passive, active (information-seeking) Passive use treats controls as given; active localization couples the filter with planning methods that trade off task progress and information gain.
Number of robots Single robot, multi-robot (cooperative) Multi-robot settings introduce shared maps and inter-robot observations, leading to coupled estimation problems and opportunities for improved robustness.

Robot localization problems can differ substantially depending on how much is known about the initial pose, how the environment evolves, how actions are chosen, and how many robots are involved. Before turning to specific algorithms, it is helpful to organize these variations using a taxonomy.

We will use the term pose to refer to the robot’s position and orientation in a global coordinate frame. For a planar mobile robot, the pose is typically xt=(xt,yt,θt) at time t, where (x,y) is the planar position and θ is the heading angle.

Pose tracking and global pose localization.

One of the first distinctions among robot localization problems concerns what we assume we know about the initial pose:

  • Pose tracking (local localization). In pose tracking problems, the initial pose is known with reasonably small uncertainty. For example, a robot may be placed at a known charging station or docking location, with a prior belief concentrated in a small neighborhood. The goal is to maintain an accurate estimate of pose over time as the robot moves and senses, despite process and measurement noise.

  • Global localization. In global localization, the robot has very little prior information about its initial pose. For instance, it may know only that it is somewhere within a building, but not which floor, corridor, or room. The belief over poses must therefore represent multiple plausible hypotheses, often spread over a large region of the map.

  • Kidnapped robot problem. A challenge related to global localization arises when a robot that has been successfully tracking its pose is suddenly transported to a different, unknown location without its sensors or localization algorithm being aware of the event. This kidnapped robot problem requires the localization method to recover from a grossly incorrect belief and reinitialize globally.

Pose tracking problems are often amenable to unimodal Gaussian approximations, such as EKF-based methods, whereas global localization and kidnapped robot scenarios typically require non-parametric methods capable of representing multiple hypotheses, such as histogram or particle filters.

Static and dynamic environment localization.

A second axis in the taxonomy of robot localization concerns how the environment changes over time:

  • Static environments. In the simplest case, the environment map is fixed and does not change. Walls and landmarks remain in place, and any moving objects (such as people) are ignored or treated as noise. Many foundational localization algorithms are developed under this assumption.

  • Dynamic environments. In more realistic settings, parts of the environment change over time. Examples include doors that open and close, furniture that moves, or other agents that occupy the same space. In these cases, the map may be time varying or may explicitly model dynamic objects.

In this chapter, we primarily consider localization with respect to a static map, while allowing for noisy measurements that may occasionally be corrupted by dynamic elements. Handling fully dynamic maps is closely related to SLAM and tracking, and will be revisited in Chapter 14.

Active and passive localization.

Localization algorithms also differ in how they interact with the environment:

  • Passive localization. In passive localization, the algorithm treats the sequence of controls u1:t as given; it does not attempt to choose actions to improve localization performance. Many navigation systems fall into this category when localization is treated as a background process.

  • Active localization. In active localization, the robot chooses its actions with the explicit goal of reducing uncertainty about its pose. For example, the robot may move to viewpoints that disambiguate map symmetries or collect measurements that are expected to be highly informative.

The algorithms developed in this chapter apply in both settings. When used in an active framework, they provide the state and uncertainty estimates needed for planning information-seeking actions.

Single and multi-robot localization.

Finally, localization problems can involve one or multiple robots:

  • Single-robot localization. A single robot must estimate its pose using on-board sensors and possibly an external reference, such as GPS, relative to a map that we assume is given.

  • Multi-robot localization. In multi-robot settings, several robots localize simultaneously, often sharing information. Robots may observe each other, exchange measurements, or maintain a shared map. This introduces additional structure and opportunities for cooperation, but also coupling between the individual localization problems.

Throughout this chapter, we focus on single-robot localization in a known, largely static map. The methods we develop form the basis for more advanced multi-robot and SLAM systems.

13.2 Robot Localization via Bayesian Filtering

In previous chapters, we introduced several well-known variations of the Bayes filter, including the parametric EKF and the non-parametric particle filter in Chapter 12. These algorithms propagate a belief distribution over a state 𝒙t using a probabilistic Markov state transition model and a probabilistic measurement model. Recall that for a general state-space model, the belief at time t is defined as:

bel(𝒙t)p(𝒙t𝒛1:t,𝒖1:t), (13.1)

where 𝒛1:t are all measurements up to time t and 𝒖1:t are the applied controls.

In map-based localization, the state 𝒙t represents the robot pose, and we assume that a map 𝒎 of the environment is given. The map encodes information about the environment that constrains both how the robot can move and what it can measure. Our goal is to compute the posterior over robot poses conditioned on the map:

bel(𝒙t)p(𝒙t𝒛1:t,𝒖1:t,𝒎).

To incorporate the map into the filtering framework, we modify both the state transition model and the measurement model. Specifically, in Section 13.3, we introduce a map-aware state transition model p(𝒙t𝒙t1,𝒖t,𝒎) that captures the fact that some poses are inconsistent with the environment. Then, in Section 13.3.1, we introduce a map-aware measurement model p(𝒛t𝒙t,𝒎) that reflects how local sensor readings depend on nearby structures in the map. The combination of these two models leads directly to the localization algorithms we introduce in Section 13.5 and Section 13.6.

Map representation.

Before modifying the probabilistic models, it is useful to briefly review how we represent maps in this chapter. We assume that the environment can be described by a collection of spatial entities—either discrete landmarks or volumetric cells—with associated properties. Formally, we denote the map as:

𝒎={m1,m2,,mN},

where each element mi describes a portion of the environment.

Depending on the application, mi may represent the occupancy state of a grid cell (occupied/free/unknown), the position of a point landmark, mi=(mi,x,mi,y) in a global frame, or more complex attributes such as semantic labels or reflectivity. We will use the generic term “map element” for mi, and refer informally to these as “objects” or “cells” when helpful.

Refer to caption
Figure 13.1: Two examples of location-based maps. Both represent the map as a set of volumetric objects, which in these examples are cells.
Refer to caption
Figure 13.2: Two examples of feature-based maps. One uses a collection of lines and the other uses a graph representation of the empty spaces.

Two important map families arise frequently in mobile robotics:

  • Feature-based maps, where each mi is a compact feature, such as a point landmark or line segment, with precisely defined geometry. Figure 13.2 shows two examples of feature-based maps, one represented by lines and another by a graph of nodes and edges.margin: Graph-based maps are generally referred to as topological maps.

  • Cell-based (occupancy grid) maps, where the environment is discretized into a grid of cells, each with an associated occupancy probability. This is closely related to the grid-based motion planning representations discussed in the referenced section. Figure 13.1 shows examples where the environment is represented by a set of volumetric cells.

Cell-based maps trade off resolution and computational cost: smaller cells provide finer spatial detail but increase memory usage and computation time, while larger cells reduce cost but blur detail and can misrepresent narrow passages. We refer back to the grid-based planning discussion in the referenced section for a deeper treatment of these trade-offs. In this chapter, we treat the choice of map representation as given, and focus on how the map enters the filtering equations.

13.3 Map-Aware State Transition Model

The map influences how the robot can move. For example, a mobile robot cannot pass through walls or leave the known workspace. A purely kinematic transition model p(𝒙t𝒙t1,𝒖t) does not capture these constraints: it might assign nonzero probability to states that lie inside obstacles or outside the mapped area.

To incorporate the map, we consider the map-aware transition model p(𝒙t𝒙t1,𝒖t,𝒎). Directly modeling this distribution for arbitrary maps is difficult, so we adopt an approximation that reuses the original transition model and a separate, map-induced prior. Specifically, we define p(𝒙t𝒎) as the probability of a pose given only the map. This term characterizes how consistent a pose is with the environment. For example, p(𝒙t𝒎)=0 for a pose inside a wall or outside the mapped region.

Using Bayes’ rule, we can approximate the map-aware transition model as:

p(𝒙t𝒙t1,𝒖t,𝒎)ηp(𝒙t𝒙t1,𝒖t)p(𝒙t𝒎)p(𝒙t), (13.2)

where η is a normalization constant that ensures the left-hand side integrates to one. Equation 13.2 can be derived step-by-step by starting from Bayes’ rule:

p(𝒙t𝒙t1,𝒖t,𝒎)=p(𝒎𝒙t,𝒙t1,𝒖t)p(𝒙t𝒙t1,𝒖t)p(𝒎𝒙t1,𝒖t).

Since p(𝒎𝒙t1,𝒖t) does not depend on 𝒙t, we can absorb it into a constant η:

p(𝒙t𝒙t1,𝒖t,𝒎)=ηp(𝒎𝒙t,𝒙t1,𝒖t)p(𝒙t𝒙t1,𝒖t).

Next, we assume that the influence of the past on the map is captured entirely through the current pose 𝒙t:

p(𝒎𝒙t,𝒙t1,𝒖t)p(𝒎𝒙t).

Intuitively, once we know the current pose, the specific path taken to get there does not provide additional information about the static map.111This approximation becomes more accurate as the time step between t1 and t shrinks, so that the robot moves only a short distance between successive poses. With this assumption:

p(𝒙t𝒙t1,𝒖t,𝒎)ηp(𝒎𝒙t)p(𝒙t𝒙t1,𝒖t).

Applying Bayes’ rule again to p(𝒎𝒙t) gives:

p(𝒎𝒙t)=p(𝒙t𝒎)p(𝒎)p(𝒙t).

Substituting into the previous expression and absorbing constant factors that do not depend on 𝒙t into a new normalization constant η yields:

p(𝒙t𝒙t1,𝒖t,𝒎)ηp(𝒙t𝒙t1,𝒖t)p(𝒙t𝒎)p(𝒙t),

which is Equation (Equation 13.2).

In this approximation, p(𝒙t𝒎) is the probability of a state given only the map and captures the geometric consistency of that state with respect to the environmentmargin: For example, p(𝒙t𝒎)=0 for a state 𝒙t that lies inside a wall or outside the known map. . The factor p(𝒙t𝒙t1,𝒖t) encodes the motion model, and p(𝒙t𝒎) acts as a map-based correction that suppresses physically implausible states.

From a computational perspective, Equation (Equation 13.2) is attractive because it allows us to reuse existing implementations of the motion model and incorporate the map through a relatively inexpensive correction:

  • We first generate a kinematic prediction of the new pose using p(𝒙t𝒙t1,𝒖t), which depends only on the robot model and control.

  • We then reweight or prune these predictions using p(𝒙t𝒎), which often reduces to simple operations such as checking whether the pose lies in free space (for occupancy grids) or near a corridor (for semantic maps).

Thus, the map-aware transition model modifies the likelihood of proposed poses without requiring a complete redesign of the underlying motion model.

13.3.1 Map-Aware Measurement Model

The map also strongly influences sensor measurements. For instance, the range returned by a lidar beam depends on where that beam first intersects an obstacle in the map, and the bearing to a visual landmark depends on the landmark’s position in the global frame. To reflect this dependence, we introduce a map-aware measurement model:

p(𝒛t𝒙t,𝒎).

In many systems, a measurement vector 𝒛tp consists of individual components, such as individual range beams or landmark observations. A common simplifying assumption is that the individual components of the measurement vector 𝒛tp are conditionally independent given the state and map. Under this assumption, we can factor the measurement model as:

p(𝒛t𝒙t,𝒎)=i=1pp(𝒛ti𝒙t,𝒎). (13.3)

The conditional independence assumption is not exact. For example, nearby range beams may be correlated if they hit the same object. However, this assumption greatly simplifies inference and works well in many practical settings. It allows us to process multiple sensor readings either in a batch or sequentially, using the same underlying model p(𝒛ti𝒙t,𝒎) for each component.

13.4 Markov Localization

The first map-based localization algorithm we introduce is Markov localization. Markov localization applies the Bayes filter from Chapter 11 to the map-aware models introduced above. The belief over robot pose at time t is:

bel(𝒙t)p(𝒙t𝒛1:t,𝒖1:t,𝒎),

and the map 𝒎 is treated as known and fixed.

Using the map-aware transition and measurement models p(𝒙t𝒙t1,𝒖t,𝒎) and p(𝒛t𝒙t,𝒎), the Bayes filter recursion becomes:

Prediction:bel¯(𝒙t) =p(𝒙t𝒙t1,𝒖t,𝒎)bel(𝒙t1)𝑑𝒙t1,
Correction:bel(𝒙t) =ηp(𝒛t𝒙t,𝒎)bel¯(𝒙t),

where bel¯(𝒙t) denotes the predicted belief and η is a normalization constant chosen so that bel(𝒙t)𝑑𝒙t=1. We summarize this recursion in Algorithm 1.

Data: bel(𝒙t1),𝒖t,𝒛t,𝒎
Result: bel(𝒙t)
foreach 𝐱t do
      bel¯(𝒙t)=p(𝒙t𝒙t1,𝒖t,𝒎)bel(𝒙t1)𝑑𝒙t1
      bel(𝒙t)=ηp(𝒛t𝒙t,𝒎)bel¯(𝒙t)
return bel(𝒙t)
Algorithm 1 Markov Localization

Conceptually, Markov localization has the same structure as the Bayes filter from Chapter 11: a prediction step that propagates the belief through the motion model, followed by a correction step that incorporates the latest measurement. The only difference is that both the prediction and correction now depend explicitly on the map 𝒎.

In its most general form, however, Markov localization is not directly computationally tractable. The integral over all possible poses and the need to maintain an arbitrary belief function are prohibitive in high-dimensional or continuous state spaces. As in Chapter 12, the key to practicality is to choose a representation for the belief that is expressive enough for the problem at hand, yet structured enough to admit efficient computation.

In Section 13.5, we adopt a unimodal Gaussian belief and derive an EKF-based localization algorithm, which is well suited for pose tracking with moderate uncertainty. In Section 13.6, we adopt a particle-based representation and derive Monte Carlo Localization, capable of handling global localization and multimodal beliefs.

13.5 EKF Localization

We now develop an EKF-based realization of Markov localization. The EKF localization algorithm assumes that the belief over the robot’s pose can be approximated by a single Gaussian:

bel(𝒙t)𝒩(𝝁t,Σt),

and applies the EKF prediction and update equations from Chapter 12 using map-aware models. This Gaussian structure significantly improves computational efficiency relative to the full Markov localization algorithm, at the cost of not being able to represent multiple well-separated pose hypotheses.222As in Chapter 12, this unimodality assumption is well suited to pose tracking but generally insufficient for global localization.

We assume the same nonlinear state transition model as in the referenced section:

𝒙t=f(𝒙t1,𝒖t)+ϵt,

where ϵt𝒩(𝟎,Qt) is zero-mean Gaussian process noise. The corresponding state transition Jacobian is:

Ft=𝒙f(𝝁t1,𝒖t), (13.4)

where 𝝁t1 is the mean of the previous belief bel(𝒙t1).

The main difference between the general EKF and EKF localization is the presence of a feature-based map and a measurement model that relates robot poses to observed landmarks. We assume we have a map 𝒎 of N point landmarks:

𝒎={m1,m2,,mN},mj=(mj,x,mj,y),

where each landmark mj is given by its two-dimensional location (mj,x,mj,y) in the global coordinate frame. At time t the robot obtains a set of landmark measurements:

𝒛t={𝒛t1,𝒛t2,},

where each 𝒛ti is associated (implicitly or explicitly) with one landmark.

Given a pose 𝒙t and the index j of the corresponding landmark, the measurement model is:

𝒛ti=h(𝒙t,j,𝒎)+𝜹t,

where 𝜹t𝒩(𝟎,Rt) models zero-mean Gaussian sensor noise, and h() encodes the expected range, bearing, or other features to landmark mj. For each measurement, the Jacobian of the measurement model with respect to the state is:

Htcti=𝒙h(𝝁¯t,cti,𝒎), (13.5)

where 𝝁¯t is the predicted mean from the EKF prediction step, and cti is the index of the map feature associated with measurement i.

A new challenge in feature-based localization is data association. Given a set of measurements 𝒛t, which landmark does each measurement correspond to? We denote the correspondence for measurement i at time t by cti{1,,N+1}, where cti=j means that measurement i corresponds to landmark mj, and cti=N+1 indicates that measurement i does not correspond to any known landmarkmargin: For example, due to a spurious detection. .

We first consider the simpler case where we assume the correspondences cti are known.

13.5.1 EKF Localization with Known Correspondences

Assume for the moment that the correspondences 𝒄t={ct1,ct2,} are known. The EKF localization algorithm then resembles the standard EKF from Chapter 12, with two key modifications:

  1. 1.

    The measurement model relates the pose to map features via h(𝒙t,j,𝒎).

  2. 2.

    Multiple landmark measurements are processed at each time step.

Given the pose 𝒙t and the map 𝒎, and given known correspondences 𝒄t, the joint likelihood of the measurement set 𝒛t can be written as:

p(𝒛t𝒙t,𝒄t,𝒎).

Using the conditional independence assumption from Equation 13.3—now applied at the level of individual landmark measurements—we have:

p(𝒛t𝒙t,𝒄t,𝒎)=ip(𝒛ti𝒙t,cti,𝒎).

Each factor p(𝒛ti𝒙t,cti,𝒎) is a Gaussian distribution whose mean is given by h(𝒙t,cti,𝒎) and whose covariance is Rt.

Because the prior over 𝒙t is Gaussian and each measurement likelihood term is Gaussian, the posterior remains Gaussian. Moreover, under the conditional independence assumption, we can apply the standard EKF measurement update sequentially for each 𝒛ti and obtain the same result as if we had processed all measurements in a single stacked update. This is a consequence of the fact that, for Gaussian models, multiplication of likelihood terms can be carried out in any order.

Data: 𝝁t1,Σt1,𝒖t,𝒛t,𝒄t,𝒎
Result: 𝝁t,Σt
// Prediction (motion update)
𝝁¯t=f(𝝁t1,𝒖t)
Σ¯t=FtΣt1Ft+Qt
// Correction: loop over landmark measurements
foreach 𝐳ti do
      j=cti
      Sti=HtjΣ¯t[Htj]+Rt
      Kti=Σ¯t[Htj][Sti]1
      𝝁¯t=𝝁¯t+Kti(𝒛tih(𝝁¯t,j,𝒎))
      Σ¯t=(IKtiHtj)Σ¯t
 
// Final posterior
𝝁t=𝝁¯t
Σt=Σ¯t
return 𝝁t,Σt
Algorithm 2 EKF Localization with Known Correspondences

Algorithm 2 summarizes the EKF localization recursion in the known-correspondence case. This algorithm provides a useful baseline: if we knew which measurement came from which landmark, EKF localization would be a straightforward specialization of the standard EKF. The main additional difficulty in practice is that the correspondences cti are typically unknown and must be estimated jointly with the robot state.

13.5.2 EKF Localization with Unknown Correspondences

In realistic scenarios, the correspondences cti are not given and must be inferred from the data. One common approach is to estimate the correspondences using a maximum likelihood (MLE) criterion. At each time step, we choose 𝒄t={cti} to maximize the likelihood of the current measurements:

𝒄^t=argmax𝒄tp(𝒛t𝒄1:t,𝒎,𝒛1:t1,𝒖1:t).

In words, we select the assignment of measurements to landmarks that makes the observed data most probable, given the map and the past history.

To make this optimization tractable, we first marginalize over the unknown pose 𝒙t:

p(𝒛t𝒄1:t,𝒎,𝒛1:t1,𝒖1:t)=p(𝒛t𝒙t,𝒄1:t,𝒎,𝒛1:t1,𝒖1:t)p(𝒙t𝒄1:t,𝒎,𝒛1:t1,𝒖1:t)𝑑𝒙t,=p(𝒛t𝒙t,𝒄t,𝒎)bel¯(𝒙t)𝑑𝒙t,

where we used the Markov assumption to simplify p(𝒛t𝒙t,𝒄1:t,𝒎,𝒛1:t1,𝒖1:t)=p(𝒛t𝒙t,𝒄t,𝒎), and defined the predicted belief:

bel¯(𝒙t)p(𝒙t𝒄1:t,𝒎,𝒛1:t1,𝒖1:t).

The term p(𝒛t𝒙t,𝒄t,𝒎) is the measurement model with known correspondences. Using the conditional independence assumption from Equation 13.3, we can factor it as:

p(𝒛t𝒙t,𝒄t,𝒎)=ip(𝒛ti𝒙t,cti,𝒎).

Substituting into the integral, we obtain:

p(𝒛t𝒄1:t,𝒎,𝒛1:t1,𝒖1:t)=bel¯(𝒙t)ip(𝒛ti𝒙t,cti,𝒎)d𝒙t.

Although the measurements are conditionally independent given 𝒙t, they become coupled after marginalizing over 𝒙t. A common approximation is therefore to select correspondences independently by scoring each measurement-landmark pairing under the predicted belief:

c^ti=argmaxctip(𝒛ti𝒙t,cti,𝒎)bel¯(𝒙t)𝑑𝒙t.

Under the Gaussian assumptions on the belief and measurement model, the integral above is a Gaussian distribution with mean and covariance:

p(𝒛ti𝒙t,cti,𝒎)bel¯(𝒙t)𝑑𝒙t𝒩(𝒛^tcti,Stcti),

where:

𝒛^tj=h(𝝁¯t,j,𝒎),Stj=HtjΣ¯t(Htj)+Rt.

Maximizing the likelihood is therefore equivalent to choosing cti to maximize the Gaussian density 𝒩(𝒛ti𝒛^tj,Stj), or equivalently to minimize the associated Mahalanobis distance:

c^ti=argminctidti,cti, (13.6)

where:

dtij=(𝒛ti𝒛^tj)(Stj)1(𝒛ti𝒛^tj), (13.7)

is the Mahalanobis distance between the actual measurement 𝒛ti and its prediction 𝒛^tj under landmark j.

In practice, additional validation gates are often imposed: if the minimum distance dtic^ti exceeds a threshold, the measurement is treated as unmatched (assigned to the “no landmark” index N+1) and excluded from the EKF update. Once the correspondences 𝒄^t have been determined, they are treated as known in Algorithm 3, yielding the full EKF localization algorithm with unknown correspondences.

Data: 𝝁t1,Σt1,𝒖t,𝒛t,𝒎
Result: 𝝁t,Σt
𝝁¯t=f(𝝁t1,𝒖t)
Σ¯t=FtΣt1Ft+Qt
foreach 𝐳ti do
      foreach landmark k in the map do
            𝒛^tk=h(𝝁¯t,k,𝒎)
            Stk=HtkΣ¯t[Htk]+Rt
 
      j=argmink(𝒛ti𝒛^tk)[Stk]1(𝒛ti𝒛^tk)
      Kti=Σ¯t[Htj][Stj]1
      𝝁¯t=𝝁¯t+Kti(𝒛ti𝒛^tj)
      Σ¯t=(IKtiHtj)Σ¯t
 
𝝁t=𝝁¯t
Σt=Σ¯t
return 𝝁t,Σt
Algorithm 3 EKF Localization with Unknown Correspondences
Example 13.5.1 (Differential drive robot with range and bearing measurements).

Consider a differential drive robot with state 𝒙=[x,y,θ] and a sensor that measures the range r and bearing ϕ to landmarks mj𝒎 in the robot’s local coordinate frame. We assume that at each time step the robot collects multiple measurements corresponding to different features:

𝒛t={[rt1,ϕt1],[rt2,ϕt2],},

where each measurement 𝒛ti contains the range rti and bearing ϕti.

Assuming the correspondences are known, the measurement model for the range and bearing of landmark j is:

h(𝒙t,j,𝒎)=[(mj,xx)2+(mj,yy)2atan2(mj,yy,mj,xx)θ]. (13.8)

The measurement Jacobian Htj corresponding to a measurement from landmark j is therefore:

Htj=[mj,xμ¯t,x(mj,xμ¯t,x)2+(mj,yμ¯t,y)2mj,yμ¯t,y(mj,xμ¯t,x)2+(mj,yμ¯t,y)20mj,yμ¯t,y(mj,xμ¯t,x)2+(mj,yμ¯t,y)2mj,xμ¯t,x(mj,xμ¯t,x)2+(mj,yμ¯t,y)21]. (13.9)

It is also common to assume a diagonal covariance for the measurement noise:

Rt=[σr200σϕ2],

where σr is the standard deviation of the range measurement noise and σϕ is the standard deviation of the bearing measurement noise. This reflects the assumption that range and bearing errors are uncorrelated.

13.6 Monte Carlo Localization (MCL)

The second practical realization of Markov localization we consider is Monte Carlo localization (MCL). This algorithm leverages the non-parametric particle filter framework from Chapter 12 and is particularly well suited to global pose localization and the kidnapped robot problem.margin: We can also use MCL to solve the kidnapped robot problem by injecting new randomly sampled particles at each step so that the filter remains sensitive to unexpected measurements.

Like the particle filter, MCL represents the belief distribution bel(𝒙t) by a set of K particles:

𝒫t{𝒙t[1],𝒙t[2],,𝒙t[K]},

where each particle 𝒙t[k] represents a hypothesis about the true state 𝒙t. Regions of the state space with more particles correspond to higher belief.

At each step of the algorithm, we:

  1. 1.

    propagate particles forward using the map-aware state transition model, and

  2. 2.

    weight and resample the particles using the map-aware measurement model.

This is summarized in Algorithm 4, which is nearly identical to the particle filter algorithm in the referenced algorithm, the only difference being that the map 𝒎 now appears in the probabilistic state transition and measurement models.

Data: 𝒫t1,𝒖t,𝒛t,𝒎
Result: 𝒫t
𝒫¯t=𝒫t=
for k=1 to K do
      Sample 𝒙¯t[k]p(𝒙t𝒙t1[k],𝒖t,𝒎)
      wt[k]=p(𝒛t𝒙¯t[k],𝒎)
      𝒫¯t=𝒫¯t(𝒙¯t[k],wt[k])
 
for k=1 to K do
      Draw i with probability wt[i]
      Add 𝒙¯t[i] to 𝒫t
return 𝒫t
Algorithm 4 Monte Carlo Localization

In global localization, MCL typically starts from a broad prior, such as having particles spread over the entire map. As the robot moves and gathers measurements, inconsistent hypotheses are down-weighted and vanish during resampling, while particles near the true pose accumulate. This makes MCL a powerful tool for environments with strong ambiguities, repeated structures, or very uncertain initial conditions.

13.7 Summary

In this chapter, we examined the fundamental concepts and algorithms underlying robot localization—the process of estimating a robot’s pose relative to a known map of the environment. We began with a taxonomy of localization problems, distinguishing between pose tracking and global localization, static and dynamic environments, active and passive strategies, and single-robot versus multi-robot settings. This taxonomy provides a conceptual checklist for matching real-world scenarios to appropriate algorithmic tools.

Building on the Bayesian estimation framework introduced earlier, we extended the state transition and measurement models to explicitly incorporate map information. This led to the Markov localization algorithm, a general Bayesian filter that serves as a conceptual foundation for map-aware localization.

We then explored two important realizations of this framework: EKF localization, which represents the belief as a unimodal Gaussian and is effective for pose tracking with moderate uncertainty; and MCL, which uses a particle-based, non-parametric representation suitable for multi-hypothesis and global localization problems. We discussed data association—the challenge of determining correspondences between sensor measurements and known map features—and techniques such as maximum-likelihood matching and validation gates to improve robustness.

Together, these methods form the core of modern localization systems, enabling robots to estimate their position and orientation using noisy sensors, partial maps, and uncertain environments. In later chapters, these ideas will reappear in more complex settings such as simultaneous localization and mapping (SLAM), where the robot must estimate both its pose and the map at the same time.

To learn more.

For a detailed and foundational treatment of probabilistic localization, Thrun et al. (2005)11. Thrun, S., Burgard, W., Fox, D. Probabilistic Robotics. MIT Press, 2005. remains the canonical reference. The original formulation of the Monte Carlo Localization algorithm is presented by Dellaert et al. (1999)22. Dellaert, Frank, Fox, Dieter, Burgard, Wolfram, Thrun, Sebastian. “Monte carlo localization for mobile robots.” In Proceedings 1999 IEEE international conference on robotics and automation (Cat. No. 99CH36288C), 1322–1328, 1999., while Leonard and Durrant-Whyte (1991)33. Leonard, John J, Durrant-Whyte, Hugh F. “Simultaneous map building and localization for an autonomous mobile robot..” In IROS, 1442–1447, 1991. provide an early and influential treatment of EKF-based localization with geometric landmarks. Readers interested in recent advances and the connection between localization and SLAM may refer to Cadena et al. (2017)44. Cadena, Cesar, Carlone, Luca, Carrillo, Henry, Latif, Yasir, Scaramuzza, Davide, Neira, José, Reid, Ian, Leonard, John J. “Past, present, and future of simultaneous localization and mapping: Toward the robust-perception age.” IEEE Transactions on robotics 32(6), 1309–1332, 2017. and the comprehensive modern text by SLAM Handbook. From Localization and Mapping to Spatial Intelligence55. SLAM Handbook. From Localization and Mapping to Spatial Intelligence. Cambridge University Press, 2026., which unify localization and mapping under a common probabilistic and optimization-based framework.

13.8 Exercises

The starter code for the exercises provided below is available online through GitHub. To get started, download the code by running in a terminal window:

git clone https://github.com/StanfordASL/pora-exercises.git

We denote Problems requiring hand-written solutions and coding in Python with [Uncaptioned image] and [Uncaptioned image], respectively.

[Uncaptioned image] Problem 1: Extended Kalman Filter Localization

In this problem, you will implement an extended Kalman filter (EKF) for robot localization in an environment where the robot can collect relative position measurements to a set of four landmarks. We will consider a robot with a discrete-time dynamics model 𝒙t+1=f(𝒙t,𝒖t)+ϵt defined by:

xt+1=xt+Vtcos(θt)Δt+ϵtx,yt+1=yt+Vtsin(θt)Δt+ϵty,θt+1=θt+ωtΔt+ϵtθ,

and the goal is to estimate the unknown robot pose, 𝒙t=[xt,yt,θt]. The noise vector ϵt=[ϵtx,ϵty,ϵtθ] is a random variable with a zero mean Gaussian distribution ϵt𝒩(𝟎,Q), where Q=0.1Δt2I. In this problem, we assume the global ground truth positions of the four landmarks are known. The landmarks are stationary objects in the environment, and their combined state vector is:

𝒎=[m1,xm1,ym2,xm2,ym3,xm3,ym4,xm4,y].

As the robot navigates through its environment, it receives noisy measurements of the positions of four landmarks in the environment relative to the robot’s current pose. The measurement for landmark i is the relative position with the measurement model:

𝒛ti=h(𝒙t,i,𝒎)+𝜹t=[cos(θt)sin(θt)sin(θt)cos(θt)]([mi,xmi,y][xtyt])+𝜹t,

where the measurements have an associated measurement noise with 𝜹t𝒩(𝟎,R), where R=0.25I. The full measurement vector of all landmarks is:

𝒛t=[𝒛t1𝒛t2𝒛t3𝒛t4].

In the file ch13/exercises/ekf_localization.ipynb, complete the following:

  1. 1.

    Implement the functions robot_dynamics and robot_measurement to match the dynamics and measurement models described above.

  2. 2.

    Implement the function dynamics_jacobian to compute the dynamics Jacobian Ft=𝒙f(𝒙t,𝒖t).

  3. 3.

    Implement the function measurement_jacobian to compute the measurement model Jacobian Ht=𝒙h(𝒙t,𝒎) for the model that computes the full measurement vector 𝒛t.

  4. 4.

    Implement the function ekf_localization_update to implement the EKF localization update described in Algorithm 2. Note that you won’t need to explicitly have a for loop in this function for each measurement since we have defined the update to be vectorized for all measurements at once.

  5. 5.

    Run the provided code to see how the algorithm performs for the simulated robot.

[Uncaptioned image] Problem 2: Particle Filter Localization

In this problem, we consider the same problem setup defined in Problem 1, where we are localizing a robot given relative position measurements to a set of four known landmarks. In the file ch13/exercises/particle_filter_localization.ipynb, complete the following:

  1. 1.

    Implement the functions robot_dynamics and robot_measurement to match the dynamics and measurement models described above. Note: you can reuse your solution from the previous problem.

  2. 2.

    Implement the particle filter algorithm update function particle_filter_update as described in Algorithm 4.

  3. 3.

    Run the provided code to see how the algorithm performs for the simulated robot.

Practice · 2 notebooks