Skip to Content
EngEng
  • Article
  • Open Access

8 September 2026

19 Pages

Adaptive Neural PID Outer-Loop Control for Quadcopter UAVs with Asymmetric Saturation

,
and
Centro Universitario de Ciencias Exactas e Ingenierías, Universidad de Guadalajara, 1421 Marcelino García Barragán Blvd., Guadalajara 44430, Jalisco, Mexico
*
Author to whom correspondence should be addressed.
This article belongs to the Section Electrical and Electronic Engineering

Abstract

This paper presents an adaptive outer-loop neural PID control scheme with asymmetric saturation and clamping anti-windup for a quadcopter drone, using online training based on the Extended Kalman Filter. This proposal mitigates the effects of actuator saturation and maintains operational feasibility under physical constraints. Multirotors possess distinct aerodynamic capacities, requiring continuous thrust for vertical gravity compensation versus tilt-induced forces for horizontal translation. Therefore, the proposed framework incorporates coupled asymmetric saturation limits to prevent directional vector distortion alongside a clamping-based anti-windup mechanism and dynamic tuning for controller gains.

1. Introduction

1.1. Motivation and Context

The field of unmanned aerial vehicles (UAVs) has experienced a decade of sustained growth driven by advances in propulsion, sensor miniaturization, and lightweight materials [1]. This technological progress has significantly expanded the operational scope of multirotors in critical areas such as public safety, environmental monitoring, industrial inspection, and precision agriculture, to mention a few applications [1,2].
Among the various UAV configurations [3], the quadcopter stands out due to its Vertical Take-Off and Landing (VTOL) capability, high maneuverability, and stable hover characteristics [1]. This set of distinct features makes the aircraft exceptionally versatile for operations in both confined indoor spaces and complex outdoor environments [4].

1.2. Problem Formulation and Limitations of Existing Methods

The design of effective control strategies for quadcopters poses significant challenges arising from their inherently nonlinear, unstable and underactuated nature [3]. This spatial movement is governed by complex dynamics where a combination of parametric uncertainty and high susceptibility to disturbances, such as wind gusts, severely compromise operational precision [5]. Consequently, the development of control methods that ensure stability and robustness remains a central objective in aerial robotics [5].
Historically, the literature has widely proposed solutions based on linear control frameworks [5], the proportional–integral–derivative (PID) controller being the most prevalent strategy due to its balance between simplicity and practical performance [6]. Each advanced alternative method, such as the Linear Quadratic Regulator (LQR) [7], Linear Model Predictive Control (LMPC) [8], or the H ∞ control [7], has also been thoroughly documented. Nevertheless, the effectiveness of such strategies is fundamentally constrained to a local linear operating region [9], thereby inherently degrading performance during aggressive maneuvers outside the nominal equilibrium point, which is typically defined by the hovering state [10].
To overcome such limitations, research has evolved toward nonlinear control strategies [9], including Backstepping, Sliding Mode Control (SMC), and Model Predictive Control (MPC) [9]. Although these approaches exhibit superior robustness against perturbations [9], their practical implementation is typically conditioned on an exact mathematical model of vehicle dynamics and expensive parameter identification procedures [5]. This dependency substantially increases the computational cost, frequently exceeding the real-time processing capabilities of resource-constrained embedded flight computers [5].
Within this context, intelligent control strategies based on artificial neural networks (ANNs) provide a practical alternative by learning complex nonlinear mappings and adapting to changing flight conditions without an exact a priori mathematical model [11,12]. Previous research has successfully applied neural and fuzzy adaptive structures, such as radial basis function (RBF) networks and single-neuron PID architectures, to compensate for unmodeled dynamics, aerodynamic uncertainties, and external disturbances [13,14,15]. Recent studies have also introduced fuzzy wavelet fault-tolerant control [16] and distributed prescribed-time formation control [17] with guaranteed convergence. However, a major limitation in most intelligent control literature is the assumption of direct torque and full access to low-level routines [16,17]. This assumption does not hold for standard commercial and industrial UAVs [18]. Proprietary systems (such as DJI platforms) and industrial open-source flight management units (such as Pixhawk/NXP hardware running PX4 or ArduPilot) encapsulate inner-loop attitude and motor mixing dynamics inside certified, closed firmware [19,20]. Consequently, outer-loop controllers must operate as supervisory systems generating high-level velocity commands.
When linear outer-loop controllers, such as baseline P or fixed-gain PID schemes, are deployed in these cascaded systems, their inability to adapt online under wind disturbances drives control inputs into actuator saturation [5,15]. As a result, conventional bounding and anti-windup methods often cause integral accumulation, directional distortion of the control vector, and parameter divergence [21,22]. This creates the practical need for a lightweight outer-loop architecture that synthesizes velocity commands, interfaces with commercial autopilots via standard telemetry protocols, and enforces physical feasibility through asymmetric saturation mechanisms.
Table 1 compares the most relevant quadcopter control paradigms with the proposed methodology in terms of algorithmic structure, model dependence, saturation handling, and computational cost.
Table 1. Comparative analysis of representative quadcopter control schemes, operational constraints, and implementation complexities.

1.3. Proposed Approach and Main Contributions

This paper addresses the problem of robust position regulation under the constraint of an inaccessible inner loop. To tackle the combined challenges of disturbance rejection and bounded control authority, a condition that frequently triggers severe integral windup and trajectory divergence, this paper introduces a novel outer-loop neural adaptive PID control scheme enhanced with coordinate-coupled asymmetric saturation limits and a clamping-based anti-windup mechanism. The gain vector of the controller is dynamically optimized online via an Extended Kalman Filter (EKF) driven by the regulation innovation error. In the context of artificial neural network learning, the EKF effectively manages noisy measurements and unstructured data [23]. By operating as a second-order gradient optimization algorithm, it prevents premature stagnation and reduces the probability of converging to local minima, enabling fast online parameter adaptation [23].
Compared to existing methods in the bibliography, this paper makes four main contributions:
  • Formulation of a supervisory gain-adaptation strategy that dynamically synthesizes proportional, integral, and derivative actions in real time, effectively eliminating the need for heuristic manual tuning or complex gain-scheduling look-up tables under changing operational environments.
  • Introduction of coordinate-coupled saturation boundaries that constrain horizontal translational velocities independently of vertical axis, accurately mapping the asymmetric lift and drag capabilities of multirotor platforms into control loop.
  • Integration of a conditional clamping-based anti-windup mechanism explicitly coupled with estimation cycle to safeguard EKF algorithm against parameter and covariance divergence during sustained actuator saturation.
  • Rigorous experimental validation conducted entirely within a high-fidelity Hardware-in-the-Loop (HIL) simulation environment, which directly executes production PX4 autopilot firmware on physical flight microcontrollers embedded with the Gazebo physics engine to evaluate resilience under severe wind disturbances.

