Quaternion derivation and integration for attitude representation in common simulators

25 Views Asked by At

I have been checking the derivation and integration of quaternions to implement in my simple drone simulator. The problem is that I'm not sure if I can use a simplification for my case or not. The correct quaternion formula is:

${\sf q}_{t+1}=\left[\cos\left(\frac{\|\omega\||\Delta t}{2}\right)\mathrm{I}_{4}+\frac{1}{\|\omega\|}\sin\left(\frac{\|\omega\||\Delta t}{2}\right)\Omega(\omega)\right]\mathrm{q}_{t}$

being $\omega$ the angular velocity in body, $\Delta t$ the timestep of the simulator, $q_t$ the quaternion at time $t$, and $\Omega = \left[\begin{array}{c c c c}{{0}}&{{-\omega_{x}}}&{{-\omega_{y}}}&{{-\omega_{z}}}\\ {{\omega_{x}}}&{{0}}&{{\omega_{z}}}&{{-\omega_{y}}}\\ {{\omega_{y}}}&{{-\omega_{z}}}&{{0}}&{{\omega_{x}}}\\ {{\omega_{z}}}&{{\omega_{y}}}&{{-\omega_{x}}}&0\\ \end{array}\right]$

And if we simplify making $\dot\omega\sim 0$ and $\Delta t$ is small enough,

${\bf q}_{t+1}=\left[{\bf I}_{4}+\frac{1}{2}\Omega(\omega)\Delta t\right]\mathrm{q}_{t}$

This last expression is a lot simpler for my case, but I'm not sure if I "can" use this approximation. How do you usually evaluate if it is close enough in a simulator context? I'm guessing that for common simulators like pybullet, drake, etc. they always use the not approximated one?

Also, if I use RK4 integration instead of Euler could I improve the difference due to $\Delta t$ being smaller and consequentially $\dot \omega$ too?

Formulas mostly obtained in https://ahrs.readthedocs.io/en/latest/filters/angular.html