0
$\begingroup$

This question is an exact duplicate of:

I have a sensor at some arbitrary orientation (non-zero roll, yaw, pitch) given by quaternion $q_{0}$. I then pitch the sensor to orientation $q_{1}$. When I compute the relative rotation between the two as

$r = q_{1} q_{0}^{-1}$

Then I notice that the relative rotation has roll, pitch and yaw components. Why is this and how do I get a pure pitch from $r$?

$\endgroup$

marked as duplicate by Grigory M, TMM, Dan Rust, Newb, Brian Rushton Jan 2 '14 at 1:12

This question was marked as an exact duplicate of an existing question.

  • $\begingroup$ The question has been asked before but didn't have an answer. Even when this is an exact duplicate, it is the old one from same user without answer should be marked as duplicate. not this one with an answer. voted for reopen. $\endgroup$ – achille hui Jan 2 '14 at 4:04
0
$\begingroup$

If your sensor is like a needle, then the "roll" component of its orientation is irrelevant -- when you roll a needle about its axis, nothing really changes (ignoring the thread hole). If it's more like a camera, then roll does matter, and you need only hold a camera in two different orientations and try to "pitch" from one to the other to discover that you can't, in general, do it.

I'm guessing that your sensor really is more like a needle -- it's got two degrees of freedom rather than three -- and that you want to know the angle between the "before" and the "after" position (and indeed, the rotation that takes the before-direction to the after-direction. The "roll" part of the orientation-change quaternion is of no use to you.

If you're lucky, and the sensor in its unrotated state is aligned with one of the coordinate axes, like $(1, 0, 0)$, then you can write this as the quarternion $i$; after rotation by $q_1$, you can compute $q_1 i q_1^{-1}$, which is a 4-component quaternion, but its real part will be zero, so it'll have the form $xi + yj + zk$, which you should regard as the vector $v_1 = (x, y, z)$, which will be the direction-vector of the sensor. You can do the same for $q_2$. And then you can take $$ \theta = \cos^{-1}( v_1 \cdot v_2 ) $$ to be the pitch angle between the two directions.

About what direction do you want to pitch? Around the vector $v_1 \times v_2$ (or its negative...you can try one, and if it doesn't work, try the other).

You can use Rodrigues' formula to find the quaternion corresponding to this axis and angle.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.