How a drone’s attitude controller is structured
Most multirotor flight stacks, including ArduPilot, PX4 and Betaflight, control attitude with two nested loops per axis. The outer angle loop turns an attitude error into a desired rotation rate. The inner rate loop turns the rate error into motor commands; it uses the gyroscope directly and runs much faster.
Tuning therefore starts from the inside. A well-tuned rate loop is the foundation for everything else, and the outer angle loop is usually a single proportional gain. Each term has a distinct job:
- P (proportional) reacts to the current error. Too low feels sluggish; too high oscillates quickly.
- I (integral) removes steady errors such as an off-centre mass or constant wind. Too high causes slow overshoot and wobble.
- D (derivative) damps overshoot by reacting to the rate of change. It also amplifies gyro noise, so filtering matters.
- FF (feed-forward) responds to the command directly. It improves tracking without making the loop less stable.
Where the gains live in common flight stacks
Parameter names differ between firmware stacks, but the structure is the same. Using roll as the example:
| Firmware | Rate loop | Angle loop |
|---|---|---|
| ArduPilot Copter | ATC_RAT_RLL_P, _I, _D, _FF | ATC_ANG_RLL_P |
| PX4 multicopter | MC_ROLLRATE_P, _I, _D, _FF | MC_ROLL_P |
| Betaflight | Roll P, I, D and feed-forward | Angle mode strength |
Why tune on a test rig first
Free flight mixes every effect at once: translation, wind, battery sag, ground effect and pilot input. On a 3-axis rig the vehicle can only rotate, so the attitude response is isolated, repeatable and measurable, and a bad gain ends in a wobble instead of a crash.
The price is that the rig becomes part of the system. Ring inertia, bearing friction and any offset between the rotation centre and the vehicle’s centre of mass change the dynamics. Gains found on a rig are a strong starting point, not a final answer. The 3-DOF test rig guide explains which rig properties matter most.
What to measure
- Desired versus actual rate on each axis, logged at the rate-loop frequency. ArduPilot records these in its RATE log message; PX4 logs the rate setpoint and the measured angular velocity.
- Step response: rise time, overshoot and settling time after a sharp command.
- Oscillation frequency and amplitude, to tell a fast, P-driven oscillation from a slow, I-driven wobble.
- Motor outputs, to spot saturation and noise reaching the motors.
- An independent reference. On a rig with axis encoders, compare the controller’s own attitude estimate with the measured angle.
A tuning order that works
- Prepare the vehicle. Balance it in the fixture so that its centre of mass sits on the rotation centre, check motor direction and propellers, and set the gyro filters for the frame’s vibration.
- Start conservative. Reduce the rate P and D gains below the defaults and set I low. Limit throttle and keep the rig guarded.
- Tune rate P, one axis at a time. Raise P in small steps until a fast oscillation appears, then back off to leave a margin.
- Add D to damp overshoot. Increase D until steps settle cleanly. Stop if the motors get hot or noisy: D is then amplifying noise.
- Raise I for attitude hold. Increase I until the axis holds against a constant offset without a slow wobble.
- Add feed-forward, then set the angle P. Use FF to tighten tracking, then tune the outer angle gain for a crisp response without overshoot.
- Repeat for pitch and yaw, then test combined motion. Yaw usually needs less D and more I. Finish with combined-axis manoeuvres to check cross-coupling.
Typical problems and what they mean
- Fast, buzzing oscillation: P or D too high, or too little filtering.
- Slow wobble after a move: I or the angle P too high.
- Drift that returns slowly: I too low, or the centre of mass is off the rotation centre on the rig.
- Hot motors and noisy outputs: D-term noise. Revisit the gyro and D-term filters before raising D.
- Axes that disturb each other: frame flex, a loose flight-controller mount or limited yaw authority. Test combined motion.
From the rig to the first flight
Expect a short refinement in the air: aerodynamic damping, translation and battery sag are missing on the ground. ArduPilot and PX4 both offer in-flight autotune functions, and a rig-tuned starting point makes those flights shorter and safer. Fly in a stabilised mode, log the same signals and compare them with the rig recordings. Large differences usually point to the rig, its inertia, friction or centre-of-rotation offset, rather than to the controller.
INFINITE-HIL X1 supports both rig approaches: free operation, in which the vehicle’s own controller rotates it, and HIL scenarios in which the platform applies model-based disturbance torques. Operating mode and safety measures are defined per project. For tuning as part of a full validation workflow, see flight controller testing from SIL to HIL.