# Extended Kalman Filter in robotics - Worth it?

I wonder if Extended Kalman Filter(EKF) is used in robotics, or is only Kalman Filter(KF) used in robotics.

Kalman Filter is included in Linear Quadratic Gaussian(LQG) controllers. But how would EKF work i practice?

I know how to build a Extended Kalman Filter just by linearizing the mathematical model in the estimated state vector.

What is your experience in EKF?

• It is a sub-optimal filter and yes it is worth using it. – CroCo Aug 30 '17 at 21:32
• @CroCo Have you seen a better results by using a extended kalman filter insted of a regular kalman filter? Where did you implement an EKF? Robotic arm? Tank system? Hydraulic cylinder? – Daniel Mårtensson Aug 31 '17 at 16:38
• Kalman filter is an optimal filter and EKF is a suboptimal filter. I will provide more info subsequently few days may be. – CroCo Aug 31 '17 at 16:45
• I know that KF is an optimal filter and EKF is not an optimal filter. If EKF only possible if I got the physical nonlinear state space equation? Or can I estimate a physical nonlinear state space model by using subspace identification? As I know, EKF requries real physical nonlinear state space model that can be linearized with jacobians. Yes. Write here in couple of days. I am always in Stack Exchange. – Daniel Mårtensson Aug 31 '17 at 18:56
• @CroCo Why are EKF called sub-optimal filter? Why not optimal? – Daniel Mårtensson Aug 31 '17 at 19:04

The Kalman filter is an optimal linear filter in the presence of Gaussian noise. It is optimal in the sense that it minimizes the mean-squared error. This means that the covariance of the estimated states will be minimized:

$$P = E\{(x_k - \hat{x}_{k|k})(x_k - \hat{x}_{k|k})^T\}.$$

As this covariance is minimized, the goal of any kind of estimation filtering is accomplished -- the error between the true state $x_k$ and the estimated state $\hat{x}_{k|k}$ is driven to zero  .

The Extended Kalman filter is more or less a mathematical "hack" that allows you to apply these techniques to mildly nonlinear systems. I say "hack" because it is sub-optimal, i.e., it does not have any mathematical guarantees like the KF does. If you initialize the filter with poor conditions (i.e., the initial state), it will quickly diverge. If propagation and/or measurement updates happen at too great a timestep, it will quickly diverge. As you state in your question, you build an EKF by linearizing your system -- which implies that you loose information about your system and if you operate too far from your linearization point, the solution will be incorrect (like trying to fit a line to a quadratic).

There is another standard implementation of Kalman filters called the Unscented Kalman Filter (UKF). The UKF is ideal for grossly nonlinear systems because: (1) you don't have to do the math / computation to linearize, and (2) it intelligently chooses sigma points to propagate (instead of an entire model) that best represent the statistics of the system. The UKF kind of bridges "the best of both worlds" from Kalman filtering (which assumes a Gaussian noise and belief propagation) and nonlinear Particle filtering (which makes no assumption of the form of the belief propagation), another type of Bayes filter.

In my experience (3-wheeled ground robots, aerial robots), and EKF is a nice and computationally efficient way to estimate state and fuse information from multiple sensors (accel, gyro, airspeed, camera). Tuning can often be a pain, but the more intuition about your system and the noise of your sensors, the easier it becomes. Because of the EKF's efficiency, relative ease-of-implementation, and demonstrated effectiveness it is used widely in robotics.

For more information on applying an EKF to wheeled robots (or aircraft) I would direct you Dr. Randy Beard's notes on Robot Soccer and Rober Labbe's iPython Notebooks on Bayesian filters.

 R. W. Beard and T. W. McLain, Small Unmanned Aircraft. Princeton, New Jersey: Princeton University Press, 2012.

 R. Faragher, “Understanding the basis of the kalman filter via a simple and intuitive derivation [lecture notes],” IEEE Signal Process. Mag., vol. 29, no. 5, pp. 128–132, 2012.

• Did you see any difference between KF and EKF? – Daniel Mårtensson Sep 7 '17 at 17:02