# 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. Apr 16, 2020 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. Apr 16, 2020 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? Apr 17, 2020 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. Apr 18, 2020 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. Apr 19, 2020 at 18:44

Yes, it's perfectly possible. All that you'll need is to model how you think the angular velocity components of the state will evolve. Usually simple brownian (random) motion is enough, at least to start with. If you know more about how the angular velocities are constrained, then you can include that in the model.

All that it means is there are no outputs from your signal model directly from those elements of the state.

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.

• Thanks. Now I understand that I can include angular velocity into the state vector (as an unobserved state) even if I'm not getting any measurements of it. Another doubt I have is on the motion model for rotational motion. Does it make more sense to use the obtained quaternion representation directly and have a motion model that captures the relationship between the quaternion derivative and angular velocity, e.g. as described here, or would it be also feasible to use the simple motion model in the answer you linked? Apr 16, 2020 at 9:40
• @chronosynclastic. I don't know enough about the advantages of the quaternion approach. The thing the 1D approach in the other question misses is capturing the attitude that you're interested in. My (too brief) googling on the matter shows that most people use a quaternion approach to solve the problem you're interested in. This paper has an approach using the Kalman filter but a) it assumes gyros for rotational velocity measurement and b) it actually doesn't show data with the derived KF applied, so I'm skeptical about whether it worked.
– Peter K.
Apr 16, 2020 at 13:06