| 1 |
Logging in FlightGear |
| 2 |
--------------------- |
| 3 |
|
| 4 |
[Note: JSBSim also has its own independent logging facilities, which |
| 5 |
are not discussed here.] |
| 6 |
|
| 7 |
FlightGear can log any property values at any interval to one or more |
| 8 |
CSV files (which can be read and graphed using spreadsheets like |
| 9 |
Gnumeric or Excel). Logging is defined in the '/logging' subbranch of |
| 10 |
the main property tree; under '/logging', each '/log' subbranch |
| 11 |
defines a separate log with its own output file and interval. Here is |
| 12 |
a simple example that logs the rudder and aileron settings every |
| 13 |
second (1000ms) to the file steering.csv, using a comma (the default, |
| 14 |
anyway) as the field delimiter: |
| 15 |
|
| 16 |
<logging> |
| 17 |
<log> |
| 18 |
<enabled>true<enabled> |
| 19 |
<filename>steering.csv</filename> |
| 20 |
<interval-ms>1000</interval-ms> |
| 21 |
<delimiter>,</delimiter> |
| 22 |
<entry> |
| 23 |
<enabled>true</enabled> |
| 24 |
<title>Rudder</title> |
| 25 |
<property>/controls/rudder</property> |
| 26 |
</entry> |
| 27 |
<entry> |
| 28 |
<enabled>true</enabled> |
| 29 |
<title>Ailerons</title> |
| 30 |
<property>/controls/aileron</property> |
| 31 |
</entry> |
| 32 |
</log> |
| 33 |
</logging> |
| 34 |
|
| 35 |
Each 'log' subbranch contains a required 'enabled' property, an |
| 36 |
optional 'filename' property (defaults to "fg_log.csv"), an optional |
| 37 |
'delimiter' property (defaults to a comma), an optional 'interval-ms' |
| 38 |
property (defaults to 0, which logs every frame), and a series of |
| 39 |
'entry' subbranches. The 'delimiter' property uses only the first |
| 40 |
character of the property value as the delimiter. Note that the |
| 41 |
logger does no escaping, so you must choose a delimiter that will not |
| 42 |
appear in the property values (that's not hard, since most of the |
| 43 |
values are numeric, but watch for commas in the titles). |
| 44 |
|
| 45 |
Each 'entry' subbranch contains a required 'enabled' property, a |
| 46 |
'property' property specifying the name of the property to be logged, |
| 47 |
and an optional 'title' property specifying the title to use in the |
| 48 |
CSV file (defaults to the full path of the property). The elapsed |
| 49 |
time in milliseconds since the start of the simulation is always |
| 50 |
included as the first entry with the title "Time", so there is no need |
| 51 |
to include it explicitly. |
| 52 |
|
| 53 |
Here's a sample of the logging output for the above log: |
| 54 |
|
| 55 |
Time,Rudder,Ailerons |
| 56 |
6522,0.000000,0.000000 |
| 57 |
7668,-0.000000,0.000000 |
| 58 |
8702,-0.000000,0.000000 |
| 59 |
9705,-0.000000,0.000000 |
| 60 |
10784,-0.000000,0.000000 |
| 61 |
11792,-0.000000,0.000000 |
| 62 |
12808,-0.000000,-0.210000 |
| 63 |
13826,-0.000000,-0.344000 |
| 64 |
14881,-0.000000,-0.066000 |
| 65 |
15901,-0.000000,-0.806000 |
| 66 |
16943,-0.000000,-0.936000 |
| 67 |
17965,-0.000000,-0.534000 |
| 68 |
19013,-0.000000,-0.294000 |
| 69 |
20044,-0.000000,0.270000 |
| 70 |
21090,-0.000000,-1.000000 |
| 71 |
22097,-0.000000,-0.168000 |
| 72 |
|
| 73 |
Note that the requested interval is only a minimum; most of the time, |
| 74 |
the actual interval is slightly longer than the requested one. |
| 75 |
|
| 76 |
The easiest way for an end-user to define logs is to put the log in a |
| 77 |
separate XML file (usually under the user's home directory), then |
| 78 |
refer to it using the --config option, like this: |
| 79 |
|
| 80 |
fgfs --config=log-config.xml |
| 81 |
|
| 82 |
The output log files are always relative to the current directory. |
| 83 |
|
| 84 |
-- |
| 85 |
|
| 86 |
David Megginson, last updated 2002-02-01 |