## 2 Materials and Methods
### Motion Compensation
#### 2.2.2 Attitude Compensation  
Attitude compensation is achieved by calculating the attitude matrix in real time using the attitude angle measured by the CNS. According to the definition of attitude angle, the transformation matrix from M-system to F-system is given as  
\[C_{M}^{F}= \begin{bmatrix}\cos\alpha\cos\gamma+\sin\alpha\sin\beta\sin\gamma&\sin \alpha\cos\beta&\cos\alpha\sin\gamma-\sin\alpha\sin\beta\cos\gamma\\ \cos\alpha\sin\beta\sin\gamma-\sin\alpha\cos\gamma&\cos\beta\cos\alpha&-\sin \alpha\sin\gamma-\cos\alpha\sin\beta\cos\gamma\\ -\cos\beta\sin\gamma&\sin\beta&\cos\beta\cos\gamma\end{bmatrix} , \tag{3}\]  
where \(\alpha\), \(\beta\), and \(\gamma\) are the yaw, pitch, and roll angles observed by the INS, respectively. An azimuthal relationship between the M-system and F-system describes the attitude of the vehicle platform. Moreover, the methods to describe the azimuthal relationship between the two coordinate systems include the three-parameter method (Euler's angle method), the four-parameter method (quaternion method), and the nine-parameter method (directional cosine method) [37]. In this paper, the quaternion method is used to describe the rotational information in a three-dimensional space and solve the attitude transformation matrix. The quaternions of rotation of the M-system relative to the F-system are  
\[Q=q_{0}+q_{1}\overset{\rightharpoonup}{x}+q_{2}\overset{\rightharpoonup}{y}+q_ {3}\overset{\rightharpoonup}{z}, \tag{4}\]  
where \(q_{0}\), \(q_{1}\), \(q_{2}\), and \(q_{3}\) are real numbers, and \(\overset{\rightharpoonup}{x}\), \(\overset{\rightharpoonup}{y}\), and \(\overset{\rightharpoonup}{z}\) are mutually orthogonal unit vectors. Then, the quaternion expression of the angular velocity vector of the M-system relative to the F-system is given as  
\[\overset{\rightharpoonup}{\omega}_{M}^{F}=0+\omega_{Fx}\overset{\rightharpoonup}{x} +\omega_{Fy}\overset{\rightharpoonup}{y}+\omega_{Fz}\overset{\rightharpoonup}{z}, \tag{5}\]  
where \(\omega_{Fx}\), \(\omega_{Fy}\), and \(\omega_{Fz}\) are the angular velocity vectors along the N, E, and D axes, respectively. The real-time correction of \(Q\) is implemented using the quaternion differential equation, which corresponds to a matrix of the form  
\[ \begin{bmatrix}\dot{q}_{0}\\ \dot{q}_{1}\\ \dot{q}_{2}\\ \dot{q}_{3}\end{bmatrix} =\frac{1}{2} \begin{bmatrix}0&-\omega_{Fx}&-\omega_{Fy }&-\omega_{Fz}\\ \omega_{Fx}&0&\omega_{Fz}&-\omega_{Fy}\\ \omega_{Fy}&-\omega_{Fz}&0&\omega_{Fx}\\ \omega_{Fz}&\omega_{Fy}&-\omega_{Fx}&0\end{bmatrix}\begin{bmatrix}q_{0}\\ q_{1}\\ q_{2}\\ q_{3}\end{bmatrix} , \tag{6}\]  
Similarly, the quaternion expression of the angular velocity vector of the A-system relative to the M-system is  
\[\overset{\rightharpoonup}{\omega}_{A}^{M}=0+\omega_{Mx}\overset{\rightharpoonup}{x} +\omega_{My}\overset{\rightharpoonup}{y}+\omega_{Mz}\overset{\rightharpoonup}{z}, \tag{7}\]  
where \(\omega_{Mx}\), \(\omega_{My}\), and \(\omega_{Mz}\) are the angular velocity vectors along X, Y, and Z axes, respectively. Next, the angular velocity of the A-system relative to the F-system can be expressed as  
\[\overset{\rightharpoonup}{\omega}_{A}^{F}=\overset{\rightharpoonup}{ \omega}_{M}^{F}+\overset{\rightharpoonup}{\omega}_{A}^{M}, \tag{8}\]  
In addition, the attitude matrix in quaternion form can be expressed as  
\[C= \begin{bmatrix}q_{0}^{2}+q_{1}^{2}-q_{2}^{2}-q_{3}^{2}&2(q_{1}q_{2}-q_{0}q _{3})&2(q_{1}q_{3}+q_{0}q_{2})\\ 2(q_{1}q_{2}+q_{0}q_{3})&q_{0}^{2}+q_{1}^{2}+q_{2}^{2}-q_{3}^{2}&2(q_{2}q_{3}- q_{0}q_{1})\\ 2(q_{1}q_{3}-q_{0}q_{2})&2(q_{2}q_{3}+q_{0}q_{1})&q_{0}^{2}-q_{1}^{2}-q_{2}^{2}+ q_{3}^{2}\end{bmatrix} , \tag{9}\]  
The flowchart of the attitude compensation algorithm is shown in Figure 6. Firstly, the attitude angle measured by GPS/INS is substituted into a transformation matrix to obtain the attitude matrix of the M-system relative to the F-system. Here, the elements in the matrix are functions of yaw angle, roll angle, and pitch angle. Next, the attitude matrix is normalized by using the quaternion method.