Skip to content

Paparazzi Patches

Mohammad Jafar Mashhadi edited this page Aug 7, 2020 · 3 revisions

For the research project I was doing, I patched up paparazzi source code to better suit my needs. Here I am documenting the required changes.

Version Info

Paparazzi Version: 5.14 (paparazzi/paparazzi 3fb4ee4d5)

Changes

Frequency of FLIGHT_PARAM messages

This message is sent by server every 500ms [1]. To match what I was collecting from MicroPilot I changed it too 200ms.

Change this line in [5]:

let aircraft_msg_period = 200 (* ms *)

Added custom telemetry mode

I created a new telemetry mode (lazily named it mjafar) that sends required input/outputs with a 5Hz frequency. Most notable of those is the COMMANDS message that provides the servo outputs.

<mode name="mjafar">
    <message name="AIRSPEED"            period="0.2"/>
    <message name="ATTITUDE"            period="0.2"/>
    <message name="CIRCLE"              period="0.2"/>
    <message name="COMMANDS"            period="0.2"/>
    <message name="NAVIGATION"          period="0.2"/>
    <message name="DESIRED"             period="0.2"/>
    <message name="PPRZ_MODE"           period="5."/>
    <message name="SETTINGS"            period="5."/>
    <message name="GPS"                 period="0.25"/>
    <message name="ALIVE"               period="5"/>
    <message name="ESTIMATOR"           period="1.3"/>
    <message name="WP_MOVED"            period="1.4"/>
    <message name="ENERGY"              period="1.1"/>
    <message name="SEGMENT"             period="3.2"/>
    <message name="CALIBRATION"         period="5.1"/>
    <message name="NAVIGATION_REF"      period="9."/>
    <message name="STATE_FILTER_STATUS" period="5."/>
    <message name="DATALINK_REPORT"     period="5.1"/>
    <message name="DL_VALUE"            period="1.5"/>
    <message name="IR_SENSORS"          period="5.2"/>
    <message name="IMU_GYRO"            period="10.1"/>
    <message name="SURVEY"              period="2.1"/>
    <message name="GPS_SOL"             period="5.0"/>
</mode>

this message should be added to default_fixedwing.xml, and to default_fixedwing_imu.xml for Bixler.

Changed GCS default map loading policies

Hotfixed two options in GCS to load map tiles from cache only and also load them automatically as the map moves. Having to set these options from the menu every time that I opened the GCS was annoying!

(1) Set auto to true. [2]

let auto = ref true

(2) Change default policy to NoHttp somewhere during the program start. [3]

Gm.set_policy Gm.NoHttp;

Run server from Paparazzi center with logging enabled by default

In [4] change the run server option to an empty list.

run_server ("");

Add more PID loop states to PPRZ_MODE

First, edit messages.xml and add these fields to PPRZ_MODE message:

<field name="v_ctl_auto_throttle_submode" type="uint8" values="STANDARD|AGGRESSIVE|BLENDED"/>
<field name="v_ctl_climb_mode" type="uint8" values="AUTO_PITCH|AUTO_THROTTLE"/>
<field name="h_ctl_pitch_mode" type="uint8" values="THETA|AOA"/>
<field name="nav_mode" type="uint8" values="ROLL|COURSE"/>

Then edit send_mode function in autopilot_firmware.c for fixedwing aircraft:

static void send_mode(struct transport_tx *trans, struct link_device *dev)
{
  uint8_t dummy = -1;
  uint8_t ___nav_mode = (uint8_t) nav_mode;
  pprz_msg_send_PPRZ_MODE(trans, dev, AC_ID,
                          &autopilot.mode, &v_ctl_mode, &lateral_mode, &horizontal_mode, &rc_settings_mode, &mcu1_status,
                          &v_ctl_auto_throttle_submode,
                          &v_ctl_climb_mode,
#ifdef USE_AOA
                          &h_ctl_pitch_mode,
#else
                          &dummy,
#endif
                          &___nav_mode);
}