<?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=Nathan</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=Nathan"/>
	<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/wiki/Special:Contributions/Nathan"/>
	<updated>2026-06-07T17:28:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Sensors/GPS&amp;diff=6488</id>
		<title>Sensors/GPS</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Sensors/GPS&amp;diff=6488"/>
		<updated>2010-05-09T08:29:28Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* GPS configuration using U-Center */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=right&lt;br /&gt;
|-&lt;br /&gt;
| __TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[[Image:U-blox_color_warm_60.gif|100px]]&lt;br /&gt;
&lt;br /&gt;
Paparazzi autopilots are designed around the popular [http://www.u-blox.com u-blox] brand of receivers.&lt;br /&gt;
&lt;br /&gt;
*Features:&lt;br /&gt;
**Small size&lt;br /&gt;
**Excellent performance&lt;br /&gt;
**4Hz position update rate&lt;br /&gt;
&lt;br /&gt;
The '''[[Tiny]]''' features an onboard LEA series GPS receiver and patch antenna, while '''[[Classix]]''' and '''[[Previous_Autopilots|AVR-based]]''' boards require an external receiver+antenna such as the [[#Paparazzi_Stand-alone_GPS_Receivers|Paparazzi GPS]] or [[#u-Blox_SAM-LS_GPS_Smart_Antenna|SAM-LS]].  Please note that the receivers must be configured (prior to use with the autopilot) as indicated below. Both modules have proven reliable and robust. &lt;br /&gt;
&lt;br /&gt;
{|align = center&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:Lea big.jpg|200px|thumb|center|u-blox LEA GPS Receiver]]&lt;br /&gt;
|[[Image:Ublox_SAM-LS.jpg|200px|thumb|center|u-blox SAM-LS GPS receiver (w/built-in Smart Antenna)]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The proprietary UBX protocol is used as it offers more information and efficiency than the universal NMEA protocol.  The protocol is parsed in &amp;lt;tt&amp;gt;sw/airborne/gps_ubx.c&amp;lt;/tt&amp;gt;.  Other GPS brands would require a similar parsing file to be written for NMEA or other proprietary protocols.    &lt;br /&gt;
&lt;br /&gt;
==GPS Receivers==&lt;br /&gt;
&lt;br /&gt;
===u-Blox LEA Series Receivers===&lt;br /&gt;
[[Image:Lea big.jpg|100px|thumb|right|u-blox LEA]]&lt;br /&gt;
The '''[[TWOG_v1|TWOG]]''', '''[[Classix]]''' and '''[[Previous_Autopilots|AVR-based]]''' boards require an external GPS module and antenna.  The '''[[Tiny]]''' features an integrated receiver and antenna.  Either type is designed for [http://www.u-blox.com/ u-blox] 4 and 5 series GPS receivers and the proprietary UBX binary protocol.  An external battery or capacitor is typically used to enable the GPS to retain data while powered off for significantly faster signal re-aquisition.  Any of the LEA-4 and LEA-5 series receivers can be used including the less expensive LEA-4A, 4S, 5A and 5S models as the special boot configuration code required for these models is already written.&lt;br /&gt;
&lt;br /&gt;
*4Hz Position update rate&lt;br /&gt;
*Supports active or passive antennas&lt;br /&gt;
*Supports [http://en.wikipedia.org/wiki/DGPS DGPS], [http://en.wikipedia.org/wiki/WAAS WAAS], [http://en.wikipedia.org/wiki/EGNOS EGNOS], and [http://en.wikipedia.org/wiki/MSAS MSAS]&lt;br /&gt;
*Low position [http://paparazzi.enac.fr/wiki_images/Gps_rx_noise.pdf noise] figure&lt;br /&gt;
[[Image:Lea5htiny13.jpg|thumb|center|250px|LEA-4P installed on the Tiny]]&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Paparazzi Stand-alone GPS Receivers===&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Ppzgps13med01.jpg|Top&lt;br /&gt;
Image:Ppzgps13_lrg_02.jpg|Bottom&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Paparazzi CVS provides a design for an external GPS board (required for TWOG and Classix Autopilots).&lt;br /&gt;
Programming it is similar to the Tiny2.11 GPS configuration. If you build your own you will want to upload the latest u-blox firmware before you configure. See &amp;quot;Getting Hardware&amp;quot; for sources of assembled boards.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The Paparazzi design in http://cvs.savannah.gnu.org/viewcvs/paparazzi/paparazzi3/hw/sensors/gps_13.brd is based on a u-blox LEA-4P however an LEA-5H seems to work just fine as well. The board is very small and light as it has only the components required. It is powered from the 5v line on the &amp;quot;downloads&amp;quot; connector of a TWOG. Also note it is a 4-layer PCB that means better noise resistance. The board has pins for USB connection but requires a different cable and a solder jumper to be move from the ground (default) to 3.3v input to enable the USB port on the module. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[http://paparazzi.enac.fr/wiki_images/Gps_13_BOM.xls V1 BOM.xls]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://paparazzi.enac.fr/wiki_images/TinygpsBOM.txt Eagle Parts List Output.txt]&amp;lt;br&amp;gt;&lt;br /&gt;
See [[Get_Hardware|Get Hardware]] page for suppliers.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
==== Wiring Diagram ====&lt;br /&gt;
[[Image:TWOG to GPS.jpg|thumb|left]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===3rd Party u-blox reference design boards:===&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[Image:LEA5HExternalModulePinout.jpg|100px|thumb|right|LEA-5H Full Board Pinout]]&lt;br /&gt;
The only other GPS board in use seems to be u-blox reference designs or similar to it. They have either LEA-4P or LEA-5H (typically) and several interfaces. Often a larger antenna as well. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this needs fixing don't be shy, fix away.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both;&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===NAVILOCK NL-507ETTL===&lt;br /&gt;
[[Image:Navilock NL-507ETTL.jpg|thumb|left|NAVILOCK NL-507TTL]]&lt;br /&gt;
The NAVILOCK NL-507TTL u-blox TTL Modul 60416 features an LEA-4 series receiver and 25mm patch antenna on a 30mm x 30mm board.&lt;br /&gt;
* Datasheet: [http://www.navilock.de/download/Dokumente_SLASH_Sonstiges/60415_-_Datenblatt_u-blox_GPS_Module/481 http://www.navilock.de/download/Dokumente_SLASH_Sonstiges/60415_-_Datenblatt_u-blox_GPS_Module/481]&lt;br /&gt;
* Purchase:  Available for 28€ at [http://www.amazon.de/Navilock-NL-507TTL-u-blox-TTL-Modul/dp/B0011E6VQG www.amazon.de]&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both;&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SPK GS406===&lt;br /&gt;
[[Image:GS406.jpg|thumb|left|SPK GS406 with LEA-5]]&lt;br /&gt;
[http://www.sparkfun.com/commerce/product_info.php?products_id=8889 Sparkfun] sells a nice small module featuring the newer 5-series receiver and the highly rated Sarantel antenna for about $90.  The design is based around the active version of the Sarantel instead of the more appropriate passive model and there's some potentially tricky soldering involved to get around the ribbon cable but the price is great for this hardware.&lt;br /&gt;
&lt;br /&gt;
[http://store.diydrones.com/ProductDetails.asp?ProductCode=BR-0008-01 DIYDrones] has build a adapter board for this GPS module. It looks like a great solution to use this GPS module with Paparazzi.&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both;&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===u-Blox C04-5H Reference Design===&lt;br /&gt;
[[Image:abavimage.jpg|100px|thumb|left|u-blox C04-5H]]&lt;br /&gt;
u-Blox sells a complete module with antenna for around $200 and will also provide complete schematics, BOM, and PCB files for free if you wish to make your own.  Two versions are offered, one with an 18mm patch antenna and the other with the Sarantel P2 helical antenna.&lt;br /&gt;
See [http://www.u-blox.com/products/c04_5h.html http://www.u-blox.com/products/c04_5h.html] for more info.&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both;&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Connecting external receivers to Classix, 1.2.1, Lite, and RoboStix boards====&lt;br /&gt;
&lt;br /&gt;
The u-blox receivers require 3.3v power and all current models have 5V tolerant data lines. The best way to connect to the SAM-LS is to remove the bottom case and solder the 4 wires directly to the TIM-LL module (GND (pin 1) ,VCC (pin 2),TX (Pin 5),RX (pin 4)) check the TIM-LL datasheet for pinout diagrams.[http://www.u-blox.com/products/Data_Sheets/TIM-LL_Data_Sheet(GPS.G3-MS3-04035).pdf]  The Classix and Lite boards feature a 3.3V regulator to power the GPS.&lt;br /&gt;
To open the casing on a SAM-LS, remove the bottom of the casing by pulling gently, then work around popping off the solder joints (they are fairly weak) by pressing a small screwdriver against each tab in turn until it pops off.  You should then be able to access the GPS chip directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sourcing from u-blox===&lt;br /&gt;
&lt;br /&gt;
u-blox keeps tight control over the distribution of their products.  They must be obtained DIRECTLY from their own reseller offices.  These offices may not be available in your area, for example Canada does not have a reseller.  Sample quantities can be obtained from uBlox but overnight or 2 day shipping is required which drives the cost up considerably.  While it is a large hassle obtaining these devices, it is undoubtedly worth it.&lt;br /&gt;
&lt;br /&gt;
Talking with ublox sale for two years, Confirmed, that Order is possiable Directly from ublox, by knowing what project it was for &amp;amp; how was it to be use.  After long reply waiting time, the answer was: - YES,  but at least 2K-3K in volume, otherwise they're not interested.  Like to share the order ?  It is 500pcs/Roll.&lt;br /&gt;
&lt;br /&gt;
===Other potential source of u-blox GPS===&lt;br /&gt;
&lt;br /&gt;
There seems to be a few alternative source of u-blox GPS out there. They are considerably cheaper then the samples u-blox offers (at least in america). We didn't buy from these sources yet. Do not take this as a recommandation, we do not know the level of service they offer, etc.&lt;br /&gt;
&lt;br /&gt;
If you do order from any of them, please update this page with your feedback.&lt;br /&gt;
&lt;br /&gt;
Here's a few link worth exploring:&lt;br /&gt;
*http://www.rfdesign.co.za/pages/5645456/Products/GPS-Products/Antaris-4-Modules.asp&lt;br /&gt;
*http://www.comet.srl.ro/shop/info.html?ID=6195 ( Link error )&lt;br /&gt;
*http://www.expedienttech.com/product.htm  ( Singapore )&lt;br /&gt;
&lt;br /&gt;
==GPS configuration using U-Center==&lt;br /&gt;
&lt;br /&gt;
[[Image:U-center_screencap.jpg|thumb|u-center configuration software]]&lt;br /&gt;
[http://www.u-blox.com/products/u_center.html U-Center] is a very comprehensive freeware program intended for the configuration and evaluation of u-blox receivers. &lt;br /&gt;
* [http://www.u-blox.com/en/evaluation-tools-a-software/u-center/u-center.html Download u-center]&lt;br /&gt;
&lt;br /&gt;
* Note 1: You must [[Compiling#USB_flashing|install the UART tunnel]] to enable direct access to the built-in GPS on the [[Tiny|Tiny]].&lt;br /&gt;
&lt;br /&gt;
* Note 2: You will need a driver for your FTDI cable if you run u-center on Windows, which can be found  [http://www.ftdichip.com/Drivers/D2XX.htm here].&lt;br /&gt;
&lt;br /&gt;
* Note 3: You can run u-center on Linux by installing &amp;quot;Wine&amp;quot; ([http://www.winehq.org/site/download-deb Installation of Wine]) and set up COM1 as /dev/ttyUSB0. You need to create a symbolic link from the COM device to TTY like this: &lt;br /&gt;
 ln -s /dev/ttyUSB0 ~/.wine/dosdevices/COM1&lt;br /&gt;
&lt;br /&gt;
or what worked in Ubuntu 9.10&lt;br /&gt;
 &lt;br /&gt;
 ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com1&lt;br /&gt;
This command will create the symbolic link from ttyUSB0 to COM1. See Info on Wine for &amp;quot;dosdevices&amp;quot; setup. Just download the u-setup.exe and run it with Wine, follow prompts. This has been tested with Ubuntu7.10 and Ubuntu 8.04 so far.&lt;br /&gt;
&lt;br /&gt;
The u-blox and Tiny UARTs both operate at 3.3V TTL levels and are 5V TTL tolerant.  You must use a level shifter such as the common MAX232 to connect these devices to a standard PC serial port.  The easiest and most recommended method is to connect to a USB port instead of serial with the $20 [http://www.ftdichip.com/Products/EvaluationKits/TTL-232R.htm FTDI USB-TTL converter cable] available from Digikey, Mouser, or direct from FTDI.  Other similar converters are available from [http://www.pololu.com/products/pololu/0391/ pololu] / [http://www.sparkfun.com/commerce/product_info.php?products_id=199 sparkfun].  A stand-alone GPS such as the SAM-LS will require clean 3.3V/50mA power and a common ground with the TTL converter.&lt;br /&gt;
&lt;br /&gt;
* U-blox occasionally releases firmware updates.  Log on to the u-blox website using ''paparazzi'' for username &amp;amp; password to view or download the latest firmware images.  There have 'never' been any updates released for the Antaris-4 series used in the Tiny.&lt;br /&gt;
&lt;br /&gt;
Start U-center and choose your com port from the pull down list under the connect button near the top left corner of the window. Choose your baudrate from the pull down box to the right of the connect button or select the auto-baud button to the right of that.  U-blox default is 9600 baud.  This must be changed to 19200 or higher to accomodate the 4Hz update rate.&lt;br /&gt;
&amp;lt;br&amp;gt;[[Image:U-center_buttons.jpg|connect, baud, and autobaud buttons]]&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Uploading the Configuration File===&lt;br /&gt;
Download the appropriate configuration file below and use u-center to load in onto your receiver. Under the ''Tools'' menu, choose ''GPS configuration''.  Be sure the box 'Store configuration into BBR/Flash' is checked and hit the button ''File&amp;gt;&amp;gt;GPS''.  A few errors and retries are normal, but a significant number of errors may indicate a poor connection and the software will notify you if it is unable to send all the data successfully.&lt;br /&gt;
* [[Media:Tiny_LEA-4P-v6.zip|LEA-4P]]&lt;br /&gt;
* [[Media:Tim-LL-V5.zip|TIM-LL]]&lt;br /&gt;
* [http://paparazzi.enac.fr/wiki_images/Tiny_LEA-5H-v5.zip LEA-5H (For Use w/ Firmware V5 ONLY!)]&lt;br /&gt;
&lt;br /&gt;
===Manual Configuration===&lt;br /&gt;
If you prefer to setup your receiver manually or have a model not listed above, here are instructions to configure your receiver in u-center.&lt;br /&gt;
Open the message window (menu View-&amp;gt;messages view) to start the configuration process by changing the following settings:&lt;br /&gt;
&lt;br /&gt;
====LEA-4P====&lt;br /&gt;
&lt;br /&gt;
 1. Right Click on the '''NMEA''' Icon and choose '''disable child'''&lt;br /&gt;
 2. Choose UBX-&amp;gt;CFG-&amp;gt;NAV2(Navigation 2) - set it to use '''Airborne 4G''' (tells the Kalman filter to expect significant changes in direction)&lt;br /&gt;
 3. UBX-&amp;gt;CFG-&amp;gt;PRT - set '''USART1''' to '''38400bps''' (must match the value in your [[Airframe_Configuration#Hardware_definitions_-_Makefile|Airframe file]])&lt;br /&gt;
 4. Change the baudrate of U-Center to 38400bps if the connection is lost at this point&lt;br /&gt;
 5. UBX-&amp;gt;CFG-&amp;gt;RXM(Receiver Manager) - change '''GPS Mode''' to '''3 - Auto''' (Enabling faster bootup only if signal levels are very good)&lt;br /&gt;
 6. UBX-&amp;gt;CFG-&amp;gt;RATE(Rates) - change the '''Measurement Period''' to '''250ms''' (4 Hz position updates)&lt;br /&gt;
 7. UBX-&amp;gt;CFG-&amp;gt;SBAS : '''Disable''' (SBAS appears to cause occasional severe altitude calcuation errors)&lt;br /&gt;
 8. UBX-&amp;gt;NAV (not UBX-&amp;gt;CFG-&amp;gt;NAV): double click on '''POSUTM, SOL, STATUS, SVINFO, VELNED.''' They should change from grey to black&lt;br /&gt;
 9. UBX-&amp;gt;CFG-&amp;gt;CFG : '''save current config''', click '''&amp;quot;send&amp;quot;''' in the lower left corner to permanently save these settings to the receiver &lt;br /&gt;
&lt;br /&gt;
====LEA-5H====&lt;br /&gt;
&lt;br /&gt;
 1. Right Click on the '''NMEA''' Text on top of the tree and choose '''disable child messages'''&lt;br /&gt;
 2. Choose UBX-&amp;gt;CFG-&amp;gt;NAV5(Navigation 5) - set it to use '''Airborne 8 &amp;lt;4G'''. This tells the Kalman filter to expect significant changes in direction. &lt;br /&gt;
    Note that this setting is only good for faster moving airplanes. For a fixed position hovering heli, 'pedestrian' setting is better&lt;br /&gt;
 3. UBX-&amp;gt;CFG-&amp;gt;PRT - set '''USART1''' to '''38400bps''' (must match the value in your [[Airframe_Configuration#Hardware_definitions_-_Makefile|Airframe file]])&lt;br /&gt;
 4. Change the baudrate of U-Center to 38400bps if the connection is lost at this point&lt;br /&gt;
 5. UBX-&amp;gt;CFG-&amp;gt;RATE(Rates) - change the '''Measurement Period''' to '''250ms''' This gives a 4 Hz position update since 4 x 250ms is one second.&lt;br /&gt;
 6. UBX-&amp;gt;CFG-&amp;gt;SBAS : '''Disable''' (SBAS appears to cause occasional severe altitude calcuation errors)&lt;br /&gt;
 7. UBX-&amp;gt;NAV (not UBX-&amp;gt;CFG-&amp;gt;NAV): double click on '''POSLLH, SOL, STATUS, SVINFO, VELNED.''' They should change from grey to black&lt;br /&gt;
 (add the flag -DGPS_USE_LATLONG in your [[Airframe_Configuration#Hardware_definitions_-_Makefile|Airframe file]]) also make sure you set tiny_2_1_1.h if you have the latest boards Tiny/TinyWOG)&lt;br /&gt;
 8. UBX-&amp;gt;CFG-&amp;gt;CFG : '''save current config''', click '''&amp;quot;send&amp;quot;''' in the lower left corner to permanently save these settings to the receiver &lt;br /&gt;
&lt;br /&gt;
* Cycle the power and verify that the new configuration was saved&lt;br /&gt;
* To reset the receiver to the factory defaults go to ''UBX-&amp;gt;CFG-&amp;gt;CFG'', select 'Revert to default configuration', and click ''Send'' at the bottom left corner.  To permanently save these values choose 'Save current configuration' and click ''Send''.&lt;br /&gt;
* To backup the configuration to a file on your PC: under the tools menu, choose GPS configuration, then click GPS&amp;gt;&amp;gt;file.  This file can be re-loaded in a similar manner to configure additional identical receivers.  Be sure the box 'Store configuration into BBR/Flash' is checked when reloading a configuration file to make the changes permanent.&lt;br /&gt;
* To update the firmware on a LEA-5H get u-center &amp;gt;= 5.03, revert the GPS receiver to the default configuration, get an appropriate image from u-blox (fitting your receivers serial number), find the flash identification flash.txt file in the u-center install directory and be prepared to wait a long time.&lt;br /&gt;
&lt;br /&gt;
#NOTE: If you have a Tiny with LEA-5H module you must use u-center and manually setup the parameters as shown above (at least switch to 38400 baud manually before transferring the configuration file).&lt;br /&gt;
#NOTE: POSUTM is not available on LEA-5H. Instead, use POSLLH. Additionally, add the flag -DGPS_USE_LATLONG in the makefile section of the airframe xml file.&lt;br /&gt;
&lt;br /&gt;
===Reset to Default Settings===&lt;br /&gt;
The GPS module can be reset to its original default settings by pulling BOOT_INT high(3.3V) during a power cycle ([http://www.u-blox.com/customersupport/gps.g4/ANTARIS4_Modules_SIM(GPS.G4-MS4-05007).pdf Antaris Manual, p. 122]). It may be required after a wrong firmware upgrade or a bad configuration change.&lt;br /&gt;
&lt;br /&gt;
===DGPS (Differential GPS)===&lt;br /&gt;
Differential GPS is any method of improving GPS accuracy by comparing the GPS-indicated position of a nearby location to the known value and transmitting any error to the mobile unit.  DGPS was originally created as a means of bypassing the deliberately introduced inaccuracies in civilian GPS signals.  The original method used low frequency ground radios to relay correction data to the mobile unit and is still used today at airports, shipping ports, and even individual farms.  Satellite Based Augmentation System (SBAS) is a modern form of DGPS where the ground stations relay correction data to a GEO-Stationary satellite, which then relays it to the mobile unit on standard GPS frequencies eliminating the need for a separate radio reciever.  SBAS is currently available in 3 regions, [http://www.esa.int/esaNA/ESAF530VMOC_egnos_1.html WAAS, EGNOS, and MSAS regions] though only WAAS and EGNOS are officially operational.  U-blox receivers support all common varieties of DGPS [http://www.u-blox.com/customersupport/gps.g3/ENGOS_Issues(GPS.G3-CS-04009).pdf read the u-blox SBAS application note].&lt;br /&gt;
* It is important to note that DGPS methods only improve the ''accuracy'' of the position calculation, not the ''precision''.  Since Paparazzi navigation is typically performed relative to the power-on location, any static error that could be corrected with DGPS is irrelevant.&lt;br /&gt;
&lt;br /&gt;
====WAAS issues====&lt;br /&gt;
WAAS has been officially operational and &amp;quot;suitable for safety-of-life applications&amp;quot; since 2003.  The default setting of all u-blox receivers ignores WAAS correction data and only uses the WAAS satellites for regular navigation like any other satellite.  U-blox recommends further limiting this setting to exclude any stray EGNOS/MSAS satellites in North America, and completely disabling all SBAS functions for use outside North America.  In 2006 one formerly reliable Paparazzi aircraft began having great GPS problems and displaying very erratic altitude calculations, disabling WAAS immediately resolved the issue and this phenomenon was recreated several times for verification.  Turns out a new WAAS satellite was being added to the system and the others were being moved that week for better distribution.  Our advice is to completely disable WAAS.&lt;br /&gt;
&lt;br /&gt;
====EGNOS issues====&lt;br /&gt;
EGNOS officially became operational on 1 October 2009. ESA claims that it can determine position to within 2 metres compared with about 20 metres for GPS alone. Note that the service is currently provided only in western Europe. For further information see [http://www.esa.int/esaNA/egnos.html ESA EGNOS website].&lt;br /&gt;
&lt;br /&gt;
According to the [http://ec.europa.eu/transport/egnos/programme/doc/2009_egnos_sdd_os_v1.pdf EC] the EGNOS transmission will keep the &amp;quot;Do not use&amp;quot; type0/2 flag until it is certified for safety of life operations in (hopfefully) mid 2010. So you will have to enable the &amp;quot;Allow test mode use (Msg 0)&amp;quot; switch in the u-center under UBX-CFG-SBAS together with the correction to try EGNOS.&lt;br /&gt;
&lt;br /&gt;
The [http://www.u-blox.com/en/faq.html u-blox FAQ] states the following:&lt;br /&gt;
* &amp;quot;Do you see issues with EGNOS?&amp;quot;&lt;br /&gt;
*:&amp;quot;Yes. The data transmitted by EGNOS in the past were usually good and valuable although sometimes unreliable, e.g. when system tests were performed. u-blox does not guarantee performance and status of EGNOS system. For the latest update about functionality of EGNOS please check the website: [http://www.gsa.europa.eu European GNSS Supervisory Authority]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
&lt;br /&gt;
Problem: I keep getting this error with my nice shiny Tiny v2.1 with a LEA-5H:&lt;br /&gt;
Invalid_argument(&amp;quot;Latlong.of_utm&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Solution: Add the flag -DGPS_USE_LATLONG to your airframe file.&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
&lt;br /&gt;
The u-blox [http://www.u-blox.com/customersupport/antaris4_doc.html System Integration Manual] covers a lot of GPS theory as well as product specific topics.&lt;br /&gt;
&lt;br /&gt;
== Antenna options for the Tiny and Paparazzi GPS units ==&lt;br /&gt;
&lt;br /&gt;
The '''[[Tiny|Tiny 1.1]]''' features a 28mm square ground plane intended to be centered below the [[#Sangshin_13mm_Patch|Sangshin 13mm patch antenna]].  Much better performance has been seen with the 18mm antennas and an augmented ground plane.  The ground plane is a critical part of the antenna affecting not only the gain and polarization characteristics but also the center frequency of the system.  Users are advised to expand the ground plane to approximately 36mm square, centered on the ceramic portion of the antenna (not the pin).  This can be done with copper foil soldered to the vias of the existing ground plane.&lt;br /&gt;
[[image:gps_antenna_comparison.jpg|thumb|500px|left|SAM-LS 25mm / Emtac 20mm / Emtac 18mm / Sangshin 18mm / Sangshin 13mm / Sarantel P2]]&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sangshin 18mm Patch ===&lt;br /&gt;
[[image:Sangshin_18mm.jpg|thumb|Sangshin 18mm x 4mm 1580Mhz]]&lt;br /&gt;
The Sangshin KSA-ST1580MS18 antenna has proven to offer the best performance of the currently available options.  These are available from any Sanshin distributor such as [http://www.rfmw.com rfmw] ([http://www.rfmw.com/PortalProductDetail.aspx?ProdId=232436&amp;amp;fmt=1 here]) and cost approximately $6.50/ea. in small quantities.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== EMTAC 18mm Patch ===&lt;br /&gt;
[[image:Emtac_18mm.jpg|thumb|Emtac 18mm x 4mm 1580Mhz]]&lt;br /&gt;
Offering identical performance to the Sangshin in a less attractive package is the Emtac 18mm antenna.  The part number for the standard 1580MHz 18x18x4mm is ANA1580T18D40 and is not listed on their website.  Other frequencies are available on a special order basis and the 1584Mhz has proven to outperform all other frequencies when used with a 36mm ground plane and no radome.  The use of a radome (any material covering the antenna) or a larger ground plane should theoretically favor even higher frequencies.&lt;br /&gt;
&lt;br /&gt;
'''Availability'''&lt;br /&gt;
&lt;br /&gt;
* [http://www.transplantgps.com/modules.html TransplantGPS] in MN, USA.  The 1580Mhz models are usually available at a cost of $3.55ea but there may be a minimum order requirement of ~$50 USD.&lt;br /&gt;
&lt;br /&gt;
=== Sangshin 13mm Patch ===&lt;br /&gt;
&lt;br /&gt;
[[image:Sangshin_13mm_onboard.jpg|thumb|Sangshin 13mm x 4mm 1580Mhz]]&lt;br /&gt;
Part of interest: '''[http://www.sangshinec.com/eng/patch_spec.htm KSA-ST1580MS13]'''&lt;br /&gt;
&lt;br /&gt;
The Tiny 0.99 (not 0.9) and 1.1 were designed around this antenna but users are advised to install 18mm units for better performance.&lt;br /&gt;
&lt;br /&gt;
Size: 13 x 13 mm&amp;lt;br/&amp;gt;&lt;br /&gt;
Center Frequency: 1580 MHz&amp;lt;br/&amp;gt;&lt;br /&gt;
Bandwidth: 5 MHz&amp;lt;br/&amp;gt;&lt;br /&gt;
@Fo: -15 dB&amp;lt;br/&amp;gt;&lt;br /&gt;
GAIN (dBi): 0 dBi&amp;lt;br/&amp;gt;&lt;br /&gt;
Ground Plane: 50 x 50 mm&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Available From'''&lt;br /&gt;
&lt;br /&gt;
[http://www.systroninc.com/ Systronic INC.] - Alberta, Canada&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Emtac 20mm Patch ===&lt;br /&gt;
&lt;br /&gt;
[[image:Salvaged_20mm_onboard.jpg|thumb|Emtac 20mm x 4mm]]&lt;br /&gt;
The Tiny 0.9 was designed around this 1583Mhz antenna and performed extremely well.  Emtac has replaced this with an 18mm model that they claim offers even better performance.&lt;br /&gt;
&lt;br /&gt;
* Obsolete&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Spectrum Control Patch ===&lt;br /&gt;
&lt;br /&gt;
[[image:PDC_Tiny21_S1.jpg|thumb|Spectrum Control 25mm]]&lt;br /&gt;
25mm patch testing on Tiny v2.1. Manufacturer Part Number [http://www.specemc.com/docs/antenna_catalog.pdf PA251575008SALF]. These are available from Mouser for about $3: [http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMukjKvgqb7HxzmcutVCLrkxFUj/3HCdKwE%3d 657-PA251575008SALF]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sarantel GeoHelix-P2 ===&lt;br /&gt;
&lt;br /&gt;
[[image:Geohelix-p2.jpg|thumb|Sarantel Geohelix P-2 1575Mhz]]&lt;br /&gt;
&lt;br /&gt;
This antenna is popular among UAV designers due to it's natural rejection of other radio frequencies such as those originating from the modem or video system as well as it's improved rejection of signals reflected from the ground.  U-blox recommends this antenna and features it in their [http://www.u-blox.com/news/sarantel.html reference design].  Frequency and polarization are not dependent upon ground plane geometry so this antenna is sold only in the true GPS frequency of 1575Mhz.&lt;br /&gt;
The geometry makes this antenna very inconvenient to mount, especially in an airplane.  Some very non-scientific testing has been done with one of these antennas connected to a Tiny with a short length of 50 Ohm coax above a 120mm square of ungrounded aluminum foil and performance was adequate.  The helical design should theoretically outperform a patch in the air, but not on the ground, so any organized comparison will be difficult.  Possibly the most important aspect of this antenna is it's natural RFI filtering, which should be evaluated further.&lt;br /&gt;
&lt;br /&gt;
* [http://www.sarantel.com/products/geohelix-p2 GeoHelix-P2] Passive GPS Antenna [[http://www.sarantel.com/downloads/specifications/geohelix-p2.pdf datasheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Availability'''&lt;br /&gt;
&lt;br /&gt;
* Sarantel @ cost of approx $18 USD each (active versions available for ~$40)&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:both&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6464</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6464"/>
		<updated>2010-05-03T13:13:05Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Surveying an area */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
The block of code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below is an explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
 key=&amp;quot;t&amp;quot;&lt;br /&gt;
&lt;br /&gt;
the name of the block&lt;br /&gt;
 name=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This shows as the name when you hover your mouse over the button&lt;br /&gt;
 strip_button=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The name of the icon picture shown in the GCS&lt;br /&gt;
 strip_icon=&amp;quot;takeoff.png&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This turns on the option to change the throttle&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This turns on the flight time estimator&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon. I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed. This is because the autopilot is not exact in its estimation of where it is.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
This calls the PolySurvey, you may want to call this either via a button on the GCS or by calling it in external code for example an automated IR sensor (if you are looking for a person).&lt;br /&gt;
&lt;br /&gt;
== Landing your aircraft ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;final&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;flare&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Above is the final Block. This block is used to bring the aircraft towards the end of the runway (or landing area) which is the &amp;quot;AF&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
Fly from waypoint &amp;quot;AF&amp;quot; to waypoint &amp;quot;TD&amp;quot; and glide between them to maintain the angle between them. You may want these two waypoints to be a significant distance between them if you want the aircraft to come in on a very shallow angle.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;ground_alt + 10 &amp;gt; estimator_z&amp;quot; deroute=&amp;quot;flare&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;quot;flare&amp;quot; is the deroute condition and it is implemented when the aircraft is 10 meters from the ground. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;flare&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;go approaching_time=&amp;quot;0&amp;quot; from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; throttle=&amp;quot;0.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You would want the aircraft to flare just before hitting the ground. If your aircraft is not very stable at low speeds you may want to make the distance above ground lower.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
I have not idea what the above means other than the throttle part. SOMEONE PLEASE UPDATE.&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6463</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6463"/>
		<updated>2010-05-03T13:01:41Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Landing your aircraft */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
The block of code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below is an explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
 key=&amp;quot;t&amp;quot;&lt;br /&gt;
&lt;br /&gt;
the name of the block&lt;br /&gt;
 name=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This shows as the name when you hover your mouse over the button&lt;br /&gt;
 strip_button=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The name of the icon picture shown in the GCS&lt;br /&gt;
 strip_icon=&amp;quot;takeoff.png&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This turns on the option to change the throttle&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This turns on the flight time estimator&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon. I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed. This is because the autopilot is not exact in its estimation of where it is.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt; - This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt; - This calls the PolySurvey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Landing your aircraft ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;final&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;flare&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Above is the final Block. This block is used to bring the aircraft towards the end of the runway (or landing area) which is the &amp;quot;AF&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
Fly from waypoint &amp;quot;AF&amp;quot; to waypoint &amp;quot;TD&amp;quot; and glide between them to maintain the angle between them. You may want these two waypoints to be a significant distance between them if you want the aircraft to come in on a very shallow angle.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;ground_alt + 10 &amp;gt; estimator_z&amp;quot; deroute=&amp;quot;flare&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;quot;flare&amp;quot; is the deroute condition and it is implemented when the aircraft is 10 meters from the ground. &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;flare&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;go approaching_time=&amp;quot;0&amp;quot; from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; throttle=&amp;quot;0.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You would want the aircraft to flare just before hitting the ground. If your aircraft is not very stable at low speeds you may want to make the distance above ground lower.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
I have not idea what the above means other than the throttle part. SOMEONE PLEASE UPDATE.&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6462</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6462"/>
		<updated>2010-05-03T12:56:43Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct&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;br /&gt;
&lt;br /&gt;
== See also==&lt;br /&gt;
For example flight plans please see [[Flight_Plan_Examples|Flight_Plan_Examples]]&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6461</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6461"/>
		<updated>2010-05-03T12:55:53Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct&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;br /&gt;
&lt;br /&gt;
== See also==&lt;br /&gt;
For example flight plans please see [[Flight_Plan_examples|Flight_Plan_examples]]&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6460</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6460"/>
		<updated>2010-05-03T12:54:33Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct&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;br /&gt;
&lt;br /&gt;
== See also==&lt;br /&gt;
For example flight plans please see http://paparazzi.enac.fr/wiki/Flight_Plan_Examples&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6459</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6459"/>
		<updated>2010-05-03T12:53:36Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct&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;br /&gt;
&lt;br /&gt;
== See also==&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6458</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6458"/>
		<updated>2010-05-03T12:51:37Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Landing your aircraft */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
The block of code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below is an explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
 key=&amp;quot;t&amp;quot;&lt;br /&gt;
&lt;br /&gt;
the name of the block&lt;br /&gt;
 name=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This shows as the name when you hover your mouse over the button&lt;br /&gt;
 strip_button=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The name of the icon picture shown in the GCS&lt;br /&gt;
 strip_icon=&amp;quot;takeoff.png&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This turns on the option to change the throttle&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This turns on the flight time estimator&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon. I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed. This is because the autopilot is not exact in its estimation of where it is.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt; - This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt; - This calls the PolySurvey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Landing your aircraft ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;final&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;flare&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;flare&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;go approaching_time=&amp;quot;0&amp;quot; from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; throttle=&amp;quot;0.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you are landing your aircraft automatically, you need to bring it in very gently plus flare just before you land to bring it in cleanly.&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;ground_alt + 10 &amp;gt; estimator_z&amp;quot; deroute=&amp;quot;flare&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;quot;flare&amp;quot; is the deroute condition and it is implemented when the aircraft is 10 meters from the ground. You would want the aircraft to flare just before hitting the ground. If your aircraft is not very stable at low speeds you may want to make the distance above ground lower.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
Fly from waypoint &amp;quot;AF&amp;quot; to waypoint &amp;quot;TD&amp;quot; and glide between them to maintain the angle between them. You may want these two waypoints to be a significant distance between them if you want the aircraft to come in on a very shallow angle.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
I have not idea what the above means other than the throttle part. SOMEONE PLEASE UPDATE.&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6457</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6457"/>
		<updated>2010-05-03T12:45:05Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Takeoff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
The block of code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below is an explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
 key=&amp;quot;t&amp;quot;&lt;br /&gt;
&lt;br /&gt;
the name of the block&lt;br /&gt;
 name=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This shows as the name when you hover your mouse over the button&lt;br /&gt;
 strip_button=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The name of the icon picture shown in the GCS&lt;br /&gt;
 strip_icon=&amp;quot;takeoff.png&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This turns on the option to change the throttle&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This turns on the flight time estimator&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon. I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed. This is because the autopilot is not exact in its estimation of where it is.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt; - This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt; - This calls the PolySurvey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Landing your aircraft ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;final&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;flare&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;flare&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;go approaching_time=&amp;quot;0&amp;quot; from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; throttle=&amp;quot;0.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you are landing your aircraft automatically, you need to bring it in very gently.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;ground_alt + 10 &amp;gt; estimator_z&amp;quot; deroute=&amp;quot;flare&amp;quot;/&amp;gt; - &amp;quot;flare&amp;quot; is the deroute condition and it is implemented when the aircraft is 10 meters from the ground. You would want the aircraft to flare just before hitting the ground. If your aircraft is not very stable at low speeds you may want to make the distance above ground lower.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6456</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6456"/>
		<updated>2010-05-03T12:23:01Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Takeoff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
 key=&amp;quot;t&amp;quot; &lt;br /&gt;
Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
 name=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
the name of the block&lt;br /&gt;
&lt;br /&gt;
 strip_button=&amp;quot;Takeoff&amp;quot;&lt;br /&gt;
This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
 strip_icon=&amp;quot;takeoff.png&amp;quot;&lt;br /&gt;
The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
This turns on the option to change the throttle &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon. I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed. This is because the autopilot is not exact in its estimation of where it is.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt; - This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt; - This calls the PolySurvey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Landing your aircraft ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;final&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;flare&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;flare&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;go approaching_time=&amp;quot;0&amp;quot; from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; throttle=&amp;quot;0.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you are landing your aircraft automatically, you need to bring it in very gently.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;ground_alt + 10 &amp;gt; estimator_z&amp;quot; deroute=&amp;quot;flare&amp;quot;/&amp;gt; - &amp;quot;flare&amp;quot; is the deroute condition and it is implemented when the aircraft is 10 meters from the ground. You would want the aircraft to flare just before hitting the ground. If your aircraft is not very stable at low speeds you may want to make the distance above ground lower.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6455</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6455"/>
		<updated>2010-05-03T12:20:38Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon.&lt;br /&gt;
&lt;br /&gt;
I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt; - This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt; - This calls the PolySurvey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Landing your aircraft ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;final&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;flare&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;block name=&amp;quot;flare&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;go approaching_time=&amp;quot;0&amp;quot; from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; throttle=&amp;quot;0.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;attitude roll=&amp;quot;0.0&amp;quot; throttle=&amp;quot;0.0&amp;quot; until=&amp;quot;FALSE&amp;quot; vmode=&amp;quot;throttle&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you are landing your aircraft automatically, you need to bring it in very gently.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;exception cond=&amp;quot;ground_alt + 10 &amp;gt; estimator_z&amp;quot; deroute=&amp;quot;flare&amp;quot;/&amp;gt; - &amp;quot;flare&amp;quot; is the deroute condition and it is implemented when the aircraft is 10 meters from the ground. You would want the aircraft to flare just before hitting the ground. If your aircraft is not very stable at low speeds you may want to make the distance above ground lower.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;go from=&amp;quot;AF&amp;quot; hmode=&amp;quot;route&amp;quot; vmode=&amp;quot;glide&amp;quot; wp=&amp;quot;TD&amp;quot;/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6454</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6454"/>
		<updated>2010-05-03T12:15:08Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Structure of the flight plan file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon.&lt;br /&gt;
&lt;br /&gt;
I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed.&lt;br /&gt;
&lt;br /&gt;
== Surveying an area ==&lt;br /&gt;
&lt;br /&gt;
There are two types of survey, two waypoint survey or Polysurvey. PolySurvey can be called multiple times during a flight plan but I am not sure how to do this (SOMEONE PLEASE UPDATE).&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Initialize Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;block name=&amp;quot;Run Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that there are two blocks of code instead of a single block. This because when you are surveying an area you may want to stop the survey and take a closer look at something (for instance you may wish to circle something of interest). If you want to continue the survey from the point where you stopped to look closer at the thing of interest all you need to do is call the &amp;quot;Run Poly Survey&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 150, 45)&amp;quot;/&amp;gt; - This initializes the PolySurvey starting with Waypoint S1 and using 5 waypoints (in sequence, eg S1, S2, S3, S4, S5), with a distance between each survey line of 150 meters and an angle of survey of 45 degrees from the initial waypoint.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt; - This calls the PolySurvey.&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6450</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6450"/>
		<updated>2010-05-03T12:02:13Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Takeoff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;START&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;ER&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;START&amp;quot; waypoint towards &amp;quot;ER&amp;quot; (end runway) waypoint with a elevator pitch of -10% (to keep the aircraft on the ground) and throttle at 100%. You would also add a deroute option to change to the &amp;quot;CLIMB&amp;quot; waypoint (the waypoint that gets the aircraft up to the correct height) once the aircraft was moving above stall speed. I will add the code for this soon.&lt;br /&gt;
&lt;br /&gt;
I am not sure what vmode=&amp;quot;throttle&amp;quot; means SOME PLEASE UPDATE.&lt;br /&gt;
&lt;br /&gt;
This code will work in theory, but may not in practice, especially if you only have a narrow runway or your aircraft takes a long time to get up to speed.&lt;br /&gt;
&lt;br /&gt;
== Structure of the flight plan file ==&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6449</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6449"/>
		<updated>2010-05-03T11:44:50Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Takeoff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;HOME&amp;quot; waypoint towards &amp;quot;CLIMB&amp;quot; waypoint with a pitch of -10 and throttle at 100%. I am not sure what vmode=&amp;quot;throttle&amp;quot; means.&lt;br /&gt;
&lt;br /&gt;
== Structure of the flight plan file ==&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6448</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6448"/>
		<updated>2010-05-03T11:40:50Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Takeoff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;HOME&amp;quot; waypoint towards &amp;quot;CLIMB&amp;quot; waypoint with a pitch of -10 and throttle at 100%. I am not sure what vmode=&amp;quot;throttle&amp;quot; means.&lt;br /&gt;
&lt;br /&gt;
== Structure of the flight plan file ==&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6447</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6447"/>
		<updated>2010-05-03T11:39:20Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Takeoff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;HOME&amp;quot; waypoint towards &amp;quot;CLIMB&amp;quot; waypoint with a pitch of -10 and throttle at 100%. I am not sure what vmode=&amp;quot;throttle&amp;quot; means.&lt;br /&gt;
&lt;br /&gt;
== Structure of the flight plan file ==&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6446</id>
		<title>Flight Plan Examples</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plan_Examples&amp;diff=6446"/>
		<updated>2010-05-03T11:36:24Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will detail a number of flight plan examples.&lt;br /&gt;
&lt;br /&gt;
== Takeoff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;block key=&amp;quot;t&amp;quot; name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanation of the code - left to right, top to bottom.&lt;br /&gt;
&lt;br /&gt;
key=&amp;quot;t&amp;quot; - Not sure what this does - SOMEONE PLEASE UPDATE&lt;br /&gt;
&lt;br /&gt;
name=&amp;quot;Takeoff&amp;quot; - the name of the block&lt;br /&gt;
&lt;br /&gt;
strip_button=&amp;quot;Takeoff&amp;quot; - This shows as the name when you hover your mouse over the button&lt;br /&gt;
&lt;br /&gt;
strip_icon=&amp;quot;takeoff.png&amp;quot; - The name of the icon picture shown in the GCS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;kill_throttle&amp;quot;/&amp;gt; - This turns on the option to change the throttle&lt;br /&gt;
&lt;br /&gt;
&amp;lt;set value=&amp;quot;0&amp;quot; var=&amp;quot;estimator_flight_time&amp;quot;/&amp;gt; - This turns on the flight time estimator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;go from=&amp;quot;HOME&amp;quot; pitch=&amp;quot;-10&amp;quot; throttle=&amp;quot;1.0&amp;quot; vmode=&amp;quot;throttle&amp;quot; wp=&amp;quot;CLIMB&amp;quot;/&amp;gt; - This says for the aircraft to go from &amp;quot;HOME&amp;quot; waypoint towards &amp;quot;CLIMB&amp;quot; waypoint with a pitch of -10 and throttle at 100%. I am not sure what vmode=&amp;quot;throttle&amp;quot; means.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Structure of the flight plan file ==&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6429</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6429"/>
		<updated>2010-04-26T12:42:43Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Building Flight Plans */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6428</id>
		<title>GCS</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6428"/>
		<updated>2010-04-26T10:10:17Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Altitude graph widget */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{|&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|&lt;br /&gt;
[[Image:gcs.jpg|frame|right|The Paparazzi Ground Control Station is the heart of the system and the user's primary interaction interface.]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Strips ==&lt;br /&gt;
&lt;br /&gt;
Each A/C has an associated strip that displays information about the A/C and provides buttons for common commands. The strip has the following layout:&lt;br /&gt;
&lt;br /&gt;
[[Image:strip.png|Aircraft information strip]]&lt;br /&gt;
&lt;br /&gt;
=== Displayed information ===&lt;br /&gt;
&lt;br /&gt;
* Left: Flight information&lt;br /&gt;
* Center: Navigation information&lt;br /&gt;
* Right: Navigation control&lt;br /&gt;
* Bottom: Custom navigation and setting buttons&lt;br /&gt;
&lt;br /&gt;
=== Actions ===&lt;br /&gt;
&lt;br /&gt;
Every change in the waypoints (position or/and altitude) must be confirmed with the dialog box that appears after the move. A modified waypoint remains animated on the map and the GCS continues to re-send the move request until confirmation is received from the aircraft.&lt;br /&gt;
When clicked, the '''Mark''' button places a mark on the map at the A/C position. A snapshot from the video plugin is associated to this mark and can be viewed by moving the mouse over the mark. A click on the mark opens a dialog box allowing to delete the mark.&lt;br /&gt;
A click on the colored bar at the top selects the corresponding A/C in the [[#notebook|Notebook]].&lt;br /&gt;
&lt;br /&gt;
== Map ==&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSmap.png|thumb|400px|Sample map showing the various features]]&lt;br /&gt;
&lt;br /&gt;
=== Display ===&lt;br /&gt;
&lt;br /&gt;
The map display contains the following information:&lt;br /&gt;
* The A/C track: it can be erased ''via'' the ''Clear track'' option from the A/C menu.&lt;br /&gt;
* The A/C label (in clear blue near the A/C) contains the name of the A/C (Plaster), it's altitude (218 m) and it's ground speed (11.99 m/s). This option default is off. It can be activated with the ''A/C label'' option from the A/C menu.&lt;br /&gt;
* The carrot (the orange triangle). This is the point the A/C is following during autonomous navigation.&lt;br /&gt;
* The waypoints defined in the flight plan (blue diamonds).&lt;br /&gt;
* The intended trajectory is shown in green (circling waypoint 2).&lt;br /&gt;
* The default background is black. [[#google_tiles|Google tiles]] or [[Maps|user defined maps]] can be loaded to provide navigation reference.&lt;br /&gt;
* The camera footprint (the grey polygon) is representative of the swath of land currently seen by the onboard camera. This option default is off. It can be activated with the ''Cam footprint'' option from the A/C menu.&lt;br /&gt;
* The WGS84 coordinates of the mouse cursor are displayed at the top right hand corner (43.462019   1.270474).&lt;br /&gt;
* A UTM kilometric grid can be added to the background ''via'' the ''UTM grid'' option from the ''Nav'' menu.&lt;br /&gt;
* The height Above Ground Level (AGL) displays the ground altitude of the mouse near the geographic position in the top right hand corner. The [http://srtm.usgs.gov/ SRTM] option must be enabled in the ''Nav'' menu. The height information comes from SRTM data files (&amp;lt;tt&amp;gt;.hgt.zip&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.hgt.bz2&amp;lt;/tt&amp;gt;) and must be copied to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory. They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/ http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/]. For example: http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N47E016.hgt.zip is for 47 deg North latitude and 16 deg East longitude.&lt;br /&gt;
&lt;br /&gt;
=== Navigation ===&lt;br /&gt;
&lt;br /&gt;
You can pan/zoom the map using the following:&lt;br /&gt;
* Pan with the blue arrows on the map or use the arrow keys on the keyboard&lt;br /&gt;
* zoom in/out with the mouse scroll wheel, the page up/page down buttons or the small up/down buttons at the top right hand corner where the zoom factor is displayed&lt;br /&gt;
* fit the map to the window, in order to see all the waypoints and A/C, with the '''f''' key or the ''Fit'' option from the ''Nav'' menu;&lt;br /&gt;
* center the map on an A/C with the ''Center A/C'' option from the corresponding A/C menu.&lt;br /&gt;
&lt;br /&gt;
=== Google Tiles ===&lt;br /&gt;
The default black background can be automatically filled with calibrated satellite photo tiles from Google. Note: if you download too much map data from Google you may be blocked for downloading further maps for 24 hours. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Maps]] page for more info.&lt;br /&gt;
&lt;br /&gt;
=== Waypoint Editing ===&lt;br /&gt;
&lt;br /&gt;
The properties of any waypoint in the currently loaded flight plan can be modified by two methods:&lt;br /&gt;
* Drag and drop the waypoints to a new location (a confirmation dialog will appear).&lt;br /&gt;
* A single left click on a waypoint opens a dialog box where you can edit the waypoint's coordinates and altitude.&lt;br /&gt;
&lt;br /&gt;
Waypoint edits are sent to the aircraft immediately upon confirmation in the dialog box.  The GCS will re-send the data and the waypoint will animate until the aircraft confirms receipt of the move request.  New waypoints cannot be added during flight.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on waypoints.&lt;br /&gt;
&lt;br /&gt;
== Notebook ==&lt;br /&gt;
&lt;br /&gt;
The notebook frame contains one page for each running aircraft. Each aircraft page is itself divided into subpages displaying telemetry data and giving access to the autopilot tuning parameters.&lt;br /&gt;
&lt;br /&gt;
Note that the colored tabs at the top of this section allow the user to select among multiple aircraft.&lt;br /&gt;
&lt;br /&gt;
=== Flight Plan ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSfp.png|Flight plan tree]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full tree of the flight plan is given in this page. The current block and the current stage are highlighted. A double-click on a block allows the operator to immediately switch navigation to this block.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on flight plans.&lt;br /&gt;
&lt;br /&gt;
=== Settings ===&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSsettings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The setting page allows the operator to change variable values during flight. The layout of the page is generated from the &amp;lt;tt&amp;gt;dl_settings&amp;lt;/tt&amp;gt; section of the settings.xml file, one tab is associated to every section and sub-section.&lt;br /&gt;
&lt;br /&gt;
On each line is displayed (from left to right), the name of the variable, its current value (periodically sent by the A/C), a slider or radio buttons for user input, and commit/undo buttons.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Telemetry#Settings|Telemetry]] page for more information on settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The save button of this tab opens the following popup which proposes to the user to save the current values in the airframe file (according to the &amp;lt;tt&amp;gt;param&amp;lt;/tt&amp;gt; attribute in the [[Telemetry#Settings|setttings]] configuration file). The values of the checked rows will be saved in the airframe file (or any other file) for further use. Units (e.g. deg or rad) are taken into account. '''It is recommended to backup the airframe file before overwriting it with this utility''' (even if time-stamped copy of the airframe file is actually automatically done).&lt;br /&gt;
&lt;br /&gt;
Symetrically, the Upload button of this dialog button will send all the checked values of the airframe file to the live aircraft.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:Save settings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PFD ===&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSpfd.png|Primary Flight Display]]&lt;br /&gt;
&lt;br /&gt;
The Primary Flight Display contains an artificial horizon and two scales displaying the current ground speed (left side) and the altitude (right side). Minimum and maximum speeds are shown under and above the speed scale. A click on the scale resets these values to the current speed value.&lt;br /&gt;
&lt;br /&gt;
=== GPS, Infrared, Wind ===&lt;br /&gt;
&lt;br /&gt;
The '''GPS''' page gives the list of satellites tracked by the receiver and their respective signal strengths in dB.&lt;br /&gt;
(35 is low, 45 is excellent) and if they are used to compute the fix (green: used, red:not used). This page may help to tune the position of the receiver on the aircraft relatively to other components (e.g. datalink and video transmitters).&lt;br /&gt;
&lt;br /&gt;
The '''Infrared''' page is only used for aircraft not equipped with the vertical infrared sensor. This page reports the required pre-flight calibration value as well as the evolution of the in-flight calibration correction factor (from hybridization with the GPS information).&lt;br /&gt;
&lt;br /&gt;
The '''Misc''' page displays the estimated wind velocity computed by the ground station during flight and relayed back to the aircraft.  Wind velocity is estimated by vector addition of the GPS-measured ground speed in many different directions during level flight.  This computation may soon be performed by the autopilot instead of the ground station.&lt;br /&gt;
&lt;br /&gt;
== Video Plugin ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-mplayer&amp;lt;/tt&amp;gt; option of GCS allows the user to display a video stream in this window.  The video window can also be exchanged with the map by clicking anywhere inside the frame or from the menu.&lt;br /&gt;
Use the following line in your [[Control_panel.xml|control panel]] to enable the video window.&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -mplayer rtsp://localhost:7070/video -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
Note that a &amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt; widget must be specified in the used layout:&lt;br /&gt;
 &amp;lt;tt&amp;gt; &amp;lt;widget size=&amp;quot;300&amp;quot; name=&amp;quot;plugin&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-plugin&amp;lt;/tt&amp;gt; option is another way to use the plugin widget: the X subwindow id is given to the provided command:&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;mplayer video_stream -wid &amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;cvlc video_stream --drawable-xid=&amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;--vout-event=3&amp;lt;/tt&amp;gt; option can be used for vlc to disable mouse and keyboard events handling&lt;br /&gt;
&lt;br /&gt;
== Altitude graph widget ==&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:altgraph.png|400px|The GCS with the altitude graph]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An altitude graph can be displayed in the GCS by adding the widget ''altgraph'' in the layout configuration (See the [[GCS_Configuration|GCS configuration]] page). An example is provided in conf/gcs/alt.xml. To use this layout add -layout alt.xml to the /conf/control_panel.xml file. This type of layout is more suited to a multi UAV set up. The Papget ruler is a much less intrusive and better tool when you are only flying a single aircraft.&lt;br /&gt;
&lt;br /&gt;
==Papgets==&lt;br /&gt;
Graphical objects can be added to 2D maps: text, rule, gauge, buttons, .... These objects are named ''papgets''. The following snapshot&lt;br /&gt;
shows an example with buttons (left side), gauges (lower left corner), text (upper right corner) and ruler (right side). This example&lt;br /&gt;
has been produced with a layout file provided in the distribution:&lt;br /&gt;
&lt;br /&gt;
 .../gcs -layout papgets.xml &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papgets.png|516px|A 2D map augmented with papgets]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Telemetry data report===&lt;br /&gt;
The easiest way to create a papget displaying telemetry data is to drag&amp;amp;drop a message field from the Messages window onto the 2D map of the GCS. The default rendering is then a string of text. Clicking on it allows the user to change its type (currently text, ruler or gauge) and some of its attributes (color, size, range for a gauge, format for a text ...). A papget can be moved by simply dragging it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papget_editor.png|Main characteristics of a papget can be dynamically edited]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Papgets can be saved in the layout of the GCS (from the Nav menu). The description is saved in an XML file (in &amp;lt;tt&amp;gt;conf/gcs/&amp;lt;/tt&amp;gt; folder) which can be manually edited:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;message_field&amp;quot; display=&amp;quot;gauge&amp;quot; x=&amp;quot;47&amp;quot; y=&amp;quot;414&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;field&amp;quot; value=&amp;quot;BAT:voltage&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;scale&amp;quot; value=&amp;quot;0.1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;min&amp;quot; value=&amp;quot;0.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;max&amp;quot; value=&amp;quot;15.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;size&amp;quot; value=&amp;quot;50.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;text&amp;quot; value=&amp;quot;Bat(V)&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file is used later by giving it to the gcs process:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 .../gcs -layout my_fancy_papgets.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Buttons===&lt;br /&gt;
In the same way, user buttons from the strip can be dragged&amp;amp;dropped on the 2D map. However, they currently cannot be directly edited, and&lt;br /&gt;
attributes changes have to be done in the XML file. Two types of button are provided to jump to a block or to set a value:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;goto_block&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;300&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;block_name&amp;quot; value=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;home.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;variable_setting&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;variable&amp;quot; value=&amp;quot;launch&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;value&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;launch.png&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Video===&lt;br /&gt;
A video stream can be rendered in a &amp;lt;tt&amp;gt;video_plugin&amp;lt;/tt&amp;gt; papget, using the mplayer player:&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;mplayer&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;video_feed&amp;quot; value=&amp;quot;my video source&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
or any video player which takes in option the X window id :&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;plugin&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;command&amp;quot; value=&amp;quot;cvlc video_source --drawable-xid=&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Development===&lt;br /&gt;
Graphical appearence of papgets is defined in &amp;lt;tt&amp;gt;sw/lib/ocaml/papget_renderer.ml&amp;lt;/tt&amp;gt;. A renderer must implement the Papget_renderer.t class type interface (&amp;lt;tt&amp;gt;canvas_text&amp;lt;/tt&amp;gt; is probably the simpler example) and listed in the &amp;lt;tt&amp;gt;renderers&amp;lt;/tt&amp;gt; list to be available&lt;br /&gt;
in the edit popup box.&lt;br /&gt;
&lt;br /&gt;
The XML configuration is parsed in &amp;lt;tt&amp;gt;sw/ground_segment/cockpit/papgets.ml&amp;lt;/tt&amp;gt;: a new created papget identifier must listed here.&lt;br /&gt;
&lt;br /&gt;
== Alarms ==&lt;br /&gt;
&lt;br /&gt;
The alarm window displays a list of recent errors such as:&lt;br /&gt;
* Low battery warning&lt;br /&gt;
* Low altitude warning&lt;br /&gt;
* Autopilot mode changes (i.e. Manual, Auto2)&lt;br /&gt;
* Flight plan block changes&lt;br /&gt;
&lt;br /&gt;
== Configuration Options ==&lt;br /&gt;
The GCS is highly configurable and modules can be added, removed, or resized as needed. In addition to this the gcs has many command line options which can be used when launching the GCS&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[GCS_Configuration|GCS configuration]] page for details.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6427</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6427"/>
		<updated>2010-04-26T01:32:53Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Building Flight Plans */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct.&lt;br /&gt;
&lt;br /&gt;
'''Following the contours of the land'''&lt;br /&gt;
&lt;br /&gt;
To get the land contour information you need to download the SRTM data (note: the SRTM data is not accurate but it will give you a good idea). Once you have this data, you need to setup your waypoints to take advantage of this data. When you want your aircraft to follow the contours of the land you need to use the &amp;quot;height&amp;quot; attribute not the &amp;quot;alt&amp;quot; attribute. The &amp;quot;height&amp;quot; attribute = ground_alt + height, the SRTM data gives ground_alt as the altitude above sea level. If you were to use the &amp;quot;alt&amp;quot; attribute, then each waypoint altitude needs to be set to take into account the SRTM altitude at each waypoint plus the height above ground level.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6426</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6426"/>
		<updated>2010-04-26T01:31:47Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Building Flight Plans */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
'''Waypoint Settings'''&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is acceptable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct.&lt;br /&gt;
&lt;br /&gt;
'''Following the contours of the land'''&lt;br /&gt;
&lt;br /&gt;
To get the land contour information you need to download the SRTM data. Once you have this data, you need to setup your waypoints to take advantage of this data. When you want your aircraft to follow the contours of the land you need to use the &amp;quot;height&amp;quot; attribute not the &amp;quot;alt&amp;quot; attribute. The &amp;quot;height&amp;quot; attribute = ground_alt + height, the SRTM data gives ground_alt as the altitude above sea level. If you were to use the &amp;quot;alt&amp;quot; attribute, then each waypoint altitude needs to be set to take into account the SRTM altitude at each waypoint plus the height above ground level.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6425</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6425"/>
		<updated>2010-04-25T07:44:20Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;\&lt;br /&gt;
&lt;br /&gt;
== Building Flight Plans ==&lt;br /&gt;
&lt;br /&gt;
Many of the flight plan examples here and in the Paparazzi software set waypoint locations using x,y coordinates from the lat/lon in the header of the flight plan. When building flight plans on the fly where there is no requirement to stay within lat/lon boundaries, this is accepable. When you are building flight plans where you are required to stay within or overfly certain GPS coordinates, using x,y from the lat/lon in the header will not work in real life. When simulating your flight plan the aircraft always starts from the lat/lon in the header. In reality your aircraft will probably start from a different spot each time, meaning your lat/lon coordinates will change each time. If you use the x,y coordinates, then each waypoint will move and your GPS points will not longer be correct.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Advanced_Navigation_Routines&amp;diff=6420</id>
		<title>Advanced Navigation Routines</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Advanced_Navigation_Routines&amp;diff=6420"/>
		<updated>2010-04-24T01:24:43Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== [http://www.engr.usu.edu/wiki/index.php/OSAM OSAM Team] Navigation Routines ==&lt;br /&gt;
=== Flower ===&lt;br /&gt;
[[Image:FlowerScreenShot.png|thumb|Screen shot of flower routine]]&lt;br /&gt;
The flower navigation routine flies the aircraft in a flower pattern defined by two waypoints. The center waypoint defines the center of the flower and the altitude the plane flies at. The edge waypoint defines the radius of the flower. &lt;br /&gt;
To use this navigation routine, you need to include OSAMNav.h in your flight plan and OSAMNav.c to your airframe file. Then you can add flower to your flight plan like so...&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;block name=&amp;quot;Flower&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;InitializeFlower(WP_Center,WP_Edge)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;FlowerNav()&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Bungee Takeoff ===&lt;br /&gt;
The bungee takeoff routine helps to automate takeoff by turning the throttle on after the bungee has been release from the hook. The only waypoint you need for this routine is the position of where the bungee is pegged to the ground. Using this waypoint, a line is drawn from the position of the aircraft to the bungee waypoint. This line is called the launch line and will stop updating once the speed of the plane exceeds the MinSpeed. This allows the user to initialize the routine, move the plane and launch it without having to reinitialize. Once the plane is launched, it will follow the launch line until it crosses the throttle line. The throttle line is a line perpendicular to the launch line at a distance d from the bungee waypoint (see the diagram below). When the plane crosses the throttle line and the speed of the aircraft is greater than MinSpeed, the throttle comes on. After the throttle comes on, the plane keeps going straight until it reaches a specified speed and altitude above the bungee waypoint altitude. When it reaches the takeoff speed and takeoff altitude, the next block in the flight plan is executed. The takeoff speed, takeoff altitude, MinSpeed and the distance d from the bungee waypoint are specified in the airframe file. You will need to add those values to your airframe file like this...&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;section name=&amp;quot;Takeoff&amp;quot; prefix=&amp;quot;Takeoff_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;Height&amp;quot; value=&amp;quot;30&amp;quot; unit=&amp;quot;m&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;Speed&amp;quot; value=&amp;quot;15&amp;quot; unit=&amp;quot;m/s&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;Distance&amp;quot; value=&amp;quot;3&amp;quot; unit=&amp;quot;m&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;MinSpeed&amp;quot; value=&amp;quot;5&amp;quot; unit=&amp;quot;m/s&amp;quot;/&amp;gt;    &lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use this navigation routine, include OSAMNav.h in your flight plan and OSAMNav.c to your airframe file. Then you can add the bungee takeoff routine to your flight plan like so...&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;block name=&amp;quot;Takeoff&amp;quot; strip_button=&amp;quot;Takeoff (wp CLIMB)&amp;quot; strip_icon=&amp;quot;takeoff.png&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;call fun=&amp;quot;InitializeBungeeTakeoff(WP_Bungee)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;call fun=&amp;quot;BungeeTakeoff()&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get this routine to work consistantly, you will need to tune the values in the airframe config file. If the prop doesn't automatically turn on when it crosses the throttle line, it could be because the Distance and/or the MinSpeed are too big. If it turns on to early, it could be because the Distance and/or MinSpeed are too small. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#ff0000&amp;quot;&amp;gt; ***Precaution should be taken while tuning the auto takeoff. If the MinSpeed is too low, the prop could turn on while holding the aircraft!***&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:BungeeTakeoffDiagram.png|Bungee takeoff diagram&lt;br /&gt;
Image:BungeeTakeoffInit.png|After bungee takeoff initialization&lt;br /&gt;
Image:BungeeTakeoffThrottleOn.png|After crossing the throttle line&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Polygon Survey ===&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
With this navigation routine, an aircraft can survey the area of any [http://en.wikipedia.org/wiki/Convex_polygon convex polygon] given an entry point, the number of waypoints which define the polygon, the sweep width and the desired orientation of the sweeps.&lt;br /&gt;
&lt;br /&gt;
The entry point is the first corner of the polygon and the point at which the aircraft will begin surveying the area. When in the entry state, the aircraft will circle around the entry point in order to smoothly transition into the first sweep. The aircraft will also keep circling around the entry point until it gets to the waypoint altitude. After the first sweep is made, the direction of the next sweep is determined by the distance of the entry point to the edges of the polygon. If there is more area above the first sweep, the aircraft will sweep up. If there is more area below the first sweep, the aircraft will sweep down.&lt;br /&gt;
&lt;br /&gt;
The aircraft will keep sweeping back and forth until it reaches the end of the polygon. At this point, the aircraft will sweep back up/down the polygon halfway in between the sweeps previously made by the aircraft (just like the rectangle survey function). The aircraft will keep sweeping up and down the polygon unless the user manually exits the block or unless an exception is used ([[#Exceptions|see below]]).&lt;br /&gt;
&lt;br /&gt;
The orientation of the sweeps can ranges from north south to east west and any where in between (0-90 degrees respectively). The side of the polygon the aircraft starts on (ex. north or south)  is determined by the side of the polygon the entry point is located.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:PolySurveySweepDef.png|Sweep Definition&lt;br /&gt;
Image:PolySurveyEntryPic.png|Entry Point&lt;br /&gt;
Image:PolySurveySweepBack.png|Sweeping Back&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ====&lt;br /&gt;
To use this navigation routine, you need to include OSAMNav.h in your flight plan and OSAMNav.c to your airframe file. Then add this navigation routine in your flight plan like so... &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;block name=&amp;quot;Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, NumOfCorners, SweepWidth, Orientation)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The parameters are the entry waypoint, the number of waypoints in the polygon, the sweep width (meters), and the desired orientation of the sweeps (degrees). The maximum number of waypoints a polygon can have is currently ten (can be changed in the code). If the number of waypoints in the polygon exceeds the maximum number, the routine will exit and move to the next block in the flight plan. The routine will also exit if the orientation is not between 0 and 90 degrees.&lt;br /&gt;
&lt;br /&gt;
Here is an example of how you should declare each of the corners of the polygon.&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;waypoint alt=&amp;quot;1453.0&amp;quot; name=&amp;quot;S1&amp;quot; x=&amp;quot;-546.2&amp;quot; y=&amp;quot;297.4&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;waypoint alt=&amp;quot;1453.0&amp;quot; name=&amp;quot;_S2&amp;quot; x=&amp;quot;-129.8&amp;quot; y=&amp;quot;744.1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;waypoint alt=&amp;quot;1553.0&amp;quot; name=&amp;quot;_S3&amp;quot; x=&amp;quot;1030.5&amp;quot; y=&amp;quot;535.5&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;waypoint alt=&amp;quot;1453.0&amp;quot; name=&amp;quot;_S4&amp;quot; x=&amp;quot;523.0&amp;quot; y=&amp;quot;-236.7&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;waypoint alt=&amp;quot;1453.0&amp;quot; name=&amp;quot;_S5&amp;quot; x=&amp;quot;-285.9&amp;quot; y=&amp;quot;-255.7&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
S1 is the entry waypoint and the first corner. The other corners should be in order clockwise or counter clockwise around the polygon. Even though this group of waypoints must be declared together, where the group appears in the list of waypoints doesn't matter.&lt;br /&gt;
&lt;br /&gt;
If you want the edges of the polygon to show up on the GCS, you can also declare the polygon as a sector. This is not required to run the routine.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;sectors&amp;gt;&lt;br /&gt;
    &amp;lt;sector name=&amp;quot;PolySector&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;corner name=&amp;quot;S1&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;corner name=&amp;quot;_S2&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;corner name=&amp;quot;_S3&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;corner name=&amp;quot;_S4&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;corner name=&amp;quot;_S5&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/sector&amp;gt;&lt;br /&gt;
  &amp;lt;/sectors&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;A Range of Different Sweep Orientations&amp;quot;&amp;gt;&lt;br /&gt;
Image:PolySurvey0DegreeEx.png|0 Degrees&lt;br /&gt;
Image:PolySurvey30DegreeEx.png|30 Degrees&lt;br /&gt;
Image:PolySurvey65DegreeEx.png|65 Degrees&lt;br /&gt;
Image:PolySurvey90DegreeEx.png|90 Degrees&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Alternative configurations ====&lt;br /&gt;
If you are wanting to start and stop the Poly Survey this is possible by splitting the Poly Survey code above into the initialization routine and the execution routine. You might want to do this if you are searching for something inside the Poly Survey, think you have found it and then realized you haven't, so you want to continue the survey (not restart it). Using the example above, but with the initialisation and execution code separate:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;block name=&amp;quot;Init Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, NumOfCorners, SweepWidth, Orientation)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;block name=&amp;quot;Execute Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Exceptions ====&lt;br /&gt;
There are a couple of built in variables which can be used to exit the routine with an exception. PolySurveySweepNum gives the number of sweeps the aircraft has made and PolySurveySweepBackNum gives the number of times the aircraft has gotten to the bottom of the polygon and swept back. The first example would deroute the aircraft to standby after the aircraft made it's second sweep. The second example would deroute the aircraft to standby before it starts to sweep back up the polygon for the first time.&lt;br /&gt;
&lt;br /&gt;
    block name=&amp;quot;Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;exception cond=&amp;quot;PolySurveySweepNum &amp;gt;= 2&amp;quot; deroute=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 200, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    block name=&amp;quot;Poly Survey&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;exception cond=&amp;quot;PolySurveySweepBackNum &amp;gt;= 1&amp;quot; deroute=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;InitializePolygonSurvey(WP_S1, 5, 200, 45)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;PolygonSurvey()&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6416</id>
		<title>GCS</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6416"/>
		<updated>2010-04-22T15:04:41Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Altitude graph widget */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{|&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|&lt;br /&gt;
[[Image:gcs.jpg|frame|right|The Paparazzi Ground Control Station is the heart of the system and the user's primary interaction interface.]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Strips ==&lt;br /&gt;
&lt;br /&gt;
Each A/C has an associated strip that displays information about the A/C and provides buttons for common commands. The strip has the following layout:&lt;br /&gt;
&lt;br /&gt;
[[Image:strip.png|Aircraft information strip]]&lt;br /&gt;
&lt;br /&gt;
=== Displayed information ===&lt;br /&gt;
&lt;br /&gt;
* Left: Flight information&lt;br /&gt;
* Center: Navigation information&lt;br /&gt;
* Right: Navigation control&lt;br /&gt;
* Bottom: Custom navigation and setting buttons&lt;br /&gt;
&lt;br /&gt;
=== Actions ===&lt;br /&gt;
&lt;br /&gt;
Every change in the waypoints (position or/and altitude) must be confirmed with the dialog box that appears after the move. A modified waypoint remains animated on the map and the GCS continues to re-send the move request until confirmation is received from the aircraft.&lt;br /&gt;
When clicked, the '''Mark''' button places a mark on the map at the A/C position. A snapshot from the video plugin is associated to this mark and can be viewed by moving the mouse over the mark. A click on the mark opens a dialog box allowing to delete the mark.&lt;br /&gt;
A click on the colored bar at the top selects the corresponding A/C in the [[#notebook|Notebook]].&lt;br /&gt;
&lt;br /&gt;
== Map ==&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSmap.png|thumb|400px|Sample map showing the various features]]&lt;br /&gt;
&lt;br /&gt;
=== Display ===&lt;br /&gt;
&lt;br /&gt;
The map display contains the following information:&lt;br /&gt;
* The A/C track: it can be erased ''via'' the ''Clear track'' option from the A/C menu.&lt;br /&gt;
* The A/C label (in clear blue near the A/C) contains the name of the A/C (Plaster), it's altitude (218 m) and it's ground speed (11.99 m/s). This option default is off. It can be activated with the ''A/C label'' option from the A/C menu.&lt;br /&gt;
* The carrot (the orange triangle). This is the point the A/C is following during autonomous navigation.&lt;br /&gt;
* The waypoints defined in the flight plan (blue diamonds).&lt;br /&gt;
* The intended trajectory is shown in green (circling waypoint 2).&lt;br /&gt;
* The default background is black. [[#google_tiles|Google tiles]] or [[Maps|user defined maps]] can be loaded to provide navigation reference.&lt;br /&gt;
* The camera footprint (the grey polygon) is representative of the swath of land currently seen by the onboard camera. This option default is off. It can be activated with the ''Cam footprint'' option from the A/C menu.&lt;br /&gt;
* The WGS84 coordinates of the mouse cursor are displayed at the top right hand corner (43.462019   1.270474).&lt;br /&gt;
* A UTM kilometric grid can be added to the background ''via'' the ''UTM grid'' option from the ''Nav'' menu.&lt;br /&gt;
* The height Above Ground Level (AGL) displays the ground altitude of the mouse near the geographic position in the top right hand corner. The [http://srtm.usgs.gov/ SRTM] option must be enabled in the ''Nav'' menu. The height information comes from SRTM data files (&amp;lt;tt&amp;gt;.hgt.zip&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.hgt.bz2&amp;lt;/tt&amp;gt;) and must be copied to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory. They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/ http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/]. For example: http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N47E016.hgt.zip is for 47 deg North latitude and 16 deg East longitude.&lt;br /&gt;
&lt;br /&gt;
=== Navigation ===&lt;br /&gt;
&lt;br /&gt;
You can pan/zoom the map using the following:&lt;br /&gt;
* Pan with the blue arrows on the map or use the arrow keys on the keyboard&lt;br /&gt;
* zoom in/out with the mouse scroll wheel, the page up/page down buttons or the small up/down buttons at the top right hand corner where the zoom factor is displayed&lt;br /&gt;
* fit the map to the window, in order to see all the waypoints and A/C, with the '''f''' key or the ''Fit'' option from the ''Nav'' menu;&lt;br /&gt;
* center the map on an A/C with the ''Center A/C'' option from the corresponding A/C menu.&lt;br /&gt;
&lt;br /&gt;
=== Google Tiles ===&lt;br /&gt;
The default black background can be automatically filled with calibrated satellite photo tiles from Google. Note: if you download too much map data from Google you may be blocked for downloading further maps for 24 hours. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Maps]] page for more info.&lt;br /&gt;
&lt;br /&gt;
=== Waypoint Editing ===&lt;br /&gt;
&lt;br /&gt;
The properties of any waypoint in the currently loaded flight plan can be modified by two methods:&lt;br /&gt;
* Drag and drop the waypoints to a new location (a confirmation dialog will appear).&lt;br /&gt;
* A single left click on a waypoint opens a dialog box where you can edit the waypoint's coordinates and altitude.&lt;br /&gt;
&lt;br /&gt;
Waypoint edits are sent to the aircraft immediately upon confirmation in the dialog box.  The GCS will re-send the data and the waypoint will animate until the aircraft confirms receipt of the move request.  New waypoints cannot be added during flight.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on waypoints.&lt;br /&gt;
&lt;br /&gt;
== Notebook ==&lt;br /&gt;
&lt;br /&gt;
The notebook frame contains one page for each running aircraft. Each aircraft page is itself divided into subpages displaying telemetry data and giving access to the autopilot tuning parameters.&lt;br /&gt;
&lt;br /&gt;
Note that the colored tabs at the top of this section allow the user to select among multiple aircraft.&lt;br /&gt;
&lt;br /&gt;
=== Flight Plan ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSfp.png|Flight plan tree]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full tree of the flight plan is given in this page. The current block and the current stage are highlighted. A double-click on a block allows the operator to immediately switch navigation to this block.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on flight plans.&lt;br /&gt;
&lt;br /&gt;
=== Settings ===&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSsettings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The setting page allows the operator to change variable values during flight. The layout of the page is generated from the &amp;lt;tt&amp;gt;dl_settings&amp;lt;/tt&amp;gt; section of the settings.xml file, one tab is associated to every section and sub-section.&lt;br /&gt;
&lt;br /&gt;
On each line is displayed (from left to right), the name of the variable, its current value (periodically sent by the A/C), a slider or radio buttons for user input, and commit/undo buttons.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Telemetry#Settings|Telemetry]] page for more information on settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The save button of this tab opens the following popup which proposes to the user to save the current values in the airframe file (according to the &amp;lt;tt&amp;gt;param&amp;lt;/tt&amp;gt; attribute in the [[Telemetry#Settings|setttings]] configuration file). The values of the checked rows will be saved in the airframe file (or any other file) for further use. Units (e.g. deg or rad) are taken into account. '''It is recommended to backup the airframe file before overwriting it with this utility''' (even if time-stamped copy of the airframe file is actually automatically done).&lt;br /&gt;
&lt;br /&gt;
Symetrically, the Upload button of this dialog button will send all the checked values of the airframe file to the live aircraft.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:Save settings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PFD ===&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSpfd.png|Primary Flight Display]]&lt;br /&gt;
&lt;br /&gt;
The Primary Flight Display contains an artificial horizon and two scales displaying the current ground speed (left side) and the altitude (right side). Minimum and maximum speeds are shown under and above the speed scale. A click on the scale resets these values to the current speed value.&lt;br /&gt;
&lt;br /&gt;
=== GPS, Infrared, Wind ===&lt;br /&gt;
&lt;br /&gt;
The '''GPS''' page gives the list of satellites tracked by the receiver and their respective signal strengths in dB.&lt;br /&gt;
(35 is low, 45 is excellent) and if they are used to compute the fix (green: used, red:not used). This page may help to tune the position of the receiver on the aircraft relatively to other components (e.g. datalink and video transmitters).&lt;br /&gt;
&lt;br /&gt;
The '''Infrared''' page is only used for aircraft not equipped with the vertical infrared sensor. This page reports the required pre-flight calibration value as well as the evolution of the in-flight calibration correction factor (from hybridization with the GPS information).&lt;br /&gt;
&lt;br /&gt;
The '''Misc''' page displays the estimated wind velocity computed by the ground station during flight and relayed back to the aircraft.  Wind velocity is estimated by vector addition of the GPS-measured ground speed in many different directions during level flight.  This computation may soon be performed by the autopilot instead of the ground station.&lt;br /&gt;
&lt;br /&gt;
== Video Plugin ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-mplayer&amp;lt;/tt&amp;gt; option of GCS allows the user to display a video stream in this window.  The video window can also be exchanged with the map by clicking anywhere inside the frame or from the menu.&lt;br /&gt;
Use the following line in your [[Control_panel.xml|control panel]] to enable the video window.&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -mplayer rtsp://localhost:7070/video -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
Note that a &amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt; widget must be specified in the used layout:&lt;br /&gt;
 &amp;lt;tt&amp;gt; &amp;lt;widget size=&amp;quot;300&amp;quot; name=&amp;quot;plugin&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-plugin&amp;lt;/tt&amp;gt; option is another way to use the plugin widget: the X subwindow id is given to the provided command:&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;mplayer video_stream -wid &amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;cvlc video_stream --drawable-xid=&amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;--vout-event=3&amp;lt;/tt&amp;gt; option can be used for vlc to disable mouse and keyboard events handling&lt;br /&gt;
&lt;br /&gt;
== Altitude graph widget ==&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:altgraph.png|400px|The GCS with the altitude graph]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An altitude graph can be displayed in the GCS by adding the widget ''altgraph'' in the layout configuration (See the [[GCS_Configuration|GCS configuration]] page). An example is provided in conf/gcs/alt.xml (launch GCS with the option -layout alt.xml). This type of layout is more suited to a multi UAV set up. The Papget ruler is a much less intrusive and better tool when you are only flying a single aircraft.&lt;br /&gt;
&lt;br /&gt;
==Papgets==&lt;br /&gt;
Graphical objects can be added to 2D maps: text, rule, gauge, buttons, .... These objects are named ''papgets''. The following snapshot&lt;br /&gt;
shows an example with buttons (left side), gauges (lower left corner), text (upper right corner) and ruler (right side). This example&lt;br /&gt;
has been produced with a layout file provided in the distribution:&lt;br /&gt;
&lt;br /&gt;
 .../gcs -layout papgets.xml &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papgets.png|516px|A 2D map augmented with papgets]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Telemetry data report===&lt;br /&gt;
The easiest way to create a papget displaying telemetry data is to drag&amp;amp;drop a message field from the Messages window onto the 2D map of the GCS. The default rendering is then a string of text. Clicking on it allows the user to change its type (currently text, ruler or gauge) and some of its attributes (color, size, range for a gauge, format for a text ...). A papget can be moved by simply dragging it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papget_editor.png|Main characteristics of a papget can be dynamically edited]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Papgets can be saved in the layout of the GCS (from the Nav menu). The description is saved in an XML file (in &amp;lt;tt&amp;gt;conf/gcs/&amp;lt;/tt&amp;gt; folder) which can be manually edited:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;message_field&amp;quot; display=&amp;quot;gauge&amp;quot; x=&amp;quot;47&amp;quot; y=&amp;quot;414&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;field&amp;quot; value=&amp;quot;BAT:voltage&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;scale&amp;quot; value=&amp;quot;0.1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;min&amp;quot; value=&amp;quot;0.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;max&amp;quot; value=&amp;quot;15.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;size&amp;quot; value=&amp;quot;50.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;text&amp;quot; value=&amp;quot;Bat(V)&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file is used later by giving it to the gcs process:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 .../gcs -layout my_fancy_papgets.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Buttons===&lt;br /&gt;
In the same way, user buttons from the strip can be dragged&amp;amp;dropped on the 2D map. However, they currently cannot be directly edited, and&lt;br /&gt;
attributes changes have to be done in the XML file. Two types of button are provided to jump to a block or to set a value:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;goto_block&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;300&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;block_name&amp;quot; value=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;home.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;variable_setting&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;variable&amp;quot; value=&amp;quot;launch&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;value&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;launch.png&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Video===&lt;br /&gt;
A video stream can be rendered in a &amp;lt;tt&amp;gt;video_plugin&amp;lt;/tt&amp;gt; papget, using the mplayer player:&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;mplayer&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;video_feed&amp;quot; value=&amp;quot;my video source&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
or any video player which takes in option the X window id :&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;plugin&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;command&amp;quot; value=&amp;quot;cvlc video_source --drawable-xid=&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Development===&lt;br /&gt;
Graphical appearence of papgets is defined in &amp;lt;tt&amp;gt;sw/lib/ocaml/papget_renderer.ml&amp;lt;/tt&amp;gt;. A renderer must implement the Papget_renderer.t class type interface (&amp;lt;tt&amp;gt;canvas_text&amp;lt;/tt&amp;gt; is probably the simpler example) and listed in the &amp;lt;tt&amp;gt;renderers&amp;lt;/tt&amp;gt; list to be available&lt;br /&gt;
in the edit popup box.&lt;br /&gt;
&lt;br /&gt;
The XML configuration is parsed in &amp;lt;tt&amp;gt;sw/ground_segment/cockpit/papgets.ml&amp;lt;/tt&amp;gt;: a new created papget identifier must listed here.&lt;br /&gt;
&lt;br /&gt;
== Alarms ==&lt;br /&gt;
&lt;br /&gt;
The alarm window displays a list of recent errors such as:&lt;br /&gt;
* Low battery warning&lt;br /&gt;
* Low altitude warning&lt;br /&gt;
* Autopilot mode changes (i.e. Manual, Auto2)&lt;br /&gt;
* Flight plan block changes&lt;br /&gt;
&lt;br /&gt;
== Configuration Options ==&lt;br /&gt;
The GCS is highly configurable and modules can be added, removed, or resized as needed. In addition to this the gcs has many command line options which can be used when launching the GCS&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[GCS_Configuration|GCS configuration]] page for details.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6415</id>
		<title>GCS</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6415"/>
		<updated>2010-04-22T15:01:53Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Google Tiles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{|&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|&lt;br /&gt;
[[Image:gcs.jpg|frame|right|The Paparazzi Ground Control Station is the heart of the system and the user's primary interaction interface.]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Strips ==&lt;br /&gt;
&lt;br /&gt;
Each A/C has an associated strip that displays information about the A/C and provides buttons for common commands. The strip has the following layout:&lt;br /&gt;
&lt;br /&gt;
[[Image:strip.png|Aircraft information strip]]&lt;br /&gt;
&lt;br /&gt;
=== Displayed information ===&lt;br /&gt;
&lt;br /&gt;
* Left: Flight information&lt;br /&gt;
* Center: Navigation information&lt;br /&gt;
* Right: Navigation control&lt;br /&gt;
* Bottom: Custom navigation and setting buttons&lt;br /&gt;
&lt;br /&gt;
=== Actions ===&lt;br /&gt;
&lt;br /&gt;
Every change in the waypoints (position or/and altitude) must be confirmed with the dialog box that appears after the move. A modified waypoint remains animated on the map and the GCS continues to re-send the move request until confirmation is received from the aircraft.&lt;br /&gt;
When clicked, the '''Mark''' button places a mark on the map at the A/C position. A snapshot from the video plugin is associated to this mark and can be viewed by moving the mouse over the mark. A click on the mark opens a dialog box allowing to delete the mark.&lt;br /&gt;
A click on the colored bar at the top selects the corresponding A/C in the [[#notebook|Notebook]].&lt;br /&gt;
&lt;br /&gt;
== Map ==&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSmap.png|thumb|400px|Sample map showing the various features]]&lt;br /&gt;
&lt;br /&gt;
=== Display ===&lt;br /&gt;
&lt;br /&gt;
The map display contains the following information:&lt;br /&gt;
* The A/C track: it can be erased ''via'' the ''Clear track'' option from the A/C menu.&lt;br /&gt;
* The A/C label (in clear blue near the A/C) contains the name of the A/C (Plaster), it's altitude (218 m) and it's ground speed (11.99 m/s). This option default is off. It can be activated with the ''A/C label'' option from the A/C menu.&lt;br /&gt;
* The carrot (the orange triangle). This is the point the A/C is following during autonomous navigation.&lt;br /&gt;
* The waypoints defined in the flight plan (blue diamonds).&lt;br /&gt;
* The intended trajectory is shown in green (circling waypoint 2).&lt;br /&gt;
* The default background is black. [[#google_tiles|Google tiles]] or [[Maps|user defined maps]] can be loaded to provide navigation reference.&lt;br /&gt;
* The camera footprint (the grey polygon) is representative of the swath of land currently seen by the onboard camera. This option default is off. It can be activated with the ''Cam footprint'' option from the A/C menu.&lt;br /&gt;
* The WGS84 coordinates of the mouse cursor are displayed at the top right hand corner (43.462019   1.270474).&lt;br /&gt;
* A UTM kilometric grid can be added to the background ''via'' the ''UTM grid'' option from the ''Nav'' menu.&lt;br /&gt;
* The height Above Ground Level (AGL) displays the ground altitude of the mouse near the geographic position in the top right hand corner. The [http://srtm.usgs.gov/ SRTM] option must be enabled in the ''Nav'' menu. The height information comes from SRTM data files (&amp;lt;tt&amp;gt;.hgt.zip&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.hgt.bz2&amp;lt;/tt&amp;gt;) and must be copied to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory. They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/ http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/]. For example: http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N47E016.hgt.zip is for 47 deg North latitude and 16 deg East longitude.&lt;br /&gt;
&lt;br /&gt;
=== Navigation ===&lt;br /&gt;
&lt;br /&gt;
You can pan/zoom the map using the following:&lt;br /&gt;
* Pan with the blue arrows on the map or use the arrow keys on the keyboard&lt;br /&gt;
* zoom in/out with the mouse scroll wheel, the page up/page down buttons or the small up/down buttons at the top right hand corner where the zoom factor is displayed&lt;br /&gt;
* fit the map to the window, in order to see all the waypoints and A/C, with the '''f''' key or the ''Fit'' option from the ''Nav'' menu;&lt;br /&gt;
* center the map on an A/C with the ''Center A/C'' option from the corresponding A/C menu.&lt;br /&gt;
&lt;br /&gt;
=== Google Tiles ===&lt;br /&gt;
The default black background can be automatically filled with calibrated satellite photo tiles from Google. Note: if you download too much map data from Google you may be blocked for downloading further maps for 24 hours. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Maps]] page for more info.&lt;br /&gt;
&lt;br /&gt;
=== Waypoint Editing ===&lt;br /&gt;
&lt;br /&gt;
The properties of any waypoint in the currently loaded flight plan can be modified by two methods:&lt;br /&gt;
* Drag and drop the waypoints to a new location (a confirmation dialog will appear).&lt;br /&gt;
* A single left click on a waypoint opens a dialog box where you can edit the waypoint's coordinates and altitude.&lt;br /&gt;
&lt;br /&gt;
Waypoint edits are sent to the aircraft immediately upon confirmation in the dialog box.  The GCS will re-send the data and the waypoint will animate until the aircraft confirms receipt of the move request.  New waypoints cannot be added during flight.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on waypoints.&lt;br /&gt;
&lt;br /&gt;
== Notebook ==&lt;br /&gt;
&lt;br /&gt;
The notebook frame contains one page for each running aircraft. Each aircraft page is itself divided into subpages displaying telemetry data and giving access to the autopilot tuning parameters.&lt;br /&gt;
&lt;br /&gt;
Note that the colored tabs at the top of this section allow the user to select among multiple aircraft.&lt;br /&gt;
&lt;br /&gt;
=== Flight Plan ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSfp.png|Flight plan tree]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full tree of the flight plan is given in this page. The current block and the current stage are highlighted. A double-click on a block allows the operator to immediately switch navigation to this block.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on flight plans.&lt;br /&gt;
&lt;br /&gt;
=== Settings ===&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSsettings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The setting page allows the operator to change variable values during flight. The layout of the page is generated from the &amp;lt;tt&amp;gt;dl_settings&amp;lt;/tt&amp;gt; section of the settings.xml file, one tab is associated to every section and sub-section.&lt;br /&gt;
&lt;br /&gt;
On each line is displayed (from left to right), the name of the variable, its current value (periodically sent by the A/C), a slider or radio buttons for user input, and commit/undo buttons.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Telemetry#Settings|Telemetry]] page for more information on settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The save button of this tab opens the following popup which proposes to the user to save the current values in the airframe file (according to the &amp;lt;tt&amp;gt;param&amp;lt;/tt&amp;gt; attribute in the [[Telemetry#Settings|setttings]] configuration file). The values of the checked rows will be saved in the airframe file (or any other file) for further use. Units (e.g. deg or rad) are taken into account. '''It is recommended to backup the airframe file before overwriting it with this utility''' (even if time-stamped copy of the airframe file is actually automatically done).&lt;br /&gt;
&lt;br /&gt;
Symetrically, the Upload button of this dialog button will send all the checked values of the airframe file to the live aircraft.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:Save settings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PFD ===&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSpfd.png|Primary Flight Display]]&lt;br /&gt;
&lt;br /&gt;
The Primary Flight Display contains an artificial horizon and two scales displaying the current ground speed (left side) and the altitude (right side). Minimum and maximum speeds are shown under and above the speed scale. A click on the scale resets these values to the current speed value.&lt;br /&gt;
&lt;br /&gt;
=== GPS, Infrared, Wind ===&lt;br /&gt;
&lt;br /&gt;
The '''GPS''' page gives the list of satellites tracked by the receiver and their respective signal strengths in dB.&lt;br /&gt;
(35 is low, 45 is excellent) and if they are used to compute the fix (green: used, red:not used). This page may help to tune the position of the receiver on the aircraft relatively to other components (e.g. datalink and video transmitters).&lt;br /&gt;
&lt;br /&gt;
The '''Infrared''' page is only used for aircraft not equipped with the vertical infrared sensor. This page reports the required pre-flight calibration value as well as the evolution of the in-flight calibration correction factor (from hybridization with the GPS information).&lt;br /&gt;
&lt;br /&gt;
The '''Misc''' page displays the estimated wind velocity computed by the ground station during flight and relayed back to the aircraft.  Wind velocity is estimated by vector addition of the GPS-measured ground speed in many different directions during level flight.  This computation may soon be performed by the autopilot instead of the ground station.&lt;br /&gt;
&lt;br /&gt;
== Video Plugin ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-mplayer&amp;lt;/tt&amp;gt; option of GCS allows the user to display a video stream in this window.  The video window can also be exchanged with the map by clicking anywhere inside the frame or from the menu.&lt;br /&gt;
Use the following line in your [[Control_panel.xml|control panel]] to enable the video window.&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -mplayer rtsp://localhost:7070/video -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
Note that a &amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt; widget must be specified in the used layout:&lt;br /&gt;
 &amp;lt;tt&amp;gt; &amp;lt;widget size=&amp;quot;300&amp;quot; name=&amp;quot;plugin&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-plugin&amp;lt;/tt&amp;gt; option is another way to use the plugin widget: the X subwindow id is given to the provided command:&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;mplayer video_stream -wid &amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;cvlc video_stream --drawable-xid=&amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;--vout-event=3&amp;lt;/tt&amp;gt; option can be used for vlc to disable mouse and keyboard events handling&lt;br /&gt;
&lt;br /&gt;
== Altitude graph widget ==&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:altgraph.png|400px|The GCS with the altitude graph]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An altitude graph can be displayed in the GCS by adding the widget ''altgraph'' in the layout configuration (See the [[GCS_Configuration|GCS configuration]] page). An example is provided in conf/gcs/alt.xml (launch GCS with the option -layout alt.xml).&lt;br /&gt;
&lt;br /&gt;
==Papgets==&lt;br /&gt;
Graphical objects can be added to 2D maps: text, rule, gauge, buttons, .... These objects are named ''papgets''. The following snapshot&lt;br /&gt;
shows an example with buttons (left side), gauges (lower left corner), text (upper right corner) and ruler (right side). This example&lt;br /&gt;
has been produced with a layout file provided in the distribution:&lt;br /&gt;
&lt;br /&gt;
 .../gcs -layout papgets.xml &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papgets.png|516px|A 2D map augmented with papgets]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Telemetry data report===&lt;br /&gt;
The easiest way to create a papget displaying telemetry data is to drag&amp;amp;drop a message field from the Messages window onto the 2D map of the GCS. The default rendering is then a string of text. Clicking on it allows the user to change its type (currently text, ruler or gauge) and some of its attributes (color, size, range for a gauge, format for a text ...). A papget can be moved by simply dragging it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papget_editor.png|Main characteristics of a papget can be dynamically edited]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Papgets can be saved in the layout of the GCS (from the Nav menu). The description is saved in an XML file (in &amp;lt;tt&amp;gt;conf/gcs/&amp;lt;/tt&amp;gt; folder) which can be manually edited:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;message_field&amp;quot; display=&amp;quot;gauge&amp;quot; x=&amp;quot;47&amp;quot; y=&amp;quot;414&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;field&amp;quot; value=&amp;quot;BAT:voltage&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;scale&amp;quot; value=&amp;quot;0.1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;min&amp;quot; value=&amp;quot;0.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;max&amp;quot; value=&amp;quot;15.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;size&amp;quot; value=&amp;quot;50.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;text&amp;quot; value=&amp;quot;Bat(V)&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file is used later by giving it to the gcs process:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 .../gcs -layout my_fancy_papgets.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Buttons===&lt;br /&gt;
In the same way, user buttons from the strip can be dragged&amp;amp;dropped on the 2D map. However, they currently cannot be directly edited, and&lt;br /&gt;
attributes changes have to be done in the XML file. Two types of button are provided to jump to a block or to set a value:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;goto_block&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;300&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;block_name&amp;quot; value=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;home.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;variable_setting&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;variable&amp;quot; value=&amp;quot;launch&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;value&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;launch.png&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Video===&lt;br /&gt;
A video stream can be rendered in a &amp;lt;tt&amp;gt;video_plugin&amp;lt;/tt&amp;gt; papget, using the mplayer player:&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;mplayer&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;video_feed&amp;quot; value=&amp;quot;my video source&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
or any video player which takes in option the X window id :&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;plugin&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;command&amp;quot; value=&amp;quot;cvlc video_source --drawable-xid=&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Development===&lt;br /&gt;
Graphical appearence of papgets is defined in &amp;lt;tt&amp;gt;sw/lib/ocaml/papget_renderer.ml&amp;lt;/tt&amp;gt;. A renderer must implement the Papget_renderer.t class type interface (&amp;lt;tt&amp;gt;canvas_text&amp;lt;/tt&amp;gt; is probably the simpler example) and listed in the &amp;lt;tt&amp;gt;renderers&amp;lt;/tt&amp;gt; list to be available&lt;br /&gt;
in the edit popup box.&lt;br /&gt;
&lt;br /&gt;
The XML configuration is parsed in &amp;lt;tt&amp;gt;sw/ground_segment/cockpit/papgets.ml&amp;lt;/tt&amp;gt;: a new created papget identifier must listed here.&lt;br /&gt;
&lt;br /&gt;
== Alarms ==&lt;br /&gt;
&lt;br /&gt;
The alarm window displays a list of recent errors such as:&lt;br /&gt;
* Low battery warning&lt;br /&gt;
* Low altitude warning&lt;br /&gt;
* Autopilot mode changes (i.e. Manual, Auto2)&lt;br /&gt;
* Flight plan block changes&lt;br /&gt;
&lt;br /&gt;
== Configuration Options ==&lt;br /&gt;
The GCS is highly configurable and modules can be added, removed, or resized as needed. In addition to this the gcs has many command line options which can be used when launching the GCS&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[GCS_Configuration|GCS configuration]] page for details.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6414</id>
		<title>GCS</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=GCS&amp;diff=6414"/>
		<updated>2010-04-22T15:00:38Z</updated>

		<summary type="html">&lt;p&gt;Nathan: /* Google Tiles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{|&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|&lt;br /&gt;
[[Image:gcs.jpg|frame|right|The Paparazzi Ground Control Station is the heart of the system and the user's primary interaction interface.]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Strips ==&lt;br /&gt;
&lt;br /&gt;
Each A/C has an associated strip that displays information about the A/C and provides buttons for common commands. The strip has the following layout:&lt;br /&gt;
&lt;br /&gt;
[[Image:strip.png|Aircraft information strip]]&lt;br /&gt;
&lt;br /&gt;
=== Displayed information ===&lt;br /&gt;
&lt;br /&gt;
* Left: Flight information&lt;br /&gt;
* Center: Navigation information&lt;br /&gt;
* Right: Navigation control&lt;br /&gt;
* Bottom: Custom navigation and setting buttons&lt;br /&gt;
&lt;br /&gt;
=== Actions ===&lt;br /&gt;
&lt;br /&gt;
Every change in the waypoints (position or/and altitude) must be confirmed with the dialog box that appears after the move. A modified waypoint remains animated on the map and the GCS continues to re-send the move request until confirmation is received from the aircraft.&lt;br /&gt;
When clicked, the '''Mark''' button places a mark on the map at the A/C position. A snapshot from the video plugin is associated to this mark and can be viewed by moving the mouse over the mark. A click on the mark opens a dialog box allowing to delete the mark.&lt;br /&gt;
A click on the colored bar at the top selects the corresponding A/C in the [[#notebook|Notebook]].&lt;br /&gt;
&lt;br /&gt;
== Map ==&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSmap.png|thumb|400px|Sample map showing the various features]]&lt;br /&gt;
&lt;br /&gt;
=== Display ===&lt;br /&gt;
&lt;br /&gt;
The map display contains the following information:&lt;br /&gt;
* The A/C track: it can be erased ''via'' the ''Clear track'' option from the A/C menu.&lt;br /&gt;
* The A/C label (in clear blue near the A/C) contains the name of the A/C (Plaster), it's altitude (218 m) and it's ground speed (11.99 m/s). This option default is off. It can be activated with the ''A/C label'' option from the A/C menu.&lt;br /&gt;
* The carrot (the orange triangle). This is the point the A/C is following during autonomous navigation.&lt;br /&gt;
* The waypoints defined in the flight plan (blue diamonds).&lt;br /&gt;
* The intended trajectory is shown in green (circling waypoint 2).&lt;br /&gt;
* The default background is black. [[#google_tiles|Google tiles]] or [[Maps|user defined maps]] can be loaded to provide navigation reference.&lt;br /&gt;
* The camera footprint (the grey polygon) is representative of the swath of land currently seen by the onboard camera. This option default is off. It can be activated with the ''Cam footprint'' option from the A/C menu.&lt;br /&gt;
* The WGS84 coordinates of the mouse cursor are displayed at the top right hand corner (43.462019   1.270474).&lt;br /&gt;
* A UTM kilometric grid can be added to the background ''via'' the ''UTM grid'' option from the ''Nav'' menu.&lt;br /&gt;
* The height Above Ground Level (AGL) displays the ground altitude of the mouse near the geographic position in the top right hand corner. The [http://srtm.usgs.gov/ SRTM] option must be enabled in the ''Nav'' menu. The height information comes from SRTM data files (&amp;lt;tt&amp;gt;.hgt.zip&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.hgt.bz2&amp;lt;/tt&amp;gt;) and must be copied to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory. They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/ http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/]. For example: http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N47E016.hgt.zip is for 47 deg North latitude and 16 deg East longitude.&lt;br /&gt;
&lt;br /&gt;
=== Navigation ===&lt;br /&gt;
&lt;br /&gt;
You can pan/zoom the map using the following:&lt;br /&gt;
* Pan with the blue arrows on the map or use the arrow keys on the keyboard&lt;br /&gt;
* zoom in/out with the mouse scroll wheel, the page up/page down buttons or the small up/down buttons at the top right hand corner where the zoom factor is displayed&lt;br /&gt;
* fit the map to the window, in order to see all the waypoints and A/C, with the '''f''' key or the ''Fit'' option from the ''Nav'' menu;&lt;br /&gt;
* center the map on an A/C with the ''Center A/C'' option from the corresponding A/C menu.&lt;br /&gt;
&lt;br /&gt;
=== Google Tiles ===&lt;br /&gt;
&lt;br /&gt;
The default black background can be automatically filled with calibrated satellite photo tiles from Google. If you download too much map data from Google you may be blocked for downloading further maps for 24 hours. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Maps]] page for more info.&lt;br /&gt;
&lt;br /&gt;
=== Waypoint Editing ===&lt;br /&gt;
&lt;br /&gt;
The properties of any waypoint in the currently loaded flight plan can be modified by two methods:&lt;br /&gt;
* Drag and drop the waypoints to a new location (a confirmation dialog will appear).&lt;br /&gt;
* A single left click on a waypoint opens a dialog box where you can edit the waypoint's coordinates and altitude.&lt;br /&gt;
&lt;br /&gt;
Waypoint edits are sent to the aircraft immediately upon confirmation in the dialog box.  The GCS will re-send the data and the waypoint will animate until the aircraft confirms receipt of the move request.  New waypoints cannot be added during flight.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on waypoints.&lt;br /&gt;
&lt;br /&gt;
== Notebook ==&lt;br /&gt;
&lt;br /&gt;
The notebook frame contains one page for each running aircraft. Each aircraft page is itself divided into subpages displaying telemetry data and giving access to the autopilot tuning parameters.&lt;br /&gt;
&lt;br /&gt;
Note that the colored tabs at the top of this section allow the user to select among multiple aircraft.&lt;br /&gt;
&lt;br /&gt;
=== Flight Plan ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSfp.png|Flight plan tree]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full tree of the flight plan is given in this page. The current block and the current stage are highlighted. A double-click on a block allows the operator to immediately switch navigation to this block.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Flight_Plans|Flight plans]] and [[Flight_Plan_Editor|Flight Plan Editor]] pages for more information on flight plans.&lt;br /&gt;
&lt;br /&gt;
=== Settings ===&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:GCSsettings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The setting page allows the operator to change variable values during flight. The layout of the page is generated from the &amp;lt;tt&amp;gt;dl_settings&amp;lt;/tt&amp;gt; section of the settings.xml file, one tab is associated to every section and sub-section.&lt;br /&gt;
&lt;br /&gt;
On each line is displayed (from left to right), the name of the variable, its current value (periodically sent by the A/C), a slider or radio buttons for user input, and commit/undo buttons.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[Telemetry#Settings|Telemetry]] page for more information on settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The save button of this tab opens the following popup which proposes to the user to save the current values in the airframe file (according to the &amp;lt;tt&amp;gt;param&amp;lt;/tt&amp;gt; attribute in the [[Telemetry#Settings|setttings]] configuration file). The values of the checked rows will be saved in the airframe file (or any other file) for further use. Units (e.g. deg or rad) are taken into account. '''It is recommended to backup the airframe file before overwriting it with this utility''' (even if time-stamped copy of the airframe file is actually automatically done).&lt;br /&gt;
&lt;br /&gt;
Symetrically, the Upload button of this dialog button will send all the checked values of the airframe file to the live aircraft.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:Save settings.png|Settings tab]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PFD ===&lt;br /&gt;
&lt;br /&gt;
[[Image:GCSpfd.png|Primary Flight Display]]&lt;br /&gt;
&lt;br /&gt;
The Primary Flight Display contains an artificial horizon and two scales displaying the current ground speed (left side) and the altitude (right side). Minimum and maximum speeds are shown under and above the speed scale. A click on the scale resets these values to the current speed value.&lt;br /&gt;
&lt;br /&gt;
=== GPS, Infrared, Wind ===&lt;br /&gt;
&lt;br /&gt;
The '''GPS''' page gives the list of satellites tracked by the receiver and their respective signal strengths in dB.&lt;br /&gt;
(35 is low, 45 is excellent) and if they are used to compute the fix (green: used, red:not used). This page may help to tune the position of the receiver on the aircraft relatively to other components (e.g. datalink and video transmitters).&lt;br /&gt;
&lt;br /&gt;
The '''Infrared''' page is only used for aircraft not equipped with the vertical infrared sensor. This page reports the required pre-flight calibration value as well as the evolution of the in-flight calibration correction factor (from hybridization with the GPS information).&lt;br /&gt;
&lt;br /&gt;
The '''Misc''' page displays the estimated wind velocity computed by the ground station during flight and relayed back to the aircraft.  Wind velocity is estimated by vector addition of the GPS-measured ground speed in many different directions during level flight.  This computation may soon be performed by the autopilot instead of the ground station.&lt;br /&gt;
&lt;br /&gt;
== Video Plugin ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-mplayer&amp;lt;/tt&amp;gt; option of GCS allows the user to display a video stream in this window.  The video window can also be exchanged with the map by clicking anywhere inside the frame or from the menu.&lt;br /&gt;
Use the following line in your [[Control_panel.xml|control panel]] to enable the video window.&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -mplayer rtsp://localhost:7070/video -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
Note that a &amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt; widget must be specified in the used layout:&lt;br /&gt;
 &amp;lt;tt&amp;gt; &amp;lt;widget size=&amp;quot;300&amp;quot; name=&amp;quot;plugin&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-plugin&amp;lt;/tt&amp;gt; option is another way to use the plugin widget: the X subwindow id is given to the provided command:&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;mplayer video_stream -wid &amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;path_to_ground_segment/cockpit/gcs -plugin &amp;quot;cvlc video_stream --drawable-xid=&amp;quot; -layout appropriate_layout.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;--vout-event=3&amp;lt;/tt&amp;gt; option can be used for vlc to disable mouse and keyboard events handling&lt;br /&gt;
&lt;br /&gt;
== Altitude graph widget ==&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:altgraph.png|400px|The GCS with the altitude graph]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An altitude graph can be displayed in the GCS by adding the widget ''altgraph'' in the layout configuration (See the [[GCS_Configuration|GCS configuration]] page). An example is provided in conf/gcs/alt.xml (launch GCS with the option -layout alt.xml).&lt;br /&gt;
&lt;br /&gt;
==Papgets==&lt;br /&gt;
Graphical objects can be added to 2D maps: text, rule, gauge, buttons, .... These objects are named ''papgets''. The following snapshot&lt;br /&gt;
shows an example with buttons (left side), gauges (lower left corner), text (upper right corner) and ruler (right side). This example&lt;br /&gt;
has been produced with a layout file provided in the distribution:&lt;br /&gt;
&lt;br /&gt;
 .../gcs -layout papgets.xml &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papgets.png|516px|A 2D map augmented with papgets]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Telemetry data report===&lt;br /&gt;
The easiest way to create a papget displaying telemetry data is to drag&amp;amp;drop a message field from the Messages window onto the 2D map of the GCS. The default rendering is then a string of text. Clicking on it allows the user to change its type (currently text, ruler or gauge) and some of its attributes (color, size, range for a gauge, format for a text ...). A papget can be moved by simply dragging it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[Image:papget_editor.png|Main characteristics of a papget can be dynamically edited]]&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Papgets can be saved in the layout of the GCS (from the Nav menu). The description is saved in an XML file (in &amp;lt;tt&amp;gt;conf/gcs/&amp;lt;/tt&amp;gt; folder) which can be manually edited:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;message_field&amp;quot; display=&amp;quot;gauge&amp;quot; x=&amp;quot;47&amp;quot; y=&amp;quot;414&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;field&amp;quot; value=&amp;quot;BAT:voltage&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;scale&amp;quot; value=&amp;quot;0.1&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;min&amp;quot; value=&amp;quot;0.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;max&amp;quot; value=&amp;quot;15.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;size&amp;quot; value=&amp;quot;50.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;text&amp;quot; value=&amp;quot;Bat(V)&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file is used later by giving it to the gcs process:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 .../gcs -layout my_fancy_papgets.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Buttons===&lt;br /&gt;
In the same way, user buttons from the strip can be dragged&amp;amp;dropped on the 2D map. However, they currently cannot be directly edited, and&lt;br /&gt;
attributes changes have to be done in the XML file. Two types of button are provided to jump to a block or to set a value:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;goto_block&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;300&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;block_name&amp;quot; value=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;home.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;variable_setting&amp;quot; display=&amp;quot;button&amp;quot; x=&amp;quot;10&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;variable&amp;quot; value=&amp;quot;launch&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;value&amp;quot; value=&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;property name=&amp;quot;icon&amp;quot; value=&amp;quot;launch.png&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Video===&lt;br /&gt;
A video stream can be rendered in a &amp;lt;tt&amp;gt;video_plugin&amp;lt;/tt&amp;gt; papget, using the mplayer player:&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;mplayer&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;video_feed&amp;quot; value=&amp;quot;my video source&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
or any video player which takes in option the X window id :&lt;br /&gt;
 &amp;lt;papget type=&amp;quot;video_plugin&amp;quot; display=&amp;quot;plugin&amp;quot; x=&amp;quot;300&amp;quot; y=&amp;quot;250&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;property name=&amp;quot;command&amp;quot; value=&amp;quot;cvlc video_source --drawable-xid=&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;width&amp;quot; VALUE=&amp;quot;320&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;property NAME=&amp;quot;height&amp;quot; VALUE=&amp;quot;240&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/papget&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Development===&lt;br /&gt;
Graphical appearence of papgets is defined in &amp;lt;tt&amp;gt;sw/lib/ocaml/papget_renderer.ml&amp;lt;/tt&amp;gt;. A renderer must implement the Papget_renderer.t class type interface (&amp;lt;tt&amp;gt;canvas_text&amp;lt;/tt&amp;gt; is probably the simpler example) and listed in the &amp;lt;tt&amp;gt;renderers&amp;lt;/tt&amp;gt; list to be available&lt;br /&gt;
in the edit popup box.&lt;br /&gt;
&lt;br /&gt;
The XML configuration is parsed in &amp;lt;tt&amp;gt;sw/ground_segment/cockpit/papgets.ml&amp;lt;/tt&amp;gt;: a new created papget identifier must listed here.&lt;br /&gt;
&lt;br /&gt;
== Alarms ==&lt;br /&gt;
&lt;br /&gt;
The alarm window displays a list of recent errors such as:&lt;br /&gt;
* Low battery warning&lt;br /&gt;
* Low altitude warning&lt;br /&gt;
* Autopilot mode changes (i.e. Manual, Auto2)&lt;br /&gt;
* Flight plan block changes&lt;br /&gt;
&lt;br /&gt;
== Configuration Options ==&lt;br /&gt;
The GCS is highly configurable and modules can be added, removed, or resized as needed. In addition to this the gcs has many command line options which can be used when launching the GCS&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[GCS_Configuration|GCS configuration]] page for details.&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>Nathan</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6402</id>
		<title>Flight Plans</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Flight_Plans&amp;diff=6402"/>
		<updated>2010-04-20T15:46:17Z</updated>

		<summary type="html">&lt;p&gt;Nathan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The formal description of the flight plan file is given in the [http://en.wikipedia.org/wiki/Document_Type_Definition '''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 document 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 [http://en.wikipedia.org/wiki/Document_Type_Definition 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 (a optional color can be specified).&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; (sector names must not contain spaces), 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; color=&amp;quot;red&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;
=== Includes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; is used to add some flight plan elements 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&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 prefix the blocks of the &amp;lt;tt&amp;gt;procedure&amp;lt;/tt&amp;gt;, the XML referenced file.&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 (e.g. attribute of a deroute instruction or of an exception) 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;includes&amp;gt;&lt;br /&gt;
   &amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/includes&amp;gt;&amp;lt;/tt&amp;gt;&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 [[GCS#Strips|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;
In the same way, a key shortcut can be specified:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;block key=&amp;quot;D&amp;quot; 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;
Modifiers are allowed, using the syntax of [http://library.gnome.org/devel/gtk/2.15/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse GTK accelerators].&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;circlehome&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-wing 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 (15 degrees) 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 UAS move 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 (15 degrees), 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 UAS follow another UAS (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;
Note that the &amp;lt;tt&amp;gt;traffic_info.c&amp;lt;/tt&amp;gt; file is required by this feature and the &amp;lt;tt&amp;gt;TRAFFIC_INFO&amp;lt;/tt&amp;gt; flag has to be set to enable it. Then, the following lines must be added in the airframe file:&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;ap.CFLAGS += -DTRAFFIC_INFO&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.srcs += traffic_info.c&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &amp;lt;tt&amp;gt;sim.CFLAGS += -DTRAFFIC_INFO&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 UAS's 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 UAS 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;
=== Immobilize Actuators === &lt;br /&gt;
&lt;br /&gt;
h_ctl setpoints variable are set by the h_ctl_attitude_loop() (from fw_h_ctl.c) loop) which can be disabled with the&lt;br /&gt;
h_ctl_disabled flag:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_aileron_setpoint&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_elevator_setpoint&amp;quot; value=&amp;quot;MAX_PPRZ/2&amp;quot;/&amp;gt;&lt;br /&gt;
 .... waiting for a condition ...&lt;br /&gt;
 &amp;lt;set var=&amp;quot;h_ctl_disabled&amp;quot; value=&amp;quot;false&amp;quot;/&amp;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, sectors 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, ...:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!ELEMENT procedure (param*,header?,waypoints?,sectors?,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 twice or 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;
* 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;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the corresponding procedure '''landing.xml''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;!DOCTYPE procedure SYSTEM &amp;quot;flight_plan.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;procedure&amp;gt;&lt;br /&gt;
  &amp;lt;waypoints&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;AF&amp;quot; x=&amp;quot;177.4&amp;quot; y=&amp;quot;45.1&amp;quot; alt=&amp;quot;30&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;TD&amp;quot; x=&amp;quot;28.8&amp;quot; y=&amp;quot;57.0&amp;quot; alt=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;waypoint name=&amp;quot;_BASELEG&amp;quot; x=&amp;quot;168.8&amp;quot; y=&amp;quot;-13.8&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/waypoints&amp;gt;&lt;br /&gt;
  &amp;lt;blocks&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;block name=&amp;quot;land&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;call fun=&amp;quot;nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;NavCircleCount() &amp;gt; 0.5&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;circle radius=&amp;quot;nav_radius&amp;quot; until=&amp;quot;And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-10), 10 &amp;gt; fabs(estimator_z - WaypointAlt(WP__BASELEG)))&amp;quot; wp=&amp;quot;_BASELEG&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/block&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;/blocks&amp;gt;&lt;br /&gt;
 &amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the name of procedure '''land''' block will be renamed into '''landing.land''':&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;deroute block=&amp;quot;landing.land&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
will jump to this procedure block.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a go-around condition in your landing procedure. You would write it&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;exception cond=&amp;quot;...&amp;quot; deroute=&amp;quot;go-around&amp;quot;/&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
then you must link this block exit with one of your block (e.g. &amp;lt;tt&amp;gt;Standby&amp;lt;/tt&amp;gt;). So you would include the procedure as follows:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;include name=&amp;quot;landing&amp;quot; procedure=&amp;quot;landing.xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;with from=&amp;quot;go-around&amp;quot; to=&amp;quot;Standby&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/include&amp;gt;&amp;lt;/tt&amp;gt;&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>Nathan</name></author>
	</entry>
</feed>