1.4. Paper Organization

The remainder of this paper is organized as follows: Section 2 details the quadcopter kinematics and problem setup. Section 3 describes the proposed neural adaptive architecture, EKF training algorithm and asymmetric saturation anti-windup loop. Section 4 outlines the HIL methodology and experimental test bench. Section 5 presents the obtained results and a comparative discussion; Section 6 outlines conclusions and future directions.

2. Quadcopter Kinematics and Control Foundations

This section establishes the discrete-time coordinate systems and translational position regulation structure of the quadcopter. It presents a simplified kinematic formulation in the inertial frame to define the tracking problem, framing the position regulation task as an external supervisory reference generator for a closed-loop autopilot system.

2.1. Spatial Coordinate Systems

The description of the spatial movement of a quadcopter requires a dual coordinate system since the vehicle operates as a rigid body within a six-degree-of-freedom (6-DoF) space [15]. The navigation setup utilizes a local inertial reference frame ε I ( x I , y I , z I ) that adheres to the standard North–East–Down (NED) aeronautical convention [15]. Complementarily, a body-fixed reference frame ε B ( x B , y B , z B ) represents onboard workspace, whose origin is rigidly attached to the vehicle center of mass [15].
The geometric interaction between these systems is illustrated in Figure 1, where the flat surface represents a local tangent flight plane, establishing a flat-Earth kinematic approximation [24]. This assumption remains valid since the operational range of a quadcopter is structurally localized, rendering effects of Earth curvature and Coriolis accelerations negligible [24].
Figure 1. Geometric relationship between local inertial frame ϵ I and the body-fixed frame ϵ B , illustrating instantaneous translational state vector ξ ( k ) under a flat-Earth approximation.
Within this setup, the Cartesian state ξ ( k ) defines the instantaneous position of the center of mass, operating as a time-varying vector expressed in the global reference system at discrete step k:
ξ ( k ) = x ( k ) y ( k ) z ( k ) ∈ ε I
The spatial orientation of the body frame ε B relative to inertial frame ε I is determined by conventional Euler angle vector μ ( k ) = [ ϕ ( k ) , θ ( k ) , ψ ( k ) ] ⊤ , where ϕ ( k ) represents the roll angle, θ ( k ) denotes the pitch angle and ψ ( k ) corresponds to the yaw angle [24]. However, because the external offboard routine commands translation velocities directly within the local tangent plane, complex rotational transformation matrices are governed internally and transparently by native autopilot firmware [15,25].

2.2. Translational Guidance Kinematics

Assuming a forward-Euler discretization scheme with a sampling period Δ t [24], the discrete-time translational mechanics of the quadcopter center of mass can be modeled directly within an inertial framework. This relationship maps the high-level position state updates as follows:
ξ ( k + 1 ) = ξ ( k ) + Δ t · u ( k )
where u ( k ) = [ v x ( k ) , v y ( k ) , v z ( k ) ] ⊤ ∈ ε I represents the linear velocity control vector synthesized by the external guidance algorithm. This formulation bypasses rotational rigid-body transformations at the supervisory layer, establishing a direct kinematic foundation for the position regulation objective.

2.3. Position Regulation Objective

The control objective requires the mathematical formulation of a robust guidance scheme capable of executing precise point-to-point regulation under adverse flight conditions. The reference generator defines the target coordinates in three-dimensional space, which is represented as the desired constant position vector ξ d ∈ ϵ I :
ξ d = x d y d z d
where ξ d operates as a static step command during position regulation experiments designed to evaluate transient and steady-state responses under actuator constraints [26].
The tracking error variable e ( k ) yields the absolute algebraic discrepancy between the active reference target and the estimated position feedback of the aircraft:
e ( k ) = x e ( k ) y e ( k ) z e ( k ) = ξ d − ξ ( k ) = x d − x ( k ) y d − y ( k ) z d − z ( k )
The primary task of the intelligent controller is to synthesize a bounded velocity strategy that drives the tracking error asymptotically to the origin [27]. This implies satisfying the condition lim k → ∞ e ( k ) = 0 for a given stationary target, ensuring high precision and rejection of environmental perturbations.

2.4. Baseline Autopilot Cascaded Control Architecture

The cascaded paradigm establishes a hierarchical structure where the inner loop directly governs the fast rotational dynamics, thereby allowing the outer loop to focus entirely on translational behavior [15,25]. In this standard configuration [18,20], the native position control loop operates as the primary stage, translating spatial deviations into local kinematic targets while bypassing low-level multirotor actuation details.
To provide a comprehensive operational overview, Figure 2 outlines the sequential signal propagation throughout the default embedded flight system.
Figure 2. Signal propagation pipeline and multi-rate execution frequencies within the native PX4 firmware [20].
The initial translation task begins in the inertial frame, where the proportional (P) position control block processes the three-dimensional tracking error e ( k ) defined in the previous subsection alongside the desired yaw heading setpoint ψ s p . For stable stationary regulation, this heading is maintained at a constant zero reference. This loop filters the spatial deviations to synthesize the native velocity reference vector V s p ( k ) , acting as the target input for the subsequent stages:
V s p ( k ) = v x s p ( k ) v y s p ( k ) v z s p ( k )
where its individual components define the target translational velocities along the North, East, and Down directions, respectively.
As illustrated in the control loop hierarchy depicted in Figure 2, the subsequent velocity control block utilizes a PID scheme to process these references, calculating an intermediate acceleration setpoint A s p at a frequency of 50 Hz [20]. The firmware then executes a coordinate transition through the acceleration-and-yaw-to-attitude module, converting these translational demands into a target attitude quaternion q s p mapped to the body-fixed at 250 Hz [20]. Within this inner loop structure, a proportional (P) angle controller computes the commanded angular rate vector Ω s p , subsequently driving the high-frequency angular rate PID module operating at 1 kHz [20].
Finally, this internal rate stage outputs the normalized aerodynamic control demands for roll, pitch, yaw and thrust, which are denoted as δ A s p , δ E s p , δ R s p and δ T s p , respectively [20]. The mixer module processes these scaled variables to generate the collective motor commands transmitted to the physical electronic speed controllers [20]. The offboard control routine exploits this routing configuration by serializing its custom supervisory signals in real time into MAVLink communication packets, setting the stage for advanced tracking optimization [20].

