## 2 ADCS System Model
### Attitude and Orbit Dynamics
Subsequently, the attitude kinematic differential equation for the CubeSat is given by the following:  
\[\dot{q}_{\
u} =\frac{1}{2}\mathbf{\omega}_{\mathcal{B}/\mathcal{N}}q_{4}+\frac{1}{2 }\mathbf{q}_{\
u}\times\mathbf{\omega}_{\mathcal{B}/\mathcal{N}} \tag{2}\] \[\dot{q}_{4} =-\frac{1}{2}\mathbf{\omega}_{\mathcal{B}/\mathcal{N}}^{T}\mathbf{q}_{\
u}\]  
where the DCM matrix associated with \(\mathbf{q}\) is \([BN]\). Regarding angular velocity dynamics, the general equations of motion of a satellite equipped with magnetorquers are given by the following:  
\[[I]\dot{\mathbf{\omega}}_{\mathcal{B}/\mathcal{N}}=-\mathbf{\omega}_{\mathcal{B}/ \mathcal{N}}\times[I]\mathbf{\omega}_{\mathcal{B}/\mathcal{N}}+\mathbf{L}_{u}+\mathbf{L} _{\mathbf{d}} \tag{3}\]  
where \(\mathbf{L}_{u}\) is the torque control generated by the magnetorquers. Further, all these vectors and the inertia tensor \([I]\) are expressed in the body frame \(\mathcal{B}\). Assuming the nanosatellite is equipped with three magnetorquers and defining \([M]= \begin{bmatrix}\dot{\mathbf{m}}_{1}&\dot{\mathbf{m}}_{2}&\dot{\mathbf{m}}_{3}\end{bmatrix} \) where each one represents the unit vector direction for each coil,  
\[\mathbf{L}_{u}=-[\bar{\mathbf{B}}_{\text{earth}}][M] \begin{bmatrix}\mu_{1}\\ \mu_{2}\\ \mu_{3}\end{bmatrix}  \tag{4}\]  
where \(\mu_{i}\) is the strength of the magnetic dipole torque coil. The magnetorquers proposed for integration within the nanosatellite design are intended to feature a circuit arrangement comprising four layers of internally reconfigurable coils. This design allows for flexible operational configurations, wherein each magnetorquer can be adjusted into parallel, series,or mixed arrays to accommodate specific mission requirements. The resultant magnetic dipole moment of each magnetorquer is described by the following equation:  
\[\mu_{i}=n_{i}A_{i}I_{i} \tag{5}\]  
where \(n\) stands for the number of turns within a single coil corresponding to each row in the array, \(A\) represents the coil's area on the printed circuit board (PCB), and \(i\) denotes the current flowing through the coil. This configuration offers adaptability and current control when establishing the real dipole moment for the satellite's orientation, thereby facilitating mission success with optimal efficiency. Nonetheless, the disturbance torque can be modeled as follows:  
\[\mathbf{L}_{d}=\mathbf{L}_{GG}+\mathbf{L}_{zero}+\mathbf{L}_{mag} \tag{6}\]  
where \(\mathbf{L}_{GG}\) is the gravity gradient torque, \(\mathbf{L}_{zero}\) is the aerodynamic torque, and \(\mathbf{L}_{mag}\) is the magnetic torque. All aforementioned disturbance torques are expressed in the body frame \(\mathcal{B}\). Notice that, in LEO, the effect of the solar pressure is at least one order of magnitude smaller than the other phenomena, while the aerodynamic drag increases. In addition, to introduce a representative disturbance of disturbance torque, its maximum value is approximated in the next sections, and the resulting torque is introduced into the model as a Gaussian random vector with a sample time of \(T_{s}\), such that \(\mathbf{L}\{d-\max\}\sim\mathcal{N}(\mathbf{0},\sigma_{\omega}^{2}I_{3\times 3})\); the standard deviation \(\sigma_{\omega}=T_{s}L_{d-max}I_{min}^{-1}\) where \(I_{min}\) is the minimum value of the diagonal of the inertia tensor [25]. Notice that an analytical value for \(\mathbf{L}_{GG}\), \(\mathbf{L}_{zero}\), and \(\mathbf{L}_{mag}\) could be approximated for each one; however, this goes beyond the scope of this work. Gravity Gradient Torque. The interaction of the forces of gravity and the CubeSat body is different in each part of the body, so a gravity gradient is produced as an effect of this difference along the body, around its center of mass.