Let's say I want to figure out the orientation of my cell phone. Assume that the phone has two internal sensors that report orientation (a quaternion), but both are a bit unreliable, so I'd like to use them together.
HOWEVER, the coordinate frames the sensors report a quaternion are not the same.
1) Sensor 1 reports q1, a quat in the following frame: +x = up, +y = right, +z = forward
2) Sensor 2 reports q2, a quat in the following frame: +x = down, +y = forward, +z = left
Note that both frames are right handed, and there exists a quaternion that rotates frame 1 to frame 2 (I think).
I'd like to apply a rotation to whatever orientation I'm getting from sensor 1, so the data roughly matches readings from sensor 2.
qx * q1 ~= q2
I'd like to figure out what qx is.
ALTERNATE SOLUTION:
I was able to convert q1 into q2 frame using:
q1_in_q2_frame = [-q1i, q1k, q1j, q1]
But, I'd like to achieve this result by figuring out what qx is, because the coordinate frames are not necessarily like what I said before, they could be more arbitrary. Imagine sensor 2 always resets its frame to whatever orientation the cell phone was in when you turn it on/off, so a new qx has to be calculated.
WHAT I'VE TRIED:
I thought I could just multiply the following equation by q1' from left:
qx * q1 ~= q2
qx * q1 * q1' = q2 * q1'
qx = q2 * q1'
While the above solution gives me a correct mapping for the current values of q1 and q2, qx becomes no longer valid when I rotate the cell phone.
UPDATE:
I think I made an error in my quaternion multiplications.
Instead of qx * q1 ~= q2, I should really have: qx * q1 * qx' ~= q2
But given q1 and q2, how do I figure out qx now?