# Integrated Magnetic Management of Stored Angular Momentum in Autonomous Attitude Control Systems
## 2 Attitude Control System
### System Architecture  
The attitude control system is intended to receive as input the estimated attitude quaternion from the determination block, \(\mathbf{\ddot{q}}(t)\), and the reference attitude quaternion to be chased, \(\tilde{\mathbf{q}}(t)\), computed by the guidance functions. The control action is then computed on the error quaternion, which is defined as [29]:  
\[\delta\mathbf{q}(t)=\tilde{\mathbf{q}}(t)\times\tilde{\mathbf{q}}^{-1}(t). \tag{7}\]  
Note that the proposed architecture does not need any assumption on the time evolution of the reference attitude state, and the present discussion is valid for both pointing and tracking attitude control. The implementation of PID attitude control also requires the definition of the error angular velocity as:  
\[\delta\mathbf{\omega}(t)=\tilde{\mathbf{\omega}}(t)-\tilde{\mathbf{\omega}}(t), \tag{8}\]  
where the estimated angular velocity, \(\tilde{\mathbf{\omega}}(t)\), is computed by the attitude determination functions or directly retrieved from a gyroscopic sensing unit; the reference angular velocity, \(\tilde{\mathbf{\omega}}(t)\), is calculated in the attitude guidance block, and it shall be coherent with the desired time variation in the reference quaternion. Finally, to correctly manage the stored angular momentum, the system shall also receive as input the angular speed of each reaction wheel, \(\omega_{R_{i}}\), and the best estimate of the surrounding geomagnetic field, \(\tilde{\mathbf{B}}\), expressed in the body frame. Thus, the system is equipped with rotary encoders on the reaction wheels and with magnetometers or alternative magnetic field estimation functions.  
The integrated attitude control torque is a combination of two independent contributions:  
\[\mathbf{t}_{\mathrm{C}}=(1-k)\,\mathbf{t}_{\mathrm{R}}^{PID}+k\,\mathbf{t}_{ \mathrm{M}}^{PID}+\mathbf{t}_{\mathrm{R}}^{DES}, \tag{9}\]  
where \(\mathbf{t}_{\mathrm{R}}^{PID}\) and \(\mathbf{t}_{\mathrm{M}}^{PID}\) are the three-axis attitude control PID torques actuated by the reaction wheels and by the magnetic torquers, respectively; \(\mathbf{t}_{\mathrm{R}}^{DES}\) is the integrated desaturation torque commanded to the reaction wheels, which is defined to be compatible with the instantaneous magnetic controllability, as will be discussed in the dedicated section. The gain parameter \(k\in[0,1]\) is used to tune the relative intensity of the two integrated control actions. This parameter is used to properly scale the torque levels sent to the reaction wheels and to the magnetic torquers to properly adjust them according to the torque performance of the actuators. Note that the proposed integrated attitude control system needs to have the combined action of both magnetic torquers and reaction wheels. Thus, the parameter \(k\) must be different from 0 and 1. The best results in terms of balanced control subdivision between reaction wheels and magnetic torquers are obtained with a \(k\) value in the order of 5% to 25% (i.e., \(k=0.05\) to \(k=0.25\)) for typical spacecraft actuators. As a general tuning suggestion, the magnetic torquers should not generate torques greater than 50% of their maximum torque capacity during steady-state nominal operations, and they should reach torque saturation only at the maximum contingency. These design guidelines are derived from testing activities and analyses performed on different spacecraft systems. They should be used as preliminary suggestions to start the control design, which should then be customized on the specific system under consideration.  
The control torques are finally converted in the actuation commands to be sent to the actuators. Thus, the desired torque is applied to each individual reaction wheel, and the magnetic dipole moment is generated by each magnetic torquer. The architecture of the proposed attitude control system is reported in Figure 2.  
Figure 2: Attitude control system architecture scheme.