# Combining 2 quaternion derivates

The quaternion derivate from the quaternion kinematics is:

$${^G_L}{{\dot{q}}}_k =\frac{1}{2}{^G_L}{{q}}_{k-1}\otimes {^L}{{\omega}}_{q,k}$$

With G = Global frame and L = Local frame. $q$ is the quaternion and $\omega_q=[0,\omega_x,\omega_y,\omega_z]$ the pure quaternion containing angular rates. $k$ is the time step.

In my application I have 3 frames. Body (B), Vehicle (V) and Global (G). The body is inside of the moving vehicle. And I'm using inertial sensors, so everything I measure is in respect to the global (world) frame.

What I'm trying to get is the quaternion derivate of the body (B) relative to the vehicle (V). So I would assume it is correct to look for the derivate describing $B\rightarrow G$ "minus" (division/conjugate) the derivate describing $V\rightarrow G$ like so:

$${^V_B}{{\dot{q}}}_k = {^V_G}{{\dot{q}}}_k \otimes {^G_B}{{\dot{q}}}_k\\ = {^G_V}{{\dot{q}}}_k^* \otimes {^G_B}{{\dot{q}}}_k \\ =\left(\frac{1}{2}{^G_V}{{q}}_{k-1}\otimes {^V}{{\omega}}_{q,k}\right)^*\otimes \left(\frac{1}{2}{^G_B}{{q}}_{k-1}\otimes {^B}{{\omega}}_{q,k}\right)\\ =\frac{1}{2}{^V}{{\omega}}_{q,k}^*\otimes{^G_V}{{q}}_{k-1}^*\otimes \frac{1}{2}{^G_B}{{q}}_{k-1}\otimes {^B}{{\omega}}_{q,k}\\ =-\frac{1}{2}{^V}{{\omega}}_{q,k}\otimes{^V_G}{{q}}_{k-1}\otimes \frac{1}{2}{^G_B}{{q}}_{k-1}\otimes {^B}{{\omega}}_{q,k}\\ =-\frac{1}{4}{^V}{{\omega}}_{q,k}\otimes\underbrace{{^V_G}{{q}}_{k-1}\otimes {^G_B}{{q}}_{k-1}}_{{^V_B}q}\otimes {^B}{{\omega}}_{q,k}$$ Finally - using my own words - what I would get is the angular rate of the body frame expressed in the vehicle frame, followed by the inverse rotation of the vehicle. Like so:

$${^V_B}{{\dot{q}}}_k =-\frac{1}{4}{^V}{{\omega}}_{q,k}\otimes{^V_B}q_{k-1}\otimes {^B}{{\omega}}_{q,k}$$

Would this be correct?

Background: In the bigger picture this is part of a single complementary filter that takes the inputs from both sensors. Currently I'm using 2 filters, calculating separate rotations and dividing the outputs. Obviously using 1 single filter would be more elegant ;)