<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.paparazziuav.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ben+P</id>
	<title>PaparazziUAV - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.paparazziuav.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ben+P"/>
	<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/wiki/Special:Contributions/Ben_P"/>
	<updated>2026-04-08T20:20:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Airframe_Configuration&amp;diff=4127</id>
		<title>Airframe Configuration</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Airframe_Configuration&amp;diff=4127"/>
		<updated>2008-10-23T00:16:07Z</updated>

		<summary type="html">&lt;p&gt;Ben P: /* GPS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The airframe configuration file is located in &amp;lt;tt&amp;gt;conf/airframes&amp;lt;/tt&amp;gt; and contains&lt;br /&gt;
all the hardware and software settings for an aircraft. This is an [http://en.wikipedia.org/wiki/Xml XML] document containing some [http://en.wikipedia.org/wiki/Makefile Makefile] code at the bottom. All gains, trims, and behavior settings are defined with standard XML elements. The hardware definitions such as processor type, modem protocol, servo driver, etc. are contained in the makefile raw section.&lt;br /&gt;
&lt;br /&gt;
== Selecting the Airframe File ==&lt;br /&gt;
Each airframe file must be assigned a name, unique ID, flight plan, etc. in [[Conf.xml|&amp;lt;tt&amp;gt;conf/conf.xml&amp;lt;/tt&amp;gt;]] as follows:&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;lt;conf&amp;gt;&lt;br /&gt;
  &amp;lt;aircraft &lt;br /&gt;
    name=&amp;quot;Twin1&amp;quot;&lt;br /&gt;
    ac_id=&amp;quot;1&amp;quot;&lt;br /&gt;
    airframe=&amp;quot;airframes/twinstar1.xml&amp;quot; &lt;br /&gt;
    radio=&amp;quot;radios/mc3030.xml&amp;quot; &lt;br /&gt;
    flight_plan=&amp;quot;flight_plans/mav05_cw.xml&amp;quot;&lt;br /&gt;
    telemetry=&amp;quot;telemetry/default.xml&amp;quot;&lt;br /&gt;
    gui_color=&amp;quot;blue&amp;quot;&lt;br /&gt;
  /&amp;gt;&lt;br /&gt;
  &amp;lt;aircraft &lt;br /&gt;
    name=&amp;quot;Plaster&amp;quot;&lt;br /&gt;
    ac_id=&amp;quot;2&amp;quot;&lt;br /&gt;
    airframe=&amp;quot;airframes/plaster1.xml&amp;quot; &lt;br /&gt;
    radio=&amp;quot;radios/cockpitMM.xml&amp;quot; &lt;br /&gt;
    telemetry=&amp;quot;telemetry/default.xml&amp;quot;&lt;br /&gt;
    flight_plan=&amp;quot;flight_plans/dummy.xml&amp;quot;&lt;br /&gt;
  /&amp;gt;&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  &amp;lt;/conf&amp;gt;&lt;br /&gt;
Then, to compile and flash the airframe settings and associated flight plan to your autopilot, simply select the appropriate A/C and target in the [[Paparazzi_Center|Paparazzi Center]] or specify your airframe name in the flash command typed from the prompt:&lt;br /&gt;
 make AIRCRAFT=&amp;lt;b&amp;gt;Twin1&amp;lt;/b&amp;gt; ap.upload&lt;br /&gt;
More information can be found on the [[Conf.xml|conf.xml]] page&lt;br /&gt;
&lt;br /&gt;
== XML Parameters ==&lt;br /&gt;
=== Commands ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;commands&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; lists the abstract commands you need to control the aircraft. In our example, we have only three:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;commands&amp;gt;&lt;br /&gt;
  &amp;lt;axis name=&amp;quot;THROTTLE&amp;quot; failsafe_value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;axis name=&amp;quot;ROLL&amp;quot;     failsafe_value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;axis name=&amp;quot;PITCH&amp;quot;    failsafe_value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/commands&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
Each command is associated with a failsafe value which will be used if no controller is active (during initialization for example). The range of these values is [-9600:9600]. Note that these commands do not necessarily match the servo actuators. For example, the ROLL command is typically linked to two aileron actuators.&lt;br /&gt;
&lt;br /&gt;
=== Servos ===&lt;br /&gt;
&lt;br /&gt;
The above commands get translated to the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;servos&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; here.  In this example we use two ailevons (surfaces used for both pitch and roll as on a flying wing) and a motor. These are listed in the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;servos&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;servos&amp;gt;&lt;br /&gt;
  &amp;lt;servo name=&amp;quot;THROTTLE&amp;quot;      no=&amp;quot;0&amp;quot; min=&amp;quot;1000&amp;quot; neutral=&amp;quot;1000&amp;quot; max=&amp;quot;2000&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;servo name=&amp;quot;AILEVON_LEFT&amp;quot;  no=&amp;quot;1&amp;quot; min=&amp;quot;2000&amp;quot; neutral=&amp;quot;1500&amp;quot; max=&amp;quot;1000&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;servo name=&amp;quot;AILEVON_RIGHT&amp;quot; no=&amp;quot;2&amp;quot; min=&amp;quot;1000&amp;quot; neutral=&amp;quot;1500&amp;quot; max=&amp;quot;2000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/servos&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where names are associated to the corresponding servo channel number on the autopilot and the neutral value, total range and direction are defined.  Min/max/neutral values are expressed in milliseconds and the direction of travel can be reversed by exchanging min with max (as in &amp;lt;tt&amp;gt;&amp;quot;AILEVON_LEFT&amp;quot;&amp;lt;/tt&amp;gt;, above).  The ''standard'' travel for a hobby servo is 1000ms - 2000ms with a 1500ms neutral.  Trim can be added by changing this neutral value, and absolute travel limits can be increased or reduced with the min/max values.  The &amp;lt;tt&amp;gt;&amp;quot;THROTTLE&amp;quot;&amp;lt;/tt&amp;gt; servo typically has the same value for the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;neutral&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;min&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;.  Note the following tips:&lt;br /&gt;
* Reverse the servo direction by exchanging min/max&lt;br /&gt;
* Trim should always be adjusted mechanically if possible to avoid asymetrical travel&lt;br /&gt;
* Any reduction of the total travel range should be done mechanically to maintain precision&lt;br /&gt;
* Many servos will respond well to values slightly outside the normal 1000-2000ms range but experiment carefully as the servo may not operate reliably outside this range and may even suffer permanent damage.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;servos&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; are then linked to the commands in the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;command_laws&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;command_laws&amp;gt;&lt;br /&gt;
  &amp;lt;let var=&amp;quot;aileron&amp;quot;         value=&amp;quot;@ROLL  * 0.3&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;let var=&amp;quot;elevator&amp;quot;        value=&amp;quot;@PITCH * 0.7&amp;quot;/&amp;gt;  &lt;br /&gt;
  &amp;lt;set servo=&amp;quot;THROTTLE&amp;quot;      value=&amp;quot;@THROTTLE&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;set servo=&amp;quot;AILEVON_LEFT&amp;quot;  value=&amp;quot;$elevator + $aileron&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;set servo=&amp;quot;AILEVON_RIGHT&amp;quot; value=&amp;quot;$elevator - $aileron&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/command_laws&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
[[Image:airframe_sign_conventions.jpg|thumb|Sign conventions for flight dynamics]]&lt;br /&gt;
where the third line is the simplest: the throttle servo value equals throttle command value. The other lines define and control the pitch/roll mixing.  Ailevon values are computed with a combination of two commands, '''ROLL''' and '''PITCH'''. This ''mixer'' is defined with two intermediate variables '''aileron''' and '''elevator''' introduced with the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;let&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; element.  The '''@''' symbol is used to reference a command value in the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; attribute of the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;set&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;let&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; elements.  In the above example, the servos are limited to +/- 70% of their full travel for pitch and 30% for roll, only in combination can the servos reach 100% deflection.  Note that these numbers ''should add up 100% or more, never less''.  For example, you may want 100% travel available for pitch - this means if a roll is commanded along with maximum pitch only one servo will respond to the roll command as the other has already reached its mechanical limit.  If you find after tuning that these numbers add to less than 100% consider reducing the surface travel mechanically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that the signs used in the description follow the standard convention.&lt;br /&gt;
&lt;br /&gt;
=== Manual ===&lt;br /&gt;
The &amp;lt;tt&amp;gt;rc_command&amp;lt;/tt&amp;gt; sections links the channels of the RC transmitter (defined in the [[Radio_Control|Radio Control]] file) to the &amp;lt;tt&amp;gt;commands&amp;lt;/tt&amp;gt; defined above:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;rc_commands&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;THROTTLE&amp;quot; value=&amp;quot;@THROTTLE&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;ROLL&amp;quot;     value=&amp;quot;@ROLL&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;PITCH&amp;quot;    value=&amp;quot;@PITCH&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/rc_commands&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example looks trivial since the channel values have the same name than the commands.&lt;br /&gt;
&lt;br /&gt;
=== Autopilot Only Commands ===&lt;br /&gt;
For certain missions it might be required to control servos (payload) from the autopilot (gcs) at all times (even during manual flight). These commands should not be in the &amp;lt;rc_commands&amp;gt; block but in the special &amp;lt;ap_only_commands&amp;gt; block. This allows for instance the pantilt operator to keep working when in manual flight, or safety logic to automatically close cameras below a certain altitude during manual landings.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;ap_only_commands&amp;gt;&lt;br /&gt;
   &amp;lt;copy command=&amp;quot;PAN&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;copy command=&amp;quot;TILT&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;copy command=&amp;quot;SHOOT&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/ap_only_commands&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Auto1 ===&lt;br /&gt;
The next section, named &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;AUTO1&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;, gives the maximum roll and pitch (in radians) allowed for the augmented stability mode.&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;AUTO1&amp;quot; prefix=&amp;quot;AUTO1_&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_ROLL&amp;quot; value=&amp;quot;RadOfDeg(35)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_PITCH&amp;quot; value=&amp;quot;RadOfDeg(35)&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ADC === &lt;br /&gt;
In the &amp;quot;adc&amp;quot; section, you will find the conformity between arguments and their assigned pins on the autopilot board.&lt;br /&gt;
 &amp;lt;section name=&amp;quot;adc&amp;quot; prefix=&amp;quot;ADC_CHANNEL_&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR1&amp;quot; value=&amp;quot;ADC_1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR2&amp;quot; value=&amp;quot;ADC_2&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR_TOP&amp;quot; value=&amp;quot;ADC_0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
'''Important note''': To ''activate'' an ADC entry, a flag must be defined in the &amp;lt;tt&amp;gt;makefile&amp;lt;/tt&amp;gt; section. For the previous example, we would have to write:&lt;br /&gt;
&lt;br /&gt;
 ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2&lt;br /&gt;
 ap.srcs += $(SRC_ARCH)/adc_hw.c&lt;br /&gt;
&lt;br /&gt;
==== ADC Generic ====&lt;br /&gt;
&lt;br /&gt;
In addition, if you want to receive the value of some ADC channel, you can use the &amp;quot;ADC Generic&amp;quot; service. When activated, the aircraft sends 2 values corresponding to the selected ADC channels. They can be read from the &amp;quot;Messages&amp;quot; application.&lt;br /&gt;
  ap.CFLAGS += -DUSE_ADC_GENERIC -DUSE_ADC_3 -DADC_CHANNEL_GENERIC1=ADC_3 -DUSE_ADC_4 -DADC_CHANNEL_GENERIC2=ADC_4&lt;br /&gt;
  ap.srcs += adc_generic.c&lt;br /&gt;
In this example, the ADC channels 3 and 4 are read and sent by telemetry at 4Hz:&lt;br /&gt;
  &amp;lt;message name=&amp;quot;ADC_GENERIC&amp;quot; ID=&amp;quot;18&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;field name=&amp;quot;val1&amp;quot; type=&amp;quot;uint16&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;field name=&amp;quot;val2&amp;quot; type=&amp;quot;uint16&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/message&amp;gt;&lt;br /&gt;
Only two channels can be defined. If only one is activated, 0 will send for the second value.&lt;br /&gt;
&lt;br /&gt;
=== Infrared === &lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;INFRARED&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section describes the configuration of the infrared sensors.&lt;br /&gt;
&lt;br /&gt;
The first definitions are relative to the electronic neutral of the sensors (a sensor here is a pair of thermopiles). A perfect sensor should give 512 if it measures the same value on both sides.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;section name=&amp;quot;INFRARED&amp;quot; prefix=&amp;quot;IR_&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_IR1_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_IR2_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_TOP_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These neutrals are tuned with the &amp;quot;cupboard test&amp;quot;: Put the sensor in a close box (a cupboard) and read the values of the IR_SENSORS message (ir1, ir2 and vertical). Set the neutrals (they are subtracted from the measurement) to get null values. E.g. if you read 5 for the ir1 value with ADC_IR1_NEUTRAL equal to 512, change the latter to 517.&lt;br /&gt;
&lt;br /&gt;
The next lines define the installation of the horizontal and vertical sensors. The vertical sensor must  give a positive value when the temperature under the aircraft is higher than the temperature above. The two channels of the horizontal sensor must give positive values when it is warmer on the right side and the rear side. To adjust these signs, use the following declarations:&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR1_SIGN&amp;quot; value=&amp;quot;-1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR2_SIGN&amp;quot; value=&amp;quot;-1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;TOP_SIGN&amp;quot; value=&amp;quot;-1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, define how the horizontal sensor is connected to the airframe, orientation '''aligned''' or '''tilted'''. In the aligned case, ir'''1''' is along the lateral axis and ir'''2''' along the longitudian one. In the '''tilted''' case, the sensors are tilted by 45 degrees; ir'''1''' is along rear-left -- front-right, and ir'''2''' along rear-right -- front-left. The parameter &amp;quot;value&amp;quot; has no effect! If the airframe construction allows choose an aligned sensor orientation since this gives the best stabilization response results. &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;HORIZ_SENSOR_ALIGNED&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
  or&lt;br /&gt;
   &amp;lt;define name=&amp;quot;HORIZ_SENSOR_TILTED&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three axis must give similar values for similar contrasts. The following factors can be used to scale these values. For example with an horizontal tilted sensor, the following ratios are usually needed:&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;LATERAL_CORRECTION&amp;quot; value=&amp;quot;0.7&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;LONGITUDINAL_CORRECTION&amp;quot; value=&amp;quot;0.7&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;VERTICAL_CORRECTION&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
Default values are 1.&lt;br /&gt;
&lt;br /&gt;
It may be hard to align the horizontal sensor with the aircraft. A tuning in flight will be needed to adjust the following neutrals. Adjust the roll neutral to fly straight. Adjust the pitch neutral to fly level with the desired throttle.&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ROLL_NEUTRAL_DEFAULT&amp;quot; value=&amp;quot;-2.5&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;PITCH_NEUTRAL_DEFAULT&amp;quot; value=&amp;quot;6&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, an asymmetric (left/right, front/rear) correction can be added with a last set of factors.&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_UP&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_DOWN&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_LEFT&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_RIGHT&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
These corrections are set on the angles.&lt;br /&gt;
&lt;br /&gt;
The old way to define the parameters is still possible, but must not be mixed with the new one describe above.&lt;br /&gt;
&lt;br /&gt;
=== Gyro === &lt;br /&gt;
Defines the type of gyro installed, each axis neutral, and any required temperature compensation. If the gyro has two axes, the pitch neutral is defined as well. Many gyros output their internal temperature and require a temperature-dependent linear correction be made to the neutral value.  No correction is done for the temperature in this example.(&amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;ADC_TEMP_SLOPE=0&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;GYRO&amp;quot; prefix=&amp;quot;GYRO_&amp;quot;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_ROLL_COEFF&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ROLL_NEUTRAL&amp;quot; value=&amp;quot;500&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_TEMP_NEUTRAL&amp;quot; value=&amp;quot;476&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_TEMP_SLOPE&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Bat === &lt;br /&gt;
This section give characteristics for the monitoring of the main power battery. &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;MILLIAMP_PER_PERCENT&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; represents the consumption (in mA) for one percent of THROTTLE and for one time unit. It is used to compute the &amp;lt;tt&amp;gt;energy&amp;lt;/tt&amp;gt; value of the &amp;lt;tt&amp;gt;BAT&amp;lt;/tt&amp;gt; message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;CATASTROPHIC_BAT_LEVEL&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; (was previously &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;LOW_BATTERY&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;) value defines the voltage at which the autopilot will lock the throttle at 0% in autonomous mode (kill_throttle mode). This value is also used by the ground server to issue a '''CATASTROPHIC''' alarm message on the bus (this message will be displayed in the console of the GCS).  &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;CRITIC&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;LOW&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; values will also used as threshold for '''CRITIC''' and '''WARNING''' alarms. They are optional and the respective defaults are 10.0 and 10.5V.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;MAX_BAT_LEVEL&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; may be specified to improve the display of the battery gauge in the strip. This definition is optional with a default value of 12.5V.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;BAT&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MILLIAMP_PER_PERCENT&amp;quot; value=&amp;quot;0.86&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;VOLTAGE_ADC_A&amp;quot; value=&amp;quot;0.0177531&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;VOLTAGE_ADC_B&amp;quot; value=&amp;quot;0.173626&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;VoltageOfAdc(adc)&amp;quot; value =&amp;quot;(VOLTAGE_ADC_A * adc + VOLTAGE_ADC_B)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CATASTROPHIC_BAT_LEVEL&amp;quot; value=&amp;quot;6.0&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CRITIC_BAT_LEVEL&amp;quot; value=&amp;quot;6.5&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;LOW_BAT_LEVEL&amp;quot; value=&amp;quot;7.0&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_BAT_LEVEL&amp;quot; value=&amp;quot;8.4&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Horizontal Control ===&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;HORIZONTAL CONTROL&amp;quot; prefix=&amp;quot;H_CTL_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;COURSE_PGAIN&amp;quot; value=&amp;quot;-0.4&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_MAX_SETPOINT&amp;quot; value=&amp;quot;0.35&amp;quot; unit=&amp;quot;radians&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_ATTITUDE_GAIN&amp;quot; value=&amp;quot;-7500.&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_RATE_GAIN&amp;quot; value=&amp;quot;-1500&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;PITCH_PGAIN&amp;quot; value=&amp;quot;-8000.&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ELEVATOR_OF_ROLL&amp;quot; value=&amp;quot;1250&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The outer loop acts on the route. It will produce a roll command from a course setpoint and a course measurement. The COURSE_PGAIN parameter is the factor multiplied by the course error (in radian) to get a roll setpoint (in radian). So if the plane is expected to go north (course=0) and is actually flying to 57 degrees (course=1 radian, i.e. ENE), with a gain of '''-0.4''', a roll of -0.4 (23 degrees) will be set for the lower control loop.&lt;br /&gt;
&lt;br /&gt;
The ROLL_ATTITUDE_GAIN is used to compute a ROLL command from the roll error (setpoint minus measurement). If a gyro in installed, the ROLL_RATE_GAIN to keep a null roll rate. So these two gains provide a P-D controller.&lt;br /&gt;
&lt;br /&gt;
===Vertical Control===&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;section name=&amp;quot;VERTICAL CONTROL&amp;quot; prefix=&amp;quot;V_CTL_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- outer loop proportional gain --&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ALTITUDE_PGAIN&amp;quot; value=&amp;quot;-0.1&amp;quot; unit=&amp;quot;(m/s)/m&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;!-- outer loop saturation --&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ALTITUDE_MAX_CLIMB&amp;quot; value=&amp;quot;3.&amp;quot; unit=&amp;quot;m/s&amp;quot;/&amp;gt;&lt;br /&gt;
These lines are associated with vertical control loops contained in ./sw/airborne/fw_v_ctl.c.  These are outer loop parameters that calculate a desired climb rate based on altitude error. Here, if the altitude error is 10m, the climb setpoint will be set to 1m/s. ALTITUDE_MAX_CLIMB is a bounded value (in m/s) so that the outer loop does not calculate too large of a climb rate&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE&amp;quot; value=&amp;quot;0.65&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_MIN_CRUISE_THROTTLE&amp;quot; value=&amp;quot;.4&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_MAX_CRUISE_THROTTLE&amp;quot; value=&amp;quot;1&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_LOITER_TRIM&amp;quot; value=&amp;quot;1000&amp;quot; unit=&amp;quot;pprz_t&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_DASH_TRIM&amp;quot; value=&amp;quot;-2500&amp;quot; unit=&amp;quot;pprz_t&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT&amp;quot; value=&amp;quot;0.15&amp;quot; unit=&amp;quot;%/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_PGAIN&amp;quot; value=&amp;quot;-0.008&amp;quot; unit=&amp;quot;%/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_IGAIN&amp;quot; value=&amp;quot;0.25&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_PITCH_OF_VZ_PGAIN&amp;quot; value=&amp;quot;0.35&amp;quot; unit=&amp;quot;rad/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These lines are associated with vertical rate control loops contained in ./sw/airborne/fw_v_ctl.c and are used by default in most cases.  The default vertical control law is for the vertical rate to be managed by a combination of throttle and pitch.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_PGAIN&amp;quot; value=&amp;quot;-0.1&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_IGAIN&amp;quot; value=&amp;quot;0.025&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_MAX_PITCH&amp;quot; value=&amp;quot;0.5&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_MIN_PITCH&amp;quot; value=&amp;quot;-0.5&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These lines are associated with vertical control loops contained in ./sw/airborne/fw_v_ctl.c but are not used in default. The non-default vertical control law is for the vertical rate to be managed by the pitch.&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;THROTTLE_SLEW_LIMITER&amp;quot; value=&amp;quot;2&amp;quot; unit=&amp;quot;s&amp;quot;/&amp;gt;&lt;br /&gt;
THROTTLE_SLEW_LIMITER is the required time is seconds to change throttle from 0% to 100%.&lt;br /&gt;
&lt;br /&gt;
=== Misc ===&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;NOMINAL_AIRSPEED&amp;quot; value =&amp;quot;12.&amp;quot; unit=&amp;quot;m/s&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CARROT&amp;quot; value=&amp;quot;5.&amp;quot; unit=&amp;quot;s&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;KILL_MODE_DISTANCE&amp;quot; value=&amp;quot;(1.5*MAX_DIST_FROM_HOME)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CONTROL_RATE&amp;quot; value&amp;quot;60&amp;quot; unit=&amp;quot;Hz&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &amp;quot;NOMINAL_AIRSPEED&amp;quot; is mainly used in the simulator.&lt;br /&gt;
* &amp;quot;CARROT&amp;quot; gives the distance (in seconds, so ground speed is taken into account) between the carrot and the aircraft.&lt;br /&gt;
* &amp;quot;KILL_MODE_DISTANCE&amp;quot; is the threshold distance to switch the autopilot into KILL mode (defined descent with no throttle)&lt;br /&gt;
* &amp;quot;CONTROL_RATE&amp;quot; is the rate of the low level control loops in Hertz (60 or 20).&lt;br /&gt;
&lt;br /&gt;
== Hardware definitions - Makefile ==&lt;br /&gt;
&lt;br /&gt;
The airframe file must include the description of the controller board and it's low-level settings.  This is done in one &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;makefile&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section starting with the autopilot model and flashing mode:&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;makefile&amp;gt;&lt;br /&gt;
  include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;FLASH_MODE=IAP&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
 &amp;lt;/makefile&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Below this are the definintions and configuration of the peripherals and interfaces.&lt;br /&gt;
&lt;br /&gt;
=== R/C ===&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE=RC_FUTABA&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.EXTRA_SRCS += radio_control.c $(SRC_ARCH)/ppm_hw.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DACTUATORS=\&amp;quot;servos_direct_hw.h\&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.EXTRA_SRCS += $(SRC_ARCH)/servos_direct_hw.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You can set RADIO_CONTROL_TYPE to RC_FUTABA, for falling edge PPM, or RC_JR for rising edge PPM. &amp;quot;RC_FUTABA&amp;quot; is for The Futaba or compatible brands, and &amp;quot;RC_JR&amp;quot; for JR (a.k.a Graupner outside of the USA) or compatible brands.&lt;br /&gt;
&lt;br /&gt;
For the classix, you must specify which pins to use for PWM by adding &amp;quot;-DPWM_SERVO_0, etc.&amp;quot; to the line fbw.CFLAGS. This activate the PWM channel. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;tt&amp;gt;wiring on classix PWM connector&lt;br /&gt;
  connector   LPC   shared         port &lt;br /&gt;
  PWM1        PWM5  AD1_6  CAP1_3  P0.21&lt;br /&gt;
  PWM2        PWM3  RXD0   EINT0   P0.1&lt;br /&gt;
  PWM3        PWM1  TXD0           P0.0&lt;br /&gt;
  PWM4        PWM6  RXD1   EINT3   P0.9&lt;br /&gt;
  PWM5        PWM4  TXD1   AD1_1   P0.8&lt;br /&gt;
  PWM6        PWM2  SSEL0  EINT2   P0.7&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PWM1 and PWM6 should be safe. PWM4 and PWM5 should be OK if you're not using UART1 on the FBW processor - same for PWM2 and PWM3 if you're not using UART0 (disable FBW telemetry for that ).&lt;br /&gt;
&lt;br /&gt;
=== Modem ===&lt;br /&gt;
The modem protocol and baud rate must be set in both the airframe file and ground station.  Any standard baud rate can be used, with 9600 being adequate and 57600 recommended for most users to allow high speed telemetry for more detailed flight data analysis.  The actual data rate is determined by the number of messages being sent and the period of each message as defined in &amp;lt;tt&amp;gt;conf/telemetry/default.xml&amp;lt;/tt&amp;gt;.  Those wishing to experiment with &amp;quot;alternative&amp;quot; modems can reduce the number and period of each telemetry message to fit within most any bandwidth constraint.&lt;br /&gt;
&lt;br /&gt;
Paparazzi supports the following modem protocols:&lt;br /&gt;
* Standard transparent serial (pprz) - this is compatible with all modems and can be used to connect the autopilot directly to a PC for testing without a modem.&lt;br /&gt;
* Maxstream API protocol (xbee) - compatible with all Maxstream modems including the 9XTend and Zigbee.  This protocol enables hardware addressing, allowing multiple aircraft to be managed from a single ground modem.&lt;br /&gt;
* Coronis Wavecard - necessary for operation with the unusual Coronis Wavecard modem.&lt;br /&gt;
Select the baud/protocol in the airframe file by commenting/uncommenting the appropriate section as follows:&lt;br /&gt;
==== Configuring The Serial Protocol ====&lt;br /&gt;
New users are advised to start with the standard serial protocol before attempting to setup an addressed API link. There are no real reasons for the novice user to use the xbee protocol over the standard PPRZTransport. Even if you are using a Maxstream modem you should still start out with the standard. Lastly it should be pointed out that using a single UAV there is no disadvantage and that the [http://www.engr.usu.edu/wiki/index.php/OSAM OSAM] Paparazzi Team at UAS 2008 took second place using the STANDARD protocol. The serial protocol works with virtually any modem as well as direct cable connections.  The baud rates of the airborne modem, autopilot, ground modem, and PC must be configured correctly.  The PC and autopilot serial ports do not need to be set to the same baud rate, i.e. when running multiple aircraft from a single ground modem, the ground modem may require a higher baud rate than any of the airborne modems in order to stream the data from multiple simultaneous sources.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;DATALINK&amp;quot; prefix=&amp;quot;DATALINK_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_TYPE&amp;quot; value=&amp;quot;PPRZ&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_ADDRESS&amp;quot; value=&amp;quot;....&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above example tells the autopilot to send and recieve data in standard serial form.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml - makefile section at the bottom|&lt;br /&gt;
 # Serial modem &lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B57600&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c pprz_transport.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above example configures the autopilot serial port (Uart0) to 57,600 baud and calls the serial transport protocol (pprz_transport.c).  Use the &amp;quot;#&amp;quot; symbol to comment lines in this section of the airframe file. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note:&lt;br /&gt;
* The autopilot and modem serial port baud rates must match at all times and also must match the ground modem rate, check your modem documentation to find the default baud rate and configure a different rate as needed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensure that the ground station is using the same protocol and an equal or higher baud rate:&lt;br /&gt;
{{Box Code|conf/control_panel.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;session name=&amp;quot;USB&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;program name=&amp;quot;link&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-d&amp;quot; constant=&amp;quot;/dev/paparazzi/ttyUSB0&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;!-- &amp;lt;arg flag=&amp;quot;-transport&amp;quot; constant=&amp;quot;xbee&amp;quot;/&amp;gt; Comment this line for standard serial protocol --&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-uplink&amp;quot; constant=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-s&amp;quot; constant=&amp;quot;57600&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/program&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/session&amp;gt;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Use this constant /dev/paparazzi/ttyUSB0 when using either the ftdi cable or a Maxstream USB ground modem.. Otherwise use /dev/ttyUSB0 (the ttyUSB0 being the device that you are using. Note: it might not always be ttyUSB0). This paparazzi directory in the dev folder is created when setting the udev rules. [http://paparazzi.enac.fr/wiki/index.php/Installation#Setting_access_rights_for_USB_download Setting Udev rules]&lt;br /&gt;
&lt;br /&gt;
==== Configuring The Maxstream API Protocol ====&lt;br /&gt;
The optional API protocol enables hardware addressing so that multiple aircraft can be managed from a single ground modem, or multiple aircraft and multiple ground stations can work simultaneously without interference from one another.  API mode is enabled by sending an escape sequence (+++) followed by AT commands, this can be done automatically at each boot or can be permanently configured with the &amp;quot;ATWR&amp;quot; command for greater reliability.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;define name=&amp;quot;XBEE_INIT&amp;quot; value=&amp;quot;\&amp;quot;ATPL2\rATRN1\rATTT80\r\ATBD6\rATWR\r\&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
 &amp;lt;/section&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above example will program the Maxstream to API mode, 100mW power (ATPL2), 57600 baud (ATBD6), and permanently store the changes (ATWR).  After flashing allow 30 seconds for the modem to store the changes, then disable the init string by adding the line &amp;lt;tt&amp;gt;&amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;TRUE&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt; (the parameter &amp;quot;value&amp;quot; has no effect), update the baud rate as needed, and re-flash the autopilot.  The modem and autopilot serial port baud rates must match eachother at all times.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Notes: &lt;br /&gt;
* Maxtream modems are factory configured for 9600 baud, in order to change baud rates, first configure the autopilot serial port to match the modem (DUART0_BAUD=B9600), boot the system so that the baud rate change command is sent to the modem (ATBD6) and permanently saved (ATWR), allow 30 seconds for the modem configuration to complete, then reprogram the autopilot with the new baud rate (DUART0_BAUD=B57600) and disabled modem configuration string &amp;lt;tt&amp;gt;&amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;TRUE&amp;quot;/&amp;gt; &amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The ac_id defined in &amp;lt;tt&amp;gt;conf/conf.xml&amp;lt;/tt&amp;gt; is permanently programmed into the modem so this procedure would need to be re-run if the modem is moved to another plane.&lt;br /&gt;
* For temporary boot-time API configuration remove any baud rate changes, remove &amp;lt;tt&amp;gt;ATWR\r&amp;lt;/tt&amp;gt; from the end of the string.&lt;br /&gt;
* Upgrade your Maxstream firmware to the latest version before attempting API mode operation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Box Code|confAgain/airframes/myplane.xml - makefile section at the bottom|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# Maxstream API protocol&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=XBeeTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DXBEE_UART=Uart0 -DDATALINK=XBEE -DUART0_BAUD=B57600&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c xbee.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}} &lt;br /&gt;
The above example configures the autopilot serial port (Uart0) to 57,600 baud and calls the Maxstream transport protocol (xbee.c).  Use the &amp;quot;#&amp;quot; symbol to comment lines in this section of the airframe file.&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensure that the ground station is using the same protocol and an equal or higher baud rate:&lt;br /&gt;
{{Box Code|conf/control_panel.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;session name=&amp;quot;USB&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;program name=&amp;quot;link&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-d&amp;quot; constant=&amp;quot;/dev/paparazzi/ttyUSB0&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-transport&amp;quot; constant=&amp;quot;xbee&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-uplink&amp;quot; constant=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-s&amp;quot; constant=&amp;quot;57600&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/program&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/session&amp;gt;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Use this constant /dev/paparazzi/ttyUSB0 when using either the ftdi cable or a Maxstream USB ground modem.. Otherwise use /dev/ttyUSB0 (the ttyUSB0 being the device that you are using. Note: it might not always be ttyUSB0). This paparazzi directory in the dev folder is created when setting the udev rules. [http://paparazzi.enac.fr/wiki/index.php/Installation#Setting_access_rights_for_USB_download Setting Udev rules]&lt;br /&gt;
=====Alternate Method=====&lt;br /&gt;
This is the way it is done in funjet1.xml and has been tested to work by Danstah&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;define name=&amp;quot;XBEE_INIT&amp;quot; value=&amp;quot;\&amp;quot;ATPL2\rATRN1\rATTT80\r\&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;!--    &amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;TRUE&amp;quot;/&amp;gt; --&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
 &amp;lt;/section&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Also use this&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;section name=&amp;quot;DATALINK&amp;quot; prefix=&amp;quot;DATALINK_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_TYPE&amp;quot; value=&amp;quot;XBEE&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_ADDRESS&amp;quot; value=&amp;quot;....&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
And Finally use this in the makefile section&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B9600&lt;br /&gt;
ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c xbee.c&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
By reading all the information above you should be able to infer what the above does.&lt;br /&gt;
&lt;br /&gt;
Now keep in mind that the ground modem baud rate and airplanes modem baud rates do not have to match. The only things that need to match are the the modem on the planes baud rate and the rate defined in the airframe file. For example this planes modem is set to 9600 and this could be used with the ground modem configured above using 57600... &lt;br /&gt;
Also for multiple UAV's a good way to configure them is to use 9600 for the ap and use a ground modem configured to 57600 and its not a bad idea to use minimal telemetry.&lt;br /&gt;
&lt;br /&gt;
=== GPS ===&lt;br /&gt;
The serial port settings must match that of the GPS and are configured here along with the necessary files to interpret the u-blox UBX binary protocol:&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.srcs += gps_ubx.c gps.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
'''Note:'''&lt;br /&gt;
* u-blox GPS modules are factory configured for 9600 baud, 38,400 baud is recommended along with the other required changes.  The GPS can be accessed directly thru the [[Compiling#USB_flashing|UART Tunnel]] and [[GPS#GPS_configuration_using_U-Center Configured with|u-center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If using the u-blox LEA-5H, add the flag -DGPS_USE_LATLONG in the makefile section of the airframe xml file in the gps section. This flag must be inserted above &amp;quot;ap.srcs += gps_ubx.c gps.c&amp;quot; for proper operation.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400 -DGPS_USE_LATLONG&lt;br /&gt;
ap.srcs += gps_ubx.c gps.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Sensors ===&lt;br /&gt;
&lt;br /&gt;
=== Control loops ===&lt;br /&gt;
&lt;br /&gt;
The control loops can be divided in two largely independent groups : the vertical ones and the horizontal ones (files sw/airborne/fw_h_ctl.c and sw/airborne/fw_v_ctl.c ). Those loops can be commanded at different levels by either the R/C transmitter or the autonomous navigation routine.&lt;br /&gt;
&lt;br /&gt;
First the horizontal loop:&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM&lt;br /&gt;
ap.srcs += nav.c fw_h_ctl.c fw_v_ctl.c&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Radio Control ==&lt;br /&gt;
The Paparazzi autpilot interfaces directly with the PWM signal from any standard hobby R/C receiver.  Signal decoding configuration settings for this are stored in the [[Radio_Control|Radio Control]] file.&lt;/div&gt;</summary>
		<author><name>Ben P</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Airframe_Configuration&amp;diff=4069</id>
		<title>Airframe Configuration</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Airframe_Configuration&amp;diff=4069"/>
		<updated>2008-09-26T23:11:51Z</updated>

		<summary type="html">&lt;p&gt;Ben P: /* GPS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The airframe configuration file is located in &amp;lt;tt&amp;gt;conf/airframes&amp;lt;/tt&amp;gt; and contains&lt;br /&gt;
all the hardware and software settings for an aircraft. This is an [http://en.wikipedia.org/wiki/Xml XML] document containing some [http://en.wikipedia.org/wiki/Makefile Makefile] code at the bottom. All gains, trims, and behavior settings are defined with standard XML elements. The hardware definitions such as processor type, modem protocol, servo driver, etc. are contained in the makefile raw section.&lt;br /&gt;
&lt;br /&gt;
== Selecting the Airframe File ==&lt;br /&gt;
Each airframe file must be assigned a name, unique ID, flight plan, etc. in [[Conf.xml|&amp;lt;tt&amp;gt;conf/conf.xml&amp;lt;/tt&amp;gt;]] as follows:&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;lt;conf&amp;gt;&lt;br /&gt;
  &amp;lt;aircraft &lt;br /&gt;
    name=&amp;quot;Twin1&amp;quot;&lt;br /&gt;
    ac_id=&amp;quot;1&amp;quot;&lt;br /&gt;
    airframe=&amp;quot;airframes/twinstar1.xml&amp;quot; &lt;br /&gt;
    radio=&amp;quot;radios/mc3030.xml&amp;quot; &lt;br /&gt;
    flight_plan=&amp;quot;flight_plans/mav05_cw.xml&amp;quot;&lt;br /&gt;
    telemetry=&amp;quot;telemetry/default.xml&amp;quot;&lt;br /&gt;
    gui_color=&amp;quot;blue&amp;quot;&lt;br /&gt;
  /&amp;gt;&lt;br /&gt;
  &amp;lt;aircraft &lt;br /&gt;
    name=&amp;quot;Plaster&amp;quot;&lt;br /&gt;
    ac_id=&amp;quot;2&amp;quot;&lt;br /&gt;
    airframe=&amp;quot;airframes/plaster1.xml&amp;quot; &lt;br /&gt;
    radio=&amp;quot;radios/cockpitMM.xml&amp;quot; &lt;br /&gt;
    telemetry=&amp;quot;telemetry/default.xml&amp;quot;&lt;br /&gt;
    flight_plan=&amp;quot;flight_plans/dummy.xml&amp;quot;&lt;br /&gt;
  /&amp;gt;&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  &amp;lt;/conf&amp;gt;&lt;br /&gt;
Then, to compile and flash the airframe settings and associated flight plan to your autopilot, simply select the appropriate A/C and target in the [[Paparazzi_Center|Paparazzi Center]] or specify your airframe name in the flash command typed from the prompt:&lt;br /&gt;
 make AIRCRAFT=&amp;lt;b&amp;gt;Twin1&amp;lt;/b&amp;gt; ap.upload&lt;br /&gt;
More information can be found on the [[Conf.xml|conf.xml]] page&lt;br /&gt;
&lt;br /&gt;
== XML Parameters ==&lt;br /&gt;
=== Commands ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;commands&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; lists the abstract commands you need to control the aircraft. In our example, we have only three:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;commands&amp;gt;&lt;br /&gt;
  &amp;lt;axis name=&amp;quot;THROTTLE&amp;quot; failsafe_value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;axis name=&amp;quot;ROLL&amp;quot;     failsafe_value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;axis name=&amp;quot;PITCH&amp;quot;    failsafe_value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/commands&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
Each command is associated with a failsafe value which will be used if no controller is active (during initialization for example). The range of these values is [-9600:9600]. Note that these commands do not necessarily match the servo actuators. For example, the ROLL command is typically linked to two aileron actuators.&lt;br /&gt;
&lt;br /&gt;
=== Servos ===&lt;br /&gt;
&lt;br /&gt;
The above commands get translated to the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;servos&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; here.  In this example we use two ailevons (surfaces used for both pitch and roll as on a flying wing) and a motor. These are listed in the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;servos&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;servos&amp;gt;&lt;br /&gt;
  &amp;lt;servo name=&amp;quot;THROTTLE&amp;quot;      no=&amp;quot;0&amp;quot; min=&amp;quot;1000&amp;quot; neutral=&amp;quot;1000&amp;quot; max=&amp;quot;2000&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;servo name=&amp;quot;AILEVON_LEFT&amp;quot;  no=&amp;quot;1&amp;quot; min=&amp;quot;2000&amp;quot; neutral=&amp;quot;1500&amp;quot; max=&amp;quot;1000&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;servo name=&amp;quot;AILEVON_RIGHT&amp;quot; no=&amp;quot;2&amp;quot; min=&amp;quot;1000&amp;quot; neutral=&amp;quot;1500&amp;quot; max=&amp;quot;2000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/servos&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where names are associated to the corresponding servo channel number on the autopilot and the neutral value, total range and direction are defined.  Min/max/neutral values are expressed in milliseconds and the direction of travel can be reversed by exchanging min with max (as in &amp;lt;tt&amp;gt;&amp;quot;AILEVON_LEFT&amp;quot;&amp;lt;/tt&amp;gt;, above).  The ''standard'' travel for a hobby servo is 1000ms - 2000ms with a 1500ms neutral.  Trim can be added by changing this neutral value, and absolute travel limits can be increased or reduced with the min/max values.  The &amp;lt;tt&amp;gt;&amp;quot;THROTTLE&amp;quot;&amp;lt;/tt&amp;gt; servo typically has the same value for the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;neutral&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;min&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;.  Note the following tips:&lt;br /&gt;
* Reverse the servo direction by exchanging min/max&lt;br /&gt;
* Trim should always be adjusted mechanically if possible to avoid asymetrical travel&lt;br /&gt;
* Any reduction of the total travel range should be done mechanically to maintain precision&lt;br /&gt;
* Many servos will respond well to values slightly outside the normal 1000-2000ms range but experiment carefully as the servo may not operate reliably outside this range and may even suffer permanent damage.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;servos&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; are then linked to the commands in the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;command_laws&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;command_laws&amp;gt;&lt;br /&gt;
  &amp;lt;let var=&amp;quot;aileron&amp;quot;         value=&amp;quot;@ROLL  * 0.3&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;let var=&amp;quot;elevator&amp;quot;        value=&amp;quot;@PITCH * 0.7&amp;quot;/&amp;gt;  &lt;br /&gt;
  &amp;lt;set servo=&amp;quot;THROTTLE&amp;quot;      value=&amp;quot;@THROTTLE&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;set servo=&amp;quot;AILEVON_LEFT&amp;quot;  value=&amp;quot;$elevator + $aileron&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;set servo=&amp;quot;AILEVON_RIGHT&amp;quot; value=&amp;quot;$elevator - $aileron&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/command_laws&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
[[Image:airframe_sign_conventions.jpg|thumb|Sign conventions for flight dynamics]]&lt;br /&gt;
where the third line is the simplest: the throttle servo value equals throttle command value. The other lines define and control the pitch/roll mixing.  Ailevon values are computed with a combination of two commands, '''ROLL''' and '''PITCH'''. This ''mixer'' is defined with two intermediate variables '''aileron''' and '''elevator''' introduced with the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;let&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; element.  The '''@''' symbol is used to reference a command value in the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; attribute of the &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;set&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;let&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; elements.  In the above example, the servos are limited to +/- 70% of their full travel for pitch and 30% for roll, only in combination can the servos reach 100% deflection.  Note that these numbers ''should add up 100% or more, never less''.  For example, you may want 100% travel available for pitch - this means if a roll is commanded along with maximum pitch only one servo will respond to the roll command as the other has already reached its mechanical limit.  If you find after tuning that these numbers add to less than 100% consider reducing the surface travel mechanically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that the signs used in the description follow the standard convention.&lt;br /&gt;
&lt;br /&gt;
=== Manual ===&lt;br /&gt;
The &amp;lt;tt&amp;gt;rc_command&amp;lt;/tt&amp;gt; sections links the channels of the RC transmitter (defined in the [[Radio_Control|Radio Control]] file) to the &amp;lt;tt&amp;gt;commands&amp;lt;/tt&amp;gt; defined above:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;rc_commands&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;THROTTLE&amp;quot; value=&amp;quot;@THROTTLE&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;ROLL&amp;quot;     value=&amp;quot;@ROLL&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;PITCH&amp;quot;    value=&amp;quot;@PITCH&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/rc_commands&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example looks trivial since the channel values have the same name than the commands.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Auto1 ===&lt;br /&gt;
The next section, named &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;AUTO1&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;, gives the maximum roll and pitch (in radians) allowed for the augmented stability mode.&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;AUTO1&amp;quot; prefix=&amp;quot;AUTO1_&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_ROLL&amp;quot; value=&amp;quot;RadOfDeg(35)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_PITCH&amp;quot; value=&amp;quot;RadOfDeg(35)&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ADC === &lt;br /&gt;
In the &amp;quot;adc&amp;quot; section, you will find the correspondance between arguments and their assigned pins on the autopilot board.&lt;br /&gt;
 &amp;lt;section name=&amp;quot;adc&amp;quot; prefix=&amp;quot;ADC_CHANNEL_&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR1&amp;quot; value=&amp;quot;ADC_1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR2&amp;quot; value=&amp;quot;ADC_2&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR_TOP&amp;quot; value=&amp;quot;ADC_0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
'''Important note''': To ''activate'' an ADC entry, a flag must be defined in the &amp;lt;tt&amp;gt;makefile&amp;lt;/tt&amp;gt; section. For the previous example, we would have to write:&lt;br /&gt;
&lt;br /&gt;
 ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2&lt;br /&gt;
&lt;br /&gt;
=== Infrared === &lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;INFRARED&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section describes the configuration of the infrared sensors.&lt;br /&gt;
&lt;br /&gt;
The first definitions are relative to the electronic neutral of the sensors (a sensor here is a pair of thermopiles). A perfect sensor should give 512 if it measures the same value on both sides.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;section name=&amp;quot;INFRARED&amp;quot; prefix=&amp;quot;IR_&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_IR1_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_IR2_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_TOP_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These neutrals are tuned with the &amp;quot;cupboard test&amp;quot;: Put the sensor in a close box (a cupboard) and read the values of the IR_SENSORS message (ir1, ir2 and vertical). Set the neutrals (they are subtracted from the measurement) to get null values. E.g. if you read 5 for the ir1 value with ADC_IR1_NEUTRAL equal to 512, change the latter to 517.&lt;br /&gt;
&lt;br /&gt;
The next lines define the installation of the horizontal and vertical sensors. The vertical sensor must  give a positive value when the temperature under the aircraft is higher than the temperature above. The two channels of the horizontal sensor must give positive values when it is warmer on the right side and the rear side. To adjust these signs, use the following declarations:&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;IR2_SIGN&amp;quot; value=&amp;quot;-1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;TOP_SIGN&amp;quot; value=&amp;quot;-1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, define how the horizontal sensor is connected to the airframe, orientation '''aligned''' or '''tilted'''. In the aligned case, ir'''1''' is along the lateral axis and ir'''2''' along the longitudian one. In the '''tilted''' case, the sensors are tilted by 45 degrees; ir'''1''' is along rear-left -- front-right, and ir'''2''' along rear-right -- front-left. A value of &amp;quot;0&amp;quot; indicates x-y sensor is aligned with the fueslage, a value of &amp;quot;1&amp;quot; indicates a 45 deg rotation. If the airframe construction allows choose an aligned sensor orientation since this gives the best stabilization response results. &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;HORIZ_SENSOR_TILTED&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three axis must give similar values for similar contrasts. The following factors can be used to scale these values. For example with an horizontal tilted sensor, the following ratios are usually needed:&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;LATERAL_CORRECTION&amp;quot; value=&amp;quot;0.7&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;LONGITUDINAL_CORRECTION&amp;quot; value=&amp;quot;0.7&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;VERTICAL_CORRECTION&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
Default values are 1.&lt;br /&gt;
&lt;br /&gt;
It may be hard to align the horizontal sensor with the aircraft. A tuning in flight will be needed to adjust the following neutrals. Adjust the roll neutral to fly straight. Adjust the pitch neutral to fly level with the desired throttle.&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ROLL_NEUTRAL_DEFAULT&amp;quot; value=&amp;quot;-2.5&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;PITCH_NEUTRAL_DEFAULT&amp;quot; value=&amp;quot;6&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, an asymmetric (left/right, front/rear) correction can be added with a last set of factors.&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_UP&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_DOWN&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_LEFT&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;CORRECTION_RIGHT&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
These corrections are set on the angles.&lt;br /&gt;
&lt;br /&gt;
=== Gyro === &lt;br /&gt;
Defines the type of gyro installed, each axis neutral, and any required temperature compensation. If the gyro has two axes, the pitch neutral is defined as well. Many gyros output their internal temperature and require a temperature-dependent linear correction be made to the neutral value.  No correction is done for the temperature in this example.(&amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;ADC_TEMP_SLOPE=0&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;GYRO&amp;quot; prefix=&amp;quot;GYRO_&amp;quot;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_ROLL_COEFF&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ROLL_NEUTRAL&amp;quot; value=&amp;quot;500&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_TEMP_NEUTRAL&amp;quot; value=&amp;quot;476&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_TEMP_SLOPE&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Bat === &lt;br /&gt;
This section give characteristics for the monitoring of the main power battery. &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;MILLIAMP_PER_PERCENT&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; represents the consumption (in mA) for one percent of THROTTLE and for one time unit. It is used to compute the &amp;lt;tt&amp;gt;energy&amp;lt;/tt&amp;gt; value of the &amp;lt;tt&amp;gt;BAT&amp;lt;/tt&amp;gt; message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;CATASTROPHIC_BAT_LEVEL&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; (was previously &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;LOW_BATTERY&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;) value defines the voltage at which the autopilot will lock the throttle at 0% in autonomous mode (kill_throttle mode). This value is also used by the ground server to issue a '''CATASTROPHIC''' alarm message on the bus (this message will be displayed in the console of the GCS).  &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;CRITIC&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;LOW&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; values will also used as threshold for '''CRITIC''' and '''WARNING''' alarms. They are optional and the respective defaults are 10.0 and 10.5V.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;MAX_BAT_LEVEL&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; may be specified to improve the display of the battery gauge in the strip. This definition is optional with a default value of 12.5V.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;BAT&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MILLIAMP_PER_PERCENT&amp;quot; value=&amp;quot;0.86&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;VOLTAGE_ADC_A&amp;quot; value=&amp;quot;0.0177531&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;VOLTAGE_ADC_B&amp;quot; value=&amp;quot;0.173626&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;VoltageOfAdc(adc)&amp;quot; value =&amp;quot;(VOLTAGE_ADC_A * adc + VOLTAGE_ADC_B)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CATASTROPHIC_BAT_LEVEL&amp;quot; value=&amp;quot;6.0&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CRITIC_BAT_LEVEL&amp;quot; value=&amp;quot;6.5&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;LOW_BAT_LEVEL&amp;quot; value=&amp;quot;7.0&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_BAT_LEVEL&amp;quot; value=&amp;quot;8.4&amp;quot; unit=&amp;quot;V&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Horizontal Control ===&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;HORIZONTAL CONTROL&amp;quot; prefix=&amp;quot;H_CTL_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;COURSE_PGAIN&amp;quot; value=&amp;quot;-0.4&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_MAX_SETPOINT&amp;quot; value=&amp;quot;0.35&amp;quot; unit=&amp;quot;radians&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_ATTITUDE_GAIN&amp;quot; value=&amp;quot;-7500.&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_RATE_GAIN&amp;quot; value=&amp;quot;-1500&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;PITCH_PGAIN&amp;quot; value=&amp;quot;-8000.&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ELEVATOR_OF_ROLL&amp;quot; value=&amp;quot;1250&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The outer loop acts on the route. It will produce a roll command from a course setpoint and a course measurement. The COURSE_PGAIN parameter is the factor multiplied by the course error (in radian) to get a roll setpoint (in radian). So if the plane is expected to go north (course=0) and is actually flying to 57 degrees (course=1 radian, i.e. ENE), with a gain of '''-0.4''', a roll of -0.4 (23 degrees) will be set for the lower control loop.&lt;br /&gt;
&lt;br /&gt;
The ROLL_ATTITUDE_GAIN is used to compute a ROLL command from the roll error (setpoint minus measurement). If a gyro in installed, the ROLL_RATE_GAIN to keep a null roll rate. So these two gains provide a P-D controller.&lt;br /&gt;
&lt;br /&gt;
===Vertical Control===&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;section name=&amp;quot;VERTICAL CONTROL&amp;quot; prefix=&amp;quot;V_CTL_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- outer loop proportional gain --&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ALTITUDE_PGAIN&amp;quot; value=&amp;quot;-0.1&amp;quot; unit=&amp;quot;(m/s)/m&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;!-- outer loop saturation --&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ALTITUDE_MAX_CLIMB&amp;quot; value=&amp;quot;3.&amp;quot; unit=&amp;quot;m/s&amp;quot;/&amp;gt;&lt;br /&gt;
These lines are associated with vertical control loops contained in ./sw/airborne/fw_v_ctl.c.  These are outer loop parameters that calculate a desired climb rate based on altitude error. Here, if the altitude error is 10m, the climb setpoint will be set to 1m/s. ALTITUDE_MAX_CLIMB is a bounded value (in m/s) so that the outer loop does not calculate too large of a climb rate&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE&amp;quot; value=&amp;quot;0.65&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_MIN_CRUISE_THROTTLE&amp;quot; value=&amp;quot;.4&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_MAX_CRUISE_THROTTLE&amp;quot; value=&amp;quot;1&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_LOITER_TRIM&amp;quot; value=&amp;quot;1000&amp;quot; unit=&amp;quot;pprz_t&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_DASH_TRIM&amp;quot; value=&amp;quot;-2500&amp;quot; unit=&amp;quot;pprz_t&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT&amp;quot; value=&amp;quot;0.15&amp;quot; unit=&amp;quot;%/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_PGAIN&amp;quot; value=&amp;quot;-0.008&amp;quot; unit=&amp;quot;%/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_IGAIN&amp;quot; value=&amp;quot;0.25&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_PITCH_OF_VZ_PGAIN&amp;quot; value=&amp;quot;0.35&amp;quot; unit=&amp;quot;rad/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These lines are associated with vertical rate control loops contained in ./sw/airborne/fw_v_ctl.c and are used by default in most cases.  The default vertical control law is for the vertical rate to be managed by a combination of throttle and pitch.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_PGAIN&amp;quot; value=&amp;quot;-0.1&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_IGAIN&amp;quot; value=&amp;quot;0.025&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_MAX_PITCH&amp;quot; value=&amp;quot;0.5&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_MIN_PITCH&amp;quot; value=&amp;quot;-0.5&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These lines are associated with vertical control loops contained in ./sw/airborne/fw_v_ctl.c but are not used in default. The non-default vertical control law is for the vertical rate to be managed by the pitch.&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;define name=&amp;quot;THROTTLE_SLEW_LIMITER&amp;quot; value=&amp;quot;2&amp;quot; unit=&amp;quot;s&amp;quot;/&amp;gt;&lt;br /&gt;
THROTTLE_SLEW_LIMITER is the required time is seconds to change throttle from 0% to 100%.&lt;br /&gt;
&lt;br /&gt;
=== Misc ===&lt;br /&gt;
 &amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;NOMINAL_AIRSPEED&amp;quot; value =&amp;quot;12.&amp;quot; unit=&amp;quot;m/s&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CARROT&amp;quot; value=&amp;quot;5.&amp;quot; unit=&amp;quot;s&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;KILL_MODE_DISTANCE&amp;quot; value=&amp;quot;(1.5*MAX_DIST_FROM_HOME)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CONTROL_RATE&amp;quot; value&amp;quot;60&amp;quot; unit=&amp;quot;Hz&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &amp;quot;NOMINAL_AIRSPEED&amp;quot; is mainly used in the simulator.&lt;br /&gt;
* &amp;quot;CARROT&amp;quot; gives the distance (in seconds, so ground speed is taken into account) between the carrot and the aircraft.&lt;br /&gt;
* &amp;quot;KILL_MODE_DISTANCE&amp;quot; is the threshold distance to switch the autopilot into KILL mode (defined descent with no throttle)&lt;br /&gt;
* &amp;quot;CONTROL_RATE&amp;quot; is the rate of the low level control loops in Hertz (60 or 20).&lt;br /&gt;
&lt;br /&gt;
== Hardware definitions - Makefile ==&lt;br /&gt;
&lt;br /&gt;
The airframe file must include the description of the controller board and it's low-level settings.  This is done in one &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;makefile&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section starting with the autopilot model and flashing mode:&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;makefile&amp;gt;&lt;br /&gt;
  include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;FLASH_MODE=IAP&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
 &amp;lt;/makefile&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Below this are the definintions and configuration of the peripherals and interfaces.&lt;br /&gt;
&lt;br /&gt;
=== R/C ===&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE=RC_FUTABA&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.EXTRA_SRCS += radio_control.c $(SRC_ARCH)/ppm_hw.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DACTUATORS=\&amp;quot;servos_direct_hw.h\&amp;quot;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;ap.EXTRA_SRCS += $(SRC_ARCH)/servos_direct_hw.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You can set RADIO_CONTROL_TYPE to RC_FUTABA, for falling edge PPM, or RC_JR for rising edge PPM. &amp;quot;RC_FUTABA&amp;quot; is for The Futaba or compatible brands, and &amp;quot;RC_JR&amp;quot; for JR (a.k.a Graupner outside of the USA) or compatible brands.&lt;br /&gt;
&lt;br /&gt;
For the classix, you must specify which pins to use for PWM by adding &amp;quot;-DPWM_SERVO_0, etc.&amp;quot; to the line fbw.CFLAGS. This activate the PWM channel. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;tt&amp;gt;wiring on classix PWM connector&lt;br /&gt;
  connector   LPC   shared         port &lt;br /&gt;
  PWM1        PWM5  AD1_6  CAP1_3  P0.21&lt;br /&gt;
  PWM2        PWM3  RXD0   EINT0   P0.1&lt;br /&gt;
  PWM3        PWM1  TXD0           P0.0&lt;br /&gt;
  PWM4        PWM6  RXD1   EINT3   P0.9&lt;br /&gt;
  PWM5        PWM4  TXD1   AD1_1   P0.8&lt;br /&gt;
  PWM6        PWM2  SSEL0  EINT2   P0.7&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PWM1 and PWM6 should be safe. PWM4 and PWM5 should be OK if you're not using UART1 on the FBW processor - same for PWM2 and PWM3 if you're not using UART0 (disable FBW telemetry for that ).&lt;br /&gt;
&lt;br /&gt;
=== Modem ===&lt;br /&gt;
The modem protocol and baud rate must be set in both the airframe file and ground station.  Any standard baud rate can be used, with 9600 being adequate and 57600 recommended for most users to allow high speed telemetry for more detailed flight data analysis.  The actual data rate is determined by the number of messages being sent and the period of each message as defined in &amp;lt;tt&amp;gt;conf/telemetry/default.xml&amp;lt;/tt&amp;gt;.  Those wishing to experiment with &amp;quot;alternative&amp;quot; modems can reduce the number and period of each telemetry message to fit within most any bandwidth constraint.&lt;br /&gt;
&lt;br /&gt;
Paparazzi supports the following modem protocols:&lt;br /&gt;
* Standard transparent serial (pprz) - this is compatible with all modems and can be used to connect the autopilot directly to a PC for testing without a modem.&lt;br /&gt;
* Maxstream API protocol (xbee) - compatible with all Maxstream modems including the 9XTend and Zigbee.  This protocol enables hardware addressing, allowing multiple aircraft to be managed from a single ground modem.&lt;br /&gt;
* Coronis Wavecard - necessary for operation with the unusual Coronis Wavecard modem.&lt;br /&gt;
Select the baud/protocol in the airframe file by commenting/uncommenting the appropriate section as follows:&lt;br /&gt;
==== Configuring The Serial Protocol ====&lt;br /&gt;
New users are advised to start with the standard serial protocol before attempting to setup an addressed API link. There are no real reasons for the novice user to use the xbee protocol over the standard PPRZTransport. Even if you are using a Maxstream modem you should still start out with the standard. Lastly it should be pointed out that using a single UAV there is no disadvantage and that the [http://www.engr.usu.edu/wiki/index.php/OSAM OSAM] Paparazzi Team at UAS 2008 took second place using the STANDARD protocol. The serial protocol works with virtually any modem as well as direct cable connections.  The baud rates of the airborne modem, autopilot, ground modem, and PC must be configured correctly.  The PC and autopilot serial ports do not need to be set to the same baud rate, i.e. when running multiple aircraft from a single ground modem, the ground modem may require a higher baud rate than any of the airborne modems in order to stream the data from multiple simultaneous sources.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;DATALINK&amp;quot; prefix=&amp;quot;DATALINK_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_TYPE&amp;quot; value=&amp;quot;PPRZ&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_ADDRESS&amp;quot; value=&amp;quot;....&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above example tells the autopilot to send and recieve data in standard serial form.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml - makefile section at the bottom|&lt;br /&gt;
 # Serial modem &lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B57600&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c pprz_transport.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above example configures the autopilot serial port (Uart0) to 57,600 baud and calls the serial transport protocol (pprz_transport.c).  Use the &amp;quot;#&amp;quot; symbol to comment lines in this section of the airframe file. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note:&lt;br /&gt;
* The autopilot and modem serial port baud rates must match at all times and also must match the ground modem rate, check your modem documentation to find the default baud rate and configure a different rate as needed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensure that the ground station is using the same protocol and an equal or higher baud rate:&lt;br /&gt;
{{Box Code|conf/control_panel.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;session name=&amp;quot;USB&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;program name=&amp;quot;link&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-d&amp;quot; constant=&amp;quot;/dev/paparazzi/ttyUSB0&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;!-- &amp;lt;arg flag=&amp;quot;-transport&amp;quot; constant=&amp;quot;xbee&amp;quot;/&amp;gt; Comment this line for standard serial protocol --&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-uplink&amp;quot; constant=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-s&amp;quot; constant=&amp;quot;57600&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/program&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/session&amp;gt;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Use this constant /dev/paparazzi/ttyUSB0 when using either the ftdi cable or a Maxstream USB ground modem.. Otherwise use /dev/ttyUSB0 (the ttyUSB0 being the device that you are using. Note: it might not always be ttyUSB0). This paparazzi directory in the dev folder is created when setting the udev rules. [http://paparazzi.enac.fr/wiki/index.php/Installation#Setting_access_rights_for_USB_download Setting Udev rules]&lt;br /&gt;
&lt;br /&gt;
==== Configuring The Maxstream API Protocol ====&lt;br /&gt;
The optional API protocol enables hardware addressing so that multiple aircraft can be managed from a single ground modem, or multiple aircraft and multiple ground stations can work simultaneously without interference from one another.  API mode is enabled by sending an escape sequence (+++) followed by AT commands, this can be done automatically at each boot or can be permanently configured with the &amp;quot;ATWR&amp;quot; command for greater reliability.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;define name=&amp;quot;XBEE_INIT&amp;quot; value=&amp;quot;\&amp;quot;ATPL2\rATRN1\rATTT80\r\ATBD6\rATWR\r\&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;FALSE&amp;quot;/&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
 &amp;lt;/section&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above example will program the Maxstream to API mode, 100mW power (ATPL2), 57600 baud (ATBD6), and permanently store the changes (ATWR).  After flashing allow 30 seconds for the modem to store the changes, then disable the init string &amp;lt;tt&amp;gt;&amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;&amp;lt;b&amp;gt;TRUE&amp;lt;/b&amp;gt;&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;, update the baud rate as needed, and re-flash the autopilot.  The modem and autopilot serial port baud rates must match eachother at all times.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Notes: &lt;br /&gt;
* Maxtream modems are factory configured for 9600 baud, in order to change baud rates, first configure the autopilot serial port to match the modem (DUART0_BAUD=B9600), boot the system so that the baud rate change command is sent to the modem (ATBD6) and permanently saved (ATWR), allow 30 seconds for the modem configuration to complete, then reprogram the autopilot with the new baud rate (DUART0_BAUD=B57600) and disabled modem configuration string &amp;lt;tt&amp;gt;&amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;&amp;lt;b&amp;gt;TRUE&amp;lt;/b&amp;gt;&amp;quot;/&amp;gt; &amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The ac_id defined in &amp;lt;tt&amp;gt;conf/conf.xml&amp;lt;/tt&amp;gt; is permanently programmed into the modem so this procedure would need to be re-run if the modem is moved to another plane.&lt;br /&gt;
* For temporary boot-time API configuration remove any baud rate changes, remove &amp;lt;tt&amp;gt;ATWR\r&amp;lt;/tt&amp;gt; from the end of the string and keep &amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;FALSE&amp;quot;.&lt;br /&gt;
* Upgrade your Maxstream firmware to the latest version before attempting API mode operation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Box Code|confAgain/airframes/myplane.xml - makefile section at the bottom|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# Maxstream API protocol&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=XBeeTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DXBEE_UART=Uart0 -DDATALINK=XBEE -DUART0_BAUD=B57600&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c xbee.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}} &lt;br /&gt;
The above example configures the autopilot serial port (Uart0) to 57,600 baud and calls the Maxstream transport protocol (xbee.c).  Use the &amp;quot;#&amp;quot; symbol to comment lines in this section of the airframe file.&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensure that the ground station is using the same protocol and an equal or higher baud rate:&lt;br /&gt;
{{Box Code|conf/control_panel.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;session name=&amp;quot;USB&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;program name=&amp;quot;link&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-d&amp;quot; constant=&amp;quot;/dev/paparazzi/ttyUSB0&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-transport&amp;quot; constant=&amp;quot;xbee&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-uplink&amp;quot; constant=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;arg flag=&amp;quot;-s&amp;quot; constant=&amp;quot;57600&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/program&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
 &amp;lt;/session&amp;gt;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Use this constant /dev/paparazzi/ttyUSB0 when using either the ftdi cable or a Maxstream USB ground modem.. Otherwise use /dev/ttyUSB0 (the ttyUSB0 being the device that you are using. Note: it might not always be ttyUSB0). This paparazzi directory in the dev folder is created when setting the udev rules. [http://paparazzi.enac.fr/wiki/index.php/Installation#Setting_access_rights_for_USB_download Setting Udev rules]&lt;br /&gt;
=====Alternate Method=====&lt;br /&gt;
This is the way it is done in funjet1.xml and has been tested to work by Danstah&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;define name=&amp;quot;XBEE_INIT&amp;quot; value=&amp;quot;\&amp;quot;ATPL2\rATRN1\rATTT80\r\&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;!--    &amp;lt;define name=&amp;quot;NO_XBEE_API_INIT&amp;quot; value=&amp;quot;TRUE&amp;quot;/&amp;gt; --&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
 &amp;lt;/section&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
Also use this&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;section name=&amp;quot;DATALINK&amp;quot; prefix=&amp;quot;DATALINK_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_TYPE&amp;quot; value=&amp;quot;XBEE&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;DEVICE_ADDRESS&amp;quot; value=&amp;quot;....&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
And Finally use this in the makefile section&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B9600&lt;br /&gt;
ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c xbee.c&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
By reading all the information above you should be able to infer what the above does&lt;br /&gt;
&lt;br /&gt;
Now keep in mind that the ground modem baud rate and airplanes modem baud rates do not have to match. The only things that need to match are the the modem on the planes baud rate and the rate defined in the airframe file. For example this planes modem is set to 9600 and this could be used with the ground modem configured above using 57600... &lt;br /&gt;
Also for multiple UAV's a good way to configure them is to use 9600 for the ap and use a ground modem configured to 57600 and its not a bad idea to use minimal telemetry&lt;br /&gt;
&lt;br /&gt;
=== GPS ===&lt;br /&gt;
The serial port settings must match that of the GPS and are configured here along with the necessary files to interpret the u-blox UBX binary protocol:&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DGPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.srcs += gps_ubx.c gps.c&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
'''Note:'''&lt;br /&gt;
* u-blox GPS modules are factory configured for 9600 baud, 38,400 baud is recommended along with the other required changes.  The GPS can be accessed directly thru the [[Compiling#USB_flashing|UART Tunnel]] and [[GPS#GPS_configuration_using_U-Center Configured with|u-center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If using the u-blox LEA-5H, add the flag -DGPS_USE_LATLONG in the makefile section of the airframe xml file.&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DGPS_USE_LATLONG&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Sensors ===&lt;br /&gt;
&lt;br /&gt;
=== Control loops ===&lt;br /&gt;
&lt;br /&gt;
The control loops can be divided in two largely independent groups : the vertical ones and the horizontal ones (files sw/airborne/fw_h_ctl.c and sw/airborne/fw_v_ctl.c ). Those loops can be commanded at different levels by either the R/C transmitter or the autonomous navigation routine.&lt;br /&gt;
&lt;br /&gt;
First the horizontal loop:&lt;br /&gt;
{{Box Code|conf/airframes/funjet1.xml|&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM&lt;br /&gt;
ap.srcs += nav.c fw_h_ctl.c fw_v_ctl.c&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Radio Control ==&lt;br /&gt;
The Paparazzi autpilot interfaces directly with the PWM signal from any standard hobby R/C receiver.  Signal decoding configuration settings for this are stored in the [[Radio_Control|Radio Control]] file.&lt;/div&gt;</summary>
		<author><name>Ben P</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=4067</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=4067"/>
		<updated>2008-09-25T08:49:34Z</updated>

		<summary type="html">&lt;p&gt;Ben P: /* Set */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the DTD (located in &amp;lt;tt&amp;gt;conf/flight_plans/flight_plan.dtd&amp;lt;/tt&amp;gt;). This&lt;br /&gt;
