# Integrated Magnetic Management of Stored Angular Momentum in Autonomous Attitude Control Systems
## 2 Attitude Control System
### PID Three-Axis Attitude Control  
PID three-axis attitude control is a classical control law valid for both tracking and pointing modes [30]. It is defined as:  
\[\mathbf{t}^{PID}(t)=-\mathbf{k}_{P}\,\text{sign}(\delta q_{4}(t))\,\delta \mathbf{q}_{1:3}(t)-\mathbf{k}_{D}\delta\mathbf{\omega}(t)-\mathbf{k}_{I}\int\limits _{0}^{t}\text{sign}(\delta q_{4}(\tau))\,\delta\mathbf{q}_{1:3}(\tau)\,\,d\tau, \tag{10}\]  
where \(\delta\mathbf{q}_{1:3}\) and \(\delta q_{4}\) are the vector and the scalar term of the error quaternion, respectively; and \(\mathbf{k}_{P}\), \(\mathbf{k}_{D}\), and \(\mathbf{k}_{I}\) are the PID gain matrices. These are proportional to the spacecraft's inertia matrix as:  
\[\mathbf{k}_{P}=k_{P}\,\,\mathbf{I},\quad\mathbf{k}_{D}=k_{D}\,\,\mathbf{I}, \quad\mathbf{k}_{I}=k_{I}\,\,\mathbf{I}. \tag{11}\]  
They can be simplified assuming the body reference frame aligned or quasialigned with the principal inertia axes. In this case, they are diagonal matrices containing the principal moments of inertia. Note that the term \(\text{sign}(\delta q_{4})\) is included in the control law to avoid the unwinding phenomenon, guaranteeing the shortest path to the final reference state. The control design shall guarantee stability, which is inherently ensured by the control formulation via [PERSON]'s direct method [3]. The control system design should guarantee robustness of the closed loop, and the tuning of the gains should achieve minimum stability margins. In particular, the phase margin shall be greater than \(45\,\text{deg}\) and the gain margin greater than \(6\,\text{dB}\)[31]. However, the most important design goal for the proposed method is a minimum control bandwidth, which should guarantee a fast system response, well decoupled from the integrated angular momentum management control. Specifically, the three-axis attitude control should have a bandwidth \(5\) to \(10\) times larger than the other control loop. It has been seen that these values allow a good separation between the two control actions, without having a controller that is too demanding for common spacecraft hardware capabilities. Thus, the previous design requirements impose minimum and maximum threshold values for the scalar PID gains \(k_{P}\), \(k_{D}\), and \(k_{I}\). Specifically, the PID three-axis control system was designed considering:  
\[k_{P}\geq\beta,\quad k_{D}\geq 3\,\beta,\quad k_{I}\leq\frac{1}{500}\,\beta, \tag{12}\]  
where \(\beta\) is a single tuning parameter that should be selected according to the desired control bandwidth and to the available actuation capacity. Good results were obtained for \(\beta\) values in the range \(1\times 10^{-3}\) to \(1\times 10^{-2}\). The computed PID control torque is then actuated both from the reaction wheels and from the magnetic actuators. The overall control torque level is preserved, but split between the two actuators according to the gain parameter \(k\), as described in Equation (9) and represented in Figure 2. This is to implement the integrated magnetic management of the stored angular momentum. In fact, at the same time the reaction wheels are commanded to actuate the PID controller, the final command sent to output is modified in order to maintain the stored angular momentum within predefined boundary levels. To compensate for this lack of actuation from the angular exchange actuators, the magnetic torquers are activated to achieve the same overall control. As discussed in the next section, this method is different from the classic ones where the magnetic actuators were only used to purely counteract the desaturation torque. The actuation commands for the reaction wheels are computed considering the reaction wheels configuration and the spacecraft dynamics.