Does the UKF work? - or - how would a correct implementation of UKF look like?

512 Views Asked by At

I am a 5th year engineering student, and I am currently struggling to implement the Unscented Kalman Filter. I tried the regular version and a square root version and they both failed. Research showed many people failed to implement it, and only one succesful though simple implementation un the matlab central website.

This brings me to the question - does it even work? Is the UKF a reasonable solution to any random process, or maybe just to very simple cases? From its formulation, it seems to be able to handle very complicated systems, but I cant seem to be able to make it work, nor could i find too many evidence of succesful work by anyone. Currently, I am assuming my implementation is just wrong, even though I am working on it over a year (!). If this really is the case, I'd be greatfull if anyone could enlight me, as my projects deadline is this weekend and I am helpless.

The system i work on tries to estimate the orientation of an object, and contains 3 angles. The equation:$$$$ $[ \dot x_1] =\matrix [1, \space sin(x_1)tan(x_2), \space cos(x_1)tan(x_2)]*\omega $

$ [\dot x_2] =\space[0, \space cos(x_1), \space -sin(x_1)]*\omega$

$ [\dot x_3] =\space[0, \space sin(x_1)sec(x_2), \space cos(x_1)sec(x_2)]*\omega$

Represents the relation between the state and (given) angular velocity $\omega$ to the state derivation $\dot x$, so my state equation would be adding this times the sampling time dt to the state provided by last iteration.

The measurement function is given by: original picture of matrix for comparison

$$R_i^b=\left[\matrix{\cos\theta\cos\psi & \cos\psi\sin\theta\sin\phi - \cos\phi\sin\psi & \cos\psi\sin\theta\cos\phi + \sin\phi\sin\psi \\ \cos\theta\sin\psi & \sin\psi\sin\theta\sin\phi + \cos\phi\cos\psi & \sin\psi\sin\theta\cos\phi - \sin\phi\cos\psi \\ -\sin\theta & \cos\theta\sin\phi & \cos\theta\cos\phi}\right]$$ $$ \hat y = \left[\matrix{R_i^b\\ R_i^b}\right] \cdot\left[\begin{smallmatrix}0\\0\\ -g \\ M_h\\0\\M_z\end{smallmatrix}\right], \qquad\text{where $g$: gravity const; $M_h$, $M_z$: magnetic const} $$

here, note: $ x=[\phi, \space \theta, \space \psi ]^T$ - the 3 angles to estimate.

As mentioned, 2 versions of the UKF were tested, but none gave the right results. The original form of the filter kept failing with the error of covariance matrix not being positive definite, and after fixing it with various approaches, just returned wrong results, showing more like noise than anything. the square root form, given in http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.80.1421&rep=rep1&type=pdf , just kept failing at the last step of the iteration, where a downdate needs to be preformed, saying the matrix cannot be downdate due to - you guessed it - the matrix not being positive definite.

as long as the question may be, I would appreciate any help you can give me, wether consists on your experiment with the filter or just with the math or matlab in general.

with respect, Joseph.