3. Adaptive Neural PID Control with Asymmetric Saturation

This section details the theoretical design and mathematical formulation of the proposed intelligent outer-loop guidance strategy. To establish a rigorous baseline for this framework, its foundational control paradigms are defined as follows: (i) Neural PID control expands classical tracking by substituting static gains with time-varying synaptic parameters optimized online, enabling real-time adaptation against unmodeled dynamics [14,27,28]; (ii) Asymmetric saturation dictates that signal boundaries are non-uniform and axis-dependent, preventing vector distortion when physical constraints vary across different operational domains [22,29]; (iii) Anti-windup denotes the broader class of control compensation methods designed to mitigate the transient response degradation caused by actuator or velocity saturation [22]; and (iv) Clamping, or conditional integration, is a specific anti-windup mechanism that dynamically freezes the integrator state the instant saturation is detected, eliminating residual overshoot [21]. By synthesizing these distinct principles, the proposed scheme utilizes a single-neuron architecture optimized via an Extended Kalman Filter (EKF) to safely generate bounded translational velocity commands. The block diagram of the proposed control strategy is shown in Figure 3.
Figure 3. Block diagram of the proposed ANPID v i - EKF supervisory control loop for the i-th operational axis.

3.1. Single-Neuron State Mapping and Activation

The intelligent controller acts directly upon the tracking deviations expressed in the local tangent flight plane. At each discrete-time step k, the tracking error vector e ( k ) = [ e x ( k ) , e y ( k ) , e z ( k ) ] ⊤ ∈ R 3 establishes the fundamental feedback loop. To avoid notation conflicts with standard plant states and spatial coordinates, an augmented error vector ζ i ( k ) ∈ R 3 is constructed for each operational axis i ∈ { x , y , z } :
ζ i ( k ) = e i ( k ) Δ e i ( k ) I r a w i ( k )
where Δ e i ( k ) characterizes the discrete-time backward difference derivative mapping [26]:
Δ e i ( k ) = e i ( k ) − e i ( k − 1 ) Δ t
and I r a w i ( k ) denotes the unconstrained accumulation of the error channel [21,26]:
I r a w i ( k ) = I i ( k − 1 ) + e i ( k ) Δ t
The adjustable synaptic weight vector ω i ( k ) = [ ω i , 1 ( k ) , ω i , 2 ( k ) , ω i , 3 ( k ) ] ∈ R 3 substitutes the static proportional, derivative and integral gains of a conventional PID controller, respectively [28]. This single-neuron architecture is specifically selected over deep multi-layer networks to guarantee the deterministic low-latency execution on embedded microcontrollers and to preserve the physical interpretability of the control gains. The preliminary velocity command u ˜ i ( k ) is computed from the inner product of the weights and the augmented error vector, which is bounded by a nonlinear activation mapping. The hyperbolic tangent function is selected to introduce nonlinearity into the neural structure. Unlike purely linear unbounded functions, this mapping provides a continuously differentiable boundary necessary to compute the EKF Jacobian without singularities, inherently restricts the maximum command amplitude, and preserves ideal linear PID behavior near the equilibrium point:
u ˜ i ( k ) = α i tanh ω i ( k ) · ζ i ( k )
where α i ∈ R + represents the scaling parameter associated with the physical velocity limits of the multirotor system.

3.2. Extended Kalman Filter Weight Optimization

The continuous adaptation of the synaptic parameters ω i ( k ) relies on an active Extended Kalman Filter routine executing concurrently at the supervisory layer. Following a state-space formulation, the EKF treats the adjustable control gains as the state vector of an artificial dynamical system governed by a random-walk model [12,28]. The measurement update phase utilizes the tracking error to drive this online learning mechanism.
To linearize the nonlinear activation response within the estimation loop, the algorithm derives an instantaneous Jacobian H i ( k ) ∈ R 3 via the partial differentiation of tanh ( · ) with respect to the weights:
H i ( k ) = α i 1 − tanh 2 ω i ( k ) · ζ i ( k ) ζ i ( k )
The error covariance matrix P i ( k ) ∈ R 3 × 3 estimates parameter uncertainty throughout the flight routine. The algorithm computes the innovation variance S i ( k ) ∈ R and the optimal time-varying Kalman gain vector K i ( k ) ∈ R 3 using the following expressions [12,28]:
S i ( k ) = R + H i ( k ) P i ( k − 1 ) H i ⊤ ( k )
K i ( k ) = P i ( k − 1 ) H i ⊤ ( k ) S i ( k )
where R ∈ R + represents the constant measurement noise variance.
The correction phase updates the active weights online by blending the Kalman allocation strategy with localized learning rates η = [ η p , η d , η i ] ⊤ , accelerating adaptation along the gradient of the error:
ω i ( k ) = ω i ( k − 1 ) + η ⊙ K i ( k ) e i ( k )
where ⊙ denotes the element-wise Hadamard product. Finally, the covariance matrix is updated according to the discrete Riccati equation [12,28]:
P i ( k ) = I 3 × 3 − K i ( k ) H i ( k ) P i ( k − 1 ) + Q
where Q ∈ R 3 × 3 denotes the diagonal process-noise matrix designed to maintain continuous filter alertness [12,28]. Unlike batch-trained algorithms, this recursive estimation process does not retain historical data buffers. At each discrete time step k, exactly one newly collected measurement e i ( k ) is incorporated to update the weights, and the sample is immediately discarded.

3.3. Asymmetric Saturation and Conditional Anti-Windup Clamping

To ensure operational safety during large setpoint steps, the control signals are conditioned through a strict directional stabilization process before transmission. Since quadcopter platforms possess asymmetric velocity constraints across different axes, conventional axis-decoupled clipping can cause severe vector distortion [15]. Consequently, the proposed strategy executes a coupled, direction-preserving saturation routine implemented across the horizontal flight plane while maintaining a separate clamping constraint for the vertical lifting mechanics [15,20].
In the horizontal domain, the saturation mechanism monitors the coupled magnitude of the forward and lateral demands. If the Euclidean norm of these translational signals exceeds the maximum velocity threshold V max x y , the preliminary commands are scaled proportionally to preserve the original guidance vector direction:
v x ( k ) v y ( k ) = u ˜ x ( k ) u ˜ y ( k ) , if u ˜ x 2 ( k ) + u ˜ y 2 ( k ) ≤ V max x y V max x y u ˜ x 2 ( k ) + u ˜ y 2 ( k ) u ˜ x ( k ) u ˜ y ( k ) , if u ˜ x 2 ( k ) + u ˜ y 2 ( k ) > V max x y
Concurrently, the vertical velocity command v z ( k ) is restricted by a strict clamping constraint defined by the independent physical limit V max z :
v z ( k ) = max − V max z , min V max z , u ˜ z ( k )
To prevent trajectory degradation caused by integral windup during saturation intervals, the single-neuron structure implements a conditional integration rule [21,29]. This accumulation process depends directly on the argument of the activation function with the integral state updated as follows:
I i ( k ) = I i ( k − 1 ) + e i ′ ( k ) Δ t
where the filtered error variable e i ′ ( k ) responds to the following logical constraint:
e i ′ ( k ) = 0.0 , if | ω i ( k ) · ζ i ( k ) | > α i e i ( k ) , otherwise
This structural arrangement effectively freezes the integral action once the argument of the activation function indicates a saturation condition, enabling an immediate recovery without residual overshoot when the quadcopter returns to nominal tracking thresholds [21].

3.4. Parameters and Tuning Guidelines

The dynamic response and numerical stability of the ANPID v i - EKF scheme depend directly on the selection of parameters:
  • Measurement Noise Covariance (R): sets the filter confidence regarding tracking error measurements. A small R accelerates gain adaptation but increases sensitivity to sensor noise, generating high-frequency chattering in the synthesized velocity commands. Conversely, an excessively large R slows down parameter convergence, degrading disturbance rejection under wind gusts.
  • Process Noise Covariance ( Q = d i a g ( q p , q d , q i ) ): dictates the parameter variation rate. Higher values preserve filter alertness against non-stationary aerodynamic forces, preventing the covariance matrix P i ( k ) from decaying to zero. But excessively large values induce gain drift during steady-state tracking.
  • Learning Rates Vector ( η = [ η p , η d , η i ] ⊤ ): scales the gradient descent step along individual error channels. The proportional ( η p ) and integral ( η i ) rates primarily govern rise time and steady-state error compensation, while the derivative rate ( η d ) provides damping against transient overshoot.
  • Scaling Bounds ( α i , V m a x x y , V m a x z ): restrict velocity demands to the physical limits of the multirotor platform. When tracking errors exceed these operational thresholds, the clamping logic freezes error accumulation, directly safeguarding the EKF update cycle against covariance divergence.
The initial synaptic weights are set to conservative linear PID gains to ensure stable initial hovering prior to online adaptation: ω x , y ( 0 ) = [ 1.0 , 0.2 , 0.007 ] ⊤ and ω z ( 0 ) = [ 0.38 , 0.2 , 0.008 ] ⊤ . The scaling parameters α x , y = V max x y = 2.0 m/s and α z = V max z = 1.2 m/s are selected to match the physical kinematics of the tested quadcopter. Finally, the covariance matrices are initialized as R = 1.0 × 10 − 2 and Q = diag ( 10 − 4 , 10 − 4 , 10 − 5 ) to balance rapid transient adaptation with steady-state noise rejection.

4. Hardware-in-the-Loop (HIL) Simulation Environment

To evaluate the proposed ANPID v i - EKF architecture under realistic conditions, an experimental HIL platform has been developed. This setup contrasts with Software-in-the-Loop (SITL) configurations [20,25], where environment-specific firmware runs entirely on a development computer. In HIL, standard PX4 firmware executes directly on the physical flight hardware [20,25].
The main difference between the environments lies in the data injection point [20,25]. SITL relies on simulation drivers to emulate environmental data within a software process [20]. Conversely, HIL forces core firmware modules, such as the commander and sensor suites, to initialize in a startup mode that bypasses physical drivers and accepts external telemetry streams [20]. Therefore, while SITL executes more of the standard low-level system code, HIL validates the control algorithm under the exact processing and timing constraints of the physical microcontroller [20].

4.1. Distributed Embedded Hardware and Physics Co-Simulation Layer

The configuration of the HIL setup is divided into an embedded flight computing platform, a rigid-body physics emulation workspace, and a supervisory intelligent guidance layer. The physical embedded hardware core consists of the NXP MR-VMU-RT1176 Flight Management Unit (FMU) [20]. This specialized aeronautical board integrates a high-performance dual-core crossover processor featuring an ARM Cortex-M7 core operating at 1 GHz and an ARM Cortex-M4 core operating at 400 MHz [20]. The PX4 Autopilot firmware stack (v15.1.0) executes natively within this embedded hardware layer, running high-frequency state estimation via its internal EKF2 module and governing low-level attitude tracking loops [20].
Synchronization across the physical NXP FMU and the virtual environment operates deterministically [20]: Gazebo optimizes high-rate synthetic telemetry outputs, packaging them into HIL_SENSOR and HIL_GPS MAVLink messages transmitted via a high-speed FTDI serial bridge operating at a fixed baud rate of 921,600 bps directly to the physical flight controller. The PX4 stack processes these virtual inputs as raw hardware sensor readings, solves the inner-loop attitude control action and returns the computed normalized actuator demands (HIL_ACTUATOR_CONTROLS) back to the simulator, closing the physical-virtual loop at 250 Hz to preserve real-time flight dynamics [20]. Figure 4 shows the complete layout of the components and the synchronized multi-layer simulation interfaces.
Figure 4. Experimental platform setup: (a) Visualization of the simulated quadcopter Iris model within the Gazebo physics engine; (b) Global perspective of the flat-Earth localized tangent flight workspace inside the virtual world; (c) QGroundControl graphical user interface displaying the mandatory real-time HIL validation flag; and (d) Embedded NXP hardware platform executing the production autopilot firmware.

