172
edits
(Added Howto for Windows) |
(Added Screenshots & enhanced Windows section) |
||
Line 13: | Line 13: | ||
You can find good explanations on how to practically tune the controller. [http://en.wikipedia.org/wiki/PID_controller Wikipedia's article on the PID Controler] | You can find good explanations on how to practically tune the controller. [http://en.wikipedia.org/wiki/PID_controller Wikipedia's article on the PID Controler] | ||
=== Getting graphs of Controler action === | === Getting graphs of Controler action (Linux) === | ||
While it's possible to tune a PID controller by testing directly the aircraft behaviour under the autopilot control, it can be really useful 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 useful to get everything in graphical view. | ||
Line 45: | Line 45: | ||
* [http://kst.kde.org/ Kst, real-time large-dataset viewing and plotting tool] | * [http://kst.kde.org/ Kst, real-time large-dataset viewing and plotting tool] | ||
Under Windows | |||
=== Getting graphs of Controler action (Windows) === | |||
Under Windows the script of the Linux chapter works (with some minor modifications) together with Live-Graph under Windows, too. Although the output to a logfile is not as fluently as you may experience it under Linux. To get an output you first need a slightly modificated version of the above mentioned Perl script: | |||
<pre> | <pre> | ||
if (<STDIN>) { | |||
print STDOUT "##|##\n"; | |||
print STDOUT "Input|Ref|P|I|D|Output\n"; | |||
} | |||
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"; | |||
} | |||
} | |||
</pre> | </pre> | ||
Feel free to prepare %fg-root%\preferences.xml to your desired needs if you plan to start at another location (instead of KSFO) or with another plane (instead of Cessna 172p) or if you want to change other options. | |||
[[Image:Live-graph-datafile-settings.png|thumb|Setting the Logfile input]] | |||
[[Image:Livegraph-graph-settings.png|thumb|Setting the visuals]] | |||
[[Image:Livegraph-dataseries-settings.png|thumb|Finetuning the visuals]] | |||
[[Image:Livegraph-plot.png|thumb|Livegraph plotted data]] | |||
The first 4 lines prepare a kind of "header" in the Logfile so that the Grapher can use it. Copy and paste these lines into your favorite ascii text editor and save it to your fg directory (e.g. save as "fgfsparser.pl"). Next you need to install a Perl Interpreter (e.g. [http://www.activestate.com/activeperl Activestate's Active Perl]). Now start Flightgear the following way: | |||
<pre> | |||
path-to-fgfs-binary\fgfs.exe | perl fgfsparser.pl > my_file 2&1 | |||
</pre> | |||
Feel free to prepare %fg-root%\preferences.xml to your desired needs if you plan to start at another location (instead of KSFO) or with another plane (instead of Cessna 172p) or if you want to change other options. As an alternative use the command line options to modify the startup to your desired needs. | |||
The following part describes the visualization of the debug output with [http://www.live-graph.org Live Graph]. Live-Graph is a GPL'd Graph Plotter for Windows systems available at Sourceforge.org. | |||
After installing it start Live-Graph and set the Data file to your output logfile (e.g. "my_file"). Be aware that you don't have an output file before you did not start the process of debug output at least one time. In this case start Flightgear first and activate the function on the autopilot where you actived the debug output. Back to Live-Graph: The update frequency works fine with updates at 0.5 Hz to 1 Hz (every 1 to 2 seconds). Activate "Show tail data" so that your graph will not be overcrowding during the time and keep caching data active or you will experience loss of data which makes your tests useless. | |||
Next you need to define the visal output. Set the viewport on the Y-axis from min. -1.5 to max. +1.5. X-axis set to auto on both sides. It's quite handy to set the horizontal grid (I prefer a grid size of 0.2). And last but not least on X Axcis set "Dataset numbers" as type for the input. | |||
In the Data series window you can switch the single values on and off and define the way how the program should plot the data. Here in the image I aquire the data of a simple wing leveller and therefor I normalize all data to values between 0 and 1. Be aware that my settings are not mandatory. Be creative and play around with different settings until you feel satisfied with the plotted data. | |||
With "debug" in your AP.xml set to "true" you will now get the logfile filled and step by step the data will be visualized in Live-Graph. Now it's time to preset the autopilot to an initial value and to start the testing. | |||
== Alternative Method == | == Alternative Method == |
edits