ArduCopter Analytic Tune Web Tool

It has been a goal of mine to find a better way to tune helicopters. I spent almost two years developing the traditional helicopter autotune flight mode. It is far from perfect but gives users the tools to tune their helicopters. TradHeli autotune uses a frequency domain approach in which it determines the max allowable control gains (i.e. rate P or rate D) but still uses an incremental approach to increasing the gains until the tuning criteria are met. This is very similar to the multirotor autotune except it uses a time domain approach. These all use incremental steps and measure the response to determine the level of tune. This requires several flights for tuning and risk to the aircraft.

Control theory of linear systems offers a technique to be able to tune systems through analytical means. This requires the frequency response of the bare airframe dynamics which can be determined from a system ID mode flight. Once the bare airframe frequency response is obtained, the control laws are applied analytically to provide a closed loop frequency response to determine the quality of the tune. The quality of the tune can be evaluated at several levels: rate controller, attitude controller, and pilot input (includes the command model feel characteristics). Other predictions include the attitude disturbance response and stability margins for rate, attitude and entire control system.

The web tool is still under development but I think it has matured enough for users to benefit from it. It can be found here

Theory
This technique assumes the aircraft with the control system is a linear system. Control elements that cause discontinuities like acceleration and rate limits cannot be handled by this technique. Thus it is important to keep the rates and accelerations small. Changes in the control gains like use of the slew rate limiter where it was actively changing the gain during the frequency sweep would also cause problems for this technique. The frequency responses determined are most valid for the condition for which they were gathered (i.e. hover or 10 m/s forward flight). In most cases, the aircraft is tuned for hover conditions but the aircraft characteristics change through out the flight envelope. so be cautious in using the tune determined in a hover for other flight conditions. A simple control system is shown below to explain the method for analytically determining the closed loop frequency response.


The closed loop system shown in the dashed box can be described in the frequency domain by a frequency response. The frequency response shows the relationship of the aircraft response to the input in both amplitude and phase across a range of frequencies and is calculated from the system ID mode data. The frequency response of the Aircraft alone (i.e bare airframe), shown as a block in the closed loop system, can also be determined from the system ID mode data. Once the bare airframe frequency response is known, the equation for the closed loop system can be used to determine or predict the frequency response of the closed loop system. Thus, control gains, like rate P or rate D, can be changed and the predicted frequency response will show how the closed loop system response will change allowing the user to tune the aircraft response without repeatedly changing the control gains in flight and evaluating the aircraft response. It can all be done on the computer. The final tune can then be checked by conducting another system ID mode flight to verify the desired tune was obtained.

Here is the block diagram of the arducopter control laws for the roll axis.


Each of the blocks represents a transfer function of the associated Notch filter, Low pass filter or Control algorithm. The expressions for each of the closed loop systems is given below

Rate Controller

Attitude Controller

Complete Controller including pilot feel

Gathering the Data to Use the Analytic Tune Web Tool
In order to start tuning your multirotor or helicopter using the analytic tune web tool, a frequency sweep needs to be collected using the System ID mode. Follow the instructions for setting up the mode parameters. You can use SID_AXIS values of 1 through 6 to gather the data however it is recommended that SID_AXIS values of 4 (recovery roll), 5 (recovery pitch), or 6 (recover yaw) be used. If you are concerned with high accelerations or rates of the vehicle that may cause damage, then you can use SID_AXIS values of 1 - 3. The SID_MAGNITUDE should be no higher than 5 deg for pitch or roll and 5 deg/s for yaw.

Before conducting the sweep using the System ID mode, be sure that all of the INS notch filters and low pass filters are set. The tool does allow you to explore different settings but it is important to set these properly to remove the noise from the control signals to obtain the best tune.

Using the Web Tool

Loading the Log File

To start using the web tool, you will load the log file and set the Fast Fourier Transform (FFT) window size, highlighted by the red boxes. For a sample rate of 100hz, a window size of 1024 works well.

Selecting System ID Run and Initiating the Analytical Tune

After the log file is loaded, the first system ID run is shown in the time history window with it highlighted in the time history of the entire log. A table of all of the System ID runs (highlighted in red) is provided and the user can select the run they want to use. The axis of the System ID run and the time range is automatically populated. After the run is selected, click Calculate (highlighted in red) to begin analytical tuning.

Parameters

Parameters are automatically loaded from the log file. Only the attitude controller parameters for the axis being tuned are loaded. Parameters can be loaded from a *.param file using the Load Parameter button. Once the analytic tune is completed, the parameters can be saved using the Save Parameters button and then loaded onto the aircraft for testing.


Frequency Responses Available for Tuning
The list of graphs available to use for analytically tuning the aircraft are shown below. Where data is available from the System ID run, a calculated frequency response is shown. Otherwise, the predicted frequency response uses the parameters set on the page to predict the frequency response.

Bare Aircraft
The bare aircraft frequency response shows the dynamics of the aircraft alone as determined by the frequency response of the motors class input to the aircraft response.
Roll: RATE.ROut → SIDD.Gx
Pitch: RATE.POut → SIDD.Gy
Yaw: RATE.YOut → SIDD.Gz

Rate Controller
This plot is used to tune the rate controller PIDs and adjust PID low pass and notch filters.

Attitude Controller with Feedforward
This plot is used to tune the attitude controller P gain and tune the target low pass and notch filters.

Attitude Controller without Feedforward
This plot provides the frequency response of the attitude controller without the feedforward enabled. In this case, the calculated frequency response is not shown as the data was collected with the feedforward enabled.

Input Shaping
This plot shows the effects of the input shaping (feel) on the aircraft response. This is what the pilot would experience when making inputs. This response is used to tune the ATC_INPUT_TC for pitch and roll axes and the PILOT_Y_RATE_TC for the yaw axis. Differences between the calculated and predicted (shown below) when using the log parameters would most likely be caused by acceleration or rate limits.

Attitude Disturbance Rejection
This plot shows how well the attitude control loops can reject attitude disturbances. It is primarily used to determine attitude disturbance rejection bandwidth which is determined as the frequency at the -3 db crossing. The calculated frequency response is only determined for System ID runs where SID_AXIS is 4, 5 or 6.

Stability Plots
The Rate, Attitude and Entire System Stability plots are used to determine Stability margins in the respective control loop. The rate stability plot shows the stability of the rate controller. The attitude stability plot shows the stability of the attitude controller without feedforward enabled. The entire system plot shows the stability of the attitude controller with the feedforward enabled.

12 Likes

Also, Here is a link to the presentation that I gave on this tool at the Ardupilot Developers Conference. I describe a little bit on how it is used to tune a vehicle. I hope to add more discussion on how to use it to tune a helicopter.

3 Likes

I have a question. In the video, you mentioned that the aircraft might experience instability with increased oscillations, and you mentioned that testing should be stopped immediately at this point. How should the test be stopped immediately? When does the test start? Is there a function like autotune switch? I didn’t seem to find this feature in the settings. For example, I want to fly the copter to the reeds farther in front of me, turn on the switch, let it start oscillating, and immediately turn off the switch when things go wrong, and then land my copter back.

I can’t wait to try this new feature on my 34-inch prop copter.

Hey Bill, thanks for the great job you did with this.

Step 46 of the ArduPilot Methodic Configurator automatically opens your webtool in a browser. So it makes it easier for users to discover it.

1 Like

Very interested in trying out to confirm wheter my manual tuning was correct or not!!! Very good project!!

I guess I should have said that you should stop the frequency sweep which is being done through the system ID mode. So switching out of system ID mode to another flight mode would stop the sweep.

alright, I guess I must have been too tired at the time to remember to check the flight mode parameters. Anyway, I’m currently working on resolving some annoying vibration issues. Once I fix them, I’ll give it a try.

Thank you for the post, Bill!

It’s a bit hard to tell what each picture/plot shows, but I guess it’s going to become clearer once I’m doing a use-case.

But, on a related question, on the last picture you show the closed-loop overall response, I assume?
What does it mean for the depicted system to have a gain over unity at those high frequencies and phase close to 180?

Or am I reading the plot wrong?

I’m sorry that wasn’t more clear on this plot. This is the broken loop stability. The input for this frequency response is the chirp added to the output of the rate controller which is the input to the motors mixer. You would use SID_AXIS 10, 11, or 12 (mixer input). The output is the output of the rate controller. The closed loop system is broken at the input to the motor mixer.

Great question. I don’t necessarily know what that means but this analysis is used to determine gain and phase margins to instability. Instability is defined where gain is zero or phase is -180. So in this particular plot I would consider the plots to be accurate from 0.6 to 7 hz based on coherence. The phase crosses -180 deg at 0.6 and 6 hz. At 0.6 hz, the gain margin would be greater than 10dB and at 6 hz the gain margin would be approximately 6 db. Most references say that you want to be at least 6 db from instability. The gain crossed 0db at approximately 3.5 hz and the phase margin would be a little over 30 deg. Most references say that there should be at least 45 deg phase margin.

When you do a case study, increase the rate P gain while monitoring the rate stability plot. You should see the gain margin start to decrease and as you approach the instability, if you switch to the rate controller plot, you would see a hump (greater than 1db) at about the same frequency where the gain margin is seen. As you further increase the P gain, the gain margin would decrease and the hump on the rate controller plot will increase showing that you are getting closer to the instability.

I know I didn’t actually answer your question but hopefully gave you a better understanding of the plot and how it is used.

1 Like

Bill please do add this information to the webtool.

1 Like

I have one more question. In the example settings at System Identification Mode — Copter documentation, the SID_AXIS values are set to 10-12, but your article mentions using 1-6 for data collection. I know what these values mean, but what is the final difference between injecting into the input signal and injecting into the output signal? Does this significantly affect data collection, or is it only a matter of safety?

We are using the frequency sweep to do the same thing which is identify the bare airframe response (open loop response). However, the SID_AXIS of 4-6 are used in order to see how well the closed loop responses are being predicted initially. This gives confidence that the aircraft conforms to the assumption of a linear system which is what my predictions are based upon. If you were to use SID_AXIS of 10-12 then you only can calculate the open loop response and have nothing to compare the prediction to initially.

Bill, is there a basic explanation that describes the difference between Autotune in Trad-Heli and the method of tuning you’re explaining here with the web tools and System ID mode? This process is a little above my head but I’m trying to learn more. Thanks!

1 Like

Allister, The only difference is that I am tuning the aircraft with only doing one flight. That gives me the basic data to tune it on my computer. How I would go about increasing gains to tune the aircraft is basically the same. I am doing what the tradheli autotune does but just on the computer rather than in flight. This is somewhat similar to what is done for a manual tune except you have the right information to make the key decisions for how to tune the aircraft. There is very little guessing with the analytic tune method. I apologize for not having a guide on this. I will try to get that done soon.

4 Likes

Dear @bnsgeyer, your tool may be the one I need for my project. What do you think - is this method suited for my tandem?

Yes this method of tuning would be suitable for any multirotor or helicopter frame type.