4.2. Asynchronous Offboard Command Loop and Telemetry Pipeline

The proposed supervisory intelligent controller executes externally within an independent offboard node implemented in Python 3. Due to the high computational complexity associated with the online update process within the EKF weight optimization routine, the algorithm is deployed on the host companion workstation operating under Ubuntu 22.04 LTS, decoupling the advanced guidance loop from the low-level firmware tasks. The script utilizes the pymavlink library to establish a bidirectional telemetry and command routing interface with the PX4 flight stack via UDP socket serialization through port 14540 [20,30], as detailed in the network routing topology illustrated in Figure 5.
Figure 5. Block diagram of the offboard communication network.
At each discrete-time step k, the offboard node blocks execution until a valid LOCAL_POSITION_NED message is received from the NXP FMU to extract the position states x ( k ) , y ( k ) and z ( k ) [20]. The routine then evaluates the three-dimensional tracking errors relative to the reference coordinates ξ d . Subsequently, the single-neuron mapping functions, backward derivative parameters, and conditional clamping anti-windup laws are solved for each operational channel. The resulting velocity commands are then transmitted back to the autopilot at a sampling frequency of 50 Hz ( Δ t = 0.02 s). Empirical testing demonstrates that higher execution frequencies (e.g., 100 Hz or 200 Hz) do not yield substantial improvements in outer-loop translational dynamics and unnecessarily saturate the MAVLink communication bus. Furthermore, 50 Hz aligns exactly with the recommended offboard setpoint injection rate specified by the PX4 architecture [20]. The internal attitude and rate controllers operate under the standard factory optimization provided by the firmware.
To explicitly clarify the computational implementation, the continuous real-time execution loop of the offboard control node is formalized in Algorithm 1.
Algorithm 1 Real-Time Offboard ANPID v i - EKF Execution Loop
  1:
Initialization:
  2:
   Define simulation sampling time Δ t = 0.02 s (50 Hz).
  3:
   Set physical saturation bounds V max x y , V max z and scaling limits α i .
  4:
   Initialize learning rates η , covariance matrices Q , R , and weights ω i ( 0 ) .
  5:
Main Control Loop:
  6:
while Flight mode is active do
  7:
   Receive LOCAL_POSITION_NED telemetry via MAVLink.
  8:
   for each axis i ∈ { x , y , z }  do
  9:
     Compute tracking error e i ( k ) and derivative Δ e i ( k ) .
10:
     Formulate preliminary state: ζ t m p ← [ e i ( k ) , Δ e i ( k ) , I i ( k − 1 ) ] ⊤ .
11:
     if  | ω i ( k − 1 ) · ζ t m p | > α i  then
12:
         e i ′ ( k ) ← 0.0 Conditional Anti-windup
13:
     else
14:
         e i ′ ( k ) ← e i ( k )
15:
     end if
16:
     Update integral accumulation: I i ( k ) ← I i ( k − 1 ) + e i ′ ( k ) Δ t .
17:
     Formulate augmented state vector: ζ i ( k ) ← [ e i ( k ) , Δ e i ( k ) , I i ( k ) ] ⊤ .
18:
     EKF Optimization Update:
19:
        Compute Jacobian: H i ( k ) ← α i 1 − tanh 2 ω i ( k − 1 ) · ζ i ( k ) ζ i ( k ) .
20:
        Compute innovation variance: S i ( k ) ← R + H i ( k ) P i ( k − 1 ) H i ⊤ ( k ) .
21:
        Evaluate Kalman gain: K i ( k ) ← P i ( k − 1 ) H i ⊤ ( k ) S i ( k ) − 1 .
22:
        Update synaptic weights: ω i ( k ) ← ω i ( k − 1 ) + η ⊙ K i ( k ) e i ( k ) .
23:
        Update covariance matrix: P i ( k ) ← I − K i ( k ) H i ( k ) P i ( k − 1 ) + Q .
24:
     Compute neural action: u ˜ i ( k ) ← α i tanh ω i ( k ) · ζ i ( k ) .
25:
   end for
26:
   Directional Stabilization:
27:
   Scale horizontal vector [ v x , v y ] ⊤ using Equation (15).
28:
   Clamp vertical scalar v z using Equation (16).
29:
   Serialize u ( k ) = [ v x , v y , v z ] ⊤ to SET_POSITION_TARGET_LOCAL_NED.
30:
   Transmit MAVLink message to physical flight controller.
31:
end while

4.3. MAVLink Bitmask Configuration for Velocity Command Injection

To inject the velocity vector u ( k ) = [ v x ( k ) , v y ( k ) , v z ( k ) ] ⊤ generated by the single-neuron structure into the native cascaded flight software without firmware modification, the Python node utilizes the 16-bit unsigned integer bitmask (type_mask) within the SET_POSITION_TARGET_LOCAL_NED MAVLink message [20,30]. This field determines which control channels are executed by the internal loops. Following an inverse logic, setting a bit to 1 commands PX4 to bypass the corresponding tracking state, whereas a bit set to 0 activates the channel input.
The offboard routine configures the bitmask value as 3527 (0b110111000111) to isolate velocity control and bypass native position tracking [20,30]. This instructs the autopilot to disable the proportional position controllers and route the intelligent outer-loop outputs directly into the velocity PID stages, ensuring that the quadcopter response depends strictly on the neural adaptive tuning laws.

5. Results and Discussion

This section details the comprehensive performance evaluation of the proposed ANPID v i - EKF control scheme through rigorous HIL testing. To establish a robust scientific validation, the adaptive intelligent controller is compared directly against a baseline P controller and a conventional PID controller. Both baselines utilize the exact factory-certified tuning parameters provided by the PX4 firmware. All three control schemes are evaluated under identical initial flight conditions, physics engine step sizes, and deterministic wind disturbance seeds.

5.1. HIL Environmental Parameterization and Virtual Workspace Configuration

