## 4 Control System Design
### Software Design  
The core of the control system is software. The design of the software system affects the speed and precision of the levelling system [13]. The software of the control system is developed using the Arduino Integrated Development Environment (IDE) platform. The software programming is based on the C and C++ languages. The levelling algorithm is a fuzzy Proportional, Integral, Differential (PID) algorithm. The PID algorithm takes the angle error and angle error rate of the inclination sensors as the input [14], outputs the integral and differential proportion, and then looks for the appropriate value to make the angle output of the sensor more accurate. Before PID, it is necessary to obtain the inclination data in a single IMU and fuse the inclination data of the three IMUs. The Digital Motion Processor (DMP) inside the IMU can output quaternions directly, and data are converted into angle values [15]. The IMU has its own Kalman filter algorithm, which can filter the angle data, and filtering can effectively remove noise, including Quantization noise (QN), Angle random walk (ARW), Bias instability (BI), Rate random walk (RRW), and Rate ramp (RR) so that the fused angle output is more accurate. The formula for converting the angle value of the quaternion in a single IMU is as follows:  
\[\beta= \sin^{-1}\mathrm{g}^{1},\alpha= \tan^{-1}\frac{\mathrm{g}^{2}}{\mathrm{g}^{3}},\gamma= \tan^{-1}\frac{\mathrm{g}^{4}}{\mathrm{g}^{5}} \tag{12}\]  
where: \(\mathrm{g}^{1}\mathrm{g}^{2}\mathrm{g}^{3}\mathrm{g}^{4}\mathrm{g}^{5}\) is the input of \(\alpha\), \(\beta\), and \(\gamma\) angles. \(\mathrm{g}^{1}=2(\mathrm{q}1\mathrm{q}3-\mathrm{q}\mathrm{q}\mathrm{q}2)\)  
\(\mathrm{g}^{2}=2(\mathrm{q}2\mathrm{q}3+\mathrm{q}\mathrm{q}\mathrm{q}1)\)  
\(\mathrm{g}^{3}=\mathrm{q}\mathrm{q}^{2}+\mathrm{q}\mathrm{g}^{2}-\mathrm{q}2^ {2}-\mathrm{q}1^{2}\)  
\(\mathrm{g}^{4}=2(\mathrm{q}1\mathrm{q}2+\mathrm{q}\mathrm{q}\mathrm{q}3)\)  
\(\mathrm{g}^{5}=\mathrm{q}\mathrm{q}^{2}+\mathrm{q}1^{2}-\mathrm{q}2^{2}- \mathrm{q}3^{2}\)The batch estimation fusion algorithm is used to fuse the inclination values converted by the three IMUs. This algorithm can avoid a fusion result error caused by the error of multiple sensors [16]. In the levelling process of the mobile platform, two sensors detect the inclination of the \(X\)-axis, and two sensors detect the inclination of the \(Y\)-axis. They are divided into two groups for angle detection. Taking the inclination angle of the \(X\)-axis as an example, \(X_{1}\) = {x\({}_{11}\), x\({}_{12}\), x\({}_{13}\), x\({}_{14}\),..., x\({}_{\rm{In}}\)} is the inclination information detected by the 9-degree-of-freedom (DOF) inertial measurement unit (IMU), and \(X_{2}\) = {x\({}_{21}\), x\({}_{22}\), x\({}_{23}\), x\({}_{24}\),..., x\({}_{2n}\)} is the inclination information detected by the single-degree-of-freedom (DOF) inertial measurement unit (IMU). Then, the average value of the \(X_{1}\) inclination is \(\bar{X_{1}}=\frac{1}{n}\sum\limits_{\rm{i}}^{\rm{n}}x_{\rm{In}}\), the average value of the \(X_{2}\) inclination is \(\bar{X_{2}}=\frac{1}{n}\sum\limits_{\rm{j}}^{\rm{n}}x_{\rm{2n}}\), and the mean square deviation is: \(\sigma_{1}=\sqrt{\frac{1}{n-1}\sum\limits_{\rm{i=1}}^{\rm{n}}\left(x_{\rm{i1}}- \bar{X_{1}}\right)^{2}}\). and \(\sigma_{2}=\sqrt{\frac{1}{n-1}\sum\limits_{\rm{j=1}}^{\rm{n}}\left(x_{\rm{ij}} -\bar{X_{2}}\right)^{2}}\). If the mean square deviation of the previous detection information is (\(\sigma_{\cdot}\)) = \(\infty\), then (\(\sigma_{\cdot}\))\({}^{-1}\) = 0. The fusion result of the batch estimation algorithm is:  
\[