## 3 Overall Algorithm Design
### Controller Design
Defuzzification: Transform fuzzy outputs into precise incremental parameter values for real-time tuning. Due to the strong dynamic coupling inherent in quadrotor systems, the control architecture is decoupled into two subsystems:  
Position Subsystem: Governs trajectory tracking via an outer-loop controller. Attitude Subsystem: Stabilizes roll, pitch, and yaw angles via an inner-loop controller. A dual-loop control strategy is implemented, where the outer position loop generates attitude references for the inner loop, ensuring coordinated motion control under actuator disturbances. In the fuzzification process, the controller inputs \(e\) and \(ec\), along with the outputs \(\Delta k_{p}\), \(\Delta k_{i}\), and \(\Delta k_{d}\), are defined as follows:  
Fuzzy sets for all variables: [Negative Small (NS), Negative Medium (NM), Negative Big (NB), Zero (Z), Positive Big (PB), Positive Medium (PM), and Positive Small (PS)]. Fuzzy input universes of discourse:  
* \(e\): [\(-3\), \(3\)];
* \(ec\): [\(-3\), \(3\)]. Figure 7: Structure diagram of UAV control based on fuzzy adaptive PID. Fuzzy output universes of discourse:  
* \(\Delta k_{p}\): [\(-\)2.5, 2.5];
* \(\Delta k_{i}\): [\(-\)0.5, 0.5];
* \(\Delta k_{d}\): [\(-\)5, 5]. Membership functions: Both input and output variables use linear membership functions. The fuzzy controller operates in a two-input-three-output configuration, where the fuzzy inputs \(e\) and \(ec\) are continuously evaluated for their membership degrees. Through fuzzy inference rules, the membership degrees of the fuzzy outputs \(\Delta k_{p}\), \(\Delta k_{i}\), and \(\Delta k_{d}\) are determined, thereby enabling real-time adjustments to the PID parameters. During the PID parameter adjustment, the impacts of parameter variations on system performance must be carefully considered:  
* \(\Delta k_{p}\) predominantly governs the system's response speed;
* \(\Delta k_{i}\) directly influences the steady-state error;
* \(\Delta k_{d}\) critically affects the dynamic performance. Different values of these parameters result in distinct effects on system error and performance. Therefore, parameter adjustments are prioritized based on the magnitude of the error \(e\). When \(e\) is large, \(k_{p}\) and \(k_{d}\) are adjusted to enhance the transient response and stabilize dynamics; when \(e\) is small, \(k_{p}\) and \(k_{d}\) are tuned to minimize steady-state deviations. Based on combinations of \(e\) and \(ec\), 49 fuzzy rules are formulated to define the corresponding adjustments for \(\Delta k_{p}\), \(\Delta k_{i}\), and \(\Delta k_{d}\), ensuring systematic parameter adaptation. Fuzzy control rules are critical in fuzzy control systems [29], typically derived from expert knowledge and empirical data synthesis [30]. The rule design heuristics are established as follows [31]: when \(\mid\!e\!\mid\) is substantially large, selecting a larger \(k_{p}\) enhances system responsiveness to rapidly mitigate tracking errors and restore stability, while concurrently adopting a smaller \(k_{d}\) attenuates the potential overshoot. Consequently, when both \(e\) and \(ec\) register as PB, \(\Delta k_{p}\) should correspondingly be PB. For moderate \(\mid\!e\!\mid\) values, medium \(\Delta k_{p}\) magnitudes are prescribed to preclude a significant overshoot while preserving an adequate dynamic response capability; thus, when \(e\) and \(ec\) are PM, \(\Delta k_{p}\) is designated PM. When \(\mid\!e\!\mid\) is comparatively small, reduced \(k_{p}\) values are mandated to suppress steady-state oscillations, yielding the assignment \(\Delta k_{p}\) = PS for \(e\) and \(ec\) in the PS domain. By applying these formulation principles, we have refined and optimized the conventional rule base. The improved fuzzy control rule matrix is presented in Table 1.