We have spent a bit of time tuning our UAV to get it flying well. We have found the APM to be a powerful and sophisticated system, however it is very complex and requires a lot of experience to get an in-depth understanding. It can be incredibly easy when it works, but incredibly frustrating when it doesn’t. We thought it would be worth sharing some of the experiences we’ve had so that others can learn from what we have found.

The basic steps are:

  1. Fly in manual
  2. Set-up APM
  3. FBW-A (not stabilise)
  4. Airspeed autocal
  5. Autotune for the pitch and roll control loops
  6. Nav loops
  7. Altitude and speed control loop

Manual flights

I’m not going to spend too much time discussing how to get your plane flying well in manual mode – suffice to say that this is a key step. Some things to watch out for:

  • Correct weight balance is usually 1/3 of the chord length of the wing from the leading edge
  • Ensure servo control rods are secured tightly

We discovered our servo control rod linkages did not have an extra grub screw which was required. When the control rods came loose in flight we lost control of our aircraft so this was a valuable lesson to learn.

Getting the plane flying in manual is the first step..
Getting the plane flying in manual is the first step..

Set-up APM

The APM should be installed in your plane as per the instructions ArduPlane Setup. This involves:

  • Installing Mission Planner software and APM firmware
  • Connecting RC equipment
  • Setup configuration
  • Checking it out in the air

Note it is worth repeating the steps in the first-time APM setup when any modifications are made to the airframe. We omitted these steps when we transferred the APM to a new plane, resulting in RC_trims which were incorrectly set and the APM would lose control when it entered AUTO mode. A good tip is to follow the points set out in the Mission Planner software:

  • Radio calibration
  • Flight modes
  • Hardware selection

A few more notes:

  • Power management. On one occasion we had the servos and the APM sharing the same power rail. When the servos drew a lot of power this caused a brown-out to the APM which cause it reset in flight and crash.
  • Try to keep the power-lines separate from the sensitive electronics, they can cause interference – particularly to the magnetometer
  • Make sure the APM is aligned in the forward direction of the plane

Use Fly-by-Wire mode, not Stabilise Mode

Once we have the APM set-up and working properly, the next step is tuning the control loops to improve the performance. A key point here is to use the Fly-by-wire mode (FBW-A or FBW-B) when tuning, and not the Stabilise mode. The stabilise mode uses different control loops and will not help you here. We mistakenly thought our UAV was correctly tuned when we were operating in Stabilise mode, however when we switched to Auto it was revealed that the control loops were not tuned.

Airspeed Auto-calibration

An important step to a well tuned UAV is having the airspeed sensor properly calibrated. The aircraft sets it’s speed from the airspeed sensor, so if this isn’t properly calibrated the UAV will try to fly itself at the wrong speeds. The easiest way to do this we found was to use the airspeed autocalibrate function. To do this we set ARSPD_AUTOCAL parameter to 1, and take a note of the ARSPD_RATIO. We then fly the plane in circuits for a few minutes, and check the ARSPD_RATIO afterwards. The ARSP_RATIO will have been adjusted so that the airspeed matches the average ground speed.

Here our airspeed is not calibrated properly. As can be seen the average ground speed (green) is much higher than the average airspeed (red).
Here our airspeed is not calibrated properly. As can be seen the average ground speed (green) is much higher than the average airspeed (red).

Autotune for Pitch and Roll Control Loops

Autotune is a nice function available in the APM release from version 3.0.3. This tunes the pitch and roll control loops. Autotune is a flight mode, so this is set-up in the Flight Modes part of the APM setup. We also set the AUTOTUNE_LEVEL parameter to 6 which seemed to work well. Then we fly the plane doing rapid roll right and left, and pitch up and down. The APM automatically adjusts the PID control settings to optimise the roll and pitch control loops. Pretty nifty.

Tuning the Navigation Loops

The navigation loop works out what heading is required to get the next waypoint, and then commands the planes bank angle to get it there. The navigation control loop is also called the L1 Controller, because this is the algorithm that is used.

There are a few things to consider here to get this tuned right:

  • The turning radius of the plane
  • Max bank angle setting
  • L1 Period
  • Waypoint Radius

The first thing you need to do is work out what is the max bank angle your plane can withstand. The higher the bank angle, the tighter the turning radius your plane will achieve, but this also puts more stress on your plane as more power is required to maintain constant altitude. We went with 50 degrees which works well for us. See the Banked Turn page on Wikipedia for a good explanation.

We reduced L1 period from 25 to 16, I believe this sets how quickly the bank angle is changed.

The waypoint radius can be thought of as how far ahead the APM looks to see whether it needs to change direction. Our waypoint radius was initially set to 15m, which resulted in some funny behaviour. We changed this to 60m and our navigation tuning looks much better.

Waypoint radius = 15m, a lot of overshoot
Waypoint radius = 15m, a lot of overshoot
Waypoint radius set to 60m, waypoint tracking is greatly improved
Waypoint radius set to 60m, waypoint tracking is greatly improved


Altitude and Speed control

The altitude and the speed of the UAV are controlled with a control loop algorithm called the Total Energy Control System. This basically looks at what airspeed and altitude is required, and the commands the throttle and pitch to achieve this. This seemed to work pretty well for us, so we haven’t messed around with this too much.