This article explains how to use AutoTune on Copter.
AutoTune attempts to automatically tune the Stabilize P, Rate P and D, and maximum rotational accelerations to provide the highest response without significant overshoot. Copter needs to be “basically” flyable in AltHold mode before attempting to use AutoTune as the feature needs to be able to “twitch” the copter in the roll and pitch axis.
The AutoTune feature was introduced in Copter 3.1.
Setup before flying¶
- Set up one flight mode switch position to be AltHold.
- Set an Auxiliary Function Switch to Autotune to allow you to turn the auto tuning on/off with the a switch.
- Remove the camera gimbal or any other parts of the frame that could wobble in flight
- Select which combination of axis (roll, pitch, yaw) you wish to tune using the AUTOTUNE_AXES parameter
- Set the autotune’s aggressiveness using the AUTOTUNE_AGGR parameter (0.1=agressive, 0.075=medium, 0.050=weak), normally start with the default 0.1.
- For large copters (with props at least 13inch or 33cm diameter) set the Rate Roll and Pitch filters to 10hz (in Copter-3.3 these are RATE_RLL_FILT_HZ and RATE_PIT_FILT_HZ, in Copter-3.4 they are ATC_RAT_RLL_FILT, ATC_RAT_PIT_FILT)
- It is recommended to enable battery voltage scaling of PID gains
How to invoke AutoTune¶
Wait for a calm day and go to a large open area.
Ensure the ch7 or ch8 switch is in the LOW position.
Take off and put the copter into AltHold mode at a comfortable altitude.
Face the vehicle so that it will twitch at 90degrees from the direction the wind is blowing (i.e. if tuning Roll first, point the vehicle into the wind)
Set the ch7/ch8 switch to the HIGH position to engage auto tuning:
- You will see it twitch about 20 degrees left and right for a few minutes, then it will repeat forward and back.
- Use the roll and pitch stick at any time to reposition the copter if it drifts away (it will use the original PID gains during repositioning and between tests). When you release the sticks it will continue auto tuning where it left off.
- Move the ch7/ch8 switch into the LOW position at any time to abandon the autotuning and return to the origin PIDs.
- Make sure that you do not have any trim set on your transmitter or the autotune may not get the signal that the sticks are centered.
When the tune completes the copter will change back to the original PID gains.
Put the ch7/ch8 switch into the LOW position then back to the HIGH position to test the tuned PID gains.
Put the ch7/ch8 switch into the LOW position to fly using the original PID gains.
If you are happy with the autotuned PID gains, leave the ch7/ch8 switch in the HIGH position, land and disarm to save the PIDs permanently.
If you DO NOT like the new PIDS, switch ch7/ch8 LOW to return to the original PIDs. The gains will not be saved when you disarm.
If you find after performing an AutoTune that the vehicle feels overly twitchy when flying Stabilize, AltHold or PosHold (but ok in more autonomous modes like Loiter, RTL, Auto) try reducing the RC_FEEL parameter to 0.25. This smooths out the pilot’s input.
In Copter-3.3 (and higher) AutoTune can be setup as a flight-mode. Switching into or out of the AutoTune flight mode responds in the same way as raising or lowering a ch7/ch8 aux switch high assigned the AutoTune function.
AUTOTUNE_AXES allows control of which axis are to be tuned. This is useful if the vehicle’s battery life is not long enough to complete all 3-axis). “1” = tune roll, “2” = tune pitch, “4” = tune yaw. Add these numbers together to tune multiple axis in a single session (i.e. “7” = tune all axis)
AUTOTUNE_AGGR : Should be in the range of 0.05 to 0.10. Higher values will produce a more aggressive tune but sometimes results in gains that are too high. More specifically this parameter controls the threshold for D-term bounce back and P-term overshoot. This affects the tuning noise immunity (a higher value is more tolerant to flex in the frame or other disturbances that could trick the tuning algorithm). High values also leads to a tune that rejects external disturbances better. Lower values result in a tune that is more responsive to pilot input.
The full list of parameters that may be updated by AutoTune
- Roll angular P gain ATC_ANG_RLL_P (in AC3.3: STB_RLL_P)
- Roll rate P, I and D gains ATC_RAT_RLL_P, ATC_RAT_RLL_I, ATC_RAT_RLL_D (in AC3.3: RATE_RLL_P, RATE_RLL_I, RATE_RLL_D)
- Roll max acceleration ATC_ACCEL_R_MAX
- Pitch angular P gain ATC_ANG_PIT_P (in AC3.3: STB_PIT_P)
- Pitch rate P, I and D gains ATC_RAT_PIT_P, ATC_RAT_PIT_I, ATC_RAT_PIT_D (in AC3.3: RATE_PIT_P, RATE_PIT_I, RATE_PIT_D)
- Pitch max acceleration ATC_ACCEL_P_MAX
- Yaw angular P gain ATC_ANG_YAW_P (in AC3.3: STB_YAW_P)
- Yaw rate P, I gain ATC_RAT_YAW_P, ATC_RAT_YAW_I, ATC_RAT_YAW_D (in AC3.3: RATE_YAW_P, RATE_YAW_I, RATE_YAW_D)
- Yaw rate filter ATC_RAT_YAW_FILT (in AC3.3: RATE_YAW_FILT_HZ)
- Yaw max acceleration ATC_ACCEL_Y_MAX
- Roll and pitch axis rate feed-forward is enabled (ATC_RATE_FF_ENABLE)
After you have a good tune, you may wish to increase ATC_THR_MIX_MAX (or MOT_THR_MIX_MAX in Copter-3.3) to 0.9 (default is 0.5) to increase prioritisation of attitude control over throttle. This can reduce the pitch overshoot sometimes seen (especially on copters with large propellers) in AltHold if the vehicle suddenly slows after performing fast forward flight. In this situation wind catches under the propellers providing lift but also disturbs the vehicle’s attitude leading to a conflict between throttle and attitude control. The danger in increasing this parameter’s value is that if the rate gains are later raised so high that the vehicle oscillates badly it may be difficult for the vehicle to descend (because it will prioritise trying to correct the attitude oscillations and never reduce throttle sufficiently).
AutoTune can request very large and fast changes in outputs to the motors which can cause ESC sync issues especially when using SimonK firmware and/or low KV motors (under 500KV). See this video showing a test which recreates a sync problem.
AutoTune is sometimes unable to find a good tune for frames with very soft vibration dampening of the flight controller or very flexible arms.
For best results the copter shouldn’t be allowed to build up too much horizontal speed. This can be prevented by applying a quick correction between tests (twitches) to stop the vehicle from flying too fast.
Be advised that AutoTune will engage in Stabilize, so don’t accidentally flip your AutoTune switch until you are in AltHold and ready to begin the procedure.
- AutoTune can be setup as a flight-mode. Switching into or out of the AutoTune flight mode responds in the same way as raising or lowering a ch7/ch8 aux switch high assigned the AutoTune function.
- Yaw axis is also autotuned
- Upon a succesful tune these additional values are saved:
- roll and pitch axis rate feed-forward is enabled (ATC_RATE_FF_ENABLE)
- roll, pitch and yaw acceleration limits are saved (ACCEL_R_MAX, ACCEL_P_MAX, ACCEL_Y_MAX)
When reporting issues with AutoTune please include a description of your frame and a dataflash log of the flight.
ATUN (auto tune overview) and ATDE (auto tune details) messages are written to the dataflash logs. Some details of the contents of those messages can be found on the Downloading and Analyzing Data Logs in Mission Planner wiki page.