Property tree

From FlightGear wiki
Revision as of 16:34, 25 March 2013 by Hooray (talk | contribs) (courtesy of Lee E: http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg21192.html)
Jump to navigation Jump to search

The so called Property Tree in FlightGear is generally considered FlightGear's central nervous system and one of FlightGear's greatest assets!

This is because the Property Tree system provides access to low level run time state variables via a very intuitive tree-like hierarchy. This allows FlightGear's behavior to be easily controlled and manipulated at run time.

The FlightGear Property Tree is the common denominator for crucial run time state and also the interface to these internal state variables.

The concepts and mechanisms behind the "Property Tree" may not be immediately obvious to FlightGear beginners. This page is meant to help new users familiarize themselves with the FlightGear property tree.

The property system - or property tree - represents most of the internal state of all systems within FlightGear, like for example the flight dynamics model. The content of these internal state variables are presented in a hierarchically manner and can easily be accessed through a well known API. A system may present its current state to other systems and let other systems change it's current state by allowing them to write to it's own properties. One might think of the property system as a global, normalized communication platform, where subsystems may publish variables and access other subsystem's variables. In addition, callbacks can be registered to invoke code upon read/write access of properties, which serves as the backbone for a very simple, but powerful, signalling mechanism in FlightGear.

Thus, the property system acts as a routing interface, both between different high-level FG sub-systems and the outside world. Data that is required by one FG sub-system can be exposed in the property tree, where it can then be read or modified, either by other internal FG sub-systems, or by & for external input & output.

To make it easier to manipulate the tree, start FlightGear with the following command line

fgfs --httpd=5480

Then after a few moments open in a new window - http://localhost:5480

Introduction

When a simulation is running, all the variables such as position, speed, flaps, cabin lights, et all are calculated and manipulated through a property tree.

The "virtual" tree that runs the simulation appears much like a directory/file structure. eg:

/sim/aircraft = A333

/position/
/position/longitude-deg =	'-122.3576677'	(double)
/position/latitude-deg =	'37.61372424'	(double)
/position/altitude-ft =	'28.24418581'	(double)
/position/altitude-agl-ft =	'22.47049626'	(double)

/controls/seat/eject/initiate
/controls/electric/APU-generator

Some of these variables are "calculated" within the sim, whilst others can be manipulated. Writing a variable is as easy as

/* Its my turn to play the sim */
set('/controls/seat/eject/initiate', 1)

The values can also be set from the httpd interface.

What makes FG powerful is that a new aircraft can easily be designed with its unique set of properties that somehow affect the simulation. The Aircraft model has an xml file of properties within the property tree.

This is why the property tree is not consistent with fixed variables, they are created dynamically, to represent a propeller plane vs Jumbo or even a "Caspian Sea Monster".

The property tree is read, written, accessed and manipulated in a variety of ways, such as

  • internal compiled code within FG - the c/c++ code
  • Nasal scripts - this is javascript like scripting with read/write to the property tree. This is the way most aircraft are implemented.
  • sockets that are either in/out/bi - this allows send/recieve to the FG sim via sockets
  • telnet interface - query and fly the plane on the command line (see Telnet usage)
  • html interface - fly the plane with a browser or an PDA

For example, multiplayer mode is accomplished by exchanging sets of variables from the tree (height, position, speed, etc).


Flight Dynamics Model (FDM)

FlightGear uses a few Flight Dynamics Models, such as

These flight dynamics models present themselves differently in the tree, using different variables, in different places. That is what an aircraft can be designed around.