DTD must be referenced in the header of your flight plan XML file using the following line:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE flight_plan SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The flight plans are stored in the &amp;lt;tt&amp;gt;conf/flight_plans&amp;lt;/tt&amp;gt; directory. The [[Flight_Plan_Editor|flight plan editor]] can be used to create basic flight plans in the GUI. &lt;br /&gt;
&lt;br /&gt;
== Structure of the flight plan file ==&lt;br /&gt;
&lt;br /&gt;
Extract from the DTD:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT flight_plan (header?,waypoints,sectors?,include*,exceptions?,blocks)&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A flight plan is composed of two compulsory elements: [[#waypoints|waypoints]] and [[#blocks|blocks]] and typically contains optional &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt;'s and global &amp;lt;tt&amp;gt;exceptions&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The root &amp;lt;tt&amp;gt;flight_plan&amp;lt;/tt&amp;gt; element is specified with several attributes:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;flight_plan name lat0 lon0 ground alt security height qfu alt max_dist_from_home&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;: the name of the mission (a text string)&lt;br /&gt;
* &amp;lt;tt&amp;gt;lat0, lon0&amp;lt;/tt&amp;gt;: describe the latitude and longitude of the point {0,0} in WGS84 degree coordinates&lt;br /&gt;
* &amp;lt;tt&amp;gt;ground_alt&amp;lt;/tt&amp;gt;: the ground altitude (in meters). It defines the &amp;lt;tt&amp;gt;GROUND_ALT&amp;lt;/tt&amp;gt; constant value which can be used to define waypoint altitudes&lt;br /&gt;
* &amp;lt;tt&amp;gt;security_height&amp;lt;/tt&amp;gt;:  the altitude used by the circle-home failsafe procedure&lt;br /&gt;
* &amp;lt;tt&amp;gt;qfu&amp;lt;/tt&amp;gt; (optional): defines the global constant &amp;lt;tt&amp;gt;QFU&amp;lt;/tt&amp;gt;. It usually is the magnetic heading in degrees (north=0, east=90) of the runway, the opposite of wind direction. This constant may be used in the mission description. It is also used by the simulator as the original course of the aircraft.&lt;br /&gt;
* &amp;lt;tt&amp;gt;alt&amp;lt;/tt&amp;gt;: the default altitude of waypoints&lt;br /&gt;
* &amp;lt;tt&amp;gt;max_dist_from_home&amp;lt;/tt&amp;gt;: the maximum allowed distance (in meters) from the HOME waypoint.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the first line of a flight plan:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
  &amp;lt;flight_plan name=&amp;quot;Example Muret&amp;quot;&lt;br /&gt;
   lat0=&amp;quot;43.46223&amp;quot; lon0=&amp;quot;1.27289&amp;quot; max_dist_from_home=&amp;quot;300&amp;quot; qfu=&amp;quot;270&amp;quot;&lt;br /&gt;
   ground_alt=&amp;quot;185&amp;quot; security_height=&amp;quot;25&amp;quot; alt=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Waypoints ===&lt;br /&gt;
&lt;br /&gt;
The waypoints are the geographic locations used to specify the trajectories. A waypoint is specified with its name and its relative coordinates:&lt;br /&gt;
 &amp;lt;tt&amp;gt; &amp;lt;waypoint name x y [alt] /&amp;gt; &amp;lt;/tt&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; are the coordinates in meters from point {0,0}. &amp;lt;tt&amp;gt;alt&amp;lt;/tt&amp;gt; is optional and can be used to assign an altitude to a particular waypoint that is different from the globally defined &amp;lt;tt&amp;gt;alt&amp;lt;/tt&amp;gt; above.  Note that a waypoint named &amp;lt;tt&amp;gt;HOME&amp;lt;/tt&amp;gt; is required as it is used by the failsafe HOME mode procedure.&lt;br /&gt;
&lt;br /&gt;
One example:&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;waypoint name=&amp;quot;HOME&amp;quot; x=&amp;quot;0.0&amp;quot; y=&amp;quot;30.0&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;waypoint name=&amp;quot;1&amp;quot; x=&amp;quot;-100.0&amp;quot; y=&amp;quot;60.0&amp;quot; alt=&amp;quot;270.&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;waypoint name=&amp;quot;2&amp;quot; x=&amp;quot;-130.0&amp;quot; y=&amp;quot;217.5&amp;quot; alt=&amp;quot;3000.&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Waypoints are easily edited with the [[Flight_Plan_Editor|flight plan editor]].&lt;br /&gt;
&lt;br /&gt;
Waypoints which name starts with an underscore are not displayed in the GCS, except in editor mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sectors ===&lt;br /&gt;
Flat ''Sectors'' can be described as a list of waypoint corners. Such an area will be displayed in the GCS.&lt;br /&gt;
A function is generated to check if a point (usually the aircraft itself) is ''inside'' the polygon. Currently, this feature requires that the polygon is &amp;lt;b&amp;gt;convex&amp;lt;/b&amp;gt; and described in a &amp;lt;b&amp;gt;clockwise&amp;lt;/b&amp;gt; order. For a sector named &amp;lt;tt&amp;gt;Sector&amp;lt;/tt&amp;gt;, the generated function is &amp;lt;tt&amp;gt;bool_t InsideSector(float x, float y);&amp;lt;/tt&amp;gt; where &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; are east and north coordinated, in meters, relative to the geographic reference of the flight plan. Note: If the flight plan is dynamically relocated, such a sector will be relocated but the display is currently not updated on the GCS.&lt;br /&gt;
&lt;br /&gt;
For example, with the following element in a flight plan (waypoints which name starts with an underscore are not displayed in the GCS, except in editor mode)&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;sectors&amp;gt;&lt;br /&gt;
  &amp;lt;sector name=&amp;quot;Muret&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;corner name=&amp;quot;_1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;corner name=&amp;quot;_2&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;corner name=&amp;quot;_3&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;corner name=&amp;quot;_4&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/sector&amp;gt;&lt;br /&gt;
 &amp;lt;/sectors&amp;gt;&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
it is then possible to write a exception to stay inside it:&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;! InsideMuret(estimator_x, estimator_y)&amp;quot; deroute=&amp;quot;standby&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Include ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add blocks defined in an external procedure. It’s useful to include pre-written procedures with only few arguments and then clarify the flight plan.&lt;br /&gt;
Here is the structure:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name procedure [x] [y] [rotate] &amp;gt; [&amp;lt;arg name value /&amp;gt;]*[&amp;lt;with from to /&amp;gt;]*&amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; attribute of the include element will be used in this flight plan to jump to the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file. The&lt;br /&gt;
procedure can be shifted (&amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt; meters east, &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; meters north) and &amp;lt;tt&amp;gt;rotate&amp;lt;/tt&amp;gt;d (clockwise degrees, north=0).&lt;br /&gt;
Named arguments may be given with their value in the &amp;lt;tt&amp;gt;arg&amp;lt;/tt&amp;gt; elements. The &amp;lt;tt&amp;gt;with&amp;lt;/tt&amp;gt; tag allows to link labels from the procedure to blocks of the main flight plan.&lt;br /&gt;
Then, each block of the procedure is like any block of the flight plan and is designated with a dotted identifier: block &amp;lt;tt&amp;gt;b&amp;lt;/tt&amp;gt; of a procedure named &amp;lt;tt&amp;gt;p&amp;lt;/tt&amp;gt; is named &amp;lt;tt&amp;gt;b.p&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Here is an example:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;hippo1&amp;quot; procedure=&amp;quot;hippo.xml&amp;quot; x=&amp;quot;-100&amp;quot; y=&amp;quot;150&amp;quot; rotate=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;arg name=&amp;quot;alt&amp;quot; value=&amp;quot;GROUND ALT+100&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;event1&amp;quot; to=&amp;quot;penta&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where a jump to &amp;lt;tt&amp;gt;event1&amp;lt;/tt&amp;gt; inside the &amp;lt;tt&amp;gt;hippo.xml&amp;lt;/tt&amp;gt; procedure will actually jump to the &amp;lt;tt&amp;gt;penta&amp;lt;/tt&amp;gt; block of the&lt;br /&gt;
current flight plan.&lt;br /&gt;
&lt;br /&gt;
=== Blocks ===&lt;br /&gt;
&lt;br /&gt;
Block elements are the main part of a flight plan: they describe each unit of the mission.&lt;br /&gt;
They are made of various primitives, called stages and exceptions, you can put one after the other. When a&lt;br /&gt;
stage (or a block) is finished, the autopilot go to the next one. The behaviour after the last stage of the last block is undefined.&lt;br /&gt;
&lt;br /&gt;
As described in the DTD, the &amp;lt;tt&amp;gt;blocks&amp;lt;/tt&amp;gt; element is composed of &amp;lt;tt&amp;gt;block&amp;lt;/tt&amp;gt; elements which are sequence of ''stages'':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT blocks (block+)&amp;gt;&lt;br /&gt;
 &amp;lt;!ELEMENT block (exception|while|heading|attitude|go|xyz|set|circle|deroute|stay|follow&lt;br /&gt;
                           |survey_rectangle)*&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block name=&amp;quot;circlehome&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;circle radius=&amp;quot;75&amp;quot; wp=&amp;quot;HOME&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a button in the [:UserManual/GCSFeatures: strip of the aircraft] with the attribute &amp;lt;tt&amp;gt;strip_button&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block name=&amp;quot;descent&amp;quot; strip_button=&amp;quot;Descent&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;circle wp=&amp;quot;HOME&amp;quot; throttle=&amp;quot;0.0&amp;quot; pitch=&amp;quot;-15&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt; &amp;lt;/tt&amp;gt;&lt;br /&gt;
This button will activate the block.&lt;br /&gt;
&lt;br /&gt;
An icon can be specified to display the button. The &amp;lt;tt&amp;gt;strip_button&amp;lt;/tt&amp;gt; label then is a tooltip for the icon. The icon must be an image file available in the directory &amp;lt;tt&amp;gt;data/pictures/gcs_icons&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block name=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can call functions before or after each execution of the block:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block name=&amp;quot;ciclehome&amp;quot; pre_call=&amp;quot;function_to_call_before_circle()&amp;quot; post_call=&amp;quot;function_to_call_after_circle()&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;circle wp=&amp;quot;HOME&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Expressions =====&lt;br /&gt;
&lt;br /&gt;
Most of the numeric attributes in stages are analyzed as C expressions. The syntax of this C expression is restricted to &lt;br /&gt;
* numeric constants&lt;br /&gt;
* some internal autopilot variables (not fully documented, see examples)&lt;br /&gt;
* Some binary operators: &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=, &amp;lt;&amp;gt;, ==, +, -, /, *&lt;br /&gt;
* Some utility functions&lt;br /&gt;
&lt;br /&gt;
Some examples of usable expressions are given in the next sections.&lt;br /&gt;
&lt;br /&gt;
==== Exceptions ====&lt;br /&gt;
&lt;br /&gt;
The flight manager can handle exceptions. They consist in conditions checked periodically (at the same pace as the navigation control), allowing the control to jump to a given block. Here is the syntax of exceptions:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;...&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;cond&amp;lt;/tt&amp;gt; is an expression and &amp;lt;tt&amp;gt;deroute&amp;lt;/tt&amp;gt; is the name of the block we want to switch to as soon as the condition is true.&lt;br /&gt;
&lt;br /&gt;
Here are some example of exceptions:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;10 &amp;gt; PowerVoltage()&amp;quot; deroute=&amp;quot;go_down&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;(ground_alt+10 &amp;gt; estimator_z)&amp;quot; deroute=&amp;quot;go_up&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;(estimator_flight_time &amp;gt; 840)&amp;quot; deroute=&amp;quot;quick_land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exceptions can be local to a block or global to the flight plan, in the &amp;lt;tt&amp;gt;&amp;lt;exceptions&amp;gt;&amp;lt;/tt&amp;gt; element. In the following example, time since last reception of a message from the ground station is monitored and the navigation is switched to the &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt; block if no message have been received for 22s. This exception is valid for '''all''' the blocks.&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;flight_plan ...&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt; ... &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;exceptions&amp;gt;&lt;br /&gt;
    &amp;lt;exception cond=&amp;quot;datalink_time &amp;gt; 22&amp;quot; deroute=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/exceptions&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt; ...&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Deroute ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;deroute&amp;lt;/tt&amp;gt; is the ''goto'' directive of the flight plan; it switches the navigation to the given block:&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
&amp;lt;deroute block=&amp;quot;landing&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this primitive should not be used to execute loops which are provided by the following elements.&lt;br /&gt;
&lt;br /&gt;
==== Loops ====&lt;br /&gt;
&lt;br /&gt;
Unbounded loops are written with &amp;lt;tt&amp;gt;while&amp;lt;/tt&amp;gt; elements whose &amp;lt;tt&amp;gt;cond&amp;lt;/tt&amp;gt; attribute is a boolean expression.&lt;br /&gt;
Children  of &amp;lt;tt&amp;gt;while&amp;lt;/tt&amp;gt; are stages:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;while cond=&amp;quot;TRUE&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;go wp=&amp;quot;A&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;go wp=&amp;quot;B&amp;quot;/&amp;gt; &lt;br /&gt;
  &amp;lt;go wp=&amp;quot;C&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;while cond=&amp;quot;5 &amp;gt; stage_time&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/while&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
In this example, we run an infinite loop, going to waypoints &amp;lt;tt&amp;gt;A&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt; and waiting for 5 seconds before repeating.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Bounded loops are written with the &amp;lt;tt&amp;gt;for&amp;lt;/tt&amp;gt; tag:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;for var=&amp;quot;i&amp;quot; from=&amp;quot;0&amp;quot; to=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;/for&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where the body of the loop will be run four times.&lt;br /&gt;
&lt;br /&gt;
The variable of a &amp;lt;tt&amp;gt;for&amp;lt;/tt&amp;gt; loop can be used inside expressions appearing as attributes of the stages:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;for var=&amp;quot;i&amp;quot; from=&amp;quot;1&amp;quot; to=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;circle wp=&amp;quot;HOME&amp;quot; radius=&amp;quot;75&amp;quot; alt=&amp;quot;ground_alt+50*$i&amp;quot; until=&amp;quot;stage_time&amp;gt;10&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/for&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
In this example, we circle around '''HOME''' 10 seconds at height 50m, 10s at height 100m, ... until height 250m.&lt;br /&gt;
Note: Two bounded loops using the same control variable are not allowed in the same block.&lt;br /&gt;
&lt;br /&gt;
==== Navigation modes ====&lt;br /&gt;
&lt;br /&gt;
Navigation modes give the description of the desired trajectory in 3D. While the horizontal mode is specified through&lt;br /&gt;
''stages'', the vertical control is specified with various attributes of these stages. The current available navigation stages are&lt;br /&gt;
* attitude : just keep a fixed attitude;&lt;br /&gt;
* heading : keep a given course;&lt;br /&gt;
* go : go to a given waypoint;&lt;br /&gt;
* circle : circle around a waypoint;&lt;br /&gt;
* stay : hold the position (hard to realize for a fixed-win aircraft);&lt;br /&gt;
* follow : follow another aircraft;&lt;br /&gt;
* xyz : circle around a point moveable with the RC transmitter stick (obsolete with the datalink).&lt;br /&gt;
&lt;br /&gt;
The vertical control is achieved using the &amp;lt;tt&amp;gt;vmode&amp;lt;/tt&amp;gt; attribute of these stages. The possible values are &lt;br /&gt;
* '''alt''' (the default) : the autopilot keeps the desired altitude which is the altitude of the waypoint (if any) or the altitude specified with the &amp;lt;tt&amp;gt;alt&amp;lt;/tt&amp;gt; attribute;&lt;br /&gt;
* '''climb''' : the autopilot keeps the desired vertical speed specified with the &amp;lt;tt&amp;gt;climb&amp;lt;/tt&amp;gt; attribute (in m/s);&lt;br /&gt;
* '''throttle''' : the autopilots sets the desired throttle specified with the &amp;lt;tt&amp;gt;throttle&amp;lt;/tt&amp;gt; attribute (between 0 and 1);&lt;br /&gt;
* '''glide''' : the autopilot keeps the desired slope between two waypoints&lt;br /&gt;
&lt;br /&gt;
The default control is done with the throttle. However, setting the &amp;lt;tt&amp;gt;pitch&amp;lt;/tt&amp;gt; attribute to '''auto''' and the &amp;lt;tt&amp;gt;throttle&amp;lt;/tt&amp;gt; attribute to a constant allows a vertical control only by controlling the attitude of the A/C.&lt;br /&gt;
The &amp;lt;tt&amp;gt;pitch&amp;lt;/tt&amp;gt; attribute also can be set to any value (in degrees) while the throttle control is in use: it usually affects the airspeed of the aircraft.  &lt;br /&gt;
&lt;br /&gt;
The different navigation modes are detailed in the next sections.&lt;br /&gt;
&lt;br /&gt;
==== Attitude ====&lt;br /&gt;
Element &amp;lt;tt&amp;gt;attitude&amp;lt;/tt&amp;gt; is the navigation mode which corresponds to the current lowest control loop for horizontal mode.&lt;br /&gt;
The autopilot then keeps a constant attitude. The &amp;lt;tt&amp;gt;roll&amp;lt;/tt&amp;gt; attribute is required (in degrees, positive to put right wing low).&lt;br /&gt;
&lt;br /&gt;
To fly away, at constant airspeed:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;attitude roll=&amp;quot;0&amp;quot; vmode=&amp;quot;throttle&amp;quot;, throttle=&amp;quot;0.5&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To fly around, holding a given altitude:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;attitude roll=&amp;quot;30&amp;quot; alt=&amp;quot;ground_alt+50&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that it is not a ''safe'' navigation mode since the geographic position of the plane is not controlled. However, this mode is useful to tune the roll attitude control loop.&lt;br /&gt;
&lt;br /&gt;
==== Heading ====&lt;br /&gt;
&amp;lt;tt&amp;gt;heading&amp;lt;/tt&amp;gt; primitive is relative to the second level loop for horizontal mode in the autopilot which will keep the given &amp;lt;tt&amp;gt;course&amp;lt;/tt&amp;gt;, a required attribute (in degrees, clockwise, north=0, east=90).&lt;br /&gt;
&lt;br /&gt;
One example to takeoff, following the QFU, 80% throttle, nose up until height of 30m is reached:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;heading course=&amp;quot;QFU&amp;quot; vmode=&amp;quot;throttle&amp;quot; throttle=&amp;quot;0.8&amp;quot; pitch=&amp;quot;15&amp;quot; until=&amp;quot;(estimator_z &amp;gt; ground_alt+30)&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Go ====&lt;br /&gt;
The &amp;lt;tt&amp;gt;go&amp;lt;/tt&amp;gt; primitive is probably the most useful one. Basically, the autopilot will try to join a given waypoint (&amp;lt;tt&amp;gt;wp&amp;lt;/tt&amp;gt;, the only required attribute). So the simplest thing you can ask for is&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;go wp=&amp;quot;HOME&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
which will set the '''HOME''' waypoint as the desired target position. Note than since &amp;lt;tt&amp;gt;vmode=&amp;quot;alt&amp;quot;&amp;lt;/tt&amp;gt; is the default, the altitude of the target waypoint is also taken into account. The navigation will switch to the next stage as soon as the target is reached.&lt;br /&gt;
&lt;br /&gt;
It is usually not a good idea to try to join a waypoint without asking for a precise trajectory, i.e. a given line.&lt;br /&gt;
Setting the &amp;lt;tt&amp;gt;hmode&amp;lt;/tt&amp;gt; attribute to '''route''', the navigation will go over a segment joining two waypoints:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;go from=&amp;quot;wp1&amp;quot; wp=&amp;quot;wp2&amp;quot; hmode=&amp;quot;route&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The target altitude is the altitude of the target waypoint; it can also be set with the &amp;lt;tt&amp;gt;alt&amp;lt;/tt&amp;gt; attribute. The following example keeps an altitude with fixed throttle:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;go from=&amp;quot;wp2&amp;quot; wp=&amp;quot;wp3&amp;quot; hmode=&amp;quot;route&amp;quot; pitch=&amp;quot;auto&amp;quot; throttle=&amp;quot;0.75&amp;quot; alt=&amp;quot;ground_alt+100&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attributes related to the vertical control can also be set to replace the default altitude mode:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;go from=&amp;quot;wp1&amp;quot; wp=&amp;quot;wp2&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;climb&amp;quot; climb=&amp;quot;1.5&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, the &amp;lt;tt&amp;gt;approaching_time&amp;lt;/tt&amp;gt; (in seconds) attribute helps to decide when the target is ''reached''. It can be set&lt;br /&gt;
to '''0''' to go over the target waypoint (default value is the '''CARROT''' time, set in the airframe configuration file).&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;go from=&amp;quot;wp1&amp;quot; wp=&amp;quot;wp2&amp;quot; hmode=&amp;quot;route&amp;quot; approaching_time=&amp;quot;1&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Circle ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;circle&amp;lt;/tt&amp;gt; primitive is the second main navigation mode: the trajectory is defined as a circle around a given waypoint with a given radius:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;circle wp=&amp;quot;HOME&amp;quot; radius=&amp;quot;75&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
A positive radius makes the UAV fly clockwise, a negative counter-clockwise.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;until&amp;lt;/tt&amp;gt; attribute may be used to control the end of the stage. The following example defines an ascending trajectory at constant throttle, nose up, over growing circles, until the battery level is low:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;circle wp=&amp;quot;wp1&amp;quot; radius=&amp;quot;50+(estimator_z-ground_alt)/2&amp;quot; vmode=&amp;quot;throttle&amp;quot; throttle=&amp;quot;0.75&amp;quot; pitch=&amp;quot;15&amp;quot; until=&amp;quot;10&amp;gt;PowerVoltage()&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Follow ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;follow&amp;lt;/tt&amp;gt; is a special primitive which makes the UAV follow another UAV (real or simulated, named with its &amp;lt;tt&amp;gt;ac_id&amp;lt;/tt&amp;gt;) at a given &amp;lt;tt&amp;gt;distance&amp;lt;/tt&amp;gt; (in meters) behind and at a given &amp;lt;tt&amp;gt;height&amp;lt;/tt&amp;gt; (in meters) above.&lt;br /&gt;
&lt;br /&gt;
In this example, the autopilot will try to follow A/C number '''4''', staying '''50'''m behind and '''20'''m above.&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;follow ac_id=&amp;quot;4&amp;quot; distance=&amp;quot;50&amp;quot; height=&amp;quot;20&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Stay ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;stay&amp;lt;/tt&amp;gt; is a mode for UAVs able to hover:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;stay wp=&amp;quot;HOME&amp;quot; alt=&amp;quot;10&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Xyz ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;xyz&amp;lt;/tt&amp;gt; is a special mode where the UAV circles around a user moveable waypoint. This waypoint is moved with the RC sticks:&lt;br /&gt;
* YAW channel controls the point over the west-east axis;&lt;br /&gt;
* PITCH channel controls the point over the south-north axis;&lt;br /&gt;
* ROLL channel controls the altitude.&lt;br /&gt;
&lt;br /&gt;
Example (default radius is '''100'''):&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;xyz radius=&amp;quot;40&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Set ====&lt;br /&gt;
The &amp;lt;tt&amp;gt;set&amp;lt;/tt&amp;gt; element is a dangerous one which should be used only by expert users: it is used to directly set an internal variable of the autopilot. For example, you can change the value of the default ground altitude, a variable used by the home mode failsafe procedure (and maybe by your own flight plan):&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;set var=&amp;quot;ground_alt&amp;quot; value=&amp;quot;ground_alt+50&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
This directive is extremely powerful and has great potential for error - use with caution.&lt;br /&gt;
&lt;br /&gt;
==== Call ====&lt;br /&gt;
The &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; allows the user to define its own navigation procedures in C. The &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; must be a call to a boolean function which must return TRUE as long as the stage is not completed (a function which should be called only once would then return immediately FALSE).&lt;br /&gt;
This feature is illustrated with the '''line''' pattern:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;call fun=&amp;quot;nav_line_init()&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;call fun=&amp;quot;nav_line(WP_1, WP_2, nav_radius)&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;nav_line_init()&amp;lt;/tt&amp;gt; returns FALSE and &amp;lt;tt&amp;gt;nav_line()&amp;lt;/tt&amp;gt; always returns TRUE (this stage never ends).&lt;br /&gt;
Such functions usually are defined in a supplementary C file which must be specified in the airframe file (in the &amp;lt;tt&amp;gt;makefile&amp;lt;/tt&amp;gt; section)&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += nav_line.c&lt;br /&gt;
 sim.srcs += nav_line.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
These functions also must be declared in a header file which must be mentioned in the header element of the flight plan:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;header&amp;gt;&lt;br /&gt;
 #include &amp;quot;nav_line.h&amp;quot;&lt;br /&gt;
 &amp;lt;/header&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
These C source file and H header file must be located in the &amp;lt;tt&amp;gt;sw/airborne&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
== Advanced Examples ==&lt;br /&gt;
Parameters used in a flight plan can be computed expressions. In this example, the plane is asked to perform 5 circles at progressively increasing altitudes for exactly one minute at each altitude:&lt;br /&gt;
 &amp;lt;for var = &amp;quot;i&amp;quot; from = &amp;quot;1&amp;quot; to = &amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;circle wp = &amp;quot;HOME&amp;quot; radius=&amp;quot;75&amp;quot;&lt;br /&gt;
          alt = &amp;quot;ground_alt+50*$i&amp;quot;&lt;br /&gt;
          until = &amp;quot;stage_time&amp;gt;60&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/for&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Procedures ==&lt;br /&gt;
&lt;br /&gt;
Procedures are libraries which can be included in flight plans. They are composed of waypoints and blocks. The header of a procedure may&lt;br /&gt;
contain some parameters which are replaced by arguments when the procedure is included.&lt;br /&gt;
&lt;br /&gt;
Extract of the DTD: a procedure is a sequence of parameters, waypoints, optional global exceptions and blocks:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,waypoints,exceptions?,blocks)&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;param&amp;lt;/tt&amp;gt;eter is just a name. A parameter is optional if it is declared with a default value.&lt;br /&gt;
An example with a required and an optional parameter:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;param name=&amp;quot;alt&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;param name=&amp;quot;radius&amp;quot; default_value=&amp;quot;75&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Procedures are called with the &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; element in a flight plan (a procedure cannot be included by another procedure). A procedure call requires:&lt;br /&gt;
* the name of the procedure file, the name given to this inclusion; &lt;br /&gt;
* the relative position and the orientation of the procedure in the flight plan;&lt;br /&gt;
* values for the parameters;&lt;br /&gt;
* backlinks for block name exits of the procedure.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;hippo1&amp;quot; procedure=&amp;quot;hippo.xml&amp;quot; x=&amp;quot;-100&amp;quot; y=&amp;quot;150&amp;quot; rotate=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;arg name=&amp;quot;alt&amp;quot; value=&amp;quot;ground_alt+100&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;end&amp;quot; to=&amp;quot;landing&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''hippo.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;param name=&amp;quot;alt&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;param name=&amp;quot;radius&amp;quot; default value=&amp;quot;75&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;c1&amp;quot; x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;c2&amp;quot; x=&amp;quot;250&amp;quot; y=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    &amp;lt;block name=&amp;quot;oneturn&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;go hmode=&amp;quot;route&amp;quot; alt=&amp;quot;alt&amp;quot; from=&amp;quot;c1&amp;quot; from_qdr=&amp;quot;0&amp;quot; from_dist=&amp;quot;radius&amp;quot; wp=&amp;quot;c2&amp;quot; wp_qdr=&amp;quot;0&amp;quot; wp_dist=&amp;quot;radius&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle wp=&amp;quot;c2&amp;quot; radius=&amp;quot;radius&amp;quot; until=&amp;quot;Qdr(180)&amp;quot; alt=&amp;quot;alt&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go hmode=&amp;quot;route&amp;quot; alt=&amp;quot;alt&amp;quot; from=&amp;quot;c2&amp;quot; from_qdr=&amp;quot;180&amp;quot; from_dist=&amp;quot;radius&amp;quot; wp=&amp;quot;c1&amp;quot; wp_qdr=&amp;quot;180&amp;quot; wp_dist=&amp;quot;radius&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle wp=&amp;quot;c1&amp;quot; radius=&amp;quot;radius&amp;quot; until=&amp;quot;Qdr(0)&amp;quot; alt=&amp;quot;alt&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;deroute block=&amp;quot;end&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/procedure&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure block is then '''hippo1.oneturn''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;hippo1.oneturn&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
== Flight Simulation ==&lt;br /&gt;
Complex flight plans should always be carefully tested prior to flight.  See the [[Simulation|simulation]] page for details.&lt;/div&gt;</summary>
		<author><name>Ben P</name></author>
	</entry>
</feed>