# In-Orbit Results and Attitude Analysis of the SNUGLITE CubeSatellite
## 2 Materials and Methods
### Attitude System of SNUGLITE
#### 2.3.2 Onboard Attitude Determination Algorithm  
Sensing measurements from the gyroscope, magnetometer, and coarse sun-sensors must be calibrated properly for attitude estimation. The magnetometer hard-iron and soft-iron calibration was done before shipping to the launch site. In addition, temperature, and current compensation by power generation by the solar panels were also considered for magnetometer sensing [17]. The sine curvature of the photodiodes for the coarse sun-sensors was calibrated based on experimental results [20]. For gyroscope measurements, biases at each axis were implanted in the estimation filter as states. A real-time calibration process for the biases is performed in orbit. EKF was utilized as shown in Equations (1)-(4), which represent the states of the filter:  
\[\mathbf{x}(t)=\left[ \begin{array}{cccc}\mathbf{q}&\boldsymbol{\omega}& \mathbf{b}\end{array} \right]^{T} \tag{1}\]  
\[\mathbf{q}=\left[ \begin{array}{cccc}q_{0}&q_{1}&q_{2}&q_{3}\end{array}  \right]^{T} \tag{2}\]  
\[\boldsymbol{\omega}=\left[ \begin{array}{cccc}\omega_{x}&\omega_{y}&\omega_{ z}\end{array} \right]^{T} \tag{3}\]  
\[\mathbf{b}=\left[ \begin{array}{cccc}b_{x}&b_{y}&b_{z}\end{array} \right]^{T} \tag{4}\]  
Figure 3: Block diagram of an linear quadratic Gaussian (LQG)-based attitude system. The image was reproduced with permission from [20]. where \(\mathbf{q}\) is the quaternion vector, \(\mathbf{\omega}\) is the vector of three-axis angular velocity, and \(\mathbf{b}\) is the bias vector of gyroscopes. The non-linear system equation for the estimation is expressed as Equation (5), and \(\Omega(\cdot)\) is defined as Equation (6). \[\left[ \begin{array}{c}\dot{\mathbf{q}}\\ \dot{\mathbf{\omega}}\\ \dot{\mathbf{b}}\end{array} \right]=\left[ \begin{array}{c}\frac{1}{\widetilde {1}}\Omega(\mathbf{\omega}_{\mathbf{L}\mathbf{B}}^{\mathbf{B}})\mathbf{q}\\ \widetilde{1}^{-1}\left(\mathbf{\mu}\times\mathbf{B}-\mathbf{\omega}\times(\widetilde {1}\cdot\mathbf{\omega})\right)\\ 0_{3\times 3}\end{array} \right]+\left[ \begin{array}{c}0\\ \mathbf{\eta}_{\text{drift}}\\ \mathbf{\eta}_{\text{bias}}\end{array} \right] \tag{5}\]  
\[\Omega(\mathbf{\omega})\equiv\left[ \begin{array}{cccc}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] \tag{6}\]  
where \(\mathbf{\omega}_{\mathbf{L}\mathbf{B}}^{\mathbf{B}}\) is the angular velocity of the body frame with respect to the local frame, \(\widetilde{\widetilde{1}}\) is the moment of the inertia dyadic of the SNUGLITE CubeSat, \(\mathbf{\mu}\) is the magnetorquer vector for control input, and \(\mathbf{B}\) is the strength of the local magnetic field. \(\mathbf{\eta}_{\text{drift}}\) and \(\mathbf{\eta}_{\text{bias}}\) are the process noises for the system equation. The system can be expressed as Equation (7). The process noises include various disturbances; however, they are modeled as Gaussian white noise in Equations (8) and (9). \[\dot{\mathbf{x}}(t)=f(\mathbf{x}(t),\mathbf{\mu}(t))+\mathbf{w}(t) \tag{7}\]  
\[\mathbf{w}(t)\sim N(0,Q) \tag{8}\]  
\[Q=\left[ \begin{array}{cccc}\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\left(\sigma_{\text{gg}}^{2}+\sigma_{\text{sr}}^{2}+\sigma_{\text{ ad}}^{2}+\sigma_{\text{mdt}}^{2}\right)\!\!I_{3\times 3}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\left(\sigma_{\text{rrrw}}^{2}\right)\!\!I_{3\times 3} \end{array} \right] \tag{9}\]  
where \(\sigma_{\text{gg}}\) is the process noise from the gravity gradient, \(\sigma_{\text{sr}}\) is the process noise from the solar radiation pressure, \(\sigma_{\text{ad}}\) is the process noise from the air drag, and \(\sigma_{\text{mdt}}\) is the process noise from the residual dipole moment. \(\sigma_{\text{rrrw}}\) is the rate random walk process noise. Detailed values and descriptions for the criteria related to the variance matrix \(Q\) can be found in [17]. The non-linear measurement equations are shown in Equations (10)-(14).