光流

Optical Flow uses a downward facing camera and a downward facing distance sensor for position estimation. Optical Flow based navigation is supported by: EKF2 and LPE.

Setup

An Optical Flow setup requires a downward facing camera and a distance sensor (preferably a LiDAR). These can be connected via MAVLink, I2C or any other bus that supports the peripheral.

Note If connected to PX4 via MAVLink the Optical Flow device must publish to the OPTICAL_FLOW_RAD topic, and the distance sensor must publish to the DISANCE_SENSOR topic.

The output of the flow when moving in different directions must be as follows:

Vehicle movement Integrated flow
Forwards + Y
Backwards - Y
Right - X
Left + X

For pure rotations the integrated_xgyro and integrated_x (respectively integrated_ygyro and integrated_y) have to be the same.

An exemplary setup is the PX4Flow and Lidar-Lite, as shown below.

Optical flow lidar attached

Cameras

PX4Flow

The easiest way to calculate the optical flow is to use the PX4Flow board (see link for setup information).

Other Cameras

It is also possible to use a board/quad that has an integrated camera (Bebop2, Snapdragon Flight). For this the Optical Flow repo can be used (see also snap_cam).

Range Finder

You can use any supported distance sensor. However we recommend using a LIDAR over a Sonar, because of robustness and accuracy.

Estimators

Extended Kalman Filter (EKF2) {#ekf2}

For optical flow fusion using EKF2, set the use optical flow flag in the EKF2_AID_MASK parameter, as shown using QGroundControl below:

QGroundControl - Calibrate Sensors

If your optical flow sensor is offset from the vehicle centre, you can set this using the following parameters.

Parameter Description
EKF2_OF_POS_X X position of optical flow focal point in body frame (default is 0.0m).
EKF2_OF_POS_Y Y position of optical flow focal point in body frame (default is 0.0m).
EKF2_OF_POS_Z Z position of optical flow focal point in body frame (default is 0.0m).