# Methodology for CubeSat Debris Collision Avoidance Based on Its Active ADCS System
## 3 Materials and Methods
### Control Algorithm  
In this section, the fundamental control mechanism that drives the evasion maneuver in CubeSats will be detailed, focusing on the use of the reaction wheel. This essential component plays a key role in the CubeSat's ability to modify its orientation, a critical requirement for controlled ballistic coefficient change. This strategy is integrated into a holistic approach that is based on the application of the extended Kalman filter (EKF). The application of this filter allows optimizing the precision of the CubeSat state estimates, thus enabling an effective and precise evasion maneuver in the face of the threat of collisions with space debris. The CubeSat's reaction wheel control mechanism becomes the driving force of the evasion maneuver by allowing calculated changes in the satellite's orientation. This capability is exploited to modify the ballistic coefficient, thus contributing to slight adjustments in orbital height and, consequently, mitigating the risk of collisions. The entire process is managed in a coordinated manner using the EKF. In applications involving linear systems with known dynamics and Gaussian noise, the Kalman filter (KF) has become the tool par excellence. Its nonlinear counterparts, namely the EKF and the unscented Kalman filter (UKF), have found applications in real-time orientation estimation in various domains, despite their challenging implementation. In an effort to circumvent the complexities associated with the linearization procedure and the challenges posed by the EKF and UKF, this study presents a two-step filter architecture designed to mitigate noise and improve filter performance. In the first phase, the information provided by the Inertial Measurement Unit (IMU) (angular acceleration) is obtained in its quaternion form; this quaternion is then utilized as state vector in the KF, in order to determine the corresponding observation vector. With this precise value of the attitude of the spacecraft, the control law is applied to a linear quadratic regulator that implements the orientation control of the CubeSat to implement the collision avoidance maneuver. The quaternion can be defined as:  
\[Q= \begin{pmatrix}q_{0}\\ q_{1}\\ q_{2}\\ q_{3}\end{pmatrix}  \tag{2}\]  
And, therefore, the Yaw Euler angle can be found as:  
\[\varphi=\tan^{-1}\biggl{(}2\cdot\frac{(q_{0}q_{3}+q_{1}q_{2})}{1-2(q_{2}{}^{2 }+q_{3}{}^{2})}\biggr{)} \tag{3}\]  
The next step is to create the dynamic model in discrete time, rebuilding the signal using the attitude information obtained through the IMU, solving the uncertainty that comes from the noise in the measurement and the common bias that those reads come with. The dynamic equation that describes the attitude of the CubeSat can be written as:  
\[\frac{d\omega}{dt}=I^{-1}\cdot(\Delta-\omega.I.w) \tag{4}\]  
where \(\omega\) is the angular velocity, \(I\) is the velocity tensor, and \(\Delta\) is the resultant of the torques that the spacecraft is suffering, including the reaction wheel action and the perturbations. Written in quaternion form, and discretizing the previous equation, we can rewrite the equations as:  
\[I_{k+1}=I\omega_{k}+\Delta t([I\omega_{k}\mid\mathbf{x}\omega_{k}+\mathbf{ \Xi}_{t}) \tag{5}\]  
\[Q_{k+1}=\frac{Q_{t}}{2}\exp()I\omega_{k}+\Delta t([I\omega_{k}\mid\mathbf{x} \omega_{k}+\mathbf{\Xi}_{t}) \tag{6}\]And the required dynamics that the spacecraft is demanded can be written as [24]:  
\[\dot{Q}_{r}=\frac{Q_{d}}{2} \begin{pmatrix}0&w_{r}^{T}\\ \omega&-\omega\end{pmatrix}  \tag{7}\]  
We can now introduce the Quaternion Estimator to build the reconstruction of the attitude using the sensors in the IMU of the CubeSat, to provide the input for the KF.