FlightGear: Remote control

FlightGear has several interfaces that provide access to internal parameters. The HTTP interface is best suited for human interaction via a web browser. The telnet interface is the ideal choice for remotely controlling FlightGear by means of external programs.

To activate FlightGear's telnet server capabilities, call it with a --props specifiaction:

$ fgfs --props=socket,bi,5,localhost,5501,tcp


socket:FlightGear protocol
bi:bidirectional
5:polling frequency in Hertz
localhost: server name or IP-address
5501: server port
tcp:internet protocol type


In newer versions of FlightGear just type:
$ fgfs --telnet=5501

To learn more about the supported commands, connect to FlightGear with a telnet program and type in "help<RETURN>". This is what you'll get:

$ telnet localhost 5501
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
help

Valid commands are:

help             show help message
ls [<dir>]       list directory
dump             dump current state (in xml)
cd <dir>         cd to a directory, '..' to move back
pwd              display your current path
get <var>        show the value of a parameter
show <var>       synonym for get
set <var> <val>  set <var> to a new <val>
data             switch to raw data mode
prompt           switch to interactive mode (default)
quit             terminate connection

/>

Now you can browse in the property system like in a Linux file system with cd, ls, pwd.

Here you can download a sample script written in Perl, that shows how to access and manipulate FlightGear's internal parameters. It can be started before FlightGear (in which case it tries up to 2 minutes to connect) or afterwards. Then it picks a random AGL altitude and checks every 5 seconds if the aircraft has already climbed at this height. Now it starts to empty all four tanks, one after the other, until the engines stop working. Try to find a place where you can land safely. :-)

$ fgfsscript&
$ fgfs --props=socket,bi,5,localhost,5501,tcp

The script defaults to localhost and port 5501, but you can let the script control FlightGear on another host and under another port.

$ fgfsscript some.host.org 1234&

Demo programs are available in: