Nonlinear motion
Take the simplest motion a robot can make. It drives straight ahead at speed for a time , covering the distance , and does not turn. With the state , the pose after the drive is The path is a straight line, yet the new position depends on the heading through and . The command specifies how far to move in the robot’s own frame, along its heading. The state records the position in the world frame. Turning one into the other is a rotation by , and a rotation is a nonlinear function of its angle. If the heading is uncertain, the same command can put the robot in many different places. The Kalman filter used the motion model . It is the one-dimensional case of the linear model with and . The Kalman filter needs a motion model of this form, with matrices and that do not depend on the state. No matrix turns into , so even driving straight does not fit this form. The EKF accepts any differentiable motion model,Nonlinear measurements
The measurement model can be nonlinear too. The table lists three sensors found on many mobile robots. Each one measures the state , and the last two measure it relative to a landmark at a known position .
A measurement model is linear when it is a linear function of the state you chose, and this does not depend on how complex the sensor hardware is. A GPS receiver is a complex instrument, but it reports the position directly, so picks and out of the state. A range sensor is simple, and its reading is still a nonlinear function of the position.
The range is the landmark measurement model of Probabilistic Robotics (Thrun, Burgard and Fox, Section 6.6.2, Equation 6.41). The square root makes a nonlinear function of the robot’s position, so a Gaussian belief about the position does not give a Gaussian prediction of the range. In one dimension the square root cancels the square. A landmark ahead of the robot gives , which is linear in , and that is why the one-dimensional filter needed no linearization. In the plane the derivative of with respect to the robot’s position is the unit vector from the landmark to the robot. Its direction changes when the robot moves sideways to the line of sight, and that change is the nonlinearity. The EKF localization section uses this model and its Jacobian. The beam model gets the expected range by ray casting through the map instead.
A robot’s models are therefore nonlinear in two places: the motion model, through its heading, and the measurement model, through the geometry of range and bearing. The Kalman filter assumes both models are linear, so the EKF is needed when either model is nonlinear.
A Gaussian through a U-shaped function
The Kalman filter’s equations hold only for Gaussian beliefs, and the output of a nonlinear function of a Gaussian random variable is in general not Gaussian. The following example uses a simple function. Take a belief and pass it through the U-shaped function whose lowest point is at . Place the mean of the belief at that point, . Points at the same distance on either side of give the same output: and both give . This function produces positive numbers and the majority of the probability mass is near zero, where the input is most likely. To find the distribution of , draw many samples of , apply to each one, and look at the histogram of the results.Code
Code
Linearizing the function
The EKF keeps the belief Gaussian by replacing the nonlinear function with its tangent line at the mean of the belief. The tangent line to the curve at the point is the line through whose slope is the derivative : Near the curve and its tangent line are close, so the tangent line approximates the function: This approximation is the first-order Taylor expansion of around . Its right-hand side is linear in . If the input is , the output of the tangent line is Gaussian again: In only is random, so the mean and variance follow directly. Since , The mean comes out as because the expansion point is the mean of the belief. This is the mean of the tangent line’s output. The mean of itself is in general different, because for a nonlinear . Try the tangent line on the U-shaped function. Center the belief on the right arm of the U, at , with the same width . The slope there is , so the tangent line predicts . The code below compares that prediction with samples pushed through itself.Code
Code
The Jacobian of a vector function is the matrix of its first partial derivatives, with entries . Row is the gradient of the output , and the whole matrix is the best linear approximation of near the point where it is evaluated. We have seen Jacobians in backpropagation in deep networks and the references therein.
The linear algebra review covers the matrix products, and the multivariate Gaussian section plots a bivariate Gaussian whose covariance couples the two variables. Its linear-Gaussian theorem gives the covariance of plus independent noise as . With , and the motion noise , this is the EKF’s predicted covariance .
The extended Kalman filter algorithm
Write the state as , the action as and the measurement as . The motion model and the measurement model are now nonlinear functions with additive Gaussian noise: and The EKF linearizes around the previous mean and around the predicted mean . The two Jacobians are One step of the filter takes the previous belief , the action and the measurement , and returns the new belief : Here is the motion noise covariance and is the measurement noise covariance, the convention of most Kalman filter code. Probabilistic Robotics swaps the two letters: its is the motion noise and its the measurement noise. With the size of the state, the size of the action and the size of the measurement, the quantities in the algorithm have these sizes:
The matrix inverted in line 3 is , the size of the measurement, and the gain turns an -dimensional innovation into an -dimensional correction of the mean. For the robot of the EKF localization section, the state is the pose with , the action is the two wheel speeds with , and a range and bearing to one landmark has .
Compared with the Kalman filter:
- The means pass through the nonlinear functions themselves, in lines 1 and 4.
- The covariances pass through the Jacobians and , which take the place of the fixed matrices of the linear model.
Code
Code
When linearization fails
Move the same belief to the lowest point of the U, , where the slope is zero, and compare again.Code
Code
Write with . For this the expansion ends at the second-order term and is exact:Because and , the mean of is . The linear and quadratic terms are uncorrelated, since , and a Gaussian has , soThe tangent line keeps only and , so it misses in the mean and in the variance wherever the belief is centered. At the slope is zero, so the curvature terms are the whole output: mean and variance . At with the slope is , and the same terms are small next to it: the exact moments are and , against the linearized and .
Flat motion and measurement models
A robot’s entire Jacobian is rarely zero. More often it is zero or nearly zero in particular state directions, or its slope is small compared with the model’s curvature across the belief. The table lists common cases. In each, the measurement is not directly sensitive to the flat direction. The filter can still reduce the uncertainty in that direction when the prior correlates it with directions in which the model’s slope is not zero. A GPS position fix, for example, updates the heading through the position-heading cross-covariance. Without such correlations, the covariance in the flat direction stays large or grows.
The echosounder case occurs in practice in terrain navigation. The terrain navigation module of the Kongsberg HUGIN vehicles requires “a certain degree of terrain variation” (Ånonsen et al.), and the HUGIN 3000 survey data used in a 2022 study of bathymetric SLAM contains such a flat stretch (Torroba et al., 2022). The TurtleBot example at the end of this section shows the last row for a heading known only to 30°.
Linearization works when the function is close to a straight line over the region where the belief has most of its mass. The EKF approximation is accurate when the belief uncertainty is narrow, or when the nonlinear function has no significant curvature or sharp change near the mean of the belief. The case of belief uncertainty is treated in Belief uncertainty below.
Belief uncertainty
Probabilistic Robotics (Thrun, Burgard and Fox, Section 3.3) names two factors that determine how good the EKF’s linearization is: the degree of local nonlinearity of the function, and the degree of uncertainty in the belief. The comparison above varied the first factor. It kept the width of the belief fixed and moved it from the arm, where is nearly straight, to the bottom of the U, where bends sharply. The comparison below varies the second factor. Both beliefs are centered at on the arm, where the tangent line worked well, and only their standard deviations differ: and .Code
Code
Found an error on this page? Report an issue.
Footnotes
- is the two-argument arctangent: the angle of the point , measured counterclockwise from the positive axis, in . It differs from , which depends only on the ratio and returns angles in . The points and both give , while gives and . The two agree when , and is also defined at . ↩