To evaluate transient tracking behavior, reference convergence, and actuator saturation mitigation, a representative multi-axis step response testbench is implemented within the distributed HIL workspace. The reference generator commands a simultaneous spatial step defined by the target coordinates ξ d = [ 4.0 , 7.0 , − 10.0 ] ⊤ m, enforcing a total translation of approximately 8.06 m along the horizontal navigation plane and a localized 10-meter altitude ascent command executed along the negative Down direction of the local inertial frame.
The physical environment is governed by a custom virtual workspace configured within the Gazebo Classic engine via the hitl_iris_world SDF framework. The mechanical and aerodynamic properties are governed by an Open Dynamics Engine (ODE) solver executing at a maximum step size of Δ t sim = 0.004 s with a real-time update frequency of 250 Hz and a real-time factor equal to 1. The local gravity vector is parameterized as g = [ 0 , 0 , − 9.8066 ] ⊤ m/s2. The ODE solver constraints utilize a Constraint Force Mixing (CFM) value of 0, an Error Reduction Parameter (ERP) of 0.2, a maximum correcting velocity bound of 100 and a contact surface layer thickness of 0.001 to ensure structural simulation stability. Aerodynamic disturbances are synthesized dynamically through the libgazebo_wind_plugin.so module attached to the vehicle base_link frame.
To rigorously test the operational resilience of each controller, three independent meteorological flight scenarios are evaluated: Nominal Conditions, Moderate Wind, and Gusty Wind.

5.2. Scenario 1: Nominal Environmental Conditions (No Wind Disturbance)

The initial benchmark test evaluates the tracking capability of each framework under an ideal, disturbance-free flight profile (0 m/s). This baseline isolates the geometric tracking error from external forces, verifying the nominal transient response under the target step coordinates ξ d = [ 4.0 , 7.0 , − 10.0 ] ⊤ m. Table 2 details the quantitative performance metrics computed from the experimental code telemetry for this ideal scenario.
Table 2. Systematic performance metrics comparison under nominal environmental conditions.
The numerical data compiled in Table 2 confirm that the proposed ANPID v i - EKF establishes a superior transient tracking profile even in the absence of external perturbations. In the horizontal North axis (X), the intelligent scheme achieves complete dominance across all indicators, compressing the settling time to 7.52 s and reducing the maximum overshoot to 8.21 % compared to the 14.50 % exhibited by the conventional PID.
While the fixed-gain architectures present slightly tighter static metrics in isolated channels due to the absence of initial parameter adaptation transience, the neural mapping minimizes the global cumulative error, reducing the Integral Absolute Error (IAE) to 25.9482 m·s (X-axis) and 40.0029 m·s (Y-axis). This configuration validates that the stochastic learning loop introduces no high-frequency oscillations or tracking divergence under nominal conditions.

5.3. Scenario 2: Moderate Wind Conditions (Beaufort 4, 7.0 m/s)

The second flight scenario introduces a steady, continuous crosswind classified as Beaufort 4 (moderate breeze) targeting the step reference coordinates ξ d = [ 4.0 , 7.0 , − 10.0 ] ⊤ m [31,32]. The wind plugin parameters describe a baseline tridirectional force defined by a mean velocity V mean = 7.0 m/s, a maximum threshold V max = 8.0 m/s and a magnitude variance σ V 2 = 1.0 . The spatial alignment follows a normalized tridirectional entry vector Φ mean = [ 0.577 , 0.577 , 0.577 ] ⊤ with a directional angular variance of σ Φ 2 = 0.087 , inducing continuous turbulence variations of ± 5 ∘ . Table 3 details the quantitative performance metrics computed from the experimental code telemetry.
Table 3. Systematic performance metrics comparison under Beaufort 4 crosswind conditions.
When continuous aerodynamic disturbances are introduced, fixed-gain architectures suffer from significant performance degradation. As compiled in Table 3, the maximum overshoot in the horizontal plane expands drastically for the baseline controllers with the proportional reaching an overshoot of 51.15 % in the X-axis and the conventional PID reaching 33.95 % .
Conversely, the proposed ANPID v i - EKF successfully restrains this transient deviation to 27.89 % (X-axis) and 10.08 % (Y-axis). This optimal response confirms that the conditional clamping anti-windup integration loop effectively prevents integral saturation by isolating the error state variables during saturation periods. The online tuning optimization reduces the settling time to 6.39 s (X-axis) and 6.49 s (Y-axis), enabling the vehicle to acquire the localized step coordinates faster than the conventional baselines. This complete physical interaction, along with the internal parameter update history, is detailed in Figure 6, showcasing how the synaptic layers reach multi-axis stochastic stability.
Figure 6. Operational transient responses and parameters update profile of the proposed ANPID v i - EKF scheme under Moderate Wind. The top panel illustrates the multi-axis spatial positions tracking relative to the coordinate reference; the middle panel presents the synthesized local velocity command vectors ( v x , v y , v z ); and the bottom panels detail the autonomous stochastic convergence of the internal synaptic weight layers across each individual navigational channel.

5.4. Scenario 3: Gusty Wind Conditions (Beaufort 6, 8–14 m/s)

The final and most critical flight experiment subjects the quadcopter to severe atmospheric turbulence corresponding to Force 6 on the Beaufort Scale [31,32] under the target coordinates ξ d = [ 4.0 , 7.0 , − 10.0 ] ⊤ m. To ensure proper sensor initialization and prevent gyroscope calibration failures within the PX4 firmware stack during the system boot sequence, the simulation environment launches under near-calm nominal conditions ( 0.1 m/s). The comprehensive, multi-directional strong wind profile is subsequently introduced through the transient gust parameterization framework, which is programmed to trigger precisely at t = 25.0 s with a continuous execution duration of 45.0 s.
This atmospheric burst injects a mean velocity step increment of Δ V gust = 11.0 m/s, bounding the localized operating environment between 11.0 m/s and 14.0 m/s, with an internal stochastic turbulence variance configured at σ gust 2 = 1.5 . The spatial propagation vector of the gust targets a unidirectional horizontal alignment along the positive East axis ( Φ gust = [ 0 , 1 , 0 ] ⊤ ). Table 4 summarizes the performance parameters extracted over the entire flight profile.
Table 4. Systematic performance metrics comparison under gusty wind conditions, Beaufort 6.

5.5. Methodological Analysis of Non-Stationary Disturbances and Performance Trade-Offs

