# Is there a better filter or a modification to the Kalman filter that could take advantage of having all the data during the trajectory at once?

I am trying to reconstruct the trajectory of an object with an strapped down IMU on board to do dead reckoning. A Kalman filter seems to be in order. But the Kalman filter seems to be oriented toward real time updates of position. However I have the luxury of not having to figure out the position of the object while it is moving. At the end of the path I will have all the data(gyros and accelerometers and maybe magnetometers) I can use to calculate the path. Is there something better than Kalman that can be used?

Right now I have a superficial understanding of the Kalman filter so forgive me if this question is a little dumb. I did not want to get involved with the Kalman filter if it is sub optimal.

• I believe the Kalman filter is still the optimal, since there is no advantage of having the future data as the "current" position is only dependent on the past. Unless you have some periodic precise position sensing.. – Eugene Sh. Feb 16 '17 at 14:56
• @Eugene This reminds me a bit of Viterbi decoder. For it, rhe final position is helpful , since it eliminates some of the states. I'm not sure how would this fit in Kalman filter theory. – AndrejaKo Feb 16 '17 at 14:59
• @AndrejaKo If we have the precise final position reading it would definitely help. Not sure about the math, though :) – Eugene Sh. Feb 16 '17 at 15:00
• I believe the Data assimilation is the process you are talking about.. – Eugene Sh. Feb 16 '17 at 15:06
• Kalman filter is optimal for nonstationary data. When all the data is known a Wiener filter is optimal. (Simplistic view, Kalman is like a infinite impulse response filter and Wiener is a finite response solution for the same problem.) – skvery Feb 16 '17 at 15:08

The Kalman Filter does more than just "filtering". It disambiguates translational accelerations from reorientations with respect to gravity, and uses inputs from accelerometers and gyros to produce something that resembles true position in space. You can't do that with single-input single-output filters.

• Where the restriction on the number of inputs came from? – Eugene Sh. Feb 16 '17 at 18:26
• It's not a restriction -- its that converting such signals to physical position and orientation is inherently ill-posed. – Scott Seidman Feb 16 '17 at 20:28
• Well, probably we have a different interpretations of the question. I read it as "For the current and past measurements we have a Kalman filter to optimally approximate the current and past <values of whatever>. Is there a better method to approximate the whole history of the <value of whatever> given we have all of the historical measurements". – Eugene Sh. Feb 16 '17 at 20:33

You can try filtfilt in Matlab. It filters data forward with FIR filter of your choice and then it turns backward. The filtered data have no lag or phase shift, compared to all real time filters. filtfilt practically determines the boundary and initial conditions, so it adapts to the first and last data in the data table/buffer.

EDIT:

https://github.com/xioTechnologies/Oscillatory-Motion-Tracking-With-x-IMU/blob/master/Script.m

I have found a matlab example from xio Technologies. The guy is the famous Madgwick, author of the fusion IMU algorithm used in quadcopters. Well, indeed he also uses filtfilt to compute data in Matlab.

• filtfilt can do FIR and IIR filters, nice. – skvery Feb 16 '17 at 15:30