## 2 Orbital Simulator
### Spacecraft Attitude Dynamics  
The attitude dynamics is propagated using the quaternion formulation. Angular velocity in the body frame can be obtained by:  
\[\dot{\omega}_{B}=I^{-1}(M_{B}-\omega_{B}\times(I\omega_{B}+I_{\text{RW}}\omega _{\text{RW}}))\]  
where \(\dot{\omega}_{B}\in\mathbb{R}^{3}\) is the angular acceleration vector, \(I\in\mathbb{R}^{3,3}\) is the inertia tensor, \(M_{B}\in\mathbb{R}^{3}\) is the total torque acting on the spacecraft, \(\omega_{B}\in\mathbb{R}^{3}\) is the angular velocity of the spacecraft, \(I_{\text{RW}}\in\mathbb{R}^{3,3}\) is the inertia of the reaction wheels system, and \(\omega_{\text{RW}}\in\mathbb{R}^{3}\) is the angular velocity of the reaction wheels system. The total torque acting on the spacecraft is the sum of different elements  
\[M_{B}=M_{\text{thr}}+\Delta M_{\text{ex}}+M_{\text{RW}},\]  
where \(M_{\text{thr}}\in\mathbb{R}^{3}\) is the torque due to the RCS, \(\Delta M_{\text{ex}}\in\mathbb{R}^{3}\) is the torque due to external disturbances, and \(M_{\text{RW}}\in\mathbb{R}^{3}\) is the torque generated by the reaction wheels system. The torque generated by the thrusters system is obtained by  
\[M_{\text{thr}}=\sum_{i=1}^{12}r^{i}_{thr}\times F^{i},\]  
where \(r^{i}_{thr}\) is the position of the \(i^{th}\) thruster relative to the center of mass and \(F^{i}\) is defined by Equation (5). The external torque affecting the attitude dynamics of the spacecraft is mainly due to the gravity gradient torque. Other torque disturbances such as aerodynamic torque and torque due to the solar radiation have been neglected in the framework of this paper. The gravity gradient torque can beevaluated as  
\[\Delta M_{\text{ex}}=3\frac{\mu}{r^{3}}\sigma_{3}\times I\cdot\sigma_{3},\]  
where \(\mu\) is the Earth's gravitational constant, \(r\) is the magnitude of position vector of the spacecraft relative to the center of Earth and \(\sigma_{3}\) is related to the third column of the rotation matrix \(R_{LVLHD}(\phi,\theta,\psi)\). Kinematic equations in quaternion form can be expressed as  
\[q=\tfrac{1}{2}\Sigma(\omega_{B})q, \tag{6}\]  
with \(q=[q_{0},q_{2},q_{3},q_{4}]^{T}\in\mathbb{R}^{4}\) is the vector of quaternions and \(\Sigma(\omega_{B})\in\mathbb{R}^{(4,4)}\) is defined as  
\[\Sigma(\omega_{B})=\begin{bmatrix}0&-\omega_{B}^{T}\\ \omega_{B}&-\Omega\end{bmatrix} \tag{7}\]where \(\Omega\) is the skew-symmetric matrix  
\[\Omega=\begin{bmatrix}0&-\omega_{z}&\omega_{y}\\ \omega_{z}&0&-\omega_{x}\\ -\omega_{y}&\omega_{x}&0\end{bmatrix}\]  
For the quaternions, the following notation can also be used (useful for the SMC controller definition)  
\[\dot{q}=\tfrac{1}{2}\Sigma(q)\omega_{B}, \tag{8}\]  
where \(q=[q_{1}\,q_{2}\,q_{3}\,q_{4}]^{T}\in\mathbb{R}^{4}\) is the vector of quaternions and \(\Sigma(q)\mathbb{R}^{4,3}\) is the quaternion matrix, defined as  
\[\Sigma(q)=\begin{bmatrix}q_{4}I_{3}+Q_{13}\\ -q_{13}^{T}\end{bmatrix}, \tag{9}\]  
where \(q_{4}\in\mathbb{R}\) is the quaternion scalar component, \(q_{13}\in\mathbb{R}^{3}\) is the vector of the first three components of the vector \(q\) and \(Q_{13}\in\mathbb{R}^{3,3}\) is the skew-symmetric matrix  
\[Q_{13}=\begin{bmatrix}0&-q_{3}&q_{2}\\ q_{3}&0&-q_{1}\\ -q_{2}&q_{1}&0\end{bmatrix}.\]  
The attitude is propagated with respect to the Earth Centered Inertial (ECI) frame.  
As previously introduced, three reaction wheels, driven by electric motors powered by the spacecraft electrical power supply, are considered for the attitude control and they are managed and controlled by the onboard attitude control computer. A reaction wheel actuator produces a moment MRW, causing its angular momentum to increase. For the representation of a realistic model, a first order filter and a saturation on the maximum-minimum torque assigned by the RWs are also included in the actuator model.