# Quaternion recursive integration/filtering

Having a reference rotation, which has non-smooth transitions I want to obtain a smooth quaternion trajectory, which eventually converges to the reference. The problem is, that the reference is switching directions sometimes and the actual orientation should only follow in a smooth manner. I also need to be able to calculate the angular velocity $\omega$ and it would be great to even have the angular accelaration available.

If the orientation wouldn't be given as quaternion, I would simply set up a second order state space filter and filter the reference orientation $q_r$. Thus "generating" the derivatives.

For quaternions we have these formulae to calculate the angular velocity and acceleration. Is it feasible to take the difference quaternion $\Delta q = q_r \cdot q^{-1}$ and use $\dot{\omega} = \frac{\Delta q}{T^2}$ as angular acceleration and integrate the resulting equation?

I found a lot of papers on quaternion interpolation and approximation, but nothing recursive.

Edit: It is a continuous measurement of rotations, which I can measure in regular intervals.However, sometimes the measurement is not unique and the orientation can flip by 90 degrees. Therefore, I want to "follow" these measurements, but slowly enough, that even on these jumps I get a smooth trajectory. Sample data could be any noisy sequence of orientations with 90 degree jumps (nonsmooth sections of 2nd order). Like a lowpass filter the solution I am looking for should reduce the noise and smooth out the sudden changes in orientation.

• Example data would be helpful. Also, is it just two rotations that you would like to interpolate between or more points? Are the rotations evenly spaced in time? – Tpofofn Jun 1 '18 at 0:51
• Thanks, I added a further descriptive paragraph to hopefully make the problem more clear! – mike Jun 1 '18 at 8:12
• It seems odd that a physical system would jump in orientation by 90 deg. Are you storing your orientations in Euler angles? If you are these representations have trouble near particular orientations (i.e. Roll, Pitch, Yaw has problems when pitch is ~ $\pm$ 90 deg. – Tpofofn Jun 1 '18 at 12:25
• From measurements I infer a rotation. This calculation can sometimes yield these jumps. The measurements only give one direction, where for a complete orientation one needs at least 2 and a halfspace, or 3 directions (unit vectors). This method however is necessary for the physical system (which is pretty difficult to describe and does not add value to the question). – mike Jun 1 '18 at 14:15