# Why do we use "error quaternions" for control of attitude?

I'm working on an attitude control system in terms of quaternions, and i'm basing my approach on the book Space Vehicle Dynamics and Control (2nd ed.). If we consider a proportionate controller, i.e.

$$\mathbf{u} = -\mathbf{K}_p \mathbf{q}_e$$

it would seem logical to me to define the error quaternions to be the first three elements of

$$\begin{bmatrix} q_{1e} \\ q_{2e} \\ q_{3e} \\ q_{4e} \\ \end{bmatrix} = \begin{bmatrix} q_{1} \\ q_{2} \\ q_{3} \\ q_{4} \\ \end{bmatrix} - \begin{bmatrix} q_{1c} \\ q_{2c} \\ q_{3c} \\ q_{4c} \\ \end{bmatrix}$$

Where $$q_i$$ are the actual quaternions and $$q_c$$ are the desired (commanded) quaternions. Yet in the book, they instead define

$$\begin{bmatrix} q_{1e} \\ q_{2e} \\ q_{3e} \\ q_{4e} \\ \end{bmatrix} = \begin{bmatrix} q_{4c} & q_{3c} & -q_{2c} & -q_{1c} \\ -q_{3c} & q_{4c} & q_{1c} & -q_{2c} \\ q_{2c} & -q_{1c} & q_{4c} & -q_{3c} \\ q_{1c} & q_{2c} & q_{3c} & q_{4c}\\ \end{bmatrix}\begin{bmatrix} q_{1} \\ q_{2} \\ q_{3} \\ q_{4} \\ \end{bmatrix}$$

To me it seems like we do this because there are multiple possible quaternions that correspond to the same orientation, but I have not yet found a clear explanation for this. Can anyone enlighten me?

• Page back in the book a bit to check the math, or do some cyphering. As used in navigation, quaternions define rotations, and rotation is carried out by multiplying them together. So I would expect that $q_e$ would be the solution to either $q_i q_e$ = $q_c$, or $q_e q_i$ = $q_c$. If so, the matrix math is just how the actual numerical solution is calculated. Commented Apr 5, 2021 at 15:45
• One reason : With Quaternions you can never get in gimbal lock.
– Ben
Commented Apr 9, 2021 at 14:18