Fixedwing Configuration

From PaparazziUAV
Revision as of 12:44, 19 August 2011 by Flixr (talk | contribs) (started page for fixedwing specifc airframe file configuration)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

Firmware and Hardware definitions

Select your Board

The airframe file must include the description of the controller board and it's low-level settings. This is done in the firmware section by specifying the board attribute for the target "ap" (autopilot).

Select the appropriate hardware autopilot board you are going to use in your airframe: "twog_1.0", "tiny_0.99", "tiny_1.1", "tiny_2.1", "tiny_2.11", "lisa_l_1.0", "lisa_l_1.1", "lisa_m_1.0", "lisa_s_1.0", "pc"

File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    <target name="sim" 			board="pc"/>
    <target name="ap" 			board="twog_1.0"/>

Note that the "pc" is a special kind of "board", and is mostly used only for simulation flights of an autopilot via your computer.

Infrared Sensors

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

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

The ADC channels are already default to the correct ADCs for your board, but you can of course change the assignments:

File: conf/airframes/myplane.xml
  <firmware name="fixedwing">
    <target name="ap"              board="tiny_2.11"/>
    <subsystem name="attitude"     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"/>

Control loops

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

Just specify the appropriate subsystem in your firmware section. You can currently choose between no type (see below) and the types adaptive and new.

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

XML Parameters


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="RadOfDeg(35)"/>
 <define name="MAX_PITCH" value="RadOfDeg(35)"/>


The INFRARED section describes the configuration of the infrared sensors.

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.

<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"/>

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:

  <define name="IR1_SIGN" value="-1"/>
  <define name="IR2_SIGN" value="-1"/>
  <define name="TOP_SIGN" value="-1"/>

Then, define how the horizontal sensor is connected to the airframe, orientation aligned or tilted. In the aligned case, ir1 is along the lateral axis (The axis that passes through the plane from wingtip to wingtip) and ir2 along the longitudinal one. In the tilted case, the sensors are tilted by 45 degrees; ir1 is along rear-left -- front-right, and ir2 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 :

  <define name="HORIZ_SENSOR_ALIGNED" value="1"/>
  <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.

  <define name="CORRECTION_UP" value="1."/>
  <define name="CORRECTION_DOWN" value="1."/>
  <define name="CORRECTION_LEFT" value="1."/>
  <define name="CORRECTION_RIGHT" value="1."/>

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.


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"/>

Horizontal Control

<section name="HORIZONTAL CONTROL" prefix="H_CTL_">
   <define name="COURSE_PGAIN" value="-0.4"/>
   <define name="ROLL_MAX_SETPOINT" value="0.35" unit="radians"/>
   <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"/>

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 graphical representation of the control loops can help you to visualize the effect of each gain.

Vertical Control

  <section name="VERTICAL CONTROL" prefix="V_CTL_">
   <define name="ALTITUDE_PGAIN" value="-0.1" unit="(m/s)/m"/>
   <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_CLIMB_THROTTLE_INCREMENT" value="0.15" 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_PITCH_OF_VZ_PGAIN" value="0.35" unit="rad/(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="0.5"/>
   <define name="AUTO_PITCH_MIN_PITCH" value="-0.5"/>

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

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


<section name="MISC">
 <define name="NOMINAL_AIRSPEED" value ="12." unit="m/s"/>
 <define name="CARROT" value="5." unit="s"/>
 <define name="KILL_MODE_DISTANCE" value="(1.5*MAX_DIST_FROM_HOME)"/>
 <define name="CONTROL_RATE" value="60" unit="Hz"/>

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


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

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