Autopilot PID controller tuning resources: Difference between revisions

Jump to navigation Jump to search
Syntaxhihglight
(Syntaxhihglight)
Line 37: Line 37:
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 example 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 example of a parser script written in Perl:


<pre>
<syntaxhighlight lang="perl">
#!/usr/bin/perl -w
#!/usr/bin/perl -w
# prints: "input reference P I D output"
# prints: "input reference P I D output"
Line 50: Line 50:
         }
         }
}
}
</pre>
</syntaxhighlight>


Then you can write them in a file...
Then you can write them in a file...


<pre>
<syntaxhighlight lang="bash">
alexis@linear:~/fgfs$ /usr/local/bin/fgfs 2&gt;&1 | ./PIDcontroller_parser.pl &gt; my_file
alexis@linear:~/fgfs$ /usr/local/bin/fgfs 2&gt;&1 | ./PIDcontroller_parser.pl &gt; my_file
</pre>
</syntaxhighlight>


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.
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.
Line 69: Line 69:


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 modified version of the above mentioned Perl script:
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 modified version of the above mentioned Perl script:
<pre>
<syntaxhighlight lang="perl">
if (<STDIN>) {
if (<STDIN>) {
print STDOUT "##|##\n";
print STDOUT "##|##\n";
Line 83: Line 83:
}
}
}
}
</pre>
</syntaxhighlight>


The first 4 lines prepare a kind of "header" in the Logfile so that the Grapher can use it. In the while-part I added the pipe sign as separator so that Live-Graph can use the output. 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:
The first 4 lines prepare a kind of "header" in the Logfile so that the Grapher can use it. In the while-part I added the pipe sign as separator so that Live-Graph can use the output. 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>
<syntaxhighlight lang="bash">
path-to-fgfs-binary\fgfs.exe | perl fgfsparser.pl &gt; my_file 2&1
path-to-fgfs-binary\fgfs.exe | perl fgfsparser.pl &gt; my_file 2&1
</pre>
</syntaxhighlight>
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 start-up to your desired needs.
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 start-up to your desired needs.


Navigation menu