# Quaternions statistics from IMU

I am struggling with a problem about quaternions and how to use them in my application. I spent few days looking at a solution for this, but cannot find any similar applications or example around.

I have pretty clear all the quaternions properties and why we should use them, but maybe I am missing tiny details.

My problem is described as follow:

I have a rigid object with attached an 9axis IMU (from where quaternions are calculated) and I want to identify some specific poses (so specific orientations then) with respect to the initial orientation. In particular, the initial orientation (or every time the object is stable on a surface lets say) is easy to be identified as the IMU is at rest and acceleration and gyro energy is basically zero (or very low).

As explained in the link below, it is possible to find all the relative rotations from the initial one, and use the initial rotation as a reference one.

Relative quaternion rotation (delta rotation) produces unstable results

This step is quite clear and documented in many posts in this forum.

However, it is not clear to me how to identify all the poses that for example exceed or coincide to a specific one.

For example it will be interesting for my application to see how long the object has been held in a orientation where the pitch angle is between 0 and 45 degree (object is pointing up) or between 0 and -45. Or just to generate a flag that indicate object pointing up or object pointing down

I cannot find any way to solve this except to move from quaternions to Euler angles and from there try to infer this information by simply thresholding the Euler angles.

However, as the Euler's angles suffer of certain singularities it is basically impossible to obtain an accurate estimation.