# Application of UKF on quaternions

I'm trying to perform a state estimation on quaternions to predict the future orientation of a human head. The only sensor data I can obtain (from the AR headset) is the current orientation of the head, sampled at 200 Hz i.e. I don't have access to any gyroscope or acceloremeter data. After getting the state estimations, I would like to reuse the process/motion model (constant angular velocity) to make predictions further into the future, e.g. 20 ms to 100 ms.

Since the process model is nonlinear (due to quaternions), one option is to use an Unscented Kalman Filter (UKF). However, as discussed in this paper, quaternions cannot be directly used in the UKF and some conversions need to be made to obtain "quaternion sigma points" (Sec. 3.2 of the paper).

My question is, does it make sense at all to use this kind of method if I only have attitude measurements (quaternions) and no gyro or acceloremeter data? In this case, my state vector would be 7D: four quaternion and three angular velocity components. However, the paper (and most other works I encountered) always have some kind of gyro/acceloremeter measurements which makes me wonder if it's feasible to just have the attitude information and have the filter estimate the angular velocity.

• If the amount of rotation between samples is small enough, an extended Kalman filter will do -- you don't need an Unscented kalman. How small is "small enough" is hard to pin down, but 5 degrees or less is certainly small enough, 30 or 40 may still work, but 180 degrees is right out. – TimWescott Apr 16 '20 at 20:09
• Usually when there's a Kalman filter driven by accelerometer and gyro data, then it's probably a GPS/IMU fusion algorithm -- but that's not the only sort of Kalman filter that might deal with rotations. – TimWescott Apr 16 '20 at 20:12
• The amount of rotation between samples is around 0.1 degrees because this is head motion data and the sampling time is 5 ms (200 Hz). According to the literature, using EKF/UKF directly on quaternions doesn't seem to be the theoretically right way. Do you think that EKF on quaternions may work for small rotational changes between samples? – chronosynclastic Apr 17 '20 at 8:07
• I suspect that a "plain old" extended will work for you, except that you want to make sure that your head set doesn't flip the quaternion 180 degrees between readings -- if it doesn't have any memory it may do that; if it does tend to do that then you'll need to test for it, and carry a "headset flipped" state. – TimWescott Apr 18 '20 at 15:26
• Basically, you need quaternions because any 3D angular representation with three elements will have singularities (do a web search on "hairy ball theorem"). But one of the prices you pay is that for any one 3D rotation, there are two quaternion values that represent it, i.e., for rotation $\mathbf{r}$, the quaternions $q$ and $-q$ will result in that rotation. Hence, my suggestion to carry a "headset flipped" state (which can be true or false), which you can detect by seeing a sudden jump in the quaternion value. – TimWescott Apr 19 '20 at 18:44

For example, in this answer to another question the state is made up of the $$x$$ position and the $$x$$ velocity, but there is no velocity measurement.
\begin{align*} \mathbf{x}_{k} & =\left(\begin{array}[c]{c}x_{k}\\ \dot{x}_{k}\end{array} \right) \end{align*}
All that means is the output matrix $$H$$ zeros out that part of the state when producing the measurement.