Difference between revisions of "Fixedwing Configuration"

From PaparazziUAV
Jump to navigation Jump to search
(→‎Vertical Control: POWER_CTL_BAT_NOMINAL)
 
(19 intermediate revisions by 9 users not shown)
Line 1: Line 1:
<categorytree style="float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;" mode=pages>Airframe_Configuration</categorytree>
This page describes configuration options <span style="color:red"><b>specific to the fixedwing firmware</b></span> in the [[Airframe_Configuration|airframe file]].
This page describes configuration options <span style="color:red"><b>specific to the fixedwing firmware</b></span> in the [[Airframe_Configuration|airframe file]].
== Firmware and Hardware definitions ==
== Firmware and Hardware definitions ==
Line 4: Line 5:
=== Select your Board ===
=== Select your Board ===
Make sure you use the <b>fixedwing [[Airframe_Configuration#Firmware|firmware]]</b> and choose the correct board, e.g.
Make sure you use the <b>fixedwing [[Airframe_Configuration#Firmware|firmware]]</b> and choose the correct board, e.g.
{{Box Code|conf/airframes/myplane.xml|
{{Box Code|conf/airframes/myplane.xml|
<pre>
<source lang="xml">
   <firmware name="fixedwing">
   <firmware name="fixedwing">
     <target name="sim" board="pc"/>
     <target name="sim" board="pc"/>      <!-- For simulation -->
     <target name="ap" board="twog_1.0"/>
     <target name="ap" board="lisa_m_2.0"/> <!-- Select your board here -->
     ...
     ...
   </firmware>
   </firmware>
</pre>
</source>
}}
}}


The ap board name can be found in /conf/boards.
=== Attitude and Heading Reference System (AHRS) ===


=== Infrared Sensors ===
Next the filter for attitude estimation needs to be selected, where
To use the IR sensors for attitude estimation add the attitude infrared subsystem:
the tratidtional approach is to use infrared sensors (see blow).
To select the type of [[Subsystem/ahrs|AHRS]] use the subsystem-tag as follows:
{{Box Code|conf/airframes/myplane.xml|
{{Box Code|conf/airframes/myplane.xml|
<pre>
<source lang="xml">
   <firmware name="fixedwing">
   <firmware name="fixedwing">
     <target name="ap"             board="tiny_2.11"/>
     <target name="ap" board="tiny_2.11"/>
     ...
     ...
     <subsystem name="attitude"     type="infrared"/>
     <subsystem name="ahrs" type="int_cmpl_quat"/>
   </firmware>
   </firmware>
</pre>
</source>
}}
}}


 
==== Infrared Sensors ====
The ADC channels are already default to the correct ADCs for your board, but you can of course change the assignments:
To use the IR sensors for attitude estimation add the infrared module and ahrs infrared subsystem:
{{Box Code|conf/airframes/myplane.xml|
{{Box Code|conf/airframes/myplane.xml|
<pre>
<source lang="xml">
   <firmware name="fixedwing">
   <firmware name="fixedwing">
     <target name="ap"             board="tiny_2.11"/>
     <target name="ap" board="tiny_2.11"/>
     ...
     ...
     <subsystem name="attitude"     type="infrared">
     <subsystem name="ahrs" type="infrared"/>
      <configure name="ADC_IR1"        value="ADC_1"/>
      <configure name="ADC_IR2"        value="ADC_2"/>
      <configure name="ADC_IR_TOP"    value="ADC_0"/>
      <configure name="ADC_IR_NB_SAMPLES" value="16"/>
    </subsystem>
   </firmware>
   </firmware>
</pre>
  <modules>
    <load name="infrared_adc.xml"/>
  </modules>
</source>
}}
}}
See the [[Module/infrared|infrared module page]] for more details on configuration.


=== Control loops ===
=== Control loops ===


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.
The [[Subsystem/control|control loops]] can be divided in two independent groups:  
 
* stabilization
* guidance
 
stabilization is the part that is given a pitch and a roll angle (desired) and calculates a respective elevator or aileron deflection to reach the desired angle
 
this part is always used when engaging Auto1 or Auto2
 
in Auto1 the desired angles are generated by the RC transmitter
 
in Auto2 the desired angles are generated by the respective guidance loops


Just specify the appropriate subsystem in your firmware section. You can currently choose between no type (see below) and the types '''adaptive''' and '''new'''.
files can be found in sw/airborne/firmwares/fixedwing/stabilization/xxx.c
{{Box Code|conf/airframes/myplane.xml|
<pre>
  <firmware name="fixedwing">
    <target name="ap" board="tiny_2.11"/>
    ...
    <subsystem name="control"/>
  </firmware>
</pre>
}}




== XML Parameters ==
guidance is the part on top of stabilization that calculates the desired pitch and roll angle, taking into account the desired altitude / climb reqirement from the flight plan or the airspeed for example


=== Commands ===
only used when in Auto2


The <b><tt>commands</tt></b> lists the abstract commands you need to control the aircraft. In our example, we have only three:
files can be found in sw/airborne/firmwares/fixedwing/guidance/xxx.c
<tt>
<commands>
  <axis name="THROTTLE" failsafe_value="0"/>
  <axis name="ROLL"    failsafe_value="0"/>
  <axis name="PITCH"    failsafe_value="0"/>
</commands></tt>


Each command is also associated with a failsafe value which will be used if no controller is active, for example during initialization of the autopilot board. The range of these values is [-9600:9600]. For <tt>"THROTTLE"</tt>, the range is [0, 9600] and in the corresponding <b><tt>servo</tt></b> definition the <b><tt>neutral</tt></b> and <b><tt>min</tt></b> are usually the same (see below). Note that these commands do not necessarily match the servo actuators. For example, the <tt>"ROLL"</tt> command is typically linked to two aileron actuators.
Just specify the appropriate subsystem in your firmware section.  


=== Servos ===
Currently you can choose between:
{| class="wikitable"
|-
! type !! stabilization !! guidance !! description
|-
| - || attitude || v ||
|-
| adaptive || adaptive || v ||
|-
| new || adaptive || v_n ||
|-
| energy || attitude || [[EnergyControl|energy]] ||
|-
| energyadaptie || adaptive || [[EnergyControl|energy]] ||
|}


The above commands get translated to the <b><tt>servos</tt></b> here. In the example below we use two elevons and a motor. ([http://en.wikipedia.org/wiki/Elevon ''Elevons''] are surfaces used for both pitch and roll as on a flying wing.) These servos are listed in the <b><tt>servos</tt></b> section:
<tt>
<servos>
  <servo name="THROTTLE"        no="0" min="1000" neutral="1000" max="2000"/>
  <servo name="ELEVON_LEFTSIDE"  no="1" min="2000" neutral="1500" max="1000"/>
  <servo name="ELEVON_RIGHTSIDE" no="2" min="1000" neutral="1500" max="2000"/>
</servos></tt>


Names are associated to the corresponding '''real physical connector''' to which a servo is connected '''on the autopilot board'''. For example no="2" means connector two on the board. Also the servo neutral value, total range and direction are defined.  Min/max/neutral values are expressed in milliseconds. The direction of travel can be reversed by exchanging min with max (as in <tt>"ELEVON_LEFTSIDE"</tt>, above). The ''standard'' travel for a hobby servo is 1000ms - 2000ms with a 1500ms neutral. Trim can be added by changing this neutral value. Absolute servo travel limits can be increased or reduced with the min/max values.  The <tt>"THROTTLE"</tt> servo typically has the same value for the <b><tt>neutral</tt></b> and <b><tt>min</tt></b>. 
{{Box Code|conf/airframes/myplane.xml|
<source lang="xml">
  <firmware name="fixedwing">
    <target name="ap" board="tiny_2.11"/>
    ...
    <subsystem name="control" /> <!-- Standard fixed wing control loops -->


Note the following important tips:
    <!-- Different control loop types can be enabled instead (Use only one) -->
* Reverse the servo direction by exchanging min/max
    <subsystem name="control" type="adaptive"/>  <!-- fixed wing control loops with adaptive horizontal control, standard vertical control -->
* Trim should always be adjusted mechanically if possible to avoid asymmetrical travel
    <subsystem name="control" type="new"/>       <!-- new fixed wing control loops with merged auto pitch and auto throttle, adaptive horizontal control -->
* Any reduction of the total travel range should be done mechanically to maintain precision
    <subsystem name="control" type="energy"/>    <!-- Since v4.1.0 -->
* Many servos will respond well to values slightly outside the normal 1000-2000ms range but experiment carefully as the servo may not operate reliably outside this range and may even suffer permanent damage.
    <subsystem name="control" type="energyadaptive"/>
* Board connector numbering starts with <b>zero (0)</b> not with one
* Servos are also known under the synonym <b>actuators</b>


The <b><tt>servos</tt></b> are then linked to the commands in the <b><tt>command_laws</tt></b> section:
<tt>
<command_laws>
  <let var="aileron"            value="@ROLL  * 0.3"/>
  <let var="elevator"          value="@PITCH * 0.7"/> 
  <set servo="THROTTLE"        value="@THROTTLE"/>
  <set servo="ELEVON_LEFTSIDE"  value="$elevator + $aileron"/>
  <set servo="ELEVON_RIGHTSIDE" value="$elevator - $aileron"/>
</command_laws></tt>


[[Image:airframe_sign_conventions.jpg|thumb|Sign conventions for flight dynamics]]
  </firmware>
where the third line is the simplest: the throttle servo value equals throttle command value. The other lines define and control the pitch/roll mixing.  Elevon values are computed with a combination of two commands, '''ROLL''' and '''PITCH'''. This ''mixer'' is defined with two intermediate variables '''aileron''' and '''elevator''' introduced with the <b><tt>let</tt></b> element.  The '''@''' symbol is used to reference a command value in the <b><tt>value</tt></b> attribute of the <b><tt>set</tt></b> and <b><tt>let</tt></b> elements.  In the above example, the servos are limited to +/- 70% of their full travel for pitch and 30% for roll, only in combination can the servos reach 100% deflection.  Note that these numbers ''should add up 100% or more, never less''.  For example, you may want 100% travel available for pitch - this means if a roll is commanded along with maximum pitch only one servo will respond to the roll command as the other has already reached its mechanical limit.  If you find after tuning that these numbers add to less than 100% consider reducing the surface travel mechanically.
</source>
}}


== XML Parameters ==


Note that the signs used in the description follow the standard convention.


=== Manual ===
=== Manual ===
The <tt>rc_command</tt> sections links the channels of the RC transmitter (defined in the [[Radio_Control|Radio Control]] file) to the <tt>commands</tt> defined above:
The <tt>rc_command</tt> sections links the channels of the RC transmitter (defined in the [[Radio_Control|Radio Control]] file) to the <tt>commands</tt> defined above:
 
<source lang="xml">
  <rc_commands>
  <rc_commands>
   <set command="THROTTLE" value="@THROTTLE"/>
   <set command="THROTTLE" value="@THROTTLE"/>
Line 118: Line 122:
   <set command="PITCH"    value="@PITCH"/>
   <set command="PITCH"    value="@PITCH"/>
  </rc_commands>
  </rc_commands>
 
</source>
This example looks trivial since the channel values have the same name than the commands.
This example looks trivial since the channel values have the same name than the commands.


Line 124: Line 128:
To control servos or other servo signal compatible devices by RC in Auto1 or Auto2, define them in the <auto_rc_commands> section.
To control servos or other servo signal compatible devices by RC in Auto1 or Auto2, define them in the <auto_rc_commands> section.
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:
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:
 
<source lang="xml">
  <auto_rc_commands>
  <auto_rc_commands>
   <set command="YAW" value="@YAW"/>
   <set command="YAW" value="@YAW"/>
  </auto_rc_commands>
  </auto_rc_commands>
 
</source>
To disable this behavior (meaning no RC control of the rudder in auto) define an empty auto_rc_commands section:
To disable this behavior (meaning no RC control of the rudder in auto) define an empty auto_rc_commands section:
 
<source lang="xml">
  <auto_rc_commands>
  <auto_rc_commands>
  </auto_rc_commands>
  </auto_rc_commands>
</source>


=== Autopilot Only Commands ===
=== Autopilot Only Commands ===
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 <rc_commands> block but in the special <ap_only_commands> 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.
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 <rc_commands> block but in the special <ap_only_commands> 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.
 
<source lang="xml">
  <ap_only_commands>
  <ap_only_commands>
   <copy command="PAN"/>
   <copy command="PAN"   />
   <copy command="TILT"/>
   <copy command="TILT" />
   <copy command="SHOOT"/>
   <copy command="SHOOT" />
  </ap_only_commands>
  </ap_only_commands>
</source>


=== Auto1 ===
=== Auto1 ===
The next section, named <b><tt>AUTO1</tt></b>, gives the maximum roll and pitch (in radians) allowed for the augmented stability mode.
The next section, named <b><tt>AUTO1</tt></b>, gives the maximum roll and pitch (in radians) allowed for the augmented stability mode.
<tt>
<source lang="xml">
  <section name="AUTO1" prefix="AUTO1_">
  <section name="AUTO1" prefix="AUTO1_">
   <define name="MAX_ROLL" value="RadOfDeg(35)"/>
   <define name="MAX_ROLL" value="35" unit="deg" />
   <define name="MAX_PITCH" value="RadOfDeg(35)"/>
   <define name="MAX_PITCH" value="5"  unit="deg" />
  </section>
  </section>
</tt>
</source>


''NOTE'': [[Units|automatic unit conversion]] using <tt>unit="deg"</tt> is supported since v3.9, if you have an older version set it in radians or using <tt>value="RadOfDeg(35)"</tt>
=== Infrared ===  
=== Infrared ===  
The <b><tt>INFRARED</tt></b> section describes the configuration of the infrared sensors.
The <b><tt>INFRARED</tt></b> section describes the configuration of the infrared sensors. For additional configuration to change the defaults, see the [[Module/infrared|infrared module page]].


The first definitions are relative to the electronic neutral of the sensors (a sensor here is a '''pair''' of thermopiles). A perfect sensor should give 512 if it measures the same value on both sides.
The only mandatory definitions are the sensor neutral readings and how the IR sensors are mounted.


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.
<source lang="xml">
  <section name="INFRARED" prefix="IR_">
  <section name="INFRARED" prefix="IR_">
   <define name="ADC_IR1_NEUTRAL" value="512"/>
   <define name="ADC_IR1_NEUTRAL" value="512"/>
   <define name="ADC_IR2_NEUTRAL" value="512"/>
   <define name="ADC_IR2_NEUTRAL" value="512"/>
   <define name="ADC_TOP_NEUTRAL" value="512"/>
   <define name="ADC_TOP_NEUTRAL" value="512"/>
 
  <define name="HORIZ_SENSOR_ALIGNED" value="1"/>
</section>
</source>
These neutrals are tuned with the "cupboard test": 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.
These neutrals are tuned with the "cupboard test": 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.


The next lines define the installation of the horizontal and vertical sensors. The vertical sensor must  give a positive value when the temperature under the aircraft is higher than the temperature above. The two channels of the horizontal sensor must give positive values when it is warmer on the right side and the rear side. To adjust these signs, use the following declarations:
In the example above the horizontal sensor is connected to the airframe in ''aligned'' orientation. The other possibility is ''tilted''.
 
Define either
  <define name="IR1_SIGN" value="-1"/>
* '''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.
  <define name="IR2_SIGN" value="-1"/>
or
  <define name="TOP_SIGN" value="-1"/>
* '''HORIZ_SENSOR_TILTED''': the sensors are tilted by 45 degrees; ir1 is along rear-left -- front-right, and ir2 along rear-right -- front-left.
 
If the airframe construction allows choose an aligned sensor orientation since this gives the best stabilization response results.
Then, define how the horizontal sensor is connected to the airframe, orientation '''aligned''' or '''tilted'''. In the aligned case, ir'''1''' is along the lateral axis (The axis that passes through the plane from wingtip to wingtip) and ir'''2''' along the longitudinal one. In the '''tilted''' case, the sensors are tilted by 45 degrees; ir'''1''' is along rear-left -- front-right, and ir'''2''' along rear-right -- front-left. The parameter "value" in the aligned and tilted definition has no effect! If the airframe construction allows choose an aligned sensor orientation since this gives the best stabilization response results.
 
For help with orientation of '''Previous Versions of Infrared Sensor Boards''' try here : http://paparazzi.enac.fr/wiki/Previous_Infrared_Sensors
 
  <define name="HORIZ_SENSOR_ALIGNED" value="1"/>
  or
  <define name="HORIZ_SENSOR_TILTED" value="1"/>
 
The three axis must give similar values for similar contrasts. The following factors can be used to scale these values. For example with an horizontal tilted sensor, the following ratios are usually needed:
 
  <define name="LATERAL_CORRECTION" value="0.7"/>
  <define name="LONGITUDINAL_CORRECTION" value="0.7"/>
  <define name="VERTICAL_CORRECTION" value="1."/>
Default values are 1.
 
It may be hard to align the horizontal sensor with the aircraft. A tuning in flight will be needed to adjust the following neutrals. Adjust the roll neutral to fly straight. Adjust the pitch neutral to fly level with the desired throttle.
  <define name="ROLL_NEUTRAL_DEFAULT" value="-2.5" unit="deg"/>
  <define name="PITCH_NEUTRAL_DEFAULT" value="6" unit="deg"/>


An asymmetric (left/right, front/rear) correction can be added with a last set of factors.
=== Gyro ===
  <define name="CORRECTION_UP" value="1."/>
'''This section only applies to versions prior to v3.9 when using a gyro with IR sensors.'''
  <define name="CORRECTION_DOWN" value="1."/>
  <define name="CORRECTION_LEFT" value="1."/>
  <define name="CORRECTION_RIGHT" value="1."/>
</section>
These corrections are set on the angles.
You don't have to set these as they are set to 1. per default, but adjust them if needed.
 
=== Gyro ===
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.(<b><tt>ADC_TEMP_SLOPE=0</tt></b>).
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.(<b><tt>ADC_TEMP_SLOPE=0</tt></b>).
 
<source lang="xml">
<tt>
  <section name="GYRO" prefix="GYRO_">
  <section name="GYRO" prefix="GYRO_">
   <define name="ADC_ROLL_COEFF" value="1"/>
   <define name="ADC_ROLL_COEFF"   value="1"   />
   <define name="ROLL_NEUTRAL" value="500"/>
   <define name="ROLL_NEUTRAL"     value="500" />
   <define name="ADC_TEMP_NEUTRAL" value="476"/>
   <define name="ADC_TEMP_NEUTRAL" value="476" />
   <define name="ADC_TEMP_SLOPE" value="0"/>
   <define name="ADC_TEMP_SLOPE"   value="0"   />
  </section>
  </section>
</tt>
</source>


=== Horizontal Control ===
=== Horizontal Control ===
<tt>
<source lang="xml">
  <section name="HORIZONTAL CONTROL" prefix="H_CTL_">
  <section name="HORIZONTAL CONTROL" prefix="H_CTL_">
     <define name="COURSE_PGAIN" value="-0.4"/>
     <define name="COURSE_PGAIN"       value="0.4"   />
     <define name="ROLL_MAX_SETPOINT" value="0.35" unit="radians"/>
     <define name="ROLL_MAX_SETPOINT" value="20"   unit="deg" />
     <define name="ROLL_ATTITUDE_GAIN" value="-7500."/>
     <define name="ROLL_ATTITUDE_GAIN" value="7500." />
     <define name="ROLL_RATE_GAIN" value="-1500"/>
     <define name="ROLL_RATE_GAIN"     value="1500" />
     <define name="PITCH_PGAIN" value="-8000."/>
     <define name="PITCH_PGAIN"       value="8000." />
     <define name="ELEVATOR_OF_ROLL" value="1250"/>
     <define name="ELEVATOR_OF_ROLL"   value="1250" />
   </section>
   </section>
</tt>
</source>
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.


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.
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.


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.
 
'''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''
 
''NOTE'': [[Units|automatic unit conversion]] using <tt>unit="deg"</tt> is supported since v3.9, if you have an older version set it in radians or using <tt>value="RadOfDeg(20)"</tt>


The [[Control_Loops#Fixed-wing_autopilot|graphical representation of the control loops]] can help you to visualize the effect of each gain.
The [[Control_Loops#Fixed-wing_autopilot|graphical representation of the control loops]] can help you to visualize the effect of each gain.


===Vertical Control===
===Vertical Control===
 
<source lang="xml">
  <section name="VERTICAL CONTROL" prefix="V_CTL_">
<define name="POWER_CTL_BAT_NOMINAL" value="14.8" unit="volt"/>
</source>
This line tells PPZ to automatically adapt the throttle setting to get the same thrust you would get with a 14.8V battery. 50% throttle would alway result in the same thrust setting. If you have a input voltage that is a little less that the defined one it increases the throttle setting to get the same thrust or if the input voltage is a little higher than the defined voltage PPZ will decrease it a little.
<source lang="xml">
  <section name="VERTICAL CONTROL" prefix="V_CTL_">
     <!-- outer loop proportional gain -->
     <!-- outer loop proportional gain -->
     <define name="ALTITUDE_PGAIN" value="-0.1" unit="(m/s)/m"/>
     <define name="ALTITUDE_PGAIN"     value="0.1" unit="(m/s)/m" />
     <!-- outer loop saturation -->
     <!-- outer loop saturation -->
     <define name="ALTITUDE_MAX_CLIMB" value="3." unit="m/s"/>
     <define name="ALTITUDE_MAX_CLIMB" value="3." unit="m/s" />
</source>
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
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
     <define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.65" unit="%"/>
<source lang="xml">
     <define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE" value=".4" unit="%"/>
     <define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.65" unit="%" />
     <define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE" value="1" unit="%"/>
     <define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE"     value=".4"   unit="%" />
     <define name="AUTO_THROTTLE_LOITER_TRIM" value="1000" unit="pprz_t"/>
     <define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE"     value="1"   unit="%" />
     <define name="AUTO_THROTTLE_DASH_TRIM" value="-2500" unit="pprz_t"/>
     <define name="AUTO_THROTTLE_LOITER_TRIM" value="1000" unit="pprz_t" />
     <define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.15" unit="%/(m/s)"/>
     <define name="AUTO_THROTTLE_DASH_TRIM"   value="-2500" unit="pprz_t" />
     <define name="AUTO_THROTTLE_PGAIN" value="-0.008" unit="%/(m/s)"/>
     <define name="AUTO_THROTTLE_PGAIN" value="0.008" unit="%/(m/s)"/>
     <define name="AUTO_THROTTLE_IGAIN" value="0.25"/>
     <define name="AUTO_THROTTLE_IGAIN" value="0.25" />
     <define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN" value="0.35" unit="rad/(m/s)"/>
     <define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN"       value="0.35" unit="rad/(m/s)" />
     <define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.15" unit="%/(m/s)" />
</source>


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.
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.
 
<source lang="xml">
     <define name="AUTO_PITCH_PGAIN" value="-0.1"/>
     <define name="AUTO_PITCH_PGAIN" value="0.1"/>
     <define name="AUTO_PITCH_IGAIN" value="0.025"/>
     <define name="AUTO_PITCH_IGAIN" value="0.025"/>
     <define name="AUTO_PITCH_MAX_PITCH" value="0.5"/>
     <define name="AUTO_PITCH_MAX_PITCH" value="30" unit="deg"/>
     <define name="AUTO_PITCH_MIN_PITCH" value="-0.5"/>
     <define name="AUTO_PITCH_MIN_PITCH" value="30" unit="deg"/>
 
</source>
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.
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.
 
<source lang="xml">
   <define name="THROTTLE_SLEW_LIMITER" value="2" unit="s"/>
   <define name="THROTTLE_SLEW_LIMITER" value="2" unit="s"/>
</source>
THROTTLE_SLEW_LIMITER is the required time is seconds to change throttle from 0% to 100%.
THROTTLE_SLEW_LIMITER is the required time is seconds to change throttle from 0% to 100%.
'''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'', ''''
''NOTE'': [[Units|automatic unit conversion]] using <tt>unit="deg"</tt> is supported since v3.9, if you have an older version set it in radians or using <tt>value="RadOfDeg(20)"</tt>


The [[Control_Loops#Fixed-wing_autopilot|graphical representation of the control loops]] can help you to visualize the effect of each gain.
The [[Control_Loops#Fixed-wing_autopilot|graphical representation of the control loops]] can help you to visualize the effect of each gain.


=== Misc ===
=== Misc ===
<tt>
<source lang="xml">
  <section name="MISC">
  <section name="MISC">
   <define name="NOMINAL_AIRSPEED" value ="12." unit="m/s"/>
   <define name="NOMINAL_AIRSPEED"   value ="12.0" unit="m/s" />
   <define name="CARROT" value="5." unit="s"/>
   <define name="CONTROL_RATE"       value="60"   unit="Hz"/>
   <define name="KILL_MODE_DISTANCE" value="(1.5*MAX_DIST_FROM_HOME)"/>
   <define name="CARROT"             value="5.0"  unit="s" />
   <define name="CONTROL_RATE" value="60" unit="Hz"/>
   <define name="KILL_MODE_DISTANCE" value="(1.5*MAX_DIST_FROM_HOME)"/>
  </section>
  </section>
</tt>
</source>
 
* The "NOMINAL_AIRSPEED" is mainly used in the simulator.
* The "NOMINAL_AIRSPEED" is mainly used in the simulator.
* "CARROT" gives the distance (in seconds, so ground speed is taken into account) between the carrot and the aircraft.
* "CARROT" gives the distance (in seconds, so ground speed is taken into account) between the carrot and the aircraft.
Line 277: Line 277:
=== Simu ===
=== Simu ===
Values from this section can be used to tweak the software in the loop (SITL) simulation.
Values from this section can be used to tweak the software in the loop (SITL) simulation.
 
<source lang="xml">
<tt>
  <section name="SIMU">
  <section name="SIMU">
   <define name="WEIGHT" value ="1."/>
   <define name="WEIGHT" value ="1."/>
   <define name="YAW_RESPONSE_FACTOR" value ="1."/>
   <define name="YAW_RESPONSE_FACTOR" value ="1."/>
   <define name="ROLL_RESPONSE_FACTOR" value ="15."/>
   <define name="ROLL_RESPONSE_FACTOR" value ="15."/>
  </section>
  </section>
</tt>
</source>
 
* "YAW_RESPONSE_FACTOR" adapts the aircraft's turn rate corresponding to a bank angle; a larger value increases the turn radius
* "YAW_RESPONSE_FACTOR" adapts the aircraft's turn rate corresponding to a bank angle; a larger value increases the turn radius
* "ROLL_RESPONSE_FACTOR" is basically your aileron efficiency; a higher value increases roll agility
* "ROLL_RESPONSE_FACTOR" is basically your aileron efficiency; a higher value increases roll agility
Line 292: Line 290:




[[Category:User_Documentation]] [[Category:Software]]
[[Category:User_Documentation]] [[Category:Airframe_Configuration]]

Latest revision as of 07:41, 14 September 2015

This page describes configuration options specific to the fixedwing firmware in the airframe file.

Firmware and Hardware definitions

Select your Board

Make sure you use the fixedwing firmware and choose the correct board, e.g.


File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    <target name="sim" 	board="pc"/>       <!-- For simulation -->
    <target name="ap" 	board="lisa_m_2.0"/> <!-- Select your board here -->
     ...
  </firmware>

The ap board name can be found in /conf/boards.

Attitude and Heading Reference System (AHRS)

Next the filter for attitude estimation needs to be selected, where the tratidtional approach is to use infrared sensors (see blow). To select the type of AHRS use the subsystem-tag as follows:

File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    <target name="ap"  board="tiny_2.11"/>
     ...
    <subsystem name="ahrs" type="int_cmpl_quat"/>
  </firmware>

Infrared Sensors

To use the IR sensors for attitude estimation add the infrared module and ahrs infrared subsystem:

File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    <target name="ap"  board="tiny_2.11"/>
     ...
    <subsystem name="ahrs" type="infrared"/>
  </firmware>
  <modules>
    <load name="infrared_adc.xml"/>
  </modules>

See the infrared module page for more details on configuration.

Control loops

The control loops can be divided in two independent groups:

  • stabilization
  • guidance

stabilization is the part that is given a pitch and a roll angle (desired) and calculates a respective elevator or aileron deflection to reach the desired angle

this part is always used when engaging Auto1 or Auto2

in Auto1 the desired angles are generated by the RC transmitter

in Auto2 the desired angles are generated by the respective guidance loops

files can be found in sw/airborne/firmwares/fixedwing/stabilization/xxx.c


guidance is the part on top of stabilization that calculates the desired pitch and roll angle, taking into account the desired altitude / climb reqirement from the flight plan or the airspeed for example

only used when in Auto2

files can be found in sw/airborne/firmwares/fixedwing/guidance/xxx.c

Just specify the appropriate subsystem in your firmware section.

Currently you can choose between:

type stabilization guidance description
- attitude v
adaptive adaptive v
new adaptive v_n
energy attitude energy
energyadaptie adaptive energy


File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    <target name="ap" board="tiny_2.11"/>
     ...
    <subsystem name="control" />  <!-- Standard fixed wing control loops -->

    <!-- Different control loop types can be enabled instead (Use only one) -->
    <subsystem name="control" type="adaptive"/>  <!-- fixed wing control loops with adaptive horizontal control, standard vertical control -->
    <subsystem name="control" type="new"/>       <!-- new fixed wing control loops with merged auto pitch and auto throttle, adaptive horizontal control -->
    <subsystem name="control" type="energy"/>    <!-- Since v4.1.0 -->
    <subsystem name="control" type="energyadaptive"/>


  </firmware>

XML Parameters

Manual

The rc_command sections links the channels of the RC transmitter (defined in the Radio Control file) to the commands defined above:

 <rc_commands>
   <set command="THROTTLE" value="@THROTTLE"/>
   <set command="ROLL"     value="@ROLL"/>
   <set command="PITCH"    value="@PITCH"/>
 </rc_commands>

This example looks trivial since the channel values have the same name than the commands.

RC commands in Auto

To control servos or other servo signal compatible devices by RC in Auto1 or Auto2, define them in the <auto_rc_commands> section. 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:

 <auto_rc_commands>
   <set command="YAW" value="@YAW"/>
 </auto_rc_commands>

To disable this behavior (meaning no RC control of the rudder in auto) define an empty auto_rc_commands section:

 <auto_rc_commands>
 </auto_rc_commands>

Autopilot Only Commands

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 <rc_commands> block but in the special <ap_only_commands> 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.

 <ap_only_commands>
   <copy command="PAN"   />
   <copy command="TILT"  />
   <copy command="SHOOT" />
 </ap_only_commands>

Auto1

The next section, named AUTO1, gives the maximum roll and pitch (in radians) allowed for the augmented stability mode.

 <section name="AUTO1" prefix="AUTO1_">
  <define name="MAX_ROLL"  value="35" unit="deg" />
  <define name="MAX_PITCH" value="5"  unit="deg" />
 </section>

NOTE: automatic unit conversion using unit="deg" is supported since v3.9, if you have an older version set it in radians or using value="RadOfDeg(35)"

Infrared

The INFRARED section describes the configuration of the infrared sensors. For additional configuration to change the defaults, see the infrared module page.

The only mandatory definitions are the sensor neutral readings and how the IR sensors are mounted.

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.

 <section name="INFRARED" prefix="IR_">
   <define name="ADC_IR1_NEUTRAL" value="512"/>
   <define name="ADC_IR2_NEUTRAL" value="512"/>
   <define name="ADC_TOP_NEUTRAL" value="512"/>
   <define name="HORIZ_SENSOR_ALIGNED" value="1"/>
 </section>

These neutrals are tuned with the "cupboard test": 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.

In the example above the horizontal sensor is connected to the airframe in aligned orientation. The other possibility is tilted. Define either

  • 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.

or

  • HORIZ_SENSOR_TILTED: the sensors are tilted by 45 degrees; ir1 is along rear-left -- front-right, and ir2 along rear-right -- front-left.

If the airframe construction allows choose an aligned sensor orientation since this gives the best stabilization response results.

Gyro

This section only applies to versions prior to v3.9 when using a gyro with IR sensors. 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.(ADC_TEMP_SLOPE=0).

 <section name="GYRO" prefix="GYRO_">
  <define name="ADC_ROLL_COEFF"   value="1"   />
  <define name="ROLL_NEUTRAL"     value="500" />
  <define name="ADC_TEMP_NEUTRAL" value="476" />
  <define name="ADC_TEMP_SLOPE"   value="0"   />
 </section>

Horizontal Control

 <section name="HORIZONTAL CONTROL" prefix="H_CTL_">
    <define name="COURSE_PGAIN"       value="0.4"   />
    <define name="ROLL_MAX_SETPOINT"  value="20"    unit="deg" />
    <define name="ROLL_ATTITUDE_GAIN" value="7500." />
    <define name="ROLL_RATE_GAIN"     value="1500"  />
    <define name="PITCH_PGAIN"        value="8000." />
    <define name="ELEVATOR_OF_ROLL"   value="1250"  />
  </section>

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.

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.


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

NOTE: automatic unit conversion using unit="deg" is supported since v3.9, if you have an older version set it in radians or using value="RadOfDeg(20)"

The graphical representation of the control loops can help you to visualize the effect of each gain.

Vertical Control

<define name="POWER_CTL_BAT_NOMINAL" value="14.8" unit="volt"/>

This line tells PPZ to automatically adapt the throttle setting to get the same thrust you would get with a 14.8V battery. 50% throttle would alway result in the same thrust setting. If you have a input voltage that is a little less that the defined one it increases the throttle setting to get the same thrust or if the input voltage is a little higher than the defined voltage PPZ will decrease it a little.

  <section name="VERTICAL CONTROL" prefix="V_CTL_">
    <!-- outer loop proportional gain -->
    <define name="ALTITUDE_PGAIN"     value="0.1" unit="(m/s)/m" />
    <!-- outer loop saturation -->
    <define name="ALTITUDE_MAX_CLIMB" value="3."  unit="m/s" />

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

    <define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.65" unit="%" />
    <define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE"     value=".4"   unit="%" />
    <define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE"     value="1"    unit="%" />
    <define name="AUTO_THROTTLE_LOITER_TRIM"  value="1000"  unit="pprz_t" />
    <define name="AUTO_THROTTLE_DASH_TRIM"    value="-2500" unit="pprz_t" />
    <define name="AUTO_THROTTLE_PGAIN" value="0.008" unit="%/(m/s)"/>
    <define name="AUTO_THROTTLE_IGAIN" value="0.25" />
    <define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN"        value="0.35" unit="rad/(m/s)" />
    <define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.15" unit="%/(m/s)" />

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.

    <define name="AUTO_PITCH_PGAIN" value="0.1"/>
    <define name="AUTO_PITCH_IGAIN" value="0.025"/>
    <define name="AUTO_PITCH_MAX_PITCH" value="30" unit="deg"/>
    <define name="AUTO_PITCH_MIN_PITCH" value="30" unit="deg"/>

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.

   <define name="THROTTLE_SLEW_LIMITER" value="2" unit="s"/>

THROTTLE_SLEW_LIMITER is the required time is seconds to change throttle from 0% to 100%.


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, '

NOTE: automatic unit conversion using unit="deg" is supported since v3.9, if you have an older version set it in radians or using value="RadOfDeg(20)"

The graphical representation of the control loops can help you to visualize the effect of each gain.

Misc

 <section name="MISC">
  <define name="NOMINAL_AIRSPEED"    value ="12.0" unit="m/s" />
  <define name="CONTROL_RATE"        value="60"    unit="Hz"/>
  <define name="CARROT"              value="5.0"   unit="s" />
  <define name="KILL_MODE_DISTANCE"  value="(1.5*MAX_DIST_FROM_HOME)"/>
 </section>
  • The "NOMINAL_AIRSPEED" is mainly used in the simulator.
  • "CARROT" gives the distance (in seconds, so ground speed is taken into account) between the carrot and the aircraft.
  • "KILL_MODE_DISTANCE" is the threshold distance to switch the autopilot into KILL mode (defined descent with no throttle)
  • "CONTROL_RATE" is the rate of the low level control loops in Hertz (60 or 20).

Simu

Values from this section can be used to tweak the software in the loop (SITL) simulation.

 <section name="SIMU">
  <define name="WEIGHT" value ="1."/>
  <define name="YAW_RESPONSE_FACTOR"  value ="1."/>
  <define name="ROLL_RESPONSE_FACTOR" value ="15."/>
 </section>
  • "YAW_RESPONSE_FACTOR" adapts the aircraft's turn rate corresponding to a bank angle; a larger value increases the turn radius
  • "ROLL_RESPONSE_FACTOR" is basically your aileron efficiency; a higher value increases roll agility

If you want to use JSBSim as SITL simulator, you have to make some definitions in this section as well; see here.