I am using an IMU-Sensor (Inertial Measurement Unit) to get the absolute rotation of a sensor kit I am building. The rotation is relative to the initial orientation, that means when the device is powered up the 'zero' rotation is set.
The sensor tells me its current rotation as a quaternion and by applying this to a reference vector - lets say (1,0,0) - I am visualizing that rotation. Works perfectly so far.
Now, I want to 'zero-out' the sensor without restarting it. Naively speaking, that means I have to undo the zeroing rotation. How do I do this?
My attempt: Let the current rotation be $R$, the rotation at the zeroing moment $Z$ and the reference vector $x = (1, 0, 0)$ and we call the expected vector $y$.
Normally, I do: $y = R \cdot x$ (works perfectly) Now, I would do: $y = Z^{-1} \cdot R \cdot x$ where $Z^{-1}$ is the inverse quaternion.
At the first moment this solution works. I can see that $y$ is reset to the x-axis. However, when I start rotating my sensor very wired things happen.
Question: What is the correct concept for zeroing a rotation system?
My own mistakes during testing made me believe I applied the wrong concept. However, the solution explained above is in fact correct.