# Kalman filter for sensor fusion — what is the advantage?

Is there any meaning of using Kalman Filter for cases when you do not have good statistical model of the system?

For example, if you have a drone and it has IMU sensor and GPS sensor. You do not have any statistical information, like variance, covariance, etc. If you want to estimate your current position, is there any advantage of using Kalman filter over just averaging the two sensors?

For the above problem, if in practice the Kalman filter has some advantage, what are the reasons behind it that I did not consider in my above example?

You can't just "average the two sensors"

The acceleration readings are essentially meaningless unless you know their direction, you can't know their direction unless you have the platform orientation, and you can't know the platform orientation from the IMU (unless it has a reliable magnetometer).

For the IMU-alone case, your system basically has the information that you'd have if you were stuck inside of Einstein's elevator. The system knows -- with errors -- how rapidly its velocity (not position) is changing, and how rapidly -- with errors -- it is turning. That's all.

The best that you can do is to:

• Maintain a 3D orientation estimate by integrating the gyro readings -- basically this gives you a rotation from your vehicle frame to North East and Down, or whatever your preferred "global" reference frame is.
• Maintain a 3D velocity estimate in your global reference frame by rotating the accelerometer readings into the global frame with the orientation estimate, and then integrating.
• To complicate things, you need to know your local acceleration due to gravity and you need to correct for it in the vertical direction -- so any errors in your estimate of "down" translate immediately into an offset in the effective acceleration reading in the North or East directions.
• Maintain a 3D position estimate in your global reference frame by integrating the velocity readings.

You can say at this point "Yes, but I'm going to keep everything in the vehicle frame" -- fine, but life will be just as complicated and inaccurate. You're not going to gain any information by doing so.

Now you have a 9-state estimate (rotation, velocity, position, each in 3D), with a rather nasty nonlinear relationship between rotation and the rest.

This means that any error in starting state, plus noise, drift or offset in the IMU readings, gets integrated multiple times. It's pretty much twice for accelerometer readings, but rather complicated for gyro readings because the orientation estimate is used to rotate the accelerometer readings. It is very difficult to do. In general, with typical consumer-grade IMUs, the state estimate will be utterly useless within seconds, if it starts out perfect.

There actually are (or at least were) purely inertial navigation systems in the 1960's and 1970's that used this technique -- but they needed hugely expensive IMU hardware, they needed very careful pre-launch calibration, they needed maps of the local graviometric variations for their route, and even the ones in strategic bombers and submarines were backed up by people (or machines, in the case of nukes) taking celestial readings (star or sun shots with a sextant).

For typical consumer-grade IMU hardware, with perfect starting calibration, you can free-run for maybe a second or so before the error gets into the meters.

Need for a statistical model

In the specific case of a drone (or anything else) with an IMU and GPS, you can side-step the need for a statistical model of the vehicle, or at least you can make a model without prior knowledge of the vehicle's motion. I've done this, and it works.

Basically, you treat the IMU output as the system input (just treat the system as having mass subject to accelerations and rotations), then you compare the system's position to the GPS readings.

So your model is $$\dot x = f \left ( x, \hat u \right)$$, $$y = x_{position}$$, where $$\hat u(t)$$ is the output of the IMU. (Note that this is the state-space representation for a system that is nonlinear in the state evolution, but linear in the output).

The only statistical variation you need to account for is the IMU and GPS error. For the IMU you let $$\hat u(t) = u(t) + w(t)$$, where $$w(t)$$ is your expected IMU noise, and $$u(t)$$ is the actual body motion. Similarly, for the GPS you let $$\hat y_{position} = y_{position} + r(t)$$, where $$y_{position}$$ is your actual position, $$\hat y_{position}$$ is your actual GPS reading, and $$r(t)$$ is your expected GPS error.

So there is a "statistical model", but it's one that you can gain from a knowledge of the properties of the IMU and of GPS.

Orientations from the fusion

Because you're keeping track of everything with that covariant matrix, the Kalman filter will sort out varying accelerations into the platform orientation, position, and velocity. It doesn't actually have to know anything about the platform dynamics, because those are being directly read by the IMU.

You can reason this out intuitively. When you add GPS into the mix, the system is now in the same situation as you would be if you were stuck inside of Einstein's elevator but with a position readout. If you're in Einstein's elevator and you know that you are not moving relative to the earth then you know that the "down" that your accelerometer is telling you is also "true down".

Now you know which way is up. Let's say that you're watching your position readout, your gyro, and your accelerometer. You notice some tugs on the elevator -- your gyro says you haven't moved, the accelerometer vector has tilted toward the front wall and then the back, and the GPS is now reporting that you are some distance east of where you started. Now because you know that you moved straight east and that the sideways acceleration was in the direction of the front of the elevator. So you can face the front of the elevator, say "I am pointing to the East", and you have successfully oriented yourself.

This is what the Kalman filter is doing with it's seemingly inadequate statistical model -- if you get $$f(x, u)$$ right, because of the way the covariant matrix ends up evolving, just sitting still will rapidly let the Kalman know which way is down (because it's not moving, yet the accelerometer is reporting acceleration "upward"). Then, if the Kalman sees a changing lateral acceleration coupled with motion in the GPS reporting, it'll deduce lateral direction. Moreover, this will continue to happen -- the combination of GPS and acceleration will always give information about orientation along the line of acceleration, so if the acceleration direction continually changes, the Kalman filter will know orientation.

There's probably refinements that could be had by actually modeling the platform dynamics and using the control inputs to the platform to increase the information flowing into the filter -- but I've done it the way I describe above, and it worked great (after considerable work).

• Finding velocities and positions and angles from accelerations (angular and linear) does not require a Kalman filter. You can just integrate to get it. Also, Kalman filter deos not know the orientation either. Am I wrong? Jan 7, 2020 at 20:42
• I mean, yes by "averaging" I also mean some mathematical operations, but do we necessarily need to call it a Kalman filter? Jan 7, 2020 at 20:47
• You cannot "just integrate" accelerations and rotation rates to get velocities, positions and angles, at least over any sensible time span and with inexpensive IMU hardware. "just integrating to get it" integrates a whole lot of noise and IMU error. Added to that, you're in a gravity field. If you "just integrate" to get position, you'll come up with a solution that accelerates upward at $9.8 \mathrm{m/s^2}$. If you try to cancel that out you need to know the starting orientation. Jan 7, 2020 at 20:48
• The Kalman does not necessarily know the orientation initially. But given gyro, accelerometer, and GPS inputs, if the IMU isn't in free fall the Kalman will rapidly figure out which way is up. As soon as the IMU turns a corner, the changing acceleration, correlated with the change in position, will let the Kalman determine the IMU orientation. Jan 7, 2020 at 20:50
• Noise filtering, and also subtracting the effects of gravity is also possible without a Kalman filter right? Do you mean Kalman filter is just for estimating initial conditions? Jan 7, 2020 at 20:51