A critical analytical distinction must be established when interpreting the numerical data from Scenario 3. Under highly non-stationary and stochastic wind fields triggered mid-flight ( t = 25.0 s), traditional global metrics such as the Settling Time ( T s ) and Maximum Overshoot ( M p ) lose part of their conventional deterministic meaning. Because these parameters convolute the initial step response with the subsequent aerodynamic impact, they must be analyzed in combination with cumulative deviation tracking criteria. In cascaded commercial autopilots, unhandled actuator saturation manifests as severe integral windup. Therefore, M p and IAE serve as the primary quantitative indicators of saturation mitigation.
For instance, while the conventional PID controller yields a slightly lower global settling time in the X-axis ( 6.40 s) and tighter regulation along the vertical Z-axis, it exhibits severe path degradation and drift when the wind burst strikes, as evidenced by the high IAE values ( 98.9492 m·s and 94.6159 m·s) in the horizontal plane.
Considerable structural survival and resilience are provided by the proposed ANPID v i - EKF , which compresses the Mean Squared Error (MSE) in the North axis to 1.3823 m2 and restricts the maximum overshoot to 65.27 % compared to the catastrophic 110.38 % overshoot generated by the proportional baseline.
In the East axis (Y), which receives the horizontal perpendicular impact of the gust directly, the proposed controller isolates the cross-axis error completely, minimizing the IAE to 52.2484 m·s and settling the vehicle in just 7.76 s. This performance confirms that the intelligent layer adapts its tracking behavior on the fly, outperforming classical fixed-gain structures under extreme meteorological transitions. The resulting multi-axis translation responses for all three evaluated control schemes are compared side by side in Figure 7, highlighting the flight path deviations caused by the non-stationary atmospheric burst.
Figure 7. Response profiles under Scenario 3 (Severe Beaufort 6 Gusty Wind). The transient curves illustrate the spatial regulation capabilities and path variations of each control architecture against stochastic crosswind forces introduced at t = 25.0 s.

6. Conclusions

This paper presents an adaptive outer-loop neural PID control framework for autonomous quadrotor position regulation on a conventional PX4 flight stack within a distributed HIL configuration. The proposed controller combines a cascaded PID structure with the online adaptation capability of neural networks, granting continuous adjustment of the outer-loop gains based on an instantaneous tracking error.
The suggested methodology is experimentally validated throughout different scenarios on an HIL platform integrating Gazebo, PX4 and Pixhawk hardware, providing scenarios that closely resemble real flight while maintaining repeatability and operational safety, especially the last scenario, which accounts for wind conditions. Experimental results show that the adaptive neural outer-loop controller improves trajectory-tracking performance in comparison to the conventional P and PID fixed-gain PX4 position controllers, which are the industry baselines.
Overall, the proposed adaptive neural PID outer loop offers a practical alternative for enhancing commercial UAV flight performance through online gain adaptation while preserving the modularity of standard autopilot architectures.
Further studies will focus on trajectory tracking, disturbance rejection, adaptive payload compensation, and fully autonomous outdoor flight experiments.

Author Contributions

Conceptualization, J.O.E. and J.D.R.; methodology, J.O.E. and J.D.R.; software, J.O.E.; validation, J.O.E., J.D.R. and A.Y.A.; formal analysis, J.O.E., J.D.R. and A.Y.A.; investigation, J.O.E.; resources, J.D.R. and A.Y.A.; data curation, J.O.E.; writing—original draft preparation, J.O.E. and J.D.R.; writing—review and editing, J.O.E., J.D.R. and A.Y.A.; visualization, J.O.E.; supervision, J.D.R. and A.Y.A.; project administration, J.D.R. and A.Y.A.; funding acquisition, A.Y.A. All authors have read and agreed to the published version of the manuscript.

Funding

The authors thank the Universidad de Guadalajara for giving us the support to develop this research.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
ANNArtificial Neural Network
CFMConstraint Force Mixing
DoFDegree of Freedom
EKFExtended Kalman Filter
EKF2Extended Kalman Filter 2
FMUFlight Management Unit
FTDIFuture Technology Devices International
HILHardware-in-the-Loop
IAEIntegral Absolute Error
LQRLinear Quadratic Regulator
LMPCLinear Model Predictive Control
MAVLinkMicro Air Vehicle Link
MSEMean Squared Error
NEDNorth–East–Down
ODEOpen Dynamics Engine
PIDProportional–Integral–Derivative
PX4PX4 Autopilot
SDFSimulation Description Format
SITLSoftware-in-the-Loop
SMCSliding Mode Control
STDStandard Deviation
UAVUnmanned Aerial Vehicle
UDPUser Datagram Protocol
VTOLVertical Take-Off and Landing

References

  1. Mohsan, S.A.H.; Othman, N.Q.H.; Li, Y.; Alsharif, M.H.; Khan, M.A. Unmanned Aerial Vehicles (UAVs): Practical Aspects, Applications, Open Challenges, Security Issues, and Future Trends. Intell. Serv. Robot. 2023, 16, 109–137. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  2. Teixeira, K.; Miguel, G.; Silva, H.S.; Madeiro, F. A Survey on Applications of Unmanned Aerial Vehicles using Machine Learning. IEEE Access 2023, 11, 117582–117621. [Google Scholar] [CrossRef] [Scilit]
  3. Hassanalian, M.; Abdelkefi, A. Classifications, Applications, and Design Challenges of Drones: A Review. Prog. Aerosp. Sci. 2017, 91, 99–131. [Google Scholar] [CrossRef] [Scilit]
  4. Shakhatreh, H.; Sawalmeh, A.H.; Al-Fuqaha, A.; Dou, Z.; Almaita, E.; Khalil, I.; Othman, N.S.; Khreishah, A.; Guizani, M. Unmanned Aerial Vehicles (UAVs): A Survey on Civil Applications and Key Research Challenges. IEEE Access 2019, 7, 48572–48634. [Google Scholar] [CrossRef] [Scilit]
  5. Sadi, M.A.; Jamali, A.; Kamaruddin, A.M.N.A. Optimizing UAV Performance in Turbulent Environments Using Cascaded Model Predictive Control Algorithm and Pixhawk Hardware. J. Braz. Soc. Mech. Sci. Eng. 2025, 47, 396. [Google Scholar] [CrossRef] [Scilit]
  6. Ogata, K. Modern Control Engineering, 5th ed.; Prentice Hall: Upper Saddle River, NJ, USA, 2010. [Google Scholar]
  7. Zhou, K.; Doyle, J.C.; Glover, K. Robust and Optimal Control; Prentice Hall: Upper Saddle River, NJ, USA, 1996. [Google Scholar]
  8. Rawlings, J.B.; Mayne, D.Q.; Diehl, M.M. Model Predictive Control: Theory, Computation, and Design, 2nd ed.; Nob Hill Publishing: Madison, WI, USA, 2024. [Google Scholar]
  9. Khalil, H.K. Nonlinear Systems, 3rd ed.; Prentice Hall: Upper Saddle River, NJ, USA, 2002. [Google Scholar]
  10. Zhang, X.; Li, X.; Wang, K.; Lu, Y. A Survey of Modelling and Identification of Quadrotor Robot. Abstr. Appl. Anal. 2014, 2014, 320526. [Google Scholar] [CrossRef] [Scilit]
  11. Haykin, S. Neural Networks and Learning Machines, 3rd ed.; Prentice Hall: Upper Saddle River, NJ, USA, 2009. [Google Scholar]
  12. Rios, J.D.; Alanis, A.Y.; Lopez-Franco, C.; Arana-Daniel, N.; Sanchez, E. Neural Networks Modeling and Control: Applications for Unknown Nonlinear Delayed Systems in Discrete-Time; Elsevier: Amsterdam, The Netherlands, 2020. [Google Scholar] [CrossRef] [Scilit]
  13. Gómez-Avila, J.; López-Franco, C.; Alanis, A.Y.; Arana-Daniel, N. Control of Quadrotor using a Neural Network based PID. In Proceedings of the 2018 IEEE Latin American Conference on Computational Intelligence (LA-CCI), Guadalajara, Mexico, 7–9 November 2018; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
  14. Gomez-Avila, J.; Lopez-Franco, C.; Alanis, A.Y.; Arana-Daniel, N. Neural PD Controller for an Unmanned Aerial Vehicle. Algorithms 2020, 13, 226. [Google Scholar] [CrossRef] [Scilit]
  15. Lopez-Sanchez, I.; Moyrón, J.; Moreno-Valenzuela, J. Adaptive Neural Network-Based Trajectory Tracking Outer Loop Control for a Quadrotor. Aerosp. Sci. Technol. 2022, 129, 107847. [Google Scholar] [CrossRef] [Scilit]
  16. Song, X.; Wu, C.; Song, S.; Stojanovic, V.; Tejado, I. Fuzzy Wavelet Neural Adaptive Finite-Time Self-Triggered Fault-Tolerant Control for a Quadrotor Unmanned Aerial Vehicle with Scheduled Performance. Eng. Appl. Artif. Intell. 2024, 131, 107832. [Google Scholar] [CrossRef] [Scilit]
  17. Song, X.; Wu, C.; Dong, Y.; Song, S.; Shi, H.; Zhu, J.; Yan, B.; Wu, Q. Distributed Optimal Fuzzy Adaptive Prescribed-Time Formation Control for MQUAVs with Flexible Global Quantitative Behaviors. Sci. China Technol. Sci. 2026, 69, 1100313. [Google Scholar] [CrossRef] [Scilit]
  18. Meier, L.; Honegger, D.; Pollefeys, M. PX4: A Node-Based Multithreaded Open Source Robotics Framework for Deeply Embedded Platforms. In Proceedings of the 2015 IEEE International Conference on Robotics and Automation (ICRA), Seattle, WA, USA, 26–30 May 2015; IEEE: New York, NY, USA, 2015; pp. 6235–6240. [Google Scholar] [CrossRef] [Scilit]
  19. DJI. DJI Onboard SDK. Available online: https://developer.dji.com/onboard-sdk/ (accessed on 20 August 2026).
  20. PX4 Development Team. PX4 User Guide. Available online: https://docs.px4.io/main/en/ (accessed on 7 July 2026).
  21. Åström, K.J.; Hägglund, T. Advanced PID Control; ISA—The Instrumentation, Systems, and Automation Society: Durham, NC, USA, 2006. [Google Scholar]
  22. Horla, D. Static Anti-Windup Compensator Based on BMI Optimization for Discrete-Time Systems with Directional Change in Controls Avoidance. Bull. Pol. Acad. Sci. Tech. Sci. 2024, 72, e151046. [Google Scholar] [CrossRef] [Scilit]
  23. Alanis, A.Y. Exploring Kalman Filtering Applications for Enhancing Artificial Neural Network Learning. Algorithms 2025, 18, 587. [Google Scholar] [CrossRef] [Scilit]
  24. Beard, R.W.; McLain, T.W. Small Unmanned Aircraft: Theory and Practice; Princeton University Press: Princeton, NJ, USA, 2012. [Google Scholar]
  25. Aliane, N. A Survey of Pixhawk/PX4 Autopilot and Its Impact on Research and Education. Comput. Mater. Contin. 2026, 87, 6. [Google Scholar] [CrossRef] [Scilit]
  26. Franklin, G.F.; Powell, J.D.; Emami-Naeini, A. Feedback Control of Dynamic Systems, 8th ed.; Pearson: New York, NY, USA, 2019. [Google Scholar]
  27. Jagannathan, S.; Jagannathan, S. Neural Network Control of Nonlinear Discrete-Time Systems; CRC Press: Boca Raton, FL, USA, 2009. [Google Scholar]
  28. Hernandez-Barragan, J.; Rios, J.D.; Alanis, A.Y.; Lopez-Franco, C.; Gomez-Avila, J.; Arana-Daniel, N. Adaptive Single Neuron Anti-Windup PID Controller Based on the Extended Kalman Filter Algorithm. Electronics 2020, 9, 636. [Google Scholar] [CrossRef] [Scilit]
  29. Borase, R.P.; Maghade, D.K.; Sondkar, S.Y.; Pawar, S.N. A Review of PID Control, Tuning Methods and Applications. Int. J. Dyn. Control 2021, 9, 818–827. [Google Scholar] [CrossRef] [Scilit]
  30. MAVLink. MAVLink Developer Guide. Available online: https://mavlink.io/en/ (accessed on 1 September 2026).
  31. National Weather Service (NOAA). National Weather Service. Available online: https://www.weather.gov (accessed on 20 August 2026).
  32. Royal Meteorological Society. Beaufort Wind Scale. Available online: https://www.rmets.org/metmatters/beaufort-wind-scale (accessed on 20 August 2026).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.