For measuring the position of a mobile device in 3D space, I utilize two sensors with different characteristics that measure device orientation.
Sensor A (a combined sensor of accelerometers, a compass and a gyroscope) does a great job of estimating the device orientation, but is subject to compass drift. Therefore, the rotation measured drifts around the axis pointing down to the earths core. Notice the gap in the image where the sensor "jumped" to balance previous drift.
Sensor B (a camera with feature extraction and motion estimation) is capable of detecting rotations around the gravity axis very well, but is prone to incremental errors, since all measured rotations are relative and have to be added to gain an absolute value. Notice the incremental error around the axis pointing away from the camera in the image below.
However, for motions around the gravity axis, the results of B are still preferable over A. For the other axis, taking the measurements of A would be better.
I'm familiar with the concepts of Kalman filters for data fusion. What boggles my mind however, is that I would like to weight different rotational components of the given sensors differently when combining the data.
What mathematical approaches to represent the rotations could I use for an elegant solution?
What I've considered
Representing the rotations as Euler angles might be difficult, since Euler angles are aligned with the coordinate system. This works fine as long as I hold the device even, but no longer for complex movements.
Representing the rotations as Matrices or Quaternions is also not useful, since the rotation is represented in a way where it is not possible to access or modify single components.
Please leave a comment if those considerations seem wrong.