> For the complete documentation index, see [llms.txt](https://docs.theseus.us/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.theseus.us/cyclops/autopilot-integration/px4.md).

# PX4

{% hint style="warning" %}
This section is for PX4 multicopters. If you fly a fixed-wing or VTOL aircraft on PX4, contact us before you fly.
{% endhint %}

Cyclops works with PX4 as well as ArduPilot. The difference is how the position gets into the flight controller. On ArduPilot, Cyclops looks like a second GPS. On PX4, it feeds EKF2 through its external vision input, using the MAVLink `ODOMETRY` message.

We have flown this on PX4 1.16. If you run a different version, tell us before you fly. PX4 has changed how it reports some MAVLink fields between releases, and we check each version.

This section covers:

* [MAVLink](https://docs.theseus.us/cyclops/autopilot-integration/px4/mavlink.md): every message that goes each way, what it is used for, and what is inside the `ODOMETRY` stream.
* [Losing Cyclops in flight](https://docs.theseus.us/cyclops/autopilot-integration/px4/losing-cyclops-in-flight.md): how to tell when Cyclops stops giving PX4 a position, what PX4 does, and how Cyclops recovers.

## Parameters

Cyclops does not change any PX4 parameters, and on PX4 it does not read any either. Set these once when you set up the aircraft, then reboot the flight controller:

| Parameter          | Value              | Why                                                                                                                                 |
| ------------------ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| `EKF2_EV_CTRL`     | `1`                | Fuse the horizontal position from Cyclops. Leave the other bits clear (see below).                                                  |
| `EKF2_EV_NOISE_MD` | `0`                | Take the position noise from the `ODOMETRY` message. This is the default.                                                           |
| `EKF2_EV_QMIN`     | `50`               | Only fuse samples Cyclops marks as healthy. The default of `0` accepts everything, including samples Cyclops already knows are bad. |
| `EKF2_GPS_CTRL`    | `0`                | Don't fuse GPS when flying on Cyclops. GPS can still be logged and used to check accuracy afterwards.                               |
| `EKF2_HGT_REF`     | `0`                | Keep height on the barometer. Cyclops does not provide height to PX4.                                                               |
| `COM_POSCTL_NAVL`  | `0`                | If Cyclops stops sending a position, drop from Position mode to Altitude mode so the pilot can fly by hand. This is the default.    |
| `MAV_SYS_ID`       | must match Cyclops | Cyclops only listens to one system ID. It expects `1` unless you change it in Vozilla under *Settings > MAV*.                       |

{% hint style="warning" %}
**Check the magnetic declination.** Without GPS, PX4 can't look up the declination for your site, and the way it falls back is easy to get wrong. The PX4 parameter reference says that clearing bit 0 of `EKF2_DECL_TYPE` makes EKF2 use the value in `EKF2_MAG_DECL`. In PX4 1.16 that is not enough: bit 1 must also be set, and `EKF2_MAG_DECL` must not be `0`, which PX4 treats as "not set". Otherwise EKF2 uses a declination of zero. Every heading is then off by your local declination, and Cyclops inherits the error. If you fly without GPS, check on the ground before the first flight that the heading PX4 reports is the compass heading plus your local declination.
{% endhint %}

Cyclops also sends a velocity estimate in the same `ODOMETRY` message, which PX4 can fuse (bit 2 of `EKF2_EV_CTRL`). Velocity support is in beta.

Your failsafe parameters stay yours. Cyclops never switches flight modes on PX4, so what the aircraft does when it loses position is up to how you have set PX4 up. See [Losing Cyclops in flight](https://docs.theseus.us/cyclops/autopilot-integration/px4/losing-cyclops-in-flight.md).
