5
$\begingroup$

I'm looking for a way to find a specific rotation quaternion.

Hoping that I'll get the notation right (no mathematician) the basic problem looks as follows

Definitions

  • $t \in \{0,...,n\}$
  • $R(Q, \vec{v})$ is defined as some function that rotates vector $\vec{v}$ by rotation quaternion $Q$.
  • $A_t, B_t \in \mathbb{H}$ are rotation quaternions.
  • $\forall{\left(\vec{a_t},\vec{b_t},\vec{c_t},\vec{d_t}\right)}\in \mathbb{R}^3$

Assumptions and prior knowledge

$\forall{t} \in \{0,...,n\}$:

  • $|\vec{a_t}| = |\vec{b_t}| = |\vec{c_t}| = |\vec{d_t}| = 1$
  • //edit: WRONG! $A_t \widehat{=} B_t$ within their respective frames of reference, irregardless of sensory noise (I'm not sure about this but the underlying physical motion is the same) WRONG!
  • Correction: the angles of the rotations $A$ and $B$ are equal.

Situation

I measure two variables with sensory noise:

  1. $\vec{a_t} \in \mathbb{R}^3$ as a vector in a known reference frame $K$
  2. $B_t \in \mathbb{H}$ as an orientation in an unknown reference frame $L$

From $\vec{a_t}$ I can calculate a rotation quaternion $A$ (two actually) that represents that vector as a rotation from a given canonical unit vector, e.g., $\vec{a_0} = \left[1, 0, 0\right]$. The rotation would then be $\vec{a_t} = R(A, a_0)$. $A$ has a fixed reference frame, let's call it $K$.

Rotation $B$ comes directly from a sensor (inertial measurement unit, IMU). Like $A$ it also has a fixed reference frame, let's call it $L$. Unfortunately I don't know this reference frame - that's what I'm pretty much trying to figure out from a set of measurements.

Some background

The observation of rotation $A$ appears at a rather low frequency (about 2 to 3Hz) whereas the observation of rotation $B$ appears way more frequently (about 100Hz).

It is known that the locations of the reference frames $K$ and $L$ in a superordinated, fixed, common reference frame $M$ are equal. Unfortunately, that doesn't hold for the orientation of $L$ in $M$.

Problem

I need to, maybe iteratively (based on the recurring observations), find a quaternion $C \in \mathbb{H}$ that represents the rotation of the reference frame $L$ in $M$ so that I can translate observations of $B$ and vectors based on that like $\vec{b_t} = R(B, \vec{b_0})$ where $\vec{b_0} = \left[1, 0, 0\right]$ in $L$ (/edit: not in $M$) to $K$.

Questions

  1. Am I right that it is impossible to find the quaternion $C$ from just a single set of observations $\vec{a_0}$ and $B_0$?
  2. How can I get from the observations of $\vec{a_t}$ and $B_t$ to a robust rotation quaternion $C$?

Update 1:

Seems like it's an optimization problem. I have have the absolute orientation $A$, the measured orientation $B$, the calculated orientation $\hat{A} = B\cdot C^{-1}$ (I think) and thus an error $A_{err} = E(\hat{A}, A)$ where $E(U, V)$ with $U, V \in \mathbb{H}$ is some loss function which I have to minimize.

Do you know of any loss function that can be minimized, and do you know of any optimizer that can minimize that function online, like, based on subsequent observations (like SGD), essentially providing the $C$ that makes $\hat{A} \approx A$?

Update 2:

I've got a working approach. At least to some extent. I perform the following steps:

  1. Calculate a quaternion $E_t = A_t^{-1} \cdot B_t$ that describes the rotation error between $A_t$ and $B_t$.
  2. Turn $E_t$ into axis/angle notation as $\{E_{t;axis}, E{t;angle}\}$
  3. Make new axis/angle rotation $F_{t;axis} = E_{t;axis}$, $F_{t;angle} = \alpha E_{t;angle}$ where $\alpha$ is some "learning rate" (in my case $\alpha = 0.05$)
  4. Rotate currently assumed reference frame by quaternion $F_t$: $C_t = $C_{t-1} * F_t
  5. repeat with each measurement

After some time $B_t = A_t^{-1} \cdot C_t$ converges to $A_t$.

Remaining issues

Sometimes $C_t$ seems to drift away, starting to oscillate. Probably I'm running into some kind of gimbal lock here when $A_t$ and $B_t$ are exactly perpendicular. I'll have to further examine this behavior.

Does anyone around here have any further advice, maybe?

Update 3

Okay, I'm stuck... I think I've got two possible paths to follow, maybe even both at once.

  1. try to minimize the error by incorporating the motion itself, like, creating some additional error quaternion that describes how the IMU rotation behaves compared to the measured absolute rotation of the limb.
  2. try to incorporate the gravitational vector that always has to point into one direction.

The first might help but I haven't figured out how to create that quaternion yet. The second might also help but there's still one unknown axis: the axis along the gravitational vector, or yaw, or heading.

There has to be a way to use all the given information, i.e.

  • the error between momentarily measured absolute rotation of the limb (which is still missing supination/pronation axis of the lower arm for instance) and the limb in the IMU frame - called $A_t$ and $B_t$ above.
  • the error between motion of the measured limb and the limb in the IMU frame (still, supination/pronation may be an issue)
  • the error between the absolute gravity vector (-z) and the measured gravity vector from the IMU, transformed into the IMU reference frame

Update 4

Okay, I think I've found an approach for a solution. However I still need help solving the equation.

Since I have two sets of vectors in their respective reference frames ($\vec{a_t}$, $\vec{b_t}$ and two gravitation vectors, one global and one in the ref frame of the IMU) I think I can come up with an equation system like

$V_{b_t} = C^{-1}\cdot V_{a_t}\cdot C$

$V_{\hat{g}_t} = C^{-1}\cdot V_{g_t} \cdot C$

where $V_{u_t} = \left<0; u_{t;x}; u_{t;y}; u_{t;z}\right>$ is the corresponding vector in quaternion form.

The question is, is it possible to, and if it is, how do I solve this set of equations for $C$?

$\endgroup$
  • 1
    $\begingroup$ Welcome to MSE. Nice first question! $\endgroup$ – José Carlos Santos Nov 15 '17 at 16:24
  • $\begingroup$ Thank you very much. :-) $\endgroup$ – Hendrik Wiese Nov 15 '17 at 16:40
  • $\begingroup$ I had to correct some things. First of all $A_t$ and $B_t$ are not equal in their reference frames. That's the problem, actually. $B$ in $L$ is rotated by $C^{-1}$ with respect to $A$ in $K$. Secondly, $b_0$ is not [1, 0, 0] in $M$ but in $L$. Sorry for the confusion. Thinking in multiple iterations of coordinate transformations is really messing with my brain... $\endgroup$ – Hendrik Wiese Nov 15 '17 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.