MTSUAV

ArduPilot Optical Flow GPS-Denied Navigation Guide

ArduPilot Optical Flow GPS-Denied Navigation Guide

In the world of drone navigation, GPS-denied environments pose significant challenges, particularly in settings like indoor spaces, warehouses, urban canyons, or areas impacted by GPS jamming. Fortunately, optical flow navigation provides a viable solution for stable positioning under these conditions, making it an essential tool for engineers, operators, and researchers. This guide will explore how optical flow functions within the ArduPilot ecosystem, the requirements for effective implementation, and performance considerations.

How Optical Flow Works for Drones

The principle of optical flow relies on the movement of pixel patterns across the camera’s sensor, which can be tracked to deduce motion. This pixel displacement tracking method can estimate the velocity of the drone by measuring how quickly specific patterns shift in the camera view. Accurate optical flow calculations necessitate not only a camera but also a rangefinder to determine the altitude; without this, AltHold mode becomes unreliable.

When optical flow is integrated with the Extended Kalman Filter (EKF3) in ArduPilot, it enhances the drone’s navigational capabilities in GPS-denied situations. However, it’s important to be aware of some limitations affecting accuracy:

  • Surface Texture: Optical flow works best on textured surfaces; smooth surfaces can cause failure in motion tracking.
  • Altitude Ceiling: Most sensors can function effectively at altitudes of around 10 meters or lower.
  • Distortions: Optical flow may suffer from interference caused by rapid motion or sudden direction changes.

Optical Flow Sensor Selection

Sensor ModelInterfaceMax AltitudeResolutionWeightPriceArduPilot Compatibility
PX4FLOWI2C/MAVLink10m0.1m30g$35Yes
ThoneFlowUART12m0.05m50g$45Yes
Matek 3901-L0XI2C10m0.1m20g$50Yes
Cheerson CX-OFI2C8m0.2m25g$15Limited

Rangefinder Requirements

For effective operation, optical flow systems require a rangefinder to maintain accurate altitude measurements for Vertical Hold (AltHold) functionality. Without it, the relative altitude cannot be reliably maintained. Here are a few recommended rangefinders:

  • TFmini Plus:
  • Interface: UART
  • Range: 0.1-12m
  • LightWare SF11C:
    • Interface: I2C
    • Range: Up to 100m
  • Benewake TFmini-S:
    • Interface: UART
    • Range: 0.1-12m
  • Benewake TF02 Pro:
    • Interface: I2C
    • Range: Up to 40m
  • Configure the rangefinder in the ArduPilot parameters using RNGFND1_TYPE to match your chosen device.

    ArduPilot EKF3 Configuration

    Configuring the Extended Kalman Filter (EKF3) is crucial for integrating optical flow data. Here are key parameters that need to be set:

    1. EK3_SRC1_VELXY = 5 (Optical Flow)
    2. EK3_SRC1_VELZ = 1 (Barometer)
    3. FLOW_TYPE = 2 (PX4FLOW) or 5 (for UART sensors)
    4. FLOW_FXSCALER and FLOW_FYSCALER: Set based on sensor specifications to scale optical flow values.
    5. FLOW_POS_X/Y/Z: Configure offsets to account for sensor placement.
    6. EK3_GPS_TYPE = 3 (indicating no GPS)

    A step-by-step setup should involve connecting to the Mission Planner software, navigating to the Config/Tuning tab, then selecting the Full Parameter List or Tree to input these settings.

    Hardware Wiring

    The correct wiring is essential for the operation of optical flow and rangefinder systems. For example:

    • For the PX4FLOW sensor, connect via I2C on the Pixhawk board.
    • The ThoneFlow can be connected using a UART interface, often labeled as SERIAL4.
    • Connect the rangefinder using either UART or I2C, depending on the model.
    • Consider the orientation of the sensors for proper flow calculations.
    • Ensure vibration isolation to prevent erroneous readings due to drone movement.

    Calibration and Testing

    Calibration is essential for accurate optical flow readings.

    1. Set the FLOW_ORIENT_YAW parameter based on the sensor orientation.
    2. Perform optical flow calibration in the Mission Planner interface.
    3. Once calibration is complete, test the drone in Loiter mode to evaluate hover stability.
    4. Analyze logs to check OF.flowX and flowY values against expected movement.
    5. Monitor the EKF innovations for any anomalies.
    6. Look for common failure signatures such as sudden jumps or drift in position logs.

    Performance Limitations and Practical Boundaries

    While optical flow provides invaluable advantages in GPS-denied environments, it is not without its limitations:

    • Surface Texture Requirement: Optical flow fails to track movement effectively on smooth surfaces such as white floors or water.
    • Maximum Operating Altitude: The practical altitude limit is typically capped at around 8 meters for sensors like PX4FLOW.
    • Failure Modes: In adverse conditions, the system may revert to using accelerometer-only navigation, which introduces a drift over time.
    • Indoor Wind Interference: Air currents or disturbances can cause instability when operating indoors.

    Conclusion

    In summary, integrating optical flow with ArduPilot allows for effective navigation in GPS-denied scenarios, making it an essential component for drone operators tackling challenging environments. By understanding how optical flow functions, selecting appropriate sensors, configuring ArduPilot effectively, and being aware of performance limitations, users can maximize the capabilities of their drones. With proper calibration and testing, optical flow navigation can provide reliable positioning and insight in complex operations.

    Analyzing ArduPilot Logs for Optical Flow Issues

    What to Graph

    Optical flow troubleshooting should start with the DataFlash log messages related to the sensor and the EKF. In Mission Planner, open FlightDataDataFlash Logs, download or open the onboard log, then use the graphing tool to plot the optical flow and estimator fields.

    • Graph OF.flowX and OF.flowY to inspect the raw measured optical flow rates from the sensor.
    • Graph OF.bodyX and OF.bodyY to inspect the estimated body-frame velocity derived from the optical flow solution.
    • Graph OF.Qual to check whether the sensor had enough surface texture and image quality to produce reliable flow.
    • Graph EKF4.SV to review EKF velocity variance. When optical flow is working well, EKF4.SV should generally remain below 0.5.
    • If a rangefinder is used for optical-flow height scaling, also graph the rangefinder altitude fields, commonly logged under RNGFND, to identify spikes or dropouts that can corrupt flow-based velocity estimation.

    In MAVExplorer, load the DataFlash log and plot the same fields using graph commands such as graph OF.flowX OF.flowY, graph OF.bodyX OF.bodyY, graph OF.Qual, and graph EKF4.SV. MAVExplorer is useful for quickly comparing flow output against GPS velocity, attitude, altitude, and estimator innovations over the same time range.

    Reading Quality Score

    The optical flow quality value is logged as OF.Qual and normally ranges from 0 to 255. A healthy optical flow setup should usually show OF.Qual above 100 during normal flight over a textured, well-lit surface.

    • OF.Qual above 100 generally indicates usable image texture and acceptable tracking confidence.
    • OF.Qual near 255 indicates very strong tracking quality, assuming the sensor is not saturated or misconfigured.
    • OF.Qual dropping toward 0 indicates the sensor has lost reliable surface tracking, often due to poor texture, low light, excessive altitude, motion blur, or an unsuitable surface such as water, glossy flooring, or uniform carpet.

    Good optical flow logs show OF.flowX and OF.flowY correlating with real vehicle motion. For example, when the aircraft translates laterally, the measured flow should change consistently in the expected axis and direction. The derived body-frame velocities, OF.bodyX and OF.bodyY, should be smooth and broadly consistent with other navigation sources such as GPS velocity when GPS is available for comparison.

    Common Failure Signatures

    OF.Qual drops to 0The optical flow sensor has lost surface texture or image tracking. This is commonly caused by poor lighting, excessive height above ground, a low-texture surface, motion blur, or vibration.
    OF.flowX and OF.flowY do not correlate with vehicle movementThe sensor may be mounted with the wrong orientation, the flow scaling may be incorrect, or the sensor may be affected by vibration or lens contamination.
    OF.bodyX and OF.bodyY diverge from GPS velocityThis usually indicates optical flow calibration, orientation, scaling, or rangefinder height-scaling problems. When GPS is available, comparing optical-flow body velocity against GPS-derived motion is one of the fastest ways to identify miscalibration.
    EKF4.SV rises above 0.5The EKF is reporting increased velocity uncertainty. This may occur when optical flow quality is poor, rangefinder data is unreliable, vibration is high, or flow measurements disagree with inertial estimates.
    Altitude oscillation with RNGFND spikesOptical flow depends on accurate height above ground for velocity scaling. If rangefinder readings spike, drop out, or oscillate, the EKF can receive incorrectly scaled flow velocity, causing position or altitude instability.

    For GPS-denied tuning, the most useful confirmation is a stable combination of high OF.Qual, believable OF.flowX and OF.flowY, smooth OF.bodyX and OF.bodyY, and low EKF4.SV. If any of these disagree, resolve the sensor quality, mounting, calibration, or rangefinder issue before relying on optical flow for position hold or autonomous flight.

    Comparing GPS-Denied Navigation Methods

    MethodAccuracyCostArduPilot NativeBest For
    Optical Flow (PX4FLOW)+-5-20cm at 2-8m$30-80YesIndoor hover/research
    VIO Intel T265+-1-5cm$200-300CompanionIndoor precision
    LiDAR SLAM (RPLIDAR)map-based$100-200CompanionIndoor mapping
    UWB Anchorscm-level$500+ infraMAVLinkFixed indoor site
    Barometer onlyaltitude onlyfreeYesFallback
    IMU dead reckoningseconds onlyfreeYesEmergency only

    Optical flow is the practical choice when the aircraft only needs local position hold, slow indoor movement, or short-range GPS-denied hovering over a textured surface. It is inexpensive, supported directly by ArduPilot, and does not require a companion computer or pre-built map. It works best at low altitude with good lighting, visible floor texture, low vibration, and moderate vehicle speed. It is less suitable over glossy floors, water, uniform carpet, darkness, or high-altitude flight where the ground texture becomes too small for reliable tracking.

    For best results, combine optical flow with a stable altitude source and heading reference. In ArduPilot, the optical flow sensor estimates horizontal motion, the barometer provides altitude continuity, and the compass helps maintain yaw reference so the EKF can correctly rotate flow measurements into the vehicle navigation frame. A rangefinder is strongly recommended with optical flow because accurate height above ground is needed to scale the flow data correctly; the barometer alone is useful as a fallback but can drift with pressure changes. Calibrate the compass, minimize vibration, mount the flow sensor rigidly and level, verify sensor orientation, and tune EKF source settings so optical flow is used for horizontal velocity while barometer/rangefinder data support altitude estimation.

    Configuration Sequence

      1. Set FLOW_TYPE to match the optical flow sensor being used.

      2. Mount the optical flow sensor securely and measure FLOW_POS_X, FLOW_POS_Y, and FLOW_POS_Z relative to the flight controller center.

      3. Set FLOW_ORIENT_YAW to match the sensor’s yaw rotation relative to the aircraft frame.

      4. Configure the rangefinder by setting RNGFND1_TYPE to the correct sensor type.

      5. Set EK3_SRC1_VELXY=5 so the EKF uses optical flow for horizontal velocity estimation.

      6. Set EK3_GPS_TYPE=3 to prevent GPS from being used by the EKF in GPS-denied operation.

      7. Calibrate and test in Loiter mode at approximately 1–2 m AGL.

    The order matters because ArduPilot needs the sensor type, physical mounting offsets, and orientation configured before the EKF can correctly interpret optical flow measurements. If position or yaw orientation is wrong, the vehicle may drift, toilet-bowl, or respond incorrectly in Loiter.

    The rangefinder should be configured before relying on optical flow because optical flow velocity scaling depends on accurate height above ground. EKF source selection should be changed only after the sensors are correctly configured, and final calibration should be done at low altitude to verify stable behavior safely.

    Frequently Asked Questions

    1. Can optical flow work in complete darkness?

    Optical flow requires light to track surfaces effectively, so it may not perform well in complete darkness unless equipped with appropriate IR or low-light cameras.

    2. What is the maximum range for optical flow sensors?

    Most optical flow sensors operate effectively up to 10 meters; however, practical use often caps at around 8 meters due to accuracy declines at greater distances.

    3. How does vibration affect optical flow performance?

    Excess vibration can result in erroneous readings due to disturbances in the visual field, leading to reduced accuracy. Effective vibration isolation is critical.

    4. Are there alternatives to optical flow for GPS-denied navigation?

    Other methods include LiDAR, sonar-based sensors, and visual inertial odometry (VIO), which can serve as alternatives depending on the operational context.

    5. Can I use optical flow outdoors?

    Yes, but it is typically less effective in outdoor environments with smooth surfaces and under conditions where GPS is available. It’s best utilized in structured indoor settings.

    6. How do I troubleshoot optical flow issues?

    Check calibration settings, ensure the sensor’s orientation is correct, validate surface conditions, and review flight logs for inconsistencies or error messages.

    Sources & References

    About MTS UAV
    MTS UAV publishes independent drone research — hardware analysis, regulatory coverage, open-source UAV development, and field engineering guides.

    mtsuav.com

    MTSUAV

    Independent UAV Research & Drone Technology

    © 2026 MTSUAV — Independent Drone Research

    Hands-on. Never theoretical.