Drone Development Sharing — Learn How to Tune PID Parameters for Quadcopter Drones
Recently, drone DIY enthusiasts at Drone Dev Workshop have started building their own drones, mostly based on open-source flight controllers like PX4, APM, and INAV. Before diving into flight controller development, the first challenge they encountered was that the default PID parameters of open-source flight controllers don’t always guarantee stable flight. PID tuning is the core of quadcopter flight control, directly determining the stability, response speed, and flight feel of the aircraft. Most developers find that their newly purchased or freshly assembled drones either feel sluggish due to overly conservative default parameters, or experience dangerous oscillations from blindly increasing gains.
This article is based on the official tuning guides for PX4 and APM, explained in plain language to walk you through PID tuning step-by-step, from basics to advanced, helping you achieve optimal flight performance.
Official documentation links:
PX4 Official Tuning Guide:
https://docs.px4.io/main/en/config_mc/pid_tuning_guide_multicopter_basic
APM Official Tuning Guide:
https://ardupilot.org/copter/docs/ac_rollpitchtuning.html
1. Preparation for Tuning
1.1 PID Parameter Logic
Proportional Gain (P):
Proportional gain is used to reduce tracking error and speed up response. It should be set as high as possible without introducing oscillations.
- Too high: Causes high-frequency oscillation — the drone “won’t stop shaking”
- Too low: Slow response to transmitter inputs, easy to drift in acro mode
Derivative Gain (D):
Derivative gain provides rate damping and suppresses overshoot. It should also be set as high as possible.
- Too high: Motors become “twitchy,” prone to overheating, and amplify sensor noise
- Too low: Obvious overshoot after step inputs (e.g., drone tilts excessively after stick input)
Integral Gain (I):
Integral gain eliminates steady-state error and ensures the drone maintains the commanded attitude.
- Too high: Causes slow, low-frequency oscillation
- Too low: In acro mode, after tilting 45 degrees the drone will slowly return to level, unable to hold the angle
1.2 Critical Safety Warnings
- All gain adjustments must be made after landing — never adjust parameters in flight
- Each gain adjustment should be limited to 20%-30%. After finding the optimal value, reduce by 5%-10% to leave a safety margin
- First test flights must be conducted in open, unoccupied areas, maintaining a safe distance
1.3 Basic Tuning Principles
PX4’s flight controller uses a multi-layer closed-loop control structure:
- Inner loop (Rate Controller): Controls the angular velocity of roll, pitch, and yaw axes — this is the foundation of the entire control system
- Outer loop (Attitude Controller): Controls the aircraft’s attitude angle, outputting target angular velocity to the inner loop
Tuning must follow the order of inner loop first, then outer loop. If the inner loop isn’t tuned well, no amount of outer loop tuning will help.
1.4 Flight Mode Selection
Recommended modes:
- Stabilize mode / Altitude Hold mode for attitude tuning
- Acro mode for rate controller tuning — it isolates the attitude controller’s influence, allowing you to focus on testing rate control performance. It’s important to distinguish whether issues stem from the rate controller or attitude controller.
1.5 Basic Tuning Procedure
- If the drone has a symmetrical structure, you can quickly complete manual tuning for both roll and pitch axes simultaneously. If the aircraft structure is asymmetrical, each axis must be tuned separately.
- If the aircraft oscillates during flight, do not make large, aggressive stick inputs. Smoothly reduce throttle to land while making very small, slow roll and pitch stick adjustments to control attitude and position.
Single-axis tuning follows these steps:
- If the axis already has oscillation issues, first reduce P, D, and I parameters by 50% increments until the aircraft stabilizes, then begin manual tuning.
- Increase D (Derivative) parameter by 50% increments until oscillation is observed.
- Reduce D parameter by 10% increments until oscillation completely disappears.
- Reduce D parameter by an additional 25%.
- Increase P (Proportional) parameter by 50% increments until oscillation is observed.
- Reduce P parameter by 10% increments until oscillation completely disappears.
- Reduce P parameter by an additional 25%.
- After each P parameter modification, set I (Integral) to match the P parameter value.
It is recommended to modify these parameters on the ground with the aircraft disarmed and powered off. Experienced pilots may also modify parameters in real-time during flight via the ground station or transmitter tuning knobs.
2. Learning Tuning Methods
PX4 and other flight controllers use Proportional-Integral-Derivative (PID) controllers, currently the most widely used flight control algorithm.
The QGroundControl ground station’s PID tuning interface can display target command curves and attitude response curves in real time. Core tuning objective: Optimize P/I/D parameters so that the aircraft’s actual response curve tracks the target setpoint curve as closely as possible, achieving rapid response, no overshoot, and no oscillation.
The flight controller uses a layered architecture: upper-layer controllers output commands to lower-layer controllers for execution. The hierarchy from high to low is: Rate Controller → Attitude Controller → Velocity & Position Controller. PID tuning must strictly follow this order, prioritizing the rate controller, as its parameters directly affect all upper-layer control logic.
All controllers (rate, attitude, velocity/position) and flight axes (yaw, roll, pitch) follow the same tuning method: quickly and aggressively move the sticks to create step-input command changes, observe the aircraft attitude response curve, then drag parameter sliders to optimize tracking performance.
Rate controller tuning is the most critical. Once it meets standards, the remaining controllers typically need no adjustment or only minor fine-tuning.
2.1 Rate Controller (Inner Loop) Tuning
The rate controller is the innermost control loop, and its quality directly affects all flight modes. A poorly tuned drone will exhibit “twitching” or persistent oscillation even in position-hold mode.
Step 1: Adjust Proportional Gain (P)
- Too high: High-frequency oscillation — the drone “won’t stop shaking”
- Too low: Slow response to transmitter inputs, easy to drift in acro mode
Procedure: Slowly take off to hover. Quickly push the roll/pitch stick then rapidly return to center, observing the drone’s response. Increase MC_ROLLRATE_K and MC_PITCHRATE_K by 20% each time. Continue until slight high-frequency oscillation appears, then back off by 10%-20%.
Step 2: Adjust Derivative Gain (D)
Derivative gain provides rate damping and suppresses overshoot. Set as high as possible.
- Too high: Motors become “twitchy,” prone to overheating, amplify sensor noise
- Too low: Obvious overshoot after step inputs
Typical values (standard mode): 0.01 (4-inch racer) to 0.04 (500mm wheelbase drone)
Step 3: Adjust Integral Gain (I)
Integral gain eliminates steady-state error and ensures the drone maintains the commanded attitude.
- Too high: Slow, low-frequency oscillation
- Too low: In acro mode, after tilting 45 degrees the drone slowly returns to level, unable to hold the angle
Typical values (standard mode): 1 (500mm wheelbase drone) to 8 (4-inch racer). Pitch gain is usually slightly higher than roll gain.
3. Log Analysis: Making Tuning Scientific
Visual observation alone makes it difficult to precisely evaluate tuning results. PX4’s log analysis feature helps you evaluate control performance more scientifically.
After tuning, download the flight log and examine the following curves:
- Angular velocity curves: The desired angular velocity and actual angular velocity should overlap as closely as possible, with minimal overshoot and no persistent oscillation.
- A well-tuned log will show only very slight overshoot on rapid step inputs, then quickly track the desired value.
4. Summary
Tuning Mnemonic:
Inner loop first, then outer loop. Proportional first, then derivative, then integral. Make small adjustments each time. If oscillation appears, dial it back.
Common Issues:
- High-frequency jitter: Rate controller P or D gain too high
- Slow oscillation: Rate controller I gain too high
- Position mode drift: First check if the rate controller is stable, then adjust attitude controller gains
To all drone developers: PID tuning is a process that requires patience and experience. There are no absolutely perfect parameters — only the parameters that best suit your aircraft and flying style. Fly more, tune more, analyze logs more, and you’ll soon master this skill, making your drone rock-solid in the air!
We’ll continue sharing advanced content like PX4 custom module development, ROS2 and PX4 communication, autonomous obstacle avoidance algorithm development, and multi-drone swarm control.
Source: 无人机自由开发坊 (WeChat) — Translated from Chinese for Aomway readers.
