Setting home orientation of quaternion/euler angles

72 Views Asked by At

Background I have a physical device with an IMU that emits a quaternion of it's current orientation. I refer to euler angles / quaternions interchangeably in my question.

Question Regardless of the physical orientation of the device, I want a 'home' functionality which will set the current orientation to be (0,0,0) in euler angles. After homing, a rotation of 90° (or any other angle in yaw/pitch/roll) should be relative to the homing orientation, rather than the device absolute orientation.

Attempts My current attempt at this involves storing the orientation at the time of 'homing', and then removing that rotation for future values received. More concretely that looks like:

  • $R$ is the last raw orientation emitted by the physical device
  • $H$ is the rotation that should be applied to the raw quaternion to 'home' it
  • $C$ is $R$ after it is been homed / calibrated with $H$

At the time of 'homing', perform $H=\bar{R}$. Since $R$ is normalized I should be able to use the conjugate rather than the inverse. For future quaternions emitted from the IMU perform $C=H*R$ to rotate the raw quaternion by the homing value.

With this approach the initial 'home' functionality works (sets the orientation at that time to (0,0,0)), but future rotations are still relative to the absolute orientation rather than the homed orientation (they just start from (0,0,0) now). As an example, with this approach, after homing the device a change in only the pitch (in terms of the newly defined home axis) will not necessarily change the pitch of the homed quaternion (it may change another axis, or change multiple axis).