Analysis and verification of multi-rotors attitude control algorithms in Pixhawk

Fangzhen Lin2016 · DOI

Abstract

Pixhawk is a widely adopted open-source flight control system. This research provides a theoretical analysis of the attitude control algorithms utilized by Pixhawk for multi-rotor aircraft, supplemented by simulations and flight experiments. Our findings demonstrate that the combination of a rotation vector-based attitude error algorithm and a cascade PID controller enables stable hovering and precise execution of complex maneuvers.

Introduction

In recent years, Unmanned Aerial Vehicles (UAVs), particularly small-scale multi-rotors, have seen a surge in popularity. As the core of these systems, flight controllers like Pixhawk have gained significant attention due to their reliable hardware and sophisticated software. However, the specific mathematical implementations of Pixhawk's control algorithms are often under-researched and treated as "black boxes" by the user community.

Conventional flight controllers typically calculate attitude error by subtracting current Euler angles (roll, pitch, yaw) from target values. This approach can be inefficient and prone to mathematical singularities during aggressive maneuvers. This paper aims to demystify Pixhawk's approach, focusing on its unique method for calculating attitude error and its robust control loop architecture.

Methodology

Hybrid Angle Error Calculation

Pixhawk avoids the limitations of simple Euler angle subtraction by employing a hybrid rotation vector approach. This method dynamically adjusts based on the magnitude of the deviation:

  1. Small Deviations: When the current and target attitudes are close, the algorithm first calculates the rotation required to align the $z$-axes. It then determines a separate "yaw error" to align the $x$ and $y$ axes. This decoupling prioritizes vertical alignment, which is critical for stability.
  2. Large Deviations: For significant errors, the system transitions to a quaternion-based representation. Quaternions provide a singularity-free way to represent any orientation in 3D space.
  3. Smoothing: A weighting factor ($direct\_w$) blends these two methods, ensuring a continuous and smooth error signal across all flight regimes.

Cascade PID Controller

The core of the control logic is a nested, or cascade, PID structure. This architecture separates the control of "slow" variables (attitude angles) from "fast" variables (angular rates).

Block diagram of the Pixhawk cascade PID attitude control architecture.
  • Outer Loop: This loop processes the calculated attitude angle error and generates a target angular rate.
  • Inner Loop: This loop compares the target angular rate from the outer loop with real-time gyroscope data to produce the final motor commands. This high-frequency feedback loop is essential for rejecting disturbances and maintaining precise control.

Experimental Verification and Results

The proposed analysis was validated through both numerical simulations and physical flight tests using a quadrotor running Pixhawk firmware.

Simulation Performance

Step-response tests were conducted for both small (5°) and large (50°) target attitude changes. The results indicated rapid convergence with minimal oscillation, showcasing the efficiency of the rotation vector approach.

Simulation results for a 5° step response in roll and pitch angles.

Flight Accuracy and Maneuverability

Outdoor flight experiments confirmed the simulation findings. Under normal operating conditions, the deviation between the target and actual attitude remained consistently below 3°. Furthermore, the system demonstrated robust tracking during large-angle movements, proving that the rotation vector method effectively finds the "shortest path" for attitude regulation.

Conclusion

This study confirms that Pixhawk's use of rotation vectors for error calculation, combined with a cascade PID controller, provides superior stability and maneuverability compared to traditional Euler-based methods. While the current weighting function effectively bridges different error regimes, future work could focus on optimizing these transitions and developing more automated methods for tuning the underlying PID gains.

Summary updated

Abstract

Pixhawk is an open-source flight control system. The research on the attitude control algorithm Pixhawk uses provides a good reference for the use and development of the Pixhawk. In this paper, it provides a theoretical analysis of the attitude control algorithm of multi-rotors in Pixhawk, and it also carried out simulations and flight experiments to verify the performance of the multi-rotor attitude control algorithm. It has shown that the attitude angle error algorithm based on rotation vector and cascade PID controller the Pixhawk uses not only can stabilize the multi-rotor around hovering, but also can realize complex maneuvers. introduction in recent years, the UAV is increasingly popular, especially small scale UAV, represented by the multi-rotor. Flight control systems as the core of UAV also attract more and more attention, at the same time, open source flight control systems have received considerable attention from research communities. with reliable hardware and excellent software algorithm, Pixhawk is most popular open source flight control system, while the research on the control algorithm in Pixhawk is poor, in this paper, the attitude control algorithm of multi-rotors is concerned, we mainly talk about the method of calculating the angle error and attitude controller, at the same time, we conduct simulation experiments and flight experiments to verify the attitude control algorithm. z g are unit vector, the dot product of _
BibTeX
@misc{lin2016analysis,
  author = {Fangzhen Lin},
  title = {{Analysis and verification of multi-rotors attitude control algorithms in Pixhawk}},
  year = {2016},
  doi = {10.2991/icadme-16.2016.107},
}
Figure