<?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=Loic+drumettaz</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=Loic+drumettaz"/>
	<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/wiki/Special:Contributions/Loic_drumettaz"/>
	<updated>2026-04-07T16:17:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Subsystem/ahrs&amp;diff=16189</id>
		<title>Subsystem/ahrs</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Subsystem/ahrs&amp;diff=16189"/>
		<updated>2013-10-18T16:15:37Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Complementary Quaternion (fixed point) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree style=&amp;quot;float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;&amp;quot; mode=pages hideprefix=always&amp;gt;Subsystems&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
== AHRS subsystem ==&lt;br /&gt;
The '''A'''ttitude and '''H'''eading '''R'''eference '''S'''ystem subsystem specifies which attitude estimation filter you are using.&lt;br /&gt;
&lt;br /&gt;
Currently possible AHRS subsystem types are&lt;br /&gt;
* ''[[Subsystem/ahrs#Complementary_Quaternion_.28fixed_point.29|int_cmpl_quat]]''&lt;br /&gt;
* ''[[Subsystem/ahrs#Complementary_Quaternion.2FRotation_Matrix_.28floating_point.29|float_cmpl]]''&lt;br /&gt;
* ''[[Subsystem/ahrs#DCM_.28floating_point.29|float_dcm]]''&lt;br /&gt;
* ''[[Subsystem/ahrs#Complementary_Euler_.28fixed_point.29|int_cmpl_euler]]''&lt;br /&gt;
* ''[[Subsystem/ahrs#Kalman_Filter_Quaternion|float_mlkf]]''&lt;br /&gt;
* ''[[Subsystem/ahrs#Infrared|infrared]]''&lt;br /&gt;
&lt;br /&gt;
e.g. for the latest complementary filter:&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;fixedwing or rotorcraft&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot; type=&amp;quot;int_cmpl_quat&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
&lt;br /&gt;
There is a test program ( sw/airborne/test/ahrs/compare_ahrs.py ) to compare different AHRS implementations on simple test cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:#FF0000&amp;quot;&amp;gt;'''Caution!'''&amp;lt;/span&amp;gt; '''Please also see [https://github.com/paparazzi/paparazzi/issues/93 issue 93] about proper handling of BODY_TO_IMU in all AHRS algorithms.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Complementary Quaternion (fixed point) ===&lt;br /&gt;
&lt;br /&gt;
To measure attitude angles, gyrometers measurements are integrated. The result of integration is accurate for short term, but gyro bias is accumulated, which results in long term errors (drift). &lt;br /&gt;
On the other hand, accelerometers can be used to measure angles directly, but they suffer from noise due to vibrations. The measurement is then only accurate when averaged over a long term. Also, accelerometers alone are unable to give accurate angles when the vehicle is accelerating. &lt;br /&gt;
Complementary filter takes advantage of both sensors, using a low-pass filter on accelerometer readings and high pass filter on gyrometers readings, to estimate attitude angles.&lt;br /&gt;
* Estimates the gyro bias.&lt;br /&gt;
* By default uses magnetometer for heading.&lt;br /&gt;
* In v3.9 and later:&lt;br /&gt;
** Compensation of centrifugal force via GPS speed (to fly in circles with a fixedwing).&amp;lt;br/&amp;gt;Enabled with AHRS_GRAVITY_UPDATE_COORDINATED_TURN which is set by default for a fixedwing firmware.&lt;br /&gt;
** GPS based heading estimation: https://github.com/paparazzi/paparazzi/issues/130&lt;br /&gt;
&lt;br /&gt;
Other flags of interest are:&lt;br /&gt;
*AHRS_PROPAGATE_LOW_PASS_RATES : apply a low pass filter on rotational velocity&lt;br /&gt;
*AHRS_MAG_UPDATE_ALL_AXES : '''available since v3.9''' use mag to also update roll/pitch and not only yaw (not recommended in most cases)&lt;br /&gt;
*AHRS_MAG_UPDATE_YAW_ONLY : '''removed in v3.9, default behaviour since''' only update the yaw instead of all axes &lt;br /&gt;
&lt;br /&gt;
* NEW in master branch:&lt;br /&gt;
** Proper scaling of corrections for 100Hz fixedwing or 500Hz for rotorcraft.&lt;br /&gt;
** Allow tuning of the accel and mag correction natural freqency and damping.&lt;br /&gt;
** Tunable gravity_heuristic_factor to reduce accelerometer influence only when the vehicle is accelerating (norm of ax,ay,az ~ 9,81 m/s2).&lt;br /&gt;
&lt;br /&gt;
* Flags of interest in master branch are:&lt;br /&gt;
** AHRS_PROPAGATE_FREQUENCY: IMU gyrometer reading frequency ( Hz, depend on IMU subsystem used and its configuration)&lt;br /&gt;
** AHRS_CORRECT_FREQUENCY: IMU accelerometer reading frequency (Hz)&lt;br /&gt;
** AHRS_MAG_CORRECT_FREQUENCY: IMU magnetometer reading frequency (Hz)&lt;br /&gt;
** AHRS_ACCEL_OMEGA: Complementary filter accelerometer cut-off frequency (rd/s). Default is 0.063 rd/s, the accelerometer reading are &amp;quot;averaged&amp;quot; over 100 seconds (= 2*pi/0.063) to correct gyro bias. Lower the cut-off frequency reduce the influence of accelerometers. WARNING: if ACCEL_OMEGA is set at a lower frequency, the gyro bias variations may not be corrected fast enough. As a result, the computed attitude may show significant static (or low frequency) errors. If accel_omega is set higher, the gyro bias will be well corrected and the static accuracy of the computed angle will be very good, but the dynamic error of the computed angle may be bad. &lt;br /&gt;
** AHRS_ACCEL_ZETA: Complementary filter accelerometer damping. Default is 0.9&lt;br /&gt;
** AHRS_MAG_OMEGA:Complementary filter magnetometer cut-off frequency (rd/s). Default is 0.04 rd/s. Acts the same as accelerometer but on the yaw axis.&lt;br /&gt;
** AHRS_MAG_ZETA:Complementary filter magnetometer damping. Default is 0.9&lt;br /&gt;
** AHRS_GRAVITY_HEURISTIC_FACTOR: Default is 30. Reduce accelerometer cut-off frequency when the vehicle is accelerating: norm(ax,ay,az) ~ 9,81 m/s2. WARNING: when the IMU is not well damped, the norm of accelerometers never equals to 9,81 m/s2. As a result, the GRAVITY_HEURISTIC_FACTOR will reduce the accelerometer bandwith even if the vehicle is not accelerating. Set AHRS_GRAVITY_HEURISTIC_FACTOR = 0 in case of vibrations.&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;fixedwing or rotorcraft&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot; type=&amp;quot;int_cmpl_quat&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;section name=&amp;quot;AHRS&amp;quot; prefix=&amp;quot;AHRS_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_X&amp;quot; value=&amp;quot; 0.51562740288882&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Y&amp;quot; value=&amp;quot;-0.05707735220832&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Z&amp;quot; value=&amp;quot; 0.85490967783446&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Also see the [[Subsystem/ahrs#Local_Magnetic_Field|Local Magnetic Field]] section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
No danger of [http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock], since quaternions are used.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for fixedwings. Needs GPS!&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for rotorcraft if the magnetometer is calibrated.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The arithmetic is [http://en.wikipedia.org/wiki/Fixed-point_arithmetic fixed point] and is thus suitable if the processor (on your board) has no [http://en.wikipedia.org/wiki/Floating_point_unit FPU].&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complementary Quaternion/Rotation Matrix (floating point) ===&lt;br /&gt;
* Estimates the gyro bias.&lt;br /&gt;
* By default uses magnetometer for heading.&lt;br /&gt;
* You need to define either ''AHRS_PROPAGATE_RMAT'' or ''AHRS_PROPAGATE_QUAT'' (select if the propagation is done in rotation matrix or quaternion representation).&lt;br /&gt;
* In v3.9 and later:&lt;br /&gt;
** Compensation of centrifugal force via GPS speed (to fly in circles with a fixedwing).&amp;lt;br/&amp;gt;Enabled with AHRS_GRAVITY_UPDATE_COORDINATED_TURN which is set by default for a fixedwing firmware.&lt;br /&gt;
** GPS based heading estimation: https://github.com/paparazzi/paparazzi/issues/130&lt;br /&gt;
Other flags of interest are:&lt;br /&gt;
* AHRS_PROPAGATE_LOW_PASS_RATES : apply a low pass filter on rotational velocity&lt;br /&gt;
* AHRS_MAG_UPDATE_ALL_AXES : use mag to also update roll/pitch and not only yaw (not recommended in most cases)&lt;br /&gt;
* AHRS_GRAVITY_UPDATE_NORM_HEURISTIC: lower the gain of the gravity update based on a acceleration norm heuristic (e.g. good for bungee takeoff)&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;rotorcraft or fixedwing&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot; type=&amp;quot;float_cmpl_rmat&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;define name=&amp;quot;AHRS_PROPAGATE_QUAT&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/subsystem&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;section name=&amp;quot;AHRS&amp;quot; prefix=&amp;quot;AHRS_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_X&amp;quot; value=&amp;quot; 0.51562740288882&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Y&amp;quot; value=&amp;quot;-0.05707735220832&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Z&amp;quot; value=&amp;quot; 0.85490967783446&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Also see the [[Subsystem/ahrs#Local_Magnetic_Field|Local Magnetic Field]] section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
No danger of [http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock], since quaternions are used.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for fixedwings. Needs GPS!&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for rotorcraft if the magnetometer is calibrated.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The arithmetic is [http://en.wikipedia.org/wiki/Floating_point floating point] and is thus '''not''' suitable if the processor (on your board) has '''no''' [http://en.wikipedia.org/wiki/Floating_point_unit FPU].&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== DCM (floating point) ===&lt;br /&gt;
* No direct gyro bias estimation, but also compensates for attitude drift.&lt;br /&gt;
* Uses GPS speed for heading.&lt;br /&gt;
* Compensation of centrifugal force via GPS speed (to fly in circles with a fixedwing).&lt;br /&gt;
* '''Careful, it doesn't handle all BODY_TO_IMU rotations (mounting positions) correctly!'''&lt;br /&gt;
&lt;br /&gt;
The algorithm was developed by William Premerlani and Paul Bizard. The theory can be found here: [[Media:DCMDraft2.pdf|DCMDraft2.pdf]]  The algorithm is also used in the AHRS systems of the AdruIMU.&lt;br /&gt;
The name DCM for the algorithm is really a misnomer, as that just means that the orientation is represented as a '''D'''irection'''C'''osine'''M'''atrix (rotation matrix). But since people already know it under that name, we kept it.&lt;br /&gt;
&lt;br /&gt;
Other flags of interest are:&lt;br /&gt;
*USE_MAGNETOMETER : use magnetometer to update yaw (untested ? The magnetometer code has to be improved, since ferromagnetic materials affect the magnetic field. This is currently not implemented.)&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;rotorcraft or fixedwing&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot; type=&amp;quot;float_dcm&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Possible danger of [http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock], since quaternions are not used.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for fixedwings with GPS.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Possibly suitable for rotorcraft if the magnetometer is used to determine the yaw and well calibrated, which seems to be questionable at the moment.&lt;br /&gt;
&amp;lt;= This information needs an update (see info above)!&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The arithmetic is [http://en.wikipedia.org/wiki/Floating_point floating point] and is thus '''not''' suitable if the processor (on your board) has '''no''' [http://en.wikipedia.org/wiki/Floating_point_unit FPU].&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Complementary Euler (fixed point) ===&lt;br /&gt;
* Not recommended for fixedwings, as this filter doesn't compensate for centrifugal force when flying turns.&lt;br /&gt;
* Magnetometer is always only used for heading (yaw).&lt;br /&gt;
* '''Does not handle the accel and mag updates correctly if BODY_TO_IMU is used for more than just adjustment by a few degrees.'''&lt;br /&gt;
* In general, rather use ''[[Subsystem/ahrs#Complementary_Quaternion_.28fixed_point.29|int_cmpl_quat]]''&lt;br /&gt;
&lt;br /&gt;
Optional flags/defines are:&lt;br /&gt;
* FACE_REINJ_1 : defaults to 1024&lt;br /&gt;
* IMU_MAG_OFFSET : offset to subtract from the heading calculated by the magnetometer&lt;br /&gt;
* USE_NOISE_FILTER : apply a simple filter on the rate and accel inputs&lt;br /&gt;
* USE_NOISE_CUT : cut rate input at 1 rad/s and accel input at 20m/s²&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;fixedwing or rotorcraft&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot; type=&amp;quot;int_cmpl_euler&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;FACE_REINJ_1&amp;quot; value=&amp;quot;1024&amp;quot;/&amp;gt; &amp;lt;!-- optional, defaults to 1024 --&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Possible danger of [http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock], since quaternions are not used.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Repeat from above: '''Not''' suitable for fixedwings.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for rotorcraft. The magnetometer is used to determine the yaw and needs to be calibrated.&lt;br /&gt;
Recommended replacement: [[Subsystem/ahrs#Complementary_Quaternion_.28fixed_point.29|int_cmpl_quat]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The arithmetic is [http://en.wikipedia.org/wiki/Fixed-point_arithmetic fixed point] and is thus suitable if the processor (on your board) has no [http://en.wikipedia.org/wiki/Floating_point_unit FPU].&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Kalman Filter Quaternion ===&lt;br /&gt;
Multiplicative Linearized [http://en.wikipedia.org/wiki/Kalman_filter Kalman Filter] in quaternion formulation.&lt;br /&gt;
* Available in v5.0 and later&lt;br /&gt;
* Estimates the gyro bias.&lt;br /&gt;
* Uses magnetometer to update all 3 axes.&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;rotorcraft&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot; type=&amp;quot;float_mlkf&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;section name=&amp;quot;AHRS&amp;quot; prefix=&amp;quot;AHRS_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_X&amp;quot; value=&amp;quot; 0.51562740288882&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Y&amp;quot; value=&amp;quot;-0.05707735220832&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Z&amp;quot; value=&amp;quot; 0.85490967783446&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Also see the [[Subsystem/ahrs#Local_Magnetic_Field|Local Magnetic Field]] section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
No danger of [http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock], since quaternions are used.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Not''' suitable for fixedwings!&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Suitable for rotorcraft. The magnetometer is used and needs to be well calibrated.&lt;br /&gt;
Estimates attitude and heading. Does not use GPS.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
The arithmetic is [http://en.wikipedia.org/wiki/Floating_point floating point] and is thus '''not''' suitable if the processor (on your board) has '''no''' [http://en.wikipedia.org/wiki/Floating_point_unit FPU].&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Infrared ===&lt;br /&gt;
For use with infrared sensors that detect aircraft attitude and the [[Module/infrared| infrared module]].&lt;br /&gt;
&lt;br /&gt;
== Local Magnetic Field ==&lt;br /&gt;
[[Image:Noaa_mag_data.png|thumb|right|200px|Screenshot of noaa page]]&lt;br /&gt;
[[Image:Normalised_mag_fields.png|thumb|right|200px|Screenshot of scilab page]]&lt;br /&gt;
'''This is needed if the magnetometer should be used !'''&lt;br /&gt;
&lt;br /&gt;
First the values of the local magnetic field are needed. They can be found at the states geolocical institute.&lt;br /&gt;
&lt;br /&gt;
Neede values are:&lt;br /&gt;
* north (x)&lt;br /&gt;
* east (y)&lt;br /&gt;
* vertical (z)&lt;br /&gt;
&lt;br /&gt;
USA [http://www.ngdc.noaa.gov/geomag-web/#igrfwmm ngdc.noaa.gov]&lt;br /&gt;
&lt;br /&gt;
AHRS needs these values as values of a unit vector (the lengh of a unit vector is 1), so they need to be converted.&lt;br /&gt;
&lt;br /&gt;
'''Convert them:'''&lt;br /&gt;
&lt;br /&gt;
Copy the north(x), east(y), and vertical(z) component values into scilab and execute &amp;quot;X/norm(X)&amp;quot; or run this in ipython:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
x = np.array([20875.1, 8480.2, -51279.8])&lt;br /&gt;
x/np.linalg.norm(x)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or enter this into [http://wolframalpha.com Wolfram Alpha]:&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
{20875.1, 8480.2, -51279.8}/Norm[{20875.1, 8480.2, -51279.8}]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
[[Category:User_Documentation]] [[Category:Subsystems]]&lt;br /&gt;
&lt;br /&gt;
Lastly, enter the results into your airframe file as H_X, H_Y, and H_Z:&lt;br /&gt;
&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;section name=&amp;quot;AHRS&amp;quot; prefix=&amp;quot;AHRS_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_X&amp;quot; value=&amp;quot;0.372692&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Y&amp;quot; value=&amp;quot;0.151401&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;H_Z&amp;quot; value=&amp;quot;-0.915521&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Fixedwing_Configuration&amp;diff=15613</id>
		<title>Fixedwing Configuration</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Fixedwing_Configuration&amp;diff=15613"/>
		<updated>2013-08-01T15:04:26Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Control loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;categorytree style=&amp;quot;float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;&amp;quot; mode=pages&amp;gt;Airframe_Configuration&amp;lt;/categorytree&amp;gt;&lt;br /&gt;
This page describes configuration options &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;specific to the fixedwing firmware&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; in the [[Airframe_Configuration|airframe file]].&lt;br /&gt;
== Firmware and Hardware definitions ==&lt;br /&gt;
&lt;br /&gt;
=== Select your Board ===&lt;br /&gt;
Make sure you use the &amp;lt;b&amp;gt;fixedwing [[Airframe_Configuration#Firmware|firmware]]&amp;lt;/b&amp;gt; and choose the correct board, e.g.&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;fixedwing&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;target name=&amp;quot;sim&amp;quot; 			board=&amp;quot;pc&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;target name=&amp;quot;ap&amp;quot; 			board=&amp;quot;twog_1.0&amp;quot;/&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Infrared Sensors ===&lt;br /&gt;
To use the IR sensors for attitude estimation add the infrared module and ahrs infrared subsystem:&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;fixedwing&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;target name=&amp;quot;ap&amp;quot;              board=&amp;quot;tiny_2.11&amp;quot;/&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;ahrs&amp;quot;     type=&amp;quot;infrared&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
  &amp;lt;modules&amp;gt;&lt;br /&gt;
    &amp;lt;load name=&amp;quot;infrared_adc.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/modules&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
See the [[Module/infrared|infrared module page]] for more details on configuration.&lt;br /&gt;
&lt;br /&gt;
=== Control loops ===&lt;br /&gt;
&lt;br /&gt;
The [[Control_Loops#Fixed-wing_autopilot|control loops]] can be divided in two largely independent groups : the vertical ones and the horizontal ones (standard files sw/airborne/firmwares/fixedwing/guidance/guidance_v.c and sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c ). Those loops can be commanded at different levels by either the R/C transmitter or the autonomous navigation routine.&lt;br /&gt;
&lt;br /&gt;
Just specify the appropriate subsystem in your firmware section. You can currently choose between no type (see below) and the types '''adaptive''', '''new''' and  '''[[EnergyControl|energy]]'''.&lt;br /&gt;
{{Box Code|conf/airframes/myplane.xml|&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;firmware name=&amp;quot;fixedwing&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;target name=&amp;quot;ap&amp;quot; 			board=&amp;quot;tiny_2.11&amp;quot;/&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;control&amp;quot;/&amp;gt;  &amp;lt;!--Standard fixed wing control loops --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Different control loop types can be enabled instead (Use only one) --&amp;gt;&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;control&amp;quot; type=&amp;quot;adaptive&amp;quot;/&amp;gt;  &amp;lt;!--fixed wing control loops with adaptive horizontal control, standard vertical control--&amp;gt;&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;control&amp;quot; type=&amp;quot;new&amp;quot;/&amp;gt;    &amp;lt;!--new fixed wing control loops with merged auto pitch and auto throttle, adaptive horizontal control--&amp;gt;&lt;br /&gt;
    &amp;lt;subsystem name=&amp;quot;control&amp;quot; type=&amp;quot;energy&amp;quot;/&amp;gt; &amp;lt;!-- Since v4.1.0 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/firmware&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== XML Parameters ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Manual ===&lt;br /&gt;
The &amp;lt;tt&amp;gt;rc_command&amp;lt;/tt&amp;gt; sections links the channels of the RC transmitter (defined in the [[Radio_Control|Radio Control]] file) to the &amp;lt;tt&amp;gt;commands&amp;lt;/tt&amp;gt; defined above:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;rc_commands&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;THROTTLE&amp;quot; value=&amp;quot;@THROTTLE&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;ROLL&amp;quot;     value=&amp;quot;@ROLL&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;PITCH&amp;quot;    value=&amp;quot;@PITCH&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/rc_commands&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example looks trivial since the channel values have the same name than the commands.&lt;br /&gt;
&lt;br /&gt;
=== RC commands in Auto ===&lt;br /&gt;
To control servos or other servo signal compatible devices by RC in Auto1 or Auto2, define them in the &amp;lt;auto_rc_commands&amp;gt; section.&lt;br /&gt;
If you have an airframe with a dedicated rudder (YAW channel) then it is still controllable in auto mode via RC. This is the default behavior and is equivalent to setting the YAW command in auto_rc_commands:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;auto_rc_commands&amp;gt;&lt;br /&gt;
   &amp;lt;set command=&amp;quot;YAW&amp;quot; value=&amp;quot;@YAW&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/auto_rc_commands&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To disable this behavior (meaning no RC control of the rudder in auto) define an empty auto_rc_commands section:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;auto_rc_commands&amp;gt;&lt;br /&gt;
 &amp;lt;/auto_rc_commands&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autopilot Only Commands ===&lt;br /&gt;
For certain missions it might be required to control servos (payload) from the autopilot (gcs) at all times (even during manual flight). These commands should not be in the &amp;lt;rc_commands&amp;gt; block but in the special &amp;lt;ap_only_commands&amp;gt; block. This allows for instance the pantilt operator to keep working when in manual flight, or safety logic to automatically close cameras below a certain altitude during manual landings.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;ap_only_commands&amp;gt;&lt;br /&gt;
   &amp;lt;copy command=&amp;quot;PAN&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;copy command=&amp;quot;TILT&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;copy command=&amp;quot;SHOOT&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/ap_only_commands&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Auto1 ===&lt;br /&gt;
The next section, named &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;AUTO1&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;, gives the maximum roll and pitch (in radians) allowed for the augmented stability mode.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;AUTO1&amp;quot; prefix=&amp;quot;AUTO1_&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_ROLL&amp;quot; value=&amp;quot;35&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;MAX_PITCH&amp;quot; value=&amp;quot;5&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''NOTE'': [[Units|automatic unit conversion]] using &amp;lt;tt&amp;gt;unit=&amp;quot;deg&amp;quot;&amp;lt;/tt&amp;gt; is supported since v3.9, if you have an older version set it in radians or using &amp;lt;tt&amp;gt;value=&amp;quot;RadOfDeg(35)&amp;quot;&amp;lt;/tt&amp;gt;&lt;br /&gt;
=== Infrared === &lt;br /&gt;
The &amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;INFRARED&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt; section describes the configuration of the infrared sensors. For additional configuration to change the defaults, see the [[Module/infrared|infrared module page]].&lt;br /&gt;
&lt;br /&gt;
The only mandatory definitions are the sensor neutral readings and how the IR sensors are mounted.&lt;br /&gt;
&lt;br /&gt;
The electronic neutral of the sensors (a sensor here is a '''pair''' of thermopiles). A perfect sensor should give 512 if it measures the same value on both sides.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;INFRARED&amp;quot; prefix=&amp;quot;IR_&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_IR1_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_IR2_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;ADC_TOP_NEUTRAL&amp;quot; value=&amp;quot;512&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;HORIZ_SENSOR_ALIGNED&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
These neutrals are tuned with the &amp;quot;cupboard test&amp;quot;: Put the sensor in a close box (a cupboard) and read the values of the IR_SENSORS message (ir1, ir2 and vertical). Set the neutrals (they are subtracted from the measurement) to get null values. E.g. if you read 5 for the ir1 value with ADC_IR1_NEUTRAL equal to 512, change the latter to 517.&lt;br /&gt;
&lt;br /&gt;
In the example above the horizontal sensor is connected to the airframe in ''aligned'' orientation. The other possibility is ''tilted''.&lt;br /&gt;
Define either&lt;br /&gt;
* '''HORIZ_SENSOR_ALIGNED''': ir1 is along the lateral axis (The axis that passes through the plane from wingtip to wingtip) and ir2 along the longitudinal one.&lt;br /&gt;
or&lt;br /&gt;
* '''HORIZ_SENSOR_TILTED''': the sensors are tilted by 45 degrees; ir1 is along rear-left -- front-right, and ir2 along rear-right -- front-left.&lt;br /&gt;
If the airframe construction allows choose an aligned sensor orientation since this gives the best stabilization response results.&lt;br /&gt;
&lt;br /&gt;
=== Gyro ===&lt;br /&gt;
'''This section only applies to versions prior to v3.9 when using a gyro with IR sensors.'''&lt;br /&gt;
Defines the type of gyro installed, each axis neutral, and any required temperature compensation. If the gyro has two axes, the pitch neutral is defined as well. Many gyros output their internal temperature and require a temperature-dependent linear correction be made to the neutral value.  No correction is done for the temperature in this example.(&amp;lt;b&amp;gt;&amp;lt;tt&amp;gt;ADC_TEMP_SLOPE=0&amp;lt;/tt&amp;gt;&amp;lt;/b&amp;gt;).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;GYRO&amp;quot; prefix=&amp;quot;GYRO_&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_ROLL_COEFF&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ROLL_NEUTRAL&amp;quot; value=&amp;quot;500&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_TEMP_NEUTRAL&amp;quot; value=&amp;quot;476&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ADC_TEMP_SLOPE&amp;quot; value=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Horizontal Control ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;HORIZONTAL CONTROL&amp;quot; prefix=&amp;quot;H_CTL_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;COURSE_PGAIN&amp;quot; value=&amp;quot;0.4&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_MAX_SETPOINT&amp;quot; value=&amp;quot;20&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_ATTITUDE_GAIN&amp;quot; value=&amp;quot;7500.&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ROLL_RATE_GAIN&amp;quot; value=&amp;quot;1500&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;PITCH_PGAIN&amp;quot; value=&amp;quot;8000.&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ELEVATOR_OF_ROLL&amp;quot; value=&amp;quot;1250&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The outer loop acts on the route. It will produce a roll command from a course setpoint and a course measurement. The COURSE_PGAIN parameter is the factor multiplied by the course error (in radian) to get a roll setpoint (in radian). So if the plane is expected to go north (course=0) and is actually flying to 57 degrees (course=1 radian, i.e. ENE), with a gain of '''0.4''', a roll of -0.4 (-23 degrees) will be set for the lower control loop.&lt;br /&gt;
&lt;br /&gt;
The ROLL_ATTITUDE_GAIN is used to compute a ROLL command from the roll error (setpoint minus measurement). If a gyro in installed, the ROLL_RATE_GAIN to keep a null roll rate. So these two gains provide a P-D controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT''': Previous to v3.9 some of the gains need to be set with a '''negative sign''': ''COURSE_PGAIN'', ''ROLL_ATTITUDE_GAIN'', ''ROLL_RATE_GAIN'', ''PITCH_PGAIN''&lt;br /&gt;
&lt;br /&gt;
''NOTE'': [[Units|automatic unit conversion]] using &amp;lt;tt&amp;gt;unit=&amp;quot;deg&amp;quot;&amp;lt;/tt&amp;gt; is supported since v3.9, if you have an older version set it in radians or using &amp;lt;tt&amp;gt;value=&amp;quot;RadOfDeg(20)&amp;quot;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[Control_Loops#Fixed-wing_autopilot|graphical representation of the control loops]] can help you to visualize the effect of each gain.&lt;br /&gt;
&lt;br /&gt;
===Vertical Control===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;section name=&amp;quot;VERTICAL CONTROL&amp;quot; prefix=&amp;quot;V_CTL_&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- outer loop proportional gain --&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ALTITUDE_PGAIN&amp;quot; value=&amp;quot;0.1&amp;quot; unit=&amp;quot;(m/s)/m&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;!-- outer loop saturation --&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;ALTITUDE_MAX_CLIMB&amp;quot; value=&amp;quot;3.&amp;quot; unit=&amp;quot;m/s&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
These lines are associated with vertical control loops contained in sw/airborne/firmwares/fixedwing/guidance/guidance_v.c.  These are outer loop parameters that calculate a desired climb rate based on altitude error. Here, if the altitude error is 10m, the climb setpoint will be set to 1m/s. ALTITUDE_MAX_CLIMB is a bounded value (in m/s) so that the outer loop does not calculate too large of a climb rate&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE&amp;quot; value=&amp;quot;0.65&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_MIN_CRUISE_THROTTLE&amp;quot; value=&amp;quot;.4&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_MAX_CRUISE_THROTTLE&amp;quot; value=&amp;quot;1&amp;quot; unit=&amp;quot;%&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_LOITER_TRIM&amp;quot; value=&amp;quot;1000&amp;quot; unit=&amp;quot;pprz_t&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_DASH_TRIM&amp;quot; value=&amp;quot;-2500&amp;quot; unit=&amp;quot;pprz_t&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT&amp;quot; value=&amp;quot;0.15&amp;quot; unit=&amp;quot;%/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_PGAIN&amp;quot; value=&amp;quot;0.008&amp;quot; unit=&amp;quot;%/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_IGAIN&amp;quot; value=&amp;quot;0.25&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_THROTTLE_PITCH_OF_VZ_PGAIN&amp;quot; value=&amp;quot;0.35&amp;quot; unit=&amp;quot;rad/(m/s)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These lines are associated with vertical rate control loops contained in sw/airborne/firmwares/fixedwing/guidance/guidance_v.c and are used by default in most cases.  The default vertical control law is for the vertical rate to be managed by a combination of throttle and pitch.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_PGAIN&amp;quot; value=&amp;quot;0.1&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_IGAIN&amp;quot; value=&amp;quot;0.025&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_MAX_PITCH&amp;quot; value=&amp;quot;30&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;define name=&amp;quot;AUTO_PITCH_MIN_PITCH&amp;quot; value=&amp;quot;30&amp;quot; unit=&amp;quot;deg&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
These lines are associated with vertical control loops contained in sw/airborne/firmwares/fixedwing/guidance/guidance_v.c but are not used in default. The non-default vertical control law is for the vertical rate to be managed by the pitch.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;define name=&amp;quot;THROTTLE_SLEW_LIMITER&amp;quot; value=&amp;quot;2&amp;quot; unit=&amp;quot;s&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
THROTTLE_SLEW_LIMITER is the required time is seconds to change throttle from 0% to 100%.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT''': Previous to v3.9 some of the gains need to be set with a '''negative sign''': ''ALTITUDE_PGAIN'', ''AUTO_THROTTLE_PGAIN'', ''AUTO_PITCH_PGAIN'', ''''&lt;br /&gt;
&lt;br /&gt;
''NOTE'': [[Units|automatic unit conversion]] using &amp;lt;tt&amp;gt;unit=&amp;quot;deg&amp;quot;&amp;lt;/tt&amp;gt; is supported since v3.9, if you have an older version set it in radians or using &amp;lt;tt&amp;gt;value=&amp;quot;RadOfDeg(20)&amp;quot;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[Control_Loops#Fixed-wing_autopilot|graphical representation of the control loops]] can help you to visualize the effect of each gain.&lt;br /&gt;
&lt;br /&gt;
=== Misc ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;MISC&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;NOMINAL_AIRSPEED&amp;quot; value =&amp;quot;12.&amp;quot; unit=&amp;quot;m/s&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CARROT&amp;quot; value=&amp;quot;5.&amp;quot; unit=&amp;quot;s&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;KILL_MODE_DISTANCE&amp;quot; value=&amp;quot;(1.5*MAX_DIST_FROM_HOME)&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;CONTROL_RATE&amp;quot; value=&amp;quot;60&amp;quot; unit=&amp;quot;Hz&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* The &amp;quot;NOMINAL_AIRSPEED&amp;quot; is mainly used in the simulator.&lt;br /&gt;
* &amp;quot;CARROT&amp;quot; gives the distance (in seconds, so ground speed is taken into account) between the carrot and the aircraft.&lt;br /&gt;
* &amp;quot;KILL_MODE_DISTANCE&amp;quot; is the threshold distance to switch the autopilot into KILL mode (defined descent with no throttle)&lt;br /&gt;
* &amp;quot;CONTROL_RATE&amp;quot; is the rate of the low level control loops in Hertz (60 or 20).&lt;br /&gt;
&lt;br /&gt;
=== Simu ===&lt;br /&gt;
Values from this section can be used to tweak the software in the loop (SITL) simulation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;section name=&amp;quot;SIMU&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;WEIGHT&amp;quot; value =&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;YAW_RESPONSE_FACTOR&amp;quot; value =&amp;quot;1.&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;define name=&amp;quot;ROLL_RESPONSE_FACTOR&amp;quot; value =&amp;quot;15.&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* &amp;quot;YAW_RESPONSE_FACTOR&amp;quot; adapts the aircraft's turn rate corresponding to a bank angle; a larger value increases the turn radius&lt;br /&gt;
* &amp;quot;ROLL_RESPONSE_FACTOR&amp;quot; is basically your aileron efficiency; a higher value increases roll agility&lt;br /&gt;
&lt;br /&gt;
If you want to use JSBSim as SITL simulator, you have to make some definitions in this section as well; see [[Simulation#JSBSim|here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:User_Documentation]] [[Category:Airframe_Configuration]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15592</id>
		<title>Maps</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15592"/>
		<updated>2013-07-26T12:56:46Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Intoduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
== Satellite photo map tiles ==&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can automatically download satellite photo tiles from Google, MS Maps and Openstreetmap for the area defined in the flight plan. The tiles of Openstreetmap are not real photos (YET!) but rendered tiles. These tiles are fully calibrated and automatically stitched together by the GCS. To load the map tiles simply select Maps-&amp;gt;Google Maps Fill (Ctrl-G) from the GCS pulldown menu and the tiles corresponding to the GPS coordinates defined in the [[Flight_Plans|flight plan]] will begin downloading. Pan or zoom the map and re-fill to get more tiles. Tiles are saved in &amp;lt;tt&amp;gt;var/maps/&amp;lt;/tt&amp;gt; for off-line use.  Checking ''Maps-&amp;gt;Google Maps Auto'' will automatically fill the map with tiles while paning and zooming. There is also a command line option to start the GCS with the Auto-fill feature enabled: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;path_to_paparazzi&amp;gt;/sw/ground_segment/cockpit/gcs -maps_fill&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In v5.0 and master you can also further specify a higher maps zoom level by adding the -maps_zoom &amp;lt;level&amp;gt; option to the gcs invocation.&lt;br /&gt;
The default &amp;lt;level&amp;gt; is 18, you can go up to 22. For example: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;path_to_paparazzi&amp;gt;/sw/ground_segment/cockpit/gcs -maps_zoom 20 -maps_fill -srtm &amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(see [http://paparazzi.enac.fr/wiki/Maps#Elevation_Data Elevation Data] below for the -srtm option)&lt;br /&gt;
&lt;br /&gt;
If you are behind a firewall, you can use a proxy by setting the &amp;lt;tt&amp;gt;http_proxy&amp;lt;/tt&amp;gt; environment variable:&lt;br /&gt;
 &amp;lt;tt&amp;gt;export http_proxy=&amp;lt;nowiki&amp;gt;http://squid:3128&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to create a calibrated map from the Google tiles, so that upon launching the map2d program a map of the area is shown, go ahead and put into view the area you wish to make the map.  While holding left click, drag the area for the map.  A red border will appear around the area.  Next click on Maps-&amp;gt;Map of Region or Maps-&amp;gt;Map of Google Tiles. While the former will save the visible region (with waypoints, tracks, ...if any, under the current zoom), the latter will stich together the original Google tiles covering the selected region.  Save the xml file to the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; directory.  This program will automatically screenshot the image and take reference location points and calibrate the map using them. You will be able to load this map in your next sessions (with the Maps-&amp;gt;Load menu or with the &amp;lt;tt&amp;gt;-m&amp;lt;/tt&amp;gt; option you can add in the your section of &amp;lt;tt&amp;gt;control_panel.xml&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Example of map created from google tiles, &amp;lt;tt&amp;gt;gifhorn.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;gifhorn.jpg&amp;quot; projection=&amp;quot;Mercator&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; geo=&amp;quot;WGS84 52.527982 10.452157&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;1965&amp;quot; y=&amp;quot;1284&amp;quot; geo=&amp;quot;WGS84 52.519595 10.473248&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GCS currently supports three projections (UTM, Mercator and LambertIIe). If you try to place a calibrated map for one projection (e.g. UTM) on another projection plot (e.g. Mercator) the image will be rotated and skewed and a warning will be shown during loading.&lt;br /&gt;
&lt;br /&gt;
=== Google Restrictions ===&lt;br /&gt;
&lt;br /&gt;
==== Corrupted Maptiles ====&lt;br /&gt;
&lt;br /&gt;
Sometimes wrong Google maptiles are downloaded due to the beginning of the bandwidth restriction enforced by Google. If this happen and you do not wan to re-download all of you tiles, close the GCS type the following in a command prompt:&lt;br /&gt;
&lt;br /&gt;
 $  cd ~/paparazzi/var/maps/&lt;br /&gt;
&lt;br /&gt;
or maybe some other directory where you installed the Paparazzi software, then type&lt;br /&gt;
 &lt;br /&gt;
 $ rm ??????????????.jpg&lt;br /&gt;
&lt;br /&gt;
That are indeed 14 questionmarks, better cut and paste the line. This leaves the good resolution images and deletes the bad ones. It would be even better if you could fix the GCS sourcecode and the remove the text of this workaround here from the Wiki.&lt;br /&gt;
&lt;br /&gt;
==== No more Maptiles ====&lt;br /&gt;
&lt;br /&gt;
After downloading a lot of maptiles from google you might experience problems getting more due to restrictions enforced by Google. For flight plans covering a large area OSM can be better, as OSM has no such restrictions.&lt;br /&gt;
&lt;br /&gt;
== Manually Defined Maps ==&lt;br /&gt;
&lt;br /&gt;
Maps are used in the groundstation to give geographical reference to the flight area. These ''calibrated'' maps are described with two files: the image itself (.png, .jpg or .gif) and an xml file containing geographic references of some points of the bitmap.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;tt&amp;gt;muret_UTM.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;muret_UTM.gif&amp;quot; projection=&amp;quot;UTM&amp;quot; scale=&amp;quot;2.5&amp;quot; approx_ground_altitude=&amp;quot;185&amp;quot; utm_zone=&amp;quot;31&amp;quot; opacity=&amp;quot;100&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4815000&amp;quot; geo=&amp;quot;WGS84 43.474630 1.256652&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4813000&amp;quot; geo=&amp;quot;WGS84 43.456629 1.257169&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;800&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;361000&amp;quot; utm_y=&amp;quot;4813000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These maps can be created from any image (many are available from various websites). Save the file as a jpeg and place it in the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; folder.  From the Flight Plan Editor select Maps-&amp;gt;Calibrate. After loading the image (which is displayed), you will have to choose at least two reference points, name them with their geographic coordinates (in WGS84 or UTM) and save. The created map (an XML file describing the geographical position of your original bitmap) can then be loaded (Maps-&amp;gt;Load).&lt;br /&gt;
&lt;br /&gt;
== Elevation Data ==&lt;br /&gt;
&lt;br /&gt;
=== Intoduction ===&lt;br /&gt;
The Shuttle Radar Topography Mission (SRTM) obtained elevation data on a near-global scale to generate the most complete high-resolution digital topographic database of Earth. SRTM consisted of a specially modified radar system that flew onboard the Space Shuttle Endeavour during an 11-day mission in February of 2000.&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can use this elevation data. The [http://srtm.usgs.gov/ SRTM] option from the ''Nav'' menu in the GCS displays the ground altitude of the mouse in the top right hand corner.&lt;br /&gt;
&lt;br /&gt;
To start the GCS with the ground altitude feature enabled, the command line option is -srtm:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;path_to_paparazzi&amp;gt;/sw/ground_segment/cockpit/gcs -srtm&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting and using SRTM Data ===&lt;br /&gt;
The SRTM data files can be downloaded using the make process. The only thing that is required is to know the name of the file that is needed. If you use the GCS, it will present a dialog box with the name of the required file. However it is better to download the data before you leave to test your aircraft in the field. &lt;br /&gt;
&lt;br /&gt;
To illustrate the process. If you needed the file &amp;lt;tt&amp;gt;N47E016.hgt.zip&amp;lt;/tt&amp;gt; (47 deg North latitude, 16 deg East longitude) then you could run the following make command:&lt;br /&gt;
&amp;lt;pre&amp;gt;make N47E016.hgt.zip&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can download the 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;) to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3 http://dds.cr.usgs.gov/srtm/version2_1/SRTM3].&lt;br /&gt;
&lt;br /&gt;
Or get some new data here http://www.viewfinderpanoramas.org/dem3.html&lt;br /&gt;
&lt;br /&gt;
=== Better and more ===&lt;br /&gt;
&lt;br /&gt;
Some areas, for example high latitudes, are not well covered by official NASA SRTM data. Some additional data and data with higher accuracy has been compiled in the same format: [http://www.viewfinderpanoramas.org/dem3.html http://www.viewfinderpanoramas.org/dem3.html].&lt;br /&gt;
&lt;br /&gt;
==== Bad SRTM data issue ====&lt;br /&gt;
&lt;br /&gt;
You can have bad luck with SRTM data set quality. Sometimes there is a strong discontinuity in the SRTM model at a launching point location you want to use, for real and in the sim. If you load the SRTM model in the GCS (from the Nav menu), the ground altitude of the location of the pointer is displayed on the top right. You can read 131m on your HOME location, and 146m immediately to the north of this point. On takeoff, the simulator gets immediately an altitude of -15m and considers it as a '''crash'''. &lt;br /&gt;
&lt;br /&gt;
The simplest way to avoid this is to disable the ground detection in the simulator: &lt;br /&gt;
&lt;br /&gt;
# stop the Simulator agent, &lt;br /&gt;
# add the &amp;quot;-noground&amp;quot; option to the command&lt;br /&gt;
# and restart. &lt;br /&gt;
&lt;br /&gt;
You will read a -15m AGL during the first seconds but it won't stop. The current threshold for crash detection is -3m (sw/simulator/flightModel.ml:178 an awful numeric constant in the middle of the code, sad but true.&lt;br /&gt;
&lt;br /&gt;
=== Automating script ===&lt;br /&gt;
If you want to get a specific range of elevation data, for example if you test your UAS in various areas on a continent, use the script below. Change the values for the ranges you need.&lt;br /&gt;
&lt;br /&gt;
 $ nano grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Then copy via selecting the script below then CTRL+C and then use CTRL+SHIFT+V to paste it into the nano editor. Then use CTRL+X to save the file. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Use freely, OpenUAS 2010&lt;br /&gt;
 # Script to grab ranges of elevation data, very handy if you test your UAS in various areas in a continent ;)&lt;br /&gt;
 # Change, add or delete values in 49 50 51 and 003 004 005 006 007 008 009 to get the ranges you need.&lt;br /&gt;
 i=1&lt;br /&gt;
 for lat in 49 50 51&lt;br /&gt;
 do&lt;br /&gt;
   j=1&lt;br /&gt;
   for long in 003 004 005 006 007 008 009&lt;br /&gt;
   do&lt;br /&gt;
     let &amp;quot;j+=1&amp;quot;&lt;br /&gt;
      wget -N --waitretry=40 &amp;quot;http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N&amp;quot;$lat&amp;quot;E&amp;quot;$long&amp;quot;.hgt.zip&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   let &amp;quot;i+=1&amp;quot; &lt;br /&gt;
 done               &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
then to be able to simply run the script &lt;br /&gt;
&lt;br /&gt;
 $ chmod u+x grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Finally you can run the script, use and wait a while...&lt;br /&gt;
&lt;br /&gt;
 $ ./grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:User_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15591</id>
		<title>Maps</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15591"/>
		<updated>2013-07-26T12:53:46Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Satellite photo map tiles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
== Satellite photo map tiles ==&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can automatically download satellite photo tiles from Google, MS Maps and Openstreetmap for the area defined in the flight plan. The tiles of Openstreetmap are not real photos (YET!) but rendered tiles. These tiles are fully calibrated and automatically stitched together by the GCS. To load the map tiles simply select Maps-&amp;gt;Google Maps Fill (Ctrl-G) from the GCS pulldown menu and the tiles corresponding to the GPS coordinates defined in the [[Flight_Plans|flight plan]] will begin downloading. Pan or zoom the map and re-fill to get more tiles. Tiles are saved in &amp;lt;tt&amp;gt;var/maps/&amp;lt;/tt&amp;gt; for off-line use.  Checking ''Maps-&amp;gt;Google Maps Auto'' will automatically fill the map with tiles while paning and zooming. There is also a command line option to start the GCS with the Auto-fill feature enabled: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;path_to_paparazzi&amp;gt;/sw/ground_segment/cockpit/gcs -maps_fill&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In v5.0 and master you can also further specify a higher maps zoom level by adding the -maps_zoom &amp;lt;level&amp;gt; option to the gcs invocation.&lt;br /&gt;
The default &amp;lt;level&amp;gt; is 18, you can go up to 22. For example: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;path_to_paparazzi&amp;gt;/sw/ground_segment/cockpit/gcs -maps_zoom 20 -maps_fill -srtm &amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(see [http://paparazzi.enac.fr/wiki/Maps#Elevation_Data Elevation Data] below for the -srtm option)&lt;br /&gt;
&lt;br /&gt;
If you are behind a firewall, you can use a proxy by setting the &amp;lt;tt&amp;gt;http_proxy&amp;lt;/tt&amp;gt; environment variable:&lt;br /&gt;
 &amp;lt;tt&amp;gt;export http_proxy=&amp;lt;nowiki&amp;gt;http://squid:3128&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to create a calibrated map from the Google tiles, so that upon launching the map2d program a map of the area is shown, go ahead and put into view the area you wish to make the map.  While holding left click, drag the area for the map.  A red border will appear around the area.  Next click on Maps-&amp;gt;Map of Region or Maps-&amp;gt;Map of Google Tiles. While the former will save the visible region (with waypoints, tracks, ...if any, under the current zoom), the latter will stich together the original Google tiles covering the selected region.  Save the xml file to the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; directory.  This program will automatically screenshot the image and take reference location points and calibrate the map using them. You will be able to load this map in your next sessions (with the Maps-&amp;gt;Load menu or with the &amp;lt;tt&amp;gt;-m&amp;lt;/tt&amp;gt; option you can add in the your section of &amp;lt;tt&amp;gt;control_panel.xml&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Example of map created from google tiles, &amp;lt;tt&amp;gt;gifhorn.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;gifhorn.jpg&amp;quot; projection=&amp;quot;Mercator&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; geo=&amp;quot;WGS84 52.527982 10.452157&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;1965&amp;quot; y=&amp;quot;1284&amp;quot; geo=&amp;quot;WGS84 52.519595 10.473248&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GCS currently supports three projections (UTM, Mercator and LambertIIe). If you try to place a calibrated map for one projection (e.g. UTM) on another projection plot (e.g. Mercator) the image will be rotated and skewed and a warning will be shown during loading.&lt;br /&gt;
&lt;br /&gt;
=== Google Restrictions ===&lt;br /&gt;
&lt;br /&gt;
==== Corrupted Maptiles ====&lt;br /&gt;
&lt;br /&gt;
Sometimes wrong Google maptiles are downloaded due to the beginning of the bandwidth restriction enforced by Google. If this happen and you do not wan to re-download all of you tiles, close the GCS type the following in a command prompt:&lt;br /&gt;
&lt;br /&gt;
 $  cd ~/paparazzi/var/maps/&lt;br /&gt;
&lt;br /&gt;
or maybe some other directory where you installed the Paparazzi software, then type&lt;br /&gt;
 &lt;br /&gt;
 $ rm ??????????????.jpg&lt;br /&gt;
&lt;br /&gt;
That are indeed 14 questionmarks, better cut and paste the line. This leaves the good resolution images and deletes the bad ones. It would be even better if you could fix the GCS sourcecode and the remove the text of this workaround here from the Wiki.&lt;br /&gt;
&lt;br /&gt;
==== No more Maptiles ====&lt;br /&gt;
&lt;br /&gt;
After downloading a lot of maptiles from google you might experience problems getting more due to restrictions enforced by Google. For flight plans covering a large area OSM can be better, as OSM has no such restrictions.&lt;br /&gt;
&lt;br /&gt;
== Manually Defined Maps ==&lt;br /&gt;
&lt;br /&gt;
Maps are used in the groundstation to give geographical reference to the flight area. These ''calibrated'' maps are described with two files: the image itself (.png, .jpg or .gif) and an xml file containing geographic references of some points of the bitmap.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;tt&amp;gt;muret_UTM.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;muret_UTM.gif&amp;quot; projection=&amp;quot;UTM&amp;quot; scale=&amp;quot;2.5&amp;quot; approx_ground_altitude=&amp;quot;185&amp;quot; utm_zone=&amp;quot;31&amp;quot; opacity=&amp;quot;100&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4815000&amp;quot; geo=&amp;quot;WGS84 43.474630 1.256652&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4813000&amp;quot; geo=&amp;quot;WGS84 43.456629 1.257169&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;800&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;361000&amp;quot; utm_y=&amp;quot;4813000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These maps can be created from any image (many are available from various websites). Save the file as a jpeg and place it in the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; folder.  From the Flight Plan Editor select Maps-&amp;gt;Calibrate. After loading the image (which is displayed), you will have to choose at least two reference points, name them with their geographic coordinates (in WGS84 or UTM) and save. The created map (an XML file describing the geographical position of your original bitmap) can then be loaded (Maps-&amp;gt;Load).&lt;br /&gt;
&lt;br /&gt;
== Elevation Data ==&lt;br /&gt;
&lt;br /&gt;
=== Intoduction ===&lt;br /&gt;
The Shuttle Radar Topography Mission (SRTM) obtained elevation data on a near-global scale to generate the most complete high-resolution digital topographic database of Earth. SRTM consisted of a specially modified radar system that flew onboard the Space Shuttle Endeavour during an 11-day mission in February of 2000.&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can use this elevation data. The [http://srtm.usgs.gov/ SRTM] option from the ''Nav'' menu in the GCS displays the ground altitude of the mouse in the top right hand corner.&lt;br /&gt;
&lt;br /&gt;
To start the GCS with the ground altitude feature enabled, the command line option is:&lt;br /&gt;
sw/ground_segment/cockpit/gcs -srtm&lt;br /&gt;
&lt;br /&gt;
=== Getting and using SRTM Data ===&lt;br /&gt;
The SRTM data files can be downloaded using the make process. The only thing that is required is to know the name of the file that is needed. If you use the GCS, it will present a dialog box with the name of the required file. However it is better to download the data before you leave to test your aircraft in the field. &lt;br /&gt;
&lt;br /&gt;
To illustrate the process. If you needed the file &amp;lt;tt&amp;gt;N47E016.hgt.zip&amp;lt;/tt&amp;gt; (47 deg North latitude, 16 deg East longitude) then you could run the following make command:&lt;br /&gt;
&amp;lt;pre&amp;gt;make N47E016.hgt.zip&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can download the 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;) to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3 http://dds.cr.usgs.gov/srtm/version2_1/SRTM3].&lt;br /&gt;
&lt;br /&gt;
Or get some new data here http://www.viewfinderpanoramas.org/dem3.html&lt;br /&gt;
&lt;br /&gt;
=== Better and more ===&lt;br /&gt;
&lt;br /&gt;
Some areas, for example high latitudes, are not well covered by official NASA SRTM data. Some additional data and data with higher accuracy has been compiled in the same format: [http://www.viewfinderpanoramas.org/dem3.html http://www.viewfinderpanoramas.org/dem3.html].&lt;br /&gt;
&lt;br /&gt;
==== Bad SRTM data issue ====&lt;br /&gt;
&lt;br /&gt;
You can have bad luck with SRTM data set quality. Sometimes there is a strong discontinuity in the SRTM model at a launching point location you want to use, for real and in the sim. If you load the SRTM model in the GCS (from the Nav menu), the ground altitude of the location of the pointer is displayed on the top right. You can read 131m on your HOME location, and 146m immediately to the north of this point. On takeoff, the simulator gets immediately an altitude of -15m and considers it as a '''crash'''. &lt;br /&gt;
&lt;br /&gt;
The simplest way to avoid this is to disable the ground detection in the simulator: &lt;br /&gt;
&lt;br /&gt;
# stop the Simulator agent, &lt;br /&gt;
# add the &amp;quot;-noground&amp;quot; option to the command&lt;br /&gt;
# and restart. &lt;br /&gt;
&lt;br /&gt;
You will read a -15m AGL during the first seconds but it won't stop. The current threshold for crash detection is -3m (sw/simulator/flightModel.ml:178 an awful numeric constant in the middle of the code, sad but true.&lt;br /&gt;
&lt;br /&gt;
=== Automating script ===&lt;br /&gt;
If you want to get a specific range of elevation data, for example if you test your UAS in various areas on a continent, use the script below. Change the values for the ranges you need.&lt;br /&gt;
&lt;br /&gt;
 $ nano grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Then copy via selecting the script below then CTRL+C and then use CTRL+SHIFT+V to paste it into the nano editor. Then use CTRL+X to save the file. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Use freely, OpenUAS 2010&lt;br /&gt;
 # Script to grab ranges of elevation data, very handy if you test your UAS in various areas in a continent ;)&lt;br /&gt;
 # Change, add or delete values in 49 50 51 and 003 004 005 006 007 008 009 to get the ranges you need.&lt;br /&gt;
 i=1&lt;br /&gt;
 for lat in 49 50 51&lt;br /&gt;
 do&lt;br /&gt;
   j=1&lt;br /&gt;
   for long in 003 004 005 006 007 008 009&lt;br /&gt;
   do&lt;br /&gt;
     let &amp;quot;j+=1&amp;quot;&lt;br /&gt;
      wget -N --waitretry=40 &amp;quot;http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N&amp;quot;$lat&amp;quot;E&amp;quot;$long&amp;quot;.hgt.zip&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   let &amp;quot;i+=1&amp;quot; &lt;br /&gt;
 done               &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
then to be able to simply run the script &lt;br /&gt;
&lt;br /&gt;
 $ chmod u+x grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Finally you can run the script, use and wait a while...&lt;br /&gt;
&lt;br /&gt;
 $ ./grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:User_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15590</id>
		<title>Maps</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15590"/>
		<updated>2013-07-26T12:32:12Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Intoduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
== Satellite photo map tiles ==&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can automatically download satellite photo tiles from Google, MS Maps and Openstreetmap for the area defined in the flight plan. The tiles of Openstreetmap are not real photos (YET!) but rendered tiles. These tiles are fully calibrated and automatically stitched together by the GCS. To load the map tiles simply select Maps-&amp;gt;Google Maps Fill (Ctrl-G) from the GCS pulldown menu and the tiles corresponding to the GPS coordinates defined in the [[Flight_Plans|flight plan]] will begin downloading. Pan or zoom the map and re-fill to get more tiles. Tiles are saved in &amp;lt;tt&amp;gt;var/maps/&amp;lt;/tt&amp;gt; for off-line use.  Checking ''Maps-&amp;gt;Google Maps Auto'' will automatically fill the map with tiles while paning and zooming. There is also a command line option to start the GCS with the Auto-fill feature enabled: &lt;br /&gt;
&lt;br /&gt;
sw/ground_segment/cockpit/gcs -maps_fill  &lt;br /&gt;
&lt;br /&gt;
In v5.0 and master you can also further specify a higher maps zoom level by adding the -maps_zoom &amp;lt;level&amp;gt; option to the gcs invocation.&lt;br /&gt;
The default &amp;lt;level&amp;gt; is 18, you can go up to 22. &lt;br /&gt;
&lt;br /&gt;
For example: sw/ground_segment/cockpit/gcs -maps_zoom 20 -maps_fill -srtm&lt;br /&gt;
&lt;br /&gt;
(see description [http://paparazzi.enac.fr/wiki/Maps#Elevation_Data Elevation Data] below for the -srtm option)&lt;br /&gt;
&lt;br /&gt;
If you are behind a firewall, you can use a proxy by setting the &amp;lt;tt&amp;gt;http_proxy&amp;lt;/tt&amp;gt; environment variable:&lt;br /&gt;
 &amp;lt;tt&amp;gt;export http_proxy=&amp;lt;nowiki&amp;gt;http://squid:3128&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to create a calibrated map from the Google tiles, so that upon launching the map2d program a map of the area is shown, go ahead and put into view the area you wish to make the map.  While holding left click, drag the area for the map.  A red border will appear around the area.  Next click on Maps-&amp;gt;Map of Region or Maps-&amp;gt;Map of Google Tiles. While the former will save the visible region (with waypoints, tracks, ...if any, under the current zoom), the latter will stich together the original Google tiles covering the selected region.  Save the xml file to the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; directory.  This program will automatically screenshot the image and take reference location points and calibrate the map using them. You will be able to load this map in your next sessions (with the Maps-&amp;gt;Load menu or with the &amp;lt;tt&amp;gt;-m&amp;lt;/tt&amp;gt; option you can add in the your section of &amp;lt;tt&amp;gt;control_panel.xml&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Example of map created from google tiles, &amp;lt;tt&amp;gt;gifhorn.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;gifhorn.jpg&amp;quot; projection=&amp;quot;Mercator&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; geo=&amp;quot;WGS84 52.527982 10.452157&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;1965&amp;quot; y=&amp;quot;1284&amp;quot; geo=&amp;quot;WGS84 52.519595 10.473248&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GCS currently supports three projections (UTM, Mercator and LambertIIe). If you try to place a calibrated map for one projection (e.g. UTM) on another projection plot (e.g. Mercator) the image will be rotated and skewed and a warning will be shown during loading.&lt;br /&gt;
&lt;br /&gt;
=== Google Restrictions ===&lt;br /&gt;
&lt;br /&gt;
==== Corrupted Maptiles ====&lt;br /&gt;
&lt;br /&gt;
Sometimes wrong Google maptiles are downloaded due to the beginning of the bandwidth restriction enforced by Google. If this happen and you do not wan to re-download all of you tiles, close the GCS type the following in a command prompt:&lt;br /&gt;
&lt;br /&gt;
 $  cd ~/paparazzi/var/maps/&lt;br /&gt;
&lt;br /&gt;
or maybe some other directory where you installed the Paparazzi software, then type&lt;br /&gt;
 &lt;br /&gt;
 $ rm ??????????????.jpg&lt;br /&gt;
&lt;br /&gt;
That are indeed 14 questionmarks, better cut and paste the line. This leaves the good resolution images and deletes the bad ones. It would be even better if you could fix the GCS sourcecode and the remove the text of this workaround here from the Wiki.&lt;br /&gt;
&lt;br /&gt;
==== No more Maptiles ====&lt;br /&gt;
&lt;br /&gt;
After downloading a lot of maptiles from google you might experience problems getting more due to restrictions enforced by Google. For flight plans covering a large area OSM can be better, as OSM has no such restrictions.&lt;br /&gt;
&lt;br /&gt;
== Manually Defined Maps ==&lt;br /&gt;
&lt;br /&gt;
Maps are used in the groundstation to give geographical reference to the flight area. These ''calibrated'' maps are described with two files: the image itself (.png, .jpg or .gif) and an xml file containing geographic references of some points of the bitmap.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;tt&amp;gt;muret_UTM.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;muret_UTM.gif&amp;quot; projection=&amp;quot;UTM&amp;quot; scale=&amp;quot;2.5&amp;quot; approx_ground_altitude=&amp;quot;185&amp;quot; utm_zone=&amp;quot;31&amp;quot; opacity=&amp;quot;100&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4815000&amp;quot; geo=&amp;quot;WGS84 43.474630 1.256652&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4813000&amp;quot; geo=&amp;quot;WGS84 43.456629 1.257169&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;800&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;361000&amp;quot; utm_y=&amp;quot;4813000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These maps can be created from any image (many are available from various websites). Save the file as a jpeg and place it in the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; folder.  From the Flight Plan Editor select Maps-&amp;gt;Calibrate. After loading the image (which is displayed), you will have to choose at least two reference points, name them with their geographic coordinates (in WGS84 or UTM) and save. The created map (an XML file describing the geographical position of your original bitmap) can then be loaded (Maps-&amp;gt;Load).&lt;br /&gt;
&lt;br /&gt;
== Elevation Data ==&lt;br /&gt;
&lt;br /&gt;
=== Intoduction ===&lt;br /&gt;
The Shuttle Radar Topography Mission (SRTM) obtained elevation data on a near-global scale to generate the most complete high-resolution digital topographic database of Earth. SRTM consisted of a specially modified radar system that flew onboard the Space Shuttle Endeavour during an 11-day mission in February of 2000.&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can use this elevation data. The [http://srtm.usgs.gov/ SRTM] option from the ''Nav'' menu in the GCS displays the ground altitude of the mouse in the top right hand corner.&lt;br /&gt;
&lt;br /&gt;
To start the GCS with the ground altitude feature enabled, the command line option is:&lt;br /&gt;
sw/ground_segment/cockpit/gcs -srtm&lt;br /&gt;
&lt;br /&gt;
=== Getting and using SRTM Data ===&lt;br /&gt;
The SRTM data files can be downloaded using the make process. The only thing that is required is to know the name of the file that is needed. If you use the GCS, it will present a dialog box with the name of the required file. However it is better to download the data before you leave to test your aircraft in the field. &lt;br /&gt;
&lt;br /&gt;
To illustrate the process. If you needed the file &amp;lt;tt&amp;gt;N47E016.hgt.zip&amp;lt;/tt&amp;gt; (47 deg North latitude, 16 deg East longitude) then you could run the following make command:&lt;br /&gt;
&amp;lt;pre&amp;gt;make N47E016.hgt.zip&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can download the 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;) to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3 http://dds.cr.usgs.gov/srtm/version2_1/SRTM3].&lt;br /&gt;
&lt;br /&gt;
Or get some new data here http://www.viewfinderpanoramas.org/dem3.html&lt;br /&gt;
&lt;br /&gt;
=== Better and more ===&lt;br /&gt;
&lt;br /&gt;
Some areas, for example high latitudes, are not well covered by official NASA SRTM data. Some additional data and data with higher accuracy has been compiled in the same format: [http://www.viewfinderpanoramas.org/dem3.html http://www.viewfinderpanoramas.org/dem3.html].&lt;br /&gt;
&lt;br /&gt;
==== Bad SRTM data issue ====&lt;br /&gt;
&lt;br /&gt;
You can have bad luck with SRTM data set quality. Sometimes there is a strong discontinuity in the SRTM model at a launching point location you want to use, for real and in the sim. If you load the SRTM model in the GCS (from the Nav menu), the ground altitude of the location of the pointer is displayed on the top right. You can read 131m on your HOME location, and 146m immediately to the north of this point. On takeoff, the simulator gets immediately an altitude of -15m and considers it as a '''crash'''. &lt;br /&gt;
&lt;br /&gt;
The simplest way to avoid this is to disable the ground detection in the simulator: &lt;br /&gt;
&lt;br /&gt;
# stop the Simulator agent, &lt;br /&gt;
# add the &amp;quot;-noground&amp;quot; option to the command&lt;br /&gt;
# and restart. &lt;br /&gt;
&lt;br /&gt;
You will read a -15m AGL during the first seconds but it won't stop. The current threshold for crash detection is -3m (sw/simulator/flightModel.ml:178 an awful numeric constant in the middle of the code, sad but true.&lt;br /&gt;
&lt;br /&gt;
=== Automating script ===&lt;br /&gt;
If you want to get a specific range of elevation data, for example if you test your UAS in various areas on a continent, use the script below. Change the values for the ranges you need.&lt;br /&gt;
&lt;br /&gt;
 $ nano grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Then copy via selecting the script below then CTRL+C and then use CTRL+SHIFT+V to paste it into the nano editor. Then use CTRL+X to save the file. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Use freely, OpenUAS 2010&lt;br /&gt;
 # Script to grab ranges of elevation data, very handy if you test your UAS in various areas in a continent ;)&lt;br /&gt;
 # Change, add or delete values in 49 50 51 and 003 004 005 006 007 008 009 to get the ranges you need.&lt;br /&gt;
 i=1&lt;br /&gt;
 for lat in 49 50 51&lt;br /&gt;
 do&lt;br /&gt;
   j=1&lt;br /&gt;
   for long in 003 004 005 006 007 008 009&lt;br /&gt;
   do&lt;br /&gt;
     let &amp;quot;j+=1&amp;quot;&lt;br /&gt;
      wget -N --waitretry=40 &amp;quot;http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N&amp;quot;$lat&amp;quot;E&amp;quot;$long&amp;quot;.hgt.zip&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   let &amp;quot;i+=1&amp;quot; &lt;br /&gt;
 done               &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
then to be able to simply run the script &lt;br /&gt;
&lt;br /&gt;
 $ chmod u+x grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Finally you can run the script, use and wait a while...&lt;br /&gt;
&lt;br /&gt;
 $ ./grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:User_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15589</id>
		<title>Maps</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15589"/>
		<updated>2013-07-26T12:31:34Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Satellite photo map tiles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
== Satellite photo map tiles ==&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can automatically download satellite photo tiles from Google, MS Maps and Openstreetmap for the area defined in the flight plan. The tiles of Openstreetmap are not real photos (YET!) but rendered tiles. These tiles are fully calibrated and automatically stitched together by the GCS. To load the map tiles simply select Maps-&amp;gt;Google Maps Fill (Ctrl-G) from the GCS pulldown menu and the tiles corresponding to the GPS coordinates defined in the [[Flight_Plans|flight plan]] will begin downloading. Pan or zoom the map and re-fill to get more tiles. Tiles are saved in &amp;lt;tt&amp;gt;var/maps/&amp;lt;/tt&amp;gt; for off-line use.  Checking ''Maps-&amp;gt;Google Maps Auto'' will automatically fill the map with tiles while paning and zooming. There is also a command line option to start the GCS with the Auto-fill feature enabled: &lt;br /&gt;
&lt;br /&gt;
sw/ground_segment/cockpit/gcs -maps_fill  &lt;br /&gt;
&lt;br /&gt;
In v5.0 and master you can also further specify a higher maps zoom level by adding the -maps_zoom &amp;lt;level&amp;gt; option to the gcs invocation.&lt;br /&gt;
The default &amp;lt;level&amp;gt; is 18, you can go up to 22. &lt;br /&gt;
&lt;br /&gt;
For example: sw/ground_segment/cockpit/gcs -maps_zoom 20 -maps_fill -srtm&lt;br /&gt;
&lt;br /&gt;
(see description [http://paparazzi.enac.fr/wiki/Maps#Elevation_Data Elevation Data] below for the -srtm option)&lt;br /&gt;
&lt;br /&gt;
If you are behind a firewall, you can use a proxy by setting the &amp;lt;tt&amp;gt;http_proxy&amp;lt;/tt&amp;gt; environment variable:&lt;br /&gt;
 &amp;lt;tt&amp;gt;export http_proxy=&amp;lt;nowiki&amp;gt;http://squid:3128&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to create a calibrated map from the Google tiles, so that upon launching the map2d program a map of the area is shown, go ahead and put into view the area you wish to make the map.  While holding left click, drag the area for the map.  A red border will appear around the area.  Next click on Maps-&amp;gt;Map of Region or Maps-&amp;gt;Map of Google Tiles. While the former will save the visible region (with waypoints, tracks, ...if any, under the current zoom), the latter will stich together the original Google tiles covering the selected region.  Save the xml file to the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; directory.  This program will automatically screenshot the image and take reference location points and calibrate the map using them. You will be able to load this map in your next sessions (with the Maps-&amp;gt;Load menu or with the &amp;lt;tt&amp;gt;-m&amp;lt;/tt&amp;gt; option you can add in the your section of &amp;lt;tt&amp;gt;control_panel.xml&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Example of map created from google tiles, &amp;lt;tt&amp;gt;gifhorn.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;gifhorn.jpg&amp;quot; projection=&amp;quot;Mercator&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; geo=&amp;quot;WGS84 52.527982 10.452157&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;1965&amp;quot; y=&amp;quot;1284&amp;quot; geo=&amp;quot;WGS84 52.519595 10.473248&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GCS currently supports three projections (UTM, Mercator and LambertIIe). If you try to place a calibrated map for one projection (e.g. UTM) on another projection plot (e.g. Mercator) the image will be rotated and skewed and a warning will be shown during loading.&lt;br /&gt;
&lt;br /&gt;
=== Google Restrictions ===&lt;br /&gt;
&lt;br /&gt;
==== Corrupted Maptiles ====&lt;br /&gt;
&lt;br /&gt;
Sometimes wrong Google maptiles are downloaded due to the beginning of the bandwidth restriction enforced by Google. If this happen and you do not wan to re-download all of you tiles, close the GCS type the following in a command prompt:&lt;br /&gt;
&lt;br /&gt;
 $  cd ~/paparazzi/var/maps/&lt;br /&gt;
&lt;br /&gt;
or maybe some other directory where you installed the Paparazzi software, then type&lt;br /&gt;
 &lt;br /&gt;
 $ rm ??????????????.jpg&lt;br /&gt;
&lt;br /&gt;
That are indeed 14 questionmarks, better cut and paste the line. This leaves the good resolution images and deletes the bad ones. It would be even better if you could fix the GCS sourcecode and the remove the text of this workaround here from the Wiki.&lt;br /&gt;
&lt;br /&gt;
==== No more Maptiles ====&lt;br /&gt;
&lt;br /&gt;
After downloading a lot of maptiles from google you might experience problems getting more due to restrictions enforced by Google. For flight plans covering a large area OSM can be better, as OSM has no such restrictions.&lt;br /&gt;
&lt;br /&gt;
== Manually Defined Maps ==&lt;br /&gt;
&lt;br /&gt;
Maps are used in the groundstation to give geographical reference to the flight area. These ''calibrated'' maps are described with two files: the image itself (.png, .jpg or .gif) and an xml file containing geographic references of some points of the bitmap.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;tt&amp;gt;muret_UTM.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;muret_UTM.gif&amp;quot; projection=&amp;quot;UTM&amp;quot; scale=&amp;quot;2.5&amp;quot; approx_ground_altitude=&amp;quot;185&amp;quot; utm_zone=&amp;quot;31&amp;quot; opacity=&amp;quot;100&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4815000&amp;quot; geo=&amp;quot;WGS84 43.474630 1.256652&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4813000&amp;quot; geo=&amp;quot;WGS84 43.456629 1.257169&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;800&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;361000&amp;quot; utm_y=&amp;quot;4813000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These maps can be created from any image (many are available from various websites). Save the file as a jpeg and place it in the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; folder.  From the Flight Plan Editor select Maps-&amp;gt;Calibrate. After loading the image (which is displayed), you will have to choose at least two reference points, name them with their geographic coordinates (in WGS84 or UTM) and save. The created map (an XML file describing the geographical position of your original bitmap) can then be loaded (Maps-&amp;gt;Load).&lt;br /&gt;
&lt;br /&gt;
== Elevation Data ==&lt;br /&gt;
&lt;br /&gt;
=== Intoduction ===&lt;br /&gt;
The Shuttle Radar Topography Mission (SRTM) obtained elevation data on a near-global scale to generate the most complete high-resolution digital topographic database of Earth. SRTM consisted of a specially modified radar system that flew onboard the Space Shuttle Endeavour during an 11-day mission in February of 2000.&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can use this elevation data. The [http://srtm.usgs.gov/ SRTM] option from the ''Nav'' menu in the GCS displays the ground altitude of the mouse in the top right hand corner.&lt;br /&gt;
&lt;br /&gt;
To start the GCS with the ground altitude feature enabled, the command line option is:&lt;br /&gt;
&lt;br /&gt;
PAPARAZZI_directory/ground_segment/cockpit/gcs -srtm&lt;br /&gt;
&lt;br /&gt;
=== Getting and using SRTM Data ===&lt;br /&gt;
The SRTM data files can be downloaded using the make process. The only thing that is required is to know the name of the file that is needed. If you use the GCS, it will present a dialog box with the name of the required file. However it is better to download the data before you leave to test your aircraft in the field. &lt;br /&gt;
&lt;br /&gt;
To illustrate the process. If you needed the file &amp;lt;tt&amp;gt;N47E016.hgt.zip&amp;lt;/tt&amp;gt; (47 deg North latitude, 16 deg East longitude) then you could run the following make command:&lt;br /&gt;
&amp;lt;pre&amp;gt;make N47E016.hgt.zip&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can download the 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;) to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3 http://dds.cr.usgs.gov/srtm/version2_1/SRTM3].&lt;br /&gt;
&lt;br /&gt;
Or get some new data here http://www.viewfinderpanoramas.org/dem3.html&lt;br /&gt;
&lt;br /&gt;
=== Better and more ===&lt;br /&gt;
&lt;br /&gt;
Some areas, for example high latitudes, are not well covered by official NASA SRTM data. Some additional data and data with higher accuracy has been compiled in the same format: [http://www.viewfinderpanoramas.org/dem3.html http://www.viewfinderpanoramas.org/dem3.html].&lt;br /&gt;
&lt;br /&gt;
==== Bad SRTM data issue ====&lt;br /&gt;
&lt;br /&gt;
You can have bad luck with SRTM data set quality. Sometimes there is a strong discontinuity in the SRTM model at a launching point location you want to use, for real and in the sim. If you load the SRTM model in the GCS (from the Nav menu), the ground altitude of the location of the pointer is displayed on the top right. You can read 131m on your HOME location, and 146m immediately to the north of this point. On takeoff, the simulator gets immediately an altitude of -15m and considers it as a '''crash'''. &lt;br /&gt;
&lt;br /&gt;
The simplest way to avoid this is to disable the ground detection in the simulator: &lt;br /&gt;
&lt;br /&gt;
# stop the Simulator agent, &lt;br /&gt;
# add the &amp;quot;-noground&amp;quot; option to the command&lt;br /&gt;
# and restart. &lt;br /&gt;
&lt;br /&gt;
You will read a -15m AGL during the first seconds but it won't stop. The current threshold for crash detection is -3m (sw/simulator/flightModel.ml:178 an awful numeric constant in the middle of the code, sad but true.&lt;br /&gt;
&lt;br /&gt;
=== Automating script ===&lt;br /&gt;
If you want to get a specific range of elevation data, for example if you test your UAS in various areas on a continent, use the script below. Change the values for the ranges you need.&lt;br /&gt;
&lt;br /&gt;
 $ nano grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Then copy via selecting the script below then CTRL+C and then use CTRL+SHIFT+V to paste it into the nano editor. Then use CTRL+X to save the file. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Use freely, OpenUAS 2010&lt;br /&gt;
 # Script to grab ranges of elevation data, very handy if you test your UAS in various areas in a continent ;)&lt;br /&gt;
 # Change, add or delete values in 49 50 51 and 003 004 005 006 007 008 009 to get the ranges you need.&lt;br /&gt;
 i=1&lt;br /&gt;
 for lat in 49 50 51&lt;br /&gt;
 do&lt;br /&gt;
   j=1&lt;br /&gt;
   for long in 003 004 005 006 007 008 009&lt;br /&gt;
   do&lt;br /&gt;
     let &amp;quot;j+=1&amp;quot;&lt;br /&gt;
      wget -N --waitretry=40 &amp;quot;http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N&amp;quot;$lat&amp;quot;E&amp;quot;$long&amp;quot;.hgt.zip&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   let &amp;quot;i+=1&amp;quot; &lt;br /&gt;
 done               &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
then to be able to simply run the script &lt;br /&gt;
&lt;br /&gt;
 $ chmod u+x grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Finally you can run the script, use and wait a while...&lt;br /&gt;
&lt;br /&gt;
 $ ./grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:User_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15588</id>
		<title>Maps</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Maps&amp;diff=15588"/>
		<updated>2013-07-26T12:10:31Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Intoduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
== Satellite photo map tiles ==&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can automatically download satellite photo tiles from Google, MS Maps and Openstreetmap for the area defined in the flight plan. The tiles of Openstreetmap are not real photos (YET!) but rendered tiles. These tiles are fully calibrated and automatically stitched together by the GCS. To load the map tiles simply select Maps-&amp;gt;Google Maps Fill (Ctrl-G) from the GCS pulldown menu and the tiles corresponding to the GPS coordinates defined in the [[Flight_Plans|flight plan]] will begin downloading. Pan or zoom the map and re-fill to get more tiles. Tiles are saved in &amp;lt;tt&amp;gt;var/maps/&amp;lt;/tt&amp;gt; for off-line use.  Checking ''Maps-&amp;gt;Google Maps Auto'' will automatically fill the map with tiles while paning and zooming. There is also a command line option to start the GCS with the Auto-fill feature enabled: &lt;br /&gt;
&lt;br /&gt;
PAPARAZZI_directory/ground_segment/cockpit/gcs -maps_fill  &lt;br /&gt;
&lt;br /&gt;
If you are behind a firewall, you can use a proxy by setting the &amp;lt;tt&amp;gt;http_proxy&amp;lt;/tt&amp;gt; environment variable:&lt;br /&gt;
 &amp;lt;tt&amp;gt;export http_proxy=&amp;lt;nowiki&amp;gt;http://squid:3128&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to create a calibrated map from the Google tiles, so that upon launching the map2d program a map of the area is shown, go ahead and put into view the area you wish to make the map.  While holding left click, drag the area for the map.  A red border will appear around the area.  Next click on Maps-&amp;gt;Map of Region or Maps-&amp;gt;Map of Google Tiles. While the former will save the visible region (with waypoints, tracks, ...if any, under the current zoom), the latter will stich together the original Google tiles covering the selected region.  Save the xml file to the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; directory.  This program will automatically screenshot the image and take reference location points and calibrate the map using them. You will be able to load this map in your next sessions (with the Maps-&amp;gt;Load menu or with the &amp;lt;tt&amp;gt;-m&amp;lt;/tt&amp;gt; option you can add in the your section of &amp;lt;tt&amp;gt;control_panel.xml&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Example of map created from google tiles, &amp;lt;tt&amp;gt;gifhorn.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;gifhorn.jpg&amp;quot; projection=&amp;quot;Mercator&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; geo=&amp;quot;WGS84 52.527982 10.452157&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;1965&amp;quot; y=&amp;quot;1284&amp;quot; geo=&amp;quot;WGS84 52.519595 10.473248&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GCS currently supports three projections (UTM, Mercator and LambertIIe). If you try to place a calibrated map for one projection (e.g. UTM) on another projection plot (e.g. Mercator) the image will be rotated and skewed and a warning will be shown during loading.&lt;br /&gt;
&lt;br /&gt;
=== Google Restrictions ===&lt;br /&gt;
&lt;br /&gt;
==== Corrupted Maptiles ====&lt;br /&gt;
&lt;br /&gt;
Sometimes wrong Google maptiles are downloaded due to the beginning of the bandwidth restriction enforced by Google. If this happen and you do not wan to re-download all of you tiles, close the GCS type the following in a command prompt:&lt;br /&gt;
&lt;br /&gt;
 $  cd ~/paparazzi/var/maps/&lt;br /&gt;
&lt;br /&gt;
or maybe some other directory where you installed the Paparazzi software, then type&lt;br /&gt;
 &lt;br /&gt;
 $ rm ??????????????.jpg&lt;br /&gt;
&lt;br /&gt;
That are indeed 14 questionmarks, better cut and paste the line. This leaves the good resolution images and deletes the bad ones. It would be even better if you could fix the GCS sourcecode and the remove the text of this workaround here from the Wiki.&lt;br /&gt;
&lt;br /&gt;
==== No more Maptiles ====&lt;br /&gt;
&lt;br /&gt;
After downloading a lot of maptiles from google you might experience problems getting more due to restrictions enforced by Google. For flight plans covering a large area OSM can be better, as OSM has no such restrictions.&lt;br /&gt;
&lt;br /&gt;
== Manually Defined Maps ==&lt;br /&gt;
&lt;br /&gt;
Maps are used in the groundstation to give geographical reference to the flight area. These ''calibrated'' maps are described with two files: the image itself (.png, .jpg or .gif) and an xml file containing geographic references of some points of the bitmap.&lt;br /&gt;
&lt;br /&gt;
For example, &amp;lt;tt&amp;gt;muret_UTM.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 &amp;lt;tt&amp;gt;&amp;lt;map file=&amp;quot;muret_UTM.gif&amp;quot; projection=&amp;quot;UTM&amp;quot; scale=&amp;quot;2.5&amp;quot; approx_ground_altitude=&amp;quot;185&amp;quot; utm_zone=&amp;quot;31&amp;quot; opacity=&amp;quot;100&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4815000&amp;quot; geo=&amp;quot;WGS84 43.474630 1.256652&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;0&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;359000&amp;quot; utm_y=&amp;quot;4813000&amp;quot; geo=&amp;quot;WGS84 43.456629 1.257169&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;point x=&amp;quot;800&amp;quot; y=&amp;quot;800&amp;quot; utm_x=&amp;quot;361000&amp;quot; utm_y=&amp;quot;4813000&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/map&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These maps can be created from any image (many are available from various websites). Save the file as a jpeg and place it in the &amp;lt;tt&amp;gt;data/maps/&amp;lt;/tt&amp;gt; folder.  From the Flight Plan Editor select Maps-&amp;gt;Calibrate. After loading the image (which is displayed), you will have to choose at least two reference points, name them with their geographic coordinates (in WGS84 or UTM) and save. The created map (an XML file describing the geographical position of your original bitmap) can then be loaded (Maps-&amp;gt;Load).&lt;br /&gt;
&lt;br /&gt;
== Elevation Data ==&lt;br /&gt;
&lt;br /&gt;
=== Intoduction ===&lt;br /&gt;
The Shuttle Radar Topography Mission (SRTM) obtained elevation data on a near-global scale to generate the most complete high-resolution digital topographic database of Earth. SRTM consisted of a specially modified radar system that flew onboard the Space Shuttle Endeavour during an 11-day mission in February of 2000.&lt;br /&gt;
&lt;br /&gt;
The Paparazzi GCS can use this elevation data. The [http://srtm.usgs.gov/ SRTM] option from the ''Nav'' menu in the GCS displays the ground altitude of the mouse in the top right hand corner.&lt;br /&gt;
&lt;br /&gt;
To start the GCS with the ground altitude feature enabled, the command line option is:&lt;br /&gt;
&lt;br /&gt;
PAPARAZZI_directory/ground_segment/cockpit/gcs -srtm&lt;br /&gt;
&lt;br /&gt;
=== Getting and using SRTM Data ===&lt;br /&gt;
The SRTM data files can be downloaded using the make process. The only thing that is required is to know the name of the file that is needed. If you use the GCS, it will present a dialog box with the name of the required file. However it is better to download the data before you leave to test your aircraft in the field. &lt;br /&gt;
&lt;br /&gt;
To illustrate the process. If you needed the file &amp;lt;tt&amp;gt;N47E016.hgt.zip&amp;lt;/tt&amp;gt; (47 deg North latitude, 16 deg East longitude) then you could run the following make command:&lt;br /&gt;
&amp;lt;pre&amp;gt;make N47E016.hgt.zip&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can download the 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;) to the &amp;lt;tt&amp;gt;data/srtm/&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
They can be downloaded from [http://dds.cr.usgs.gov/srtm/version2_1/SRTM3 http://dds.cr.usgs.gov/srtm/version2_1/SRTM3].&lt;br /&gt;
&lt;br /&gt;
Or get some new data here http://www.viewfinderpanoramas.org/dem3.html&lt;br /&gt;
&lt;br /&gt;
=== Better and more ===&lt;br /&gt;
&lt;br /&gt;
Some areas, for example high latitudes, are not well covered by official NASA SRTM data. Some additional data and data with higher accuracy has been compiled in the same format: [http://www.viewfinderpanoramas.org/dem3.html http://www.viewfinderpanoramas.org/dem3.html].&lt;br /&gt;
&lt;br /&gt;
==== Bad SRTM data issue ====&lt;br /&gt;
&lt;br /&gt;
You can have bad luck with SRTM data set quality. Sometimes there is a strong discontinuity in the SRTM model at a launching point location you want to use, for real and in the sim. If you load the SRTM model in the GCS (from the Nav menu), the ground altitude of the location of the pointer is displayed on the top right. You can read 131m on your HOME location, and 146m immediately to the north of this point. On takeoff, the simulator gets immediately an altitude of -15m and considers it as a '''crash'''. &lt;br /&gt;
&lt;br /&gt;
The simplest way to avoid this is to disable the ground detection in the simulator: &lt;br /&gt;
&lt;br /&gt;
# stop the Simulator agent, &lt;br /&gt;
# add the &amp;quot;-noground&amp;quot; option to the command&lt;br /&gt;
# and restart. &lt;br /&gt;
&lt;br /&gt;
You will read a -15m AGL during the first seconds but it won't stop. The current threshold for crash detection is -3m (sw/simulator/flightModel.ml:178 an awful numeric constant in the middle of the code, sad but true.&lt;br /&gt;
&lt;br /&gt;
=== Automating script ===&lt;br /&gt;
If you want to get a specific range of elevation data, for example if you test your UAS in various areas on a continent, use the script below. Change the values for the ranges you need.&lt;br /&gt;
&lt;br /&gt;
 $ nano grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Then copy via selecting the script below then CTRL+C and then use CTRL+SHIFT+V to paste it into the nano editor. Then use CTRL+X to save the file. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Use freely, OpenUAS 2010&lt;br /&gt;
 # Script to grab ranges of elevation data, very handy if you test your UAS in various areas in a continent ;)&lt;br /&gt;
 # Change, add or delete values in 49 50 51 and 003 004 005 006 007 008 009 to get the ranges you need.&lt;br /&gt;
 i=1&lt;br /&gt;
 for lat in 49 50 51&lt;br /&gt;
 do&lt;br /&gt;
   j=1&lt;br /&gt;
   for long in 003 004 005 006 007 008 009&lt;br /&gt;
   do&lt;br /&gt;
     let &amp;quot;j+=1&amp;quot;&lt;br /&gt;
      wget -N --waitretry=40 &amp;quot;http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N&amp;quot;$lat&amp;quot;E&amp;quot;$long&amp;quot;.hgt.zip&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   let &amp;quot;i+=1&amp;quot; &lt;br /&gt;
 done               &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
then to be able to simply run the script &lt;br /&gt;
&lt;br /&gt;
 $ chmod u+x grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
Finally you can run the script, use and wait a while...&lt;br /&gt;
&lt;br /&gt;
 $ ./grabelevationdata.sh&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:User_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=12964</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=12964"/>
		<updated>2012-07-31T08:31:20Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Guidance horizontal navigation loop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note; estimator_phi is the measured roll angle, and estimator_p is the measured rate of change in roll angle.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
[[File:Climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
[[File:Z_hold.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Vertical loop ==&lt;br /&gt;
[[File:vertical_loop_V40.png]]&lt;br /&gt;
&lt;br /&gt;
the source code is located in '''guidance\guidance_v.c'''&lt;br /&gt;
&lt;br /&gt;
NOMINAL_HOVER_THROTTLE is the nominal thrust when hovering. It's calculated by default by an adaptative controller, in  '''guidance\guidance_v_adpt.h'''.&lt;br /&gt;
&lt;br /&gt;
Instead of the adaptative controller, NOMINAL_HOVER_TROTTLE can be set manually in the Airframe configuration file with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;define name=&amp;quot;NOMINAL_HOVER_THROTTLE&amp;quot; value=&amp;quot;0.5&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The value is found after flying manually in hover: NOMINAL_HOVER_THROTTLE= THRUST/MAX_PPRZ (THRUST:mean value of ROTORCRAFT_FP THRUST message in hover, MAX_PPRZ:9600) &lt;br /&gt;
&lt;br /&gt;
In most cases it makes more sense to not specify this explicitly and use the adaptive controller&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Vertical_loop_V40.png&amp;diff=12963</id>
		<title>File:Vertical loop V40.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Vertical_loop_V40.png&amp;diff=12963"/>
		<updated>2012-07-31T08:21:18Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=12962</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=12962"/>
		<updated>2012-07-31T08:20:08Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Vertical loop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note; estimator_phi is the measured roll angle, and estimator_p is the measured rate of change in roll angle.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
[[File:Climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
[[File:Z_hold.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Vertical loop ==&lt;br /&gt;
[[File:vertical_loop_V40.png]]&lt;br /&gt;
&lt;br /&gt;
the source code is located in '''guidance\guidance_v.c'''&lt;br /&gt;
&lt;br /&gt;
NOMINAL_HOVER_THROTTLE is the nominal thrust when hovering. It's calculated by default by an adaptative controller, in  '''guidance\guidance_v_adpt.h'''.&lt;br /&gt;
&lt;br /&gt;
Instead of the adaptative controller, NOMINAL_HOVER_TROTTLE can be set manually in the Airframe configuration file with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;define name=&amp;quot;NOMINAL_HOVER_THROTTLE&amp;quot; value=&amp;quot;0.5&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The value is found after flying manually in hover: NOMINAL_HOVER_THROTTLE= THRUST/MAX_PPRZ (THRUST:mean value of ROTORCRAFT_FP THRUST message in hover, MAX_PPRZ:9600) &lt;br /&gt;
&lt;br /&gt;
In most cases it makes more sense to not specify this explicitly and use the adaptive controller&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
Integral action or tracking algorithm:&lt;br /&gt;
&lt;br /&gt;
if (|guidance_h_pos_err| &amp;lt; HOLD_DISTANCE) -&amp;gt; intregal error * guidance_h_igain&lt;br /&gt;
&lt;br /&gt;
else -&amp;gt; path tracking error * guidance_h_ngain&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=12961</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=12961"/>
		<updated>2012-07-31T08:17:23Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note; estimator_phi is the measured roll angle, and estimator_p is the measured rate of change in roll angle.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
[[File:Climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
[[File:Z_hold.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Vertical loop ==&lt;br /&gt;
[[File:vertical_loop.png]]&lt;br /&gt;
&lt;br /&gt;
the source code is located in '''guidance\guidance_v.c'''&lt;br /&gt;
&lt;br /&gt;
NOMINAL_HOVER_THROTTLE is the nominal thrust when hovering. It's calculated by default by an adaptative controller, in  '''guidance\guidance_v_adpt.h'''.&lt;br /&gt;
&lt;br /&gt;
Instead of the adaptative controller, NOMINAL_TROTTLE can be set manually in the Airframe configuration file with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;define name=&amp;quot;NOMINAL_HOVER_THROTTLE&amp;quot; value=&amp;quot;0.5&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The value is found after flying manually in hover: NOMINAL_HOVER_THROTTLE= THRUST/MAX_PPRZ (THRUST:mean value of ROTORCRAFT_FP THRUST message in hover, MAX_PPRZ:9600) &lt;br /&gt;
&lt;br /&gt;
In most cases it makes more sense to not specify this explicitly and use the adaptive controller&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
Integral action or tracking algorithm:&lt;br /&gt;
&lt;br /&gt;
if (|guidance_h_pos_err| &amp;lt; HOLD_DISTANCE) -&amp;gt; intregal error * guidance_h_igain&lt;br /&gt;
&lt;br /&gt;
else -&amp;gt; path tracking error * guidance_h_ngain&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11583</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11583"/>
		<updated>2012-02-21T09:26:39Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* mode: GUIDANCE_V_MODE_HOVER */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Global View ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
[[File:Climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
[[File:Z_hold.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Vertical loop ==&lt;br /&gt;
[[File:vertical_loop.png]]&lt;br /&gt;
&lt;br /&gt;
the source code is located in '''guidance\guidance_v.c'''&lt;br /&gt;
&lt;br /&gt;
INV_M is basically the inverse of the mass. Since m.g=thrust when hovering in RC Direct mode, it can be calculated by INV_M=9.81/(thrust). (thrust message[0-256] in ROTORCRAFT_FP)&lt;br /&gt;
&lt;br /&gt;
if you specify INV_M, it will be used instead of the observer for the adaptive control (so in most cases it makes more sense to not specify this explicitly and use the adaptive controller instead)&lt;br /&gt;
the adaptative controller code is located in '''guidance\guidance_v_adpt.h'''&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
(to be developed later..)&lt;br /&gt;
&lt;br /&gt;
Integral action or tracking algorithm:&lt;br /&gt;
&lt;br /&gt;
if (|guidance_h_pos_err| &amp;lt; HOLD_DISTANCE) -&amp;gt; intregal error * guidance_h_igain&lt;br /&gt;
&lt;br /&gt;
else -&amp;gt; path tracking error * guidance_h_ngain&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11582</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11582"/>
		<updated>2012-02-21T09:25:30Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* mode: GUIDANCE_V_MODE_CLIMB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Global View ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
[[File:Climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Vertical loop ==&lt;br /&gt;
[[File:vertical_loop.png]]&lt;br /&gt;
&lt;br /&gt;
the source code is located in '''guidance\guidance_v.c'''&lt;br /&gt;
&lt;br /&gt;
INV_M is basically the inverse of the mass. Since m.g=thrust when hovering in RC Direct mode, it can be calculated by INV_M=9.81/(thrust). (thrust message[0-256] in ROTORCRAFT_FP)&lt;br /&gt;
&lt;br /&gt;
if you specify INV_M, it will be used instead of the observer for the adaptive control (so in most cases it makes more sense to not specify this explicitly and use the adaptive controller instead)&lt;br /&gt;
the adaptative controller code is located in '''guidance\guidance_v_adpt.h'''&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
(to be developed later..)&lt;br /&gt;
&lt;br /&gt;
Integral action or tracking algorithm:&lt;br /&gt;
&lt;br /&gt;
if (|guidance_h_pos_err| &amp;lt; HOLD_DISTANCE) -&amp;gt; intregal error * guidance_h_igain&lt;br /&gt;
&lt;br /&gt;
else -&amp;gt; path tracking error * guidance_h_ngain&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Climb.png&amp;diff=11581</id>
		<title>File:Climb.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Climb.png&amp;diff=11581"/>
		<updated>2012-02-21T09:23:33Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: Rotorcraft climb general description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Rotorcraft climb general description&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Z_hold.png&amp;diff=11580</id>
		<title>File:Z hold.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Z_hold.png&amp;diff=11580"/>
		<updated>2012-02-21T09:20:32Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: Rotorcraft z_hold general description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Rotorcraft z_hold general description&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Rc_climb.png&amp;diff=11579</id>
		<title>File:Rc climb.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Rc_climb.png&amp;diff=11579"/>
		<updated>2012-02-21T09:17:36Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: uploaded a new version of &amp;quot;File:Rc climb.png&amp;quot;:&amp;amp;#32;Rotorcraft rc climb loop&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;General description of RC_CLIMB mode&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Rc_climb.png&amp;diff=11578</id>
		<title>File:Rc climb.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Rc_climb.png&amp;diff=11578"/>
		<updated>2012-02-21T09:14:18Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: uploaded a new version of &amp;quot;File:Rc climb.png&amp;quot;:&amp;amp;#32;rotorcraft rc climb general description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;General description of RC_CLIMB mode&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11577</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11577"/>
		<updated>2012-02-20T16:56:30Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* Hover loop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Global View ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Vertical loop ==&lt;br /&gt;
[[File:vertical_loop.png]]&lt;br /&gt;
&lt;br /&gt;
the source code is located in '''guidance\guidance_v.c'''&lt;br /&gt;
&lt;br /&gt;
INV_M is basically the inverse of the mass. Since m.g=thrust when hovering in RC Direct mode, it can be calculated by INV_M=9.81/(thrust). (thrust message[0-256] in ROTORCRAFT_FP)&lt;br /&gt;
&lt;br /&gt;
if you specify INV_M, it will be used instead of the observer for the adaptive control (so in most cases it makes more sense to not specify this explicitly and use the adaptive controller instead)&lt;br /&gt;
the adaptative controller code is located in '''guidance\guidance_v_adpt.h'''&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
(to be developed later..)&lt;br /&gt;
&lt;br /&gt;
Integral action or tracking algorithm:&lt;br /&gt;
&lt;br /&gt;
if (|guidance_h_pos_err| &amp;lt; HOLD_DISTANCE) -&amp;gt; intregal error * guidance_h_igain&lt;br /&gt;
&lt;br /&gt;
else -&amp;gt; path tracking error * guidance_h_ngain&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Vertical_loop.png&amp;diff=11576</id>
		<title>File:Vertical loop.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Vertical_loop.png&amp;diff=11576"/>
		<updated>2012-02-20T15:58:45Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: Vertical control loop detailed description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Vertical control loop detailed description&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11575</id>
		<title>Control Loops</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=Control_Loops&amp;diff=11575"/>
		<updated>2012-02-20T15:55:27Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: /* mode: GUIDANCE_V_MODE_RC_CLIMB */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page presents the default control loops used by the Paparazzi airborne code for navigation, guidance and control.&lt;br /&gt;
&lt;br /&gt;
= General Information =&lt;br /&gt;
&lt;br /&gt;
All the possible combinations of control loops might not be fully detailed. This is especially the case when using extra features such as '''AGR_CLIMB''', '''STRONG_WIND''', etc.&lt;br /&gt;
&lt;br /&gt;
In the following diagrams, the block '''s''' is used for the '''derivative''' function and '''1/s''' is used for the '''integrator''' function.&lt;br /&gt;
&lt;br /&gt;
The variables' names are the one used in the airborne code (written in '''C'''). Most of this name can the used capitalized in the [[Airframe Configuration]] file in order to define the default value of these variables. If in capital letters in the diagrams, the value is fixed and cannot be changed using [[Settings]] mechanism.&lt;br /&gt;
&lt;br /&gt;
The best way to determine vehicle behavior is to look at the source code. For determining which control loops are engaged by various flight plan blocks and stages, it may be helpful to look at sw/airborne/subsystems/nav.h and the generated flightplan file in var/&amp;lt;AIRCRAFT_NAME&amp;gt;/generated/flight_plan.h.&lt;br /&gt;
&lt;br /&gt;
= Fixed-wing autopilot =&lt;br /&gt;
&lt;br /&gt;
== Global view ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_general.png|General overview]]&lt;br /&gt;
&lt;br /&gt;
The elements '''servos''', '''rc_commands''', '''commands''' and '''command_laws''' correspond to specific section of the [[Airframe Configuration]] file. Most of the code located in these blocks is generated from the xml of th configuration file.&lt;br /&gt;
&lt;br /&gt;
The value '''+/-9600''' correspond to '''+/-MAX_PPRZ'''. This '''pprz''' unit is used as a normalized internal unit for input and output values of the '''control_laws''' block.&lt;br /&gt;
&lt;br /&gt;
== Navigation loop ==&lt;br /&gt;
&lt;br /&gt;
The navigation loop is located in '''sw/airborne/subsystems/nav.*'''. The navigation routines are called from the [[Flight Plans]]. Advanced navigation routines are in '''sw/airborne/subsystems/navigation/'''.&lt;br /&gt;
&lt;br /&gt;
== Course loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_course_loop.png|Course loop]]&lt;br /&gt;
&lt;br /&gt;
The course loop is the upper stage of the horizontal control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/stabilization/stabilization_attitude.c''' (formerly fw_h_ctl.c).&lt;br /&gt;
&lt;br /&gt;
== Roll loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_roll_loop.png|Roll loop]]&lt;br /&gt;
&lt;br /&gt;
The roll loop is the lower stage of the horizontal control and is used for lateral attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
If &amp;lt;tt&amp;gt;H_CTL_ROLL_ATTITUDE_GAIN&amp;lt;/tt&amp;gt; is undefined, the code will fallback to a attitude-only loop, where &amp;lt;tt&amp;gt;estimator_p&amp;lt;/tt&amp;gt; is disregarded and the gain for &amp;lt;tt&amp;gt;estimator_phi&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;H_CTL_ROLL_PGAIN&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Altitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_altitude_loop.png|Altitude loop]]&lt;br /&gt;
&lt;br /&gt;
The altitude loop is the upper stage of the vertical control.&lt;br /&gt;
It is located in '''sw/airborne/firmwares/fixedwing/guidance/guidance_v.c''' (formerly fw_v_ctl.c)&lt;br /&gt;
If AGR_CLIMB is defined in the airframe file, the altitude loop also sets the v_ctl_auto_throttle_submode for use in the climb loop.&lt;br /&gt;
&lt;br /&gt;
== Auto Throttle and Auto Pitch climb loops ==&lt;br /&gt;
&lt;br /&gt;
Two climb loops are available. The are called from the [[Flight Plans#Navigation_modes|flight plan]] by changing the vertical navigation mode. The default mode is '''Auto Throttle'''. The '''Auto Pitch''' loop is only available if '''V_CTL_AUTO_PITCH_PGAIN''' is defined. Only one loop is active at a time. Note also that if '''USE_AIRSPEED''' is defined, then the Auto Throttle loop is replaced by the Auto Airspeed loop, see [Control_Loops#Control_loops_using_Airspeed_Sensor|below].&lt;br /&gt;
&lt;br /&gt;
=== Auto throttle loop ===&lt;br /&gt;
[[Image:Diagram_auto_throttle_loop.png|Auto Throttle climb loop]]&lt;br /&gt;
&lt;br /&gt;
If '''AGR_CLIMB''' is defined, then the auto throttle submode is used to determine setpoint outputs. This may be the standard control loop outputs, the aggressive outputs (static setpoints defined in airframe file) or a blend of both.&lt;br /&gt;
&lt;br /&gt;
=== Auto pitch loop ===&lt;br /&gt;
[[Image:Diagram_auto_pitch_loop.png|924px|Auto Pitch climb loop]]&lt;br /&gt;
&lt;br /&gt;
The climb loop is the intermediate stage of the vertical control. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
== Pitch loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_pitch_loop.png|Pitch loop]]&lt;br /&gt;
&lt;br /&gt;
The pitch loop is the lower stage of the vertical control and is used for longitudinal attitude stabilization. It is located in '''stabilization_attitude.c'''.&lt;br /&gt;
The first sum block of the diagram is not completely accurate. The input to the pitch stabilization loop is h_ctl_pitch_setpoint, though v_ctl_pitch_of_vz is not a direct input. Rather h_ctl_pitch_setpoint is assigned in the main autopilot loop from nav_pitch, in general (in auto1, it is assigned directly from the pitch r/c input). The nav_pitch value is obtained in a few ways, depending on which control loop(s) are active. If auto throttle is active, nav_pitch is the sum of v_ctl_pitch_of_vz and a fixed setpoint defined using the pitch attribute in the flightplan. If AGR_CLIMB is set, nav_pitch is either the airframe file defined ascent and descent pitch setpoints, the standard sum, or a blend of each. If auto pitch is active, nav_pitch is defined directly from the output of that loop. If airspeed is active, nav_pitch is defined in the auto airspeed pitch loop.&lt;br /&gt;
&lt;br /&gt;
== Control loops using Airspeed Sensor ==&lt;br /&gt;
&lt;br /&gt;
Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. The use of an airspeed sensor is described [[Airspeed_sensor|here]].&lt;br /&gt;
&lt;br /&gt;
[[Image:Diagram_auto_airspeed_loop.png|Auto Airspeed climb loop]]&lt;br /&gt;
&lt;br /&gt;
The auto airspeed cascaded control loops control both pitch and throttle. This control loop set replaces the Auto Throttle climb loop; it is engaged in the same manner in the flight plan. It is located in '''guidance_v.c'''.&lt;br /&gt;
&lt;br /&gt;
= Rotorcraft autopilot =&lt;br /&gt;
&lt;br /&gt;
The schemes of the multi-rotor autopilot were made with the drawing tool from Google docs. To edit the drawings, send an e-mail to microuav@gmail.com.&lt;br /&gt;
&lt;br /&gt;
== Global View ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_autopilot_globalview.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this autopilot is located in '''sw/airborne/firmwares/rotorcraft'''.&lt;br /&gt;
&lt;br /&gt;
== Vertical Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following vertical modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_RC_CLIMB ===&lt;br /&gt;
[[File:Rc_climb.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_CLIMB ===&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_V_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from z set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Refgen_from_z_sp.png]]&lt;br /&gt;
&lt;br /&gt;
=== from z dot set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_zdot.png]]]&lt;br /&gt;
&lt;br /&gt;
The '''adjust accel''' is a simple algorithm to set acceleration to zero when velocity reaches boundaries.&lt;br /&gt;
&lt;br /&gt;
The code for these reference generators is located in '''guidance/guidance_v_ref.h'''&lt;br /&gt;
&lt;br /&gt;
== Hover loop ==&lt;br /&gt;
&lt;br /&gt;
(coming soon...)&lt;br /&gt;
&lt;br /&gt;
== Horizontal Control ==&lt;br /&gt;
&lt;br /&gt;
Depending on the general mode selected, one of the following horizontal modes is used.&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_RATE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_RATE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_ATTITUDE ===&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_ATTITUDE.png]]&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_HOVER ===&lt;br /&gt;
&lt;br /&gt;
When this mode is entered, the measured position at the instance of initiation is set as guidance_h_pos_sp. This means that the rotorcraft will hover on that position.&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_HOVER.png]]&lt;br /&gt;
&lt;br /&gt;
rotation to body:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\phi_{cmd_{body}}= -\sin \psi \cdot x_{cmd_{earth}} + \cos \psi \cdot y_{cmd_{earth}} &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\theta_{cmd_{body}}= -\left( \cos \psi \cdot x_{cmd_{earth}} + \sin \psi \cdot y_{cmd_{earth}} \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mode: GUIDANCE_H_MODE_NAV ===&lt;br /&gt;
&lt;br /&gt;
The set points guidance_h_pos_sp (x and y coordinates) are obtained from the navigation carrot after a 'NED of ENU' transformation:&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.x = navigation_carrot.y&lt;br /&gt;
&lt;br /&gt;
guidance_h_pos_sp.y = navigation_carrot.x&lt;br /&gt;
&lt;br /&gt;
[[Image:GUIDANCE_H_MODE_NAV.png]]&lt;br /&gt;
&lt;br /&gt;
Rotation to body is the same as in GUIDANCE_H_MODE_HOVER.&lt;br /&gt;
&lt;br /&gt;
== Reference generators ==&lt;br /&gt;
&lt;br /&gt;
=== from euler attitude angle set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_att.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_attitude_ref_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from angular rate set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_rate.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
=== from pos set point ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_refgen_xy_sp.png]]&lt;br /&gt;
&lt;br /&gt;
Acceleration is set to zero when rate reaches min or max value.&lt;br /&gt;
&lt;br /&gt;
The code for this reference generator is located in '''guidance/guidance_h_ref.h'''.&lt;br /&gt;
&lt;br /&gt;
== Attitude loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:attitude_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_attitude_euler_int.c'''.&lt;br /&gt;
&lt;br /&gt;
== Rate loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:rate_loop.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''stabilization/stabilization_rate.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal hover loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:guidance_horizontal_hover.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''.&lt;br /&gt;
&lt;br /&gt;
== Guidance horizontal navigation loop ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Booz_horizontal_nav.png]]&lt;br /&gt;
&lt;br /&gt;
The code for this loop is located in '''guidance/guidance_h.c'''&lt;br /&gt;
&lt;br /&gt;
(to be developed later..)&lt;br /&gt;
&lt;br /&gt;
Integral action or tracking algorithm:&lt;br /&gt;
&lt;br /&gt;
if (|guidance_h_pos_err| &amp;lt; HOLD_DISTANCE) -&amp;gt; intregal error * guidance_h_igain&lt;br /&gt;
&lt;br /&gt;
else -&amp;gt; path tracking error * guidance_h_ngain&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]] [[Category:Developer_Documentation]]&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
	<entry>
		<id>http://wiki.paparazziuav.org/w/index.php?title=File:Rc_climb.png&amp;diff=11574</id>
		<title>File:Rc climb.png</title>
		<link rel="alternate" type="text/html" href="http://wiki.paparazziuav.org/w/index.php?title=File:Rc_climb.png&amp;diff=11574"/>
		<updated>2012-02-20T15:45:21Z</updated>

		<summary type="html">&lt;p&gt;Loic drumettaz: General description of RC_CLIMB mode&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;General description of RC_CLIMB mode&lt;/div&gt;</summary>
		<author><name>Loic drumettaz</name></author>
	</entry>
</feed>