# 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
\[\mathbf{z}(t)=h(\mathbf{x}(t))+\mathbf{v}(t) \tag{10}\]  
\[\mathbf{z}(t)=\left[ \begin{array}{cc}\mathbf{B}_{\text{meas}}&\mathbf{s}_{ \text{meas}}&\mathbf{\omega}_{\text{meas}}\end{array} \right]^{T} \tag{11}\]  
\[h(\mathbf{x}(t))=\left[ \begin{array}{cc}R_{\text{local}}^{\text{body}}{}_{ \text{FCI}}^{\text{local}}{}_{\text{ECEF}}^{\text{I}}{}_{\text{ECEF}}^{\text{ RECEF}}{}_{\text{NED}}^{\text{BF}}{}_{\text{BCRF}}\\ R_{\text{local}}^{\text{body}}{}_{\text{FCI}}^{\text{local}}{}_{\text{DE405}}^{ \text{RCD}}\\ \mathbf{\omega}+\mathbf{b}\end{array} \right] \tag{12}\]  
\[\mathbf{v}(t)\sim N(0,R) \tag{13}\]  
\[R=\left[ \begin{array}{cccc}\sigma_{\text{mag}}^{2}/|\mathbf{B}_{\text{IGRF}} |^{2}I_{3\times 3}&\overline{0}&\overline{0}\\ \overline{0}&\sigma_{\text{sur}}^{2}I_{3\times 3}&\overline{0}\\ \overline{0}&\overline{0}&\sigma_{\text{arw}}^{2}I_{3\times 3}\end{array} \right] \tag{14}\]  
where \(\mathbf{z}\) is the measurement state vector, \(\mathbf{B}_{\text{meas}}\) is the measurement vector of the 3-axis magnetometer, \(\mathbf{s}_{\text{meas}}\) is the coarse sun-sensor vector, and \(\mathbf{\omega}_{\text{meas}}\) is the vector measured by the 3-axis gyroscope. \(R_{\alpha}^{\beta}\) is the rotation matrix from the \(\alpha\)-frame to the \(\beta\)-frame. \(\mathbf{B}_{\text{IGRF}}\) is the local magnetic field based on the IGRF-12 model, and \(\mathbf{s}_{\text{DE405}}\) is the sun vector calculated from the DE405 model. The satellite position utilized for IGRF and DE405 is calculated based on information given by the on-board GPS receiver. The variance matrix for \(R\) is formed as Equation (14) considering Gaussian white noise. In Equation (14),\(\sigma_{\text{sun}}\) and \(\sigma_{\text{arw}}\) are the sun sensor measurement noise and angular random walk measurement noise, respectively. The setting values for matrix R are described in [17]. Using Equations (7) and (10), the linearized system equations for the EKF can be described by Equations (15) and (16), and the measurement equations for the EKF can be described by Equations (17) and (18), respectively. \[\dot{\mathbf{x}}=F\mathbf{x}+G\mathbf{u}+\Gamma\mathbf{w} \tag{15}\]  
\[\mathbf{w}(t)\sim N(0,Q) \tag{16}\]  
\[\mathbf{z}=H\mathbf{x}+\mathbf{v} \tag{17}\]  
\[\mathbf{v}(t)\sim N(0,R) \tag{18}\]  
where \(F\) and \(G\) in Equation (15) are partial derivatives of \(f(\mathbf{x}(t),\,\mathbf{\mu}(t))\) with respect to \(\mathbf{x}\) and \(\mathbf{u}\), respectively. \(\Gamma\) is a partial derivative of \(\mathbf{w}\) with respect to \(\mathbf{\eta}\). \(H\) in Equation (17) is a partial derivative of \(h(\mathbf{x})\) with respect to \(\mathbf{x}\). The continuous EKF is discretized using the first-order Van-Loan algorithm, as described in [21], to consider the processing capacity of the onboard computer. When the magnetorquers are in operation, the magnetometer vector in Equation (11) is excluded during measurement update because the magnetorquer influences the measurements of the magnetic sensor. Similarly, the sun sensor vector in Equation (11) is also excluded during measurement update in the eclipse area. Further descriptions of how the EKF was developed and calculated may be found in [22].