Autopilot PID controller tuning resources: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (→‎Flightgear PID Controler: and some more spelling errors)
m (Corrected some spelling errors)
Line 1: Line 1:
Flightgear Autopilot is a modular system based on PID controlers. Here are some tips to help in the tuning of such a controler. There is lot of documentation all over Internet about how to tune the parameters, having this you will have to figure out how works the Flightgear PID controler implementation.
Flightgear Autopilot is a modular system based on PID controllers. Here are some tips to help in the tuning of such a controller. There is lot of documentation all over Internet about how to tune the parameters, having this you will have to figure out how works the Flightgear PID controler implementation.


First of all, have a look at the code where you will see the algorythm wich is used for our autopilot. The reading of the existing autopilots in Flightgear aircraft datas will do the rest.
First of all, have a look at the code where you will see the algorithm wich is used for our autopilot. The reading of the existing autopilots in Flightgear aircraft datas will do the rest.


There is actually a doc about filters in Flightgear documentation. Filters can be applied on input or ouput values, in other words, before and after the PID controler.
There is actually a doc about filters in Flightgear documentation. Filters can be applied on input or ouput values, in other words, before and after the PID controller.


=== Flightgear PID Controler ===
=== FlightGear PID Controler ===


Knowing the algorithm is mandatory, certain values are forbidden, for example they can lead to a division by zero. Then you will have to understand where the parameters apply to act on the choosen correction module. See the schema wich is a good reminder while doing the tests.
Knowing the algorithm is mandatory, certain values are forbidden, for example they can lead to a division by zero. Then you will have to understand where the parameters apply to act on the choosen correction module. See the schema wich is a good reminder while doing the tests.
Line 15: Line 15:
=== Getting graphs of Controler action ===
=== Getting graphs of Controler action ===


While it's possible to tune a PID Controler by testing directly the aircraft behaviour under the autopilot control, it can be really usefull to get everything in graphical view.
While it's possible to tune a PID controller by testing directly the aircraft behaviour under the autopilot control, it can be really usefull to get everything in graphical view.


[[Image:pid_cotroler_data_graph.png|thumb|Datas of an Auto-trim PID Controler displayed as graphs]]
[[Image:pid_cotroler_data_graph.png|thumb|Datas of an Auto-trim PID Controler displayed as graphs]]


First of all you'll have to turn the PID Controler's debug mode on. That is in the autopilot.xml you are working on. (I didn't try to turn more than one PID controler's debug at the same time).
First of all you'll have to turn the PID Controler's debug mode on. That is in the autopilot.xml you are working on. (I didn't try to turn more than one PID controller's debug at the same time).


Then you will get 6 new values displayed on the console at each FG loop. You will need to catch them and format the values in one line. Here is an exemple of a parser script written in Perl:
Then you will get 6 new values displayed on the console at each FG loop. You will need to catch them and format the values in one line. Here is an exemple of a parser script written in Perl:

Revision as of 17:11, 8 January 2007

Flightgear Autopilot is a modular system based on PID controllers. Here are some tips to help in the tuning of such a controller. There is lot of documentation all over Internet about how to tune the parameters, having this you will have to figure out how works the Flightgear PID controler implementation.

First of all, have a look at the code where you will see the algorithm wich is used for our autopilot. The reading of the existing autopilots in Flightgear aircraft datas will do the rest.

There is actually a doc about filters in Flightgear documentation. Filters can be applied on input or ouput values, in other words, before and after the PID controller.

FlightGear PID Controler

Knowing the algorithm is mandatory, certain values are forbidden, for example they can lead to a division by zero. Then you will have to understand where the parameters apply to act on the choosen correction module. See the schema wich is a good reminder while doing the tests.

PID parameter's application

You can find good explanations on how to practically tune the controller. Wikipedia's article on the PID Controler

Getting graphs of Controler action

While it's possible to tune a PID controller by testing directly the aircraft behaviour under the autopilot control, it can be really usefull to get everything in graphical view.

Datas of an Auto-trim PID Controler displayed as graphs

First of all you'll have to turn the PID Controler's debug mode on. That is in the autopilot.xml you are working on. (I didn't try to turn more than one PID controller's debug at the same time).

Then you will get 6 new values displayed on the console at each FG loop. You will need to catch them and format the values in one line. Here is an exemple of a parser script written in Perl:


#!/usr/bin/perl -w
# prints: "input reference P I D output"

while (<STDIN>) {
        if ($_ =~ /input\s=\s(-*\d+.*)\sref\s=\s(-*\d+.*)/) {
                print STDOUT "$1 $2 ";
        } elsif ($_ =~ /P:(-*\d+.*)\sI:(-*\d+.*)\sD:(-*\d+.*)/) {
                print STDOUT "$1 $2 $3";
        } elsif ($_ =~ /output\s=\s(.*)/) {
                print STDOUT " $1\n";
        }
}

Then you can write them in a file...


alexis@linear:~/fgfs$ /usr/local/bin/fgfs 2>&1 | ./PIDcontroler_parser.pl > my_file

If you use Linux, You can run Kst simultaneously to read the datas on the fly and watch them displayed together in real time while testing the aircraft.


Kst, real-time large-dataset viewing and plotting tool