Optical Flow uses a downward facing camera and a downward facing distance sensor for position estimation. Optical Flow based navigation is supported by all three estimators: EKF2, LPE and INAV (see below).
As mentioned above, an Optical Flow setup requires a downward facing camera which publishes to the
OPTICAL_FLOW_RAD topic and a distance sensor (preferably a LiDAR) publishing messages to the
The output of the flow has to be as follows
|Moving direction of the MAV||Integrated flow|
And for pure rotations, the integraded_xgyro and integraded_x (respectively integraded_ygyro and integraded_y) have to be the same.
An exemplary setup is the PX4Flow and LIDAR-Lite (see picture).
The easiest way to calculate the optical flow is to use the PX4Flow board. In order to use the PX4Flow board, just connect it with I2C. The recommended way of mounting it is with the Sonar side facing forwards (see image). In this configuration the parameter
SENS_FLOW_ROT should be 270 degrees (which is the default). Make sure the the PX4Flow board is well dampened.
In order to ensure good optical flow quality, it is important to focus the camera on the PX4Flow to the desired height of flight. To focus the camera, put an object with text on (e. g. a book) and plug in the PX4Flow into USB and run QGroundControl. Under the settings menu, select the PX4Flow and you should see a camera image. Focus the lens by unscrewing the set screw and loosening and tightening the lens to find where it is in focus.
We recommend using a LIDAR over a Sonar, because of robustness and accuracy. One possibility is the LIDAR-Lite.
Extended Kalman Filter (EKF2)
In order to use the EKF2 estimator, make sure the parameter
SYS_MC_EST_GROUP is set to
2 and reboot. For Optical Flow fusion, the parameter
EKF2_AID_MASK has to be set accordingly.
Local Position Estimator (LPE)