# UAV Attitude Angle Measurement Method Based on Magnetometer-Satellite Positioning System
## 2 Measurement Principle and Error Analysis  
### Principle of Measurement of Attitude Angle Information by the Magnetometer and Satellite System  
The basic principle of using a magnetometer and satellite data to measure the attitude angle of a UAV is as follows. The three-axis magnetometer and UAV body are installed by strapdown inertial navigation, and the direction of the sensitive axis of the magnetometer is the same as that of the body coordinate system. During the flight, the magnetometer measures geomagnetic data in real-time. The relationship matrix between the magnetometer measurement data, geomagnetic data, and body attitude angle is:  
\[\begin{bmatrix}h_{bx}\\ h_{by}\\ h_{bz}\end{bmatrix} = \begin{bmatrix}\cos\theta\cos\psi&\cos\theta\sin\psi&-\sin\theta \\ -\cos\gamma\sin\psi+\sin\gamma\sin\theta\cos\psi&\cos\gamma\cos\psi+\sin\gamma \sin\theta\sin\psi&\sin\gamma\cos\theta\\ \sin\gamma\sin\psi+\cos\gamma\sin\theta\cos\psi&-\sin\gamma\cos\psi+\cos\gamma \sin\theta\sin\psi&\cos\gamma\cos\theta\end{bmatrix}\begin{bmatrix}h_{nx}\\ h_{ny}\\ h_{nz}\end{bmatrix} \tag{1}\]  
where \(h_{nx},h_{ny},h_{nz}\) are the geomagnetic components in the navigation coordinate system; \(h_{bx},h_{by},h_{bz}\) are the projection components of the geomagnetic vector in the body coordinate system; and \(\psi,\theta,\gamma\) are the yaw angle, pitch angle, and roll angle, respectively, in the navigation coordinate system.  
According to Equation (1), the attitude angle of the body can be obtained using numerous feasible solutions, which cannot meet measurement requirements in engineering practice. Therefore, the fusion of satellite measurement data is required to measure the UAV attitude angle.  
In the actual stable flight of a UAV, the angle of attack and angle of sideslip are both relatively small. Therefore, in the body coordinate and speed coordinate systems, the following relationship is satisfied:  
\[\begin{array}{l}\theta\approx\alpha+\theta_{v}\\ \psi\approx\beta+\psi_{v}\end{array} \tag{2}\]  
where \(\alpha\) and \(\beta\) are the angles of attack and sideslip, respectively, and \(\theta_{v}\) and \(\psi_{v}\) are the pitch angle and sideslip angle of the body, respectively.  
Satellite measurement equipment can measure the longitude, latitude, altitude, and speed of the position of a UAV in real-time. In the speed and navigation coordinate system, the pitch and sideslip angles of the body can be obtained using the speed information provided by the measuring equipment, as shown in the following equation:  
\[\begin{array}{l}\theta_{v}=\arctan(v_{z}/\sqrt{v_{x}^{2}+v_{y}^{2}})\\ \psi_{v}=\arctan(v_{y}/v_{x})\end{array} \tag{3}\]  
where \(v_{x},v_{y},v_{z}\) are the northward, eastward, and ground speed, respectively.  
As the flight angle of attack is small, the pitch and sideslip angles of the body can be approximated as the measurement data of the pitch and yaw angles, respectively.  
For low-spin application scenarios, when the yaw angle and pitch angle are known, the value of the roll angle can be uniquely determined using Equation (1):  
\[\gamma=\arctan\left(\frac{nl_{by}-mh_{bz}}{mh_{by}+nh_{bz}}\right) \tag{4}\]  
where:  
\[\begin{array}{l}m=-\sin\psi h_{nx}+\cos\psi h_{ny}\\ n=\cos\psi\sin\theta h_{nx}+\sin\psi\sin\theta h_{ny}+\cos\theta h_{nz}\end{array}\]