Autopilot configuration reference: Difference between revisions

Jump to navigation Jump to search
Clarifying the difference between autopilot and property-rule configurations; reordering a few sections
(→‎Related content: Links to source code)
(Clarifying the difference between autopilot and property-rule configurations; reordering a few sections)
Line 9: Line 9:


This page serves as a reference for the elements of [[FlightGear]] xml [[autopilot]] and property rule configuration files. It describes all elements available within the autopilot configuration file supported in the bleeding edge [[Git]] sources. Some of the elements may not be available in the current release version of FlightGear.
This page serves as a reference for the elements of [[FlightGear]] xml [[autopilot]] and property rule configuration files. It describes all elements available within the autopilot configuration file supported in the bleeding edge [[Git]] sources. Some of the elements may not be available in the current release version of FlightGear.
The FlightGear xml based autopilot system can run at FDM rate or at frame rate. Using a <autopilot> tag in your aircraft's -set.xml
adds the autopilot at FDM rate, using a <property-rule> runs the same configuration at frame rate.


For built-in runtime plotting of FlightGear properties (including FDM/Autopilot properties), check out [[FGPlot]] (available in FlightGear 2.11+).
For built-in runtime plotting of FlightGear properties (including FDM/Autopilot properties), check out [[FGPlot]] (available in FlightGear 2.11+).
Line 17: Line 14:
{{Systems_Modeling_Disclaimer}}
{{Systems_Modeling_Disclaimer}}


== Structure of a configuration file ==
== Autopilot vs. property-rule configurations ==
Autopilot configurations live in a separate file, formatted using the well known XML syntax like so many other FlightGear files with a <code>&lt;PropertyList&gt;</code> node as a root element. A basic skeleton file looks like this:
The main difference between XML based autopilot and property-rule systems is the update rate:
 
* Autopilot configurations run at FDM rate
* Property-rule configurations run at frame-rate


<syntaxhighlight lang="xml">
Autopilot and property-rule based elements can communicate with each other using [[Property tree|properties]]It is possible to implement a system using both autopilot and property-rule based elements, though it will be split between an autopilot and a property-rule configuration file.
<?xml version="1.0" encoding="UTF-8"?>
  <PropertyList>
  <params>
    <controls>
      <aileron>controls/flight/aileron</aileron>
      <rudder>controls/flight/rudder</rudder>
      <elevator>controls/flight/elevator</elevator>
    </controls>
  </params>
  <!-- Place your components here -->
  <!--
  <filter>
    <name>Myfilter</name>
    <input>/foo</input>
    <output>/bar</output>
  </filter>
  -->
</PropertyList>
</syntaxhighlight>


{{tip|Using aliased property names is good style and makes the configuration file more readable. For complex autopilot systems spread over multiple autopilot configuration files, the params section may be included from an external file using <tt><nowiki><params include="my-params.xml"/></nowiki></tt> to avoid duplication of code.}}
Using property-rule elements for things that does not have to run a FDM rate can improve the frame rate, in particular for complex systems and on weaker computers. For example would a fly-by-wire flight control system element augmenting an instable aircraft need to run at FDM rate, while an element depending on the flap extension would work just as well at frame rate.


The location and the name of the configuration file is up to the developer. A descriptive name like 'autopilot.xml' might be a good choice. Most developers put these files into the Systems folder of the aircraft.
== Adding a configuration to an aircraft ==
A configuration is added to an aircraft by adding the path to an XML configuration file to the <code>&lt;Aircraft&gt;-set.xml</code> file.


== Adding an autopilot configuration to aircraft &lt;autopilot&gt; ==
=== Adding an autopilot configuration ===
Autopilot configuration files are added to the aircraft by adding
Autopilot configuration files are added to the aircraft by adding


Line 69: Line 51:
node of your aircraft-set.xml file. Note, that more than one <autopilot> node may be present, each will create a new instance of the autopilot subsystem when running FlightGear. They run in the order of appearance under <systems>. For example, lateral and vertical autopilot modes could live in separate files, as could a yaw-damper system.
node of your aircraft-set.xml file. Note, that more than one <autopilot> node may be present, each will create a new instance of the autopilot subsystem when running FlightGear. They run in the order of appearance under <systems>. For example, lateral and vertical autopilot modes could live in separate files, as could a yaw-damper system.


== Adding a property-rule configuration to aircraft &lt;property-rule&gt; ==
=== Adding a property-rule configuration ===
Property-rules can also be used in which case they will run at frame rate. You can use these to process properties so their values can be used by other systems outside of the autopilot scope (for example to create smooth animations for switches that normally have discrete values)
Property-rules can also be used in which case they will run at frame rate. You can use these to process properties so their values can be used by other systems outside of the autopilot scope (for example to create smooth animations for switches that normally have discrete values)


Line 95: Line 77:
</syntaxhighlight>
</syntaxhighlight>
node of your aircraft-set.xml file. Note that you can add multiple <property-rule> elements, similar to the <autopilot> as described above.
node of your aircraft-set.xml file. Note that you can add multiple <property-rule> elements, similar to the <autopilot> as described above.
== Structure of a configuration file ==
Autopilot configurations live in a separate file, formatted using the well known XML syntax like so many other FlightGear files with a <code>&lt;PropertyList&gt;</code> node as a root element. A basic skeleton file looks like this:
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
  <params>
    <controls>
      <aileron>controls/flight/aileron</aileron>
      <rudder>controls/flight/rudder</rudder>
      <elevator>controls/flight/elevator</elevator>
    </controls>
  </params>
  <!-- Place your components here -->
  <!--
  <filter>
    <name>Myfilter</name>
    <input>/foo</input>
    <output>/bar</output>
  </filter>
  -->
</PropertyList>
</syntaxhighlight>
{{tip|Using aliased property names is good style and makes the configuration file more readable. For complex autopilot systems spread over multiple autopilot configuration files, the params section may be included from an external file using <tt><nowiki><params include="my-params.xml"/></nowiki></tt> to avoid duplication of code.}}
The location and the name of the configuration file is up to the developer. A descriptive name like 'autopilot.xml' might be a good choice. Most developers put these files into the Systems folder of the aircraft.


== Available elements ==
== Available elements ==

Navigation menu