optical flow indoor drone position hold ardupilot setup

Optical Flow Sensors: Holding Position Without GPS

Khalid Hesham Updated 5 min read

Quick Answer

An optical flow sensor is a small camera that points straight down. It watches how the ground moves under the drone. This lets the drone hold position with no GPS at all. It needs a rangefinder to measure height. It works best over a textured surface in good light, which makes it useful indoors or anywhere GPS is weak or missing.

How Optical Flow Works

An optical flow sensor is a tiny, simple camera pointed straight down. It takes fast images and compares them frame by frame. This is much like how a computer mouse tracks movement on a desk.

The sensor watches how the pattern on the ground shifts between frames. From that, it works out how far the drone has moved, and in which direction. The flight controller mixes this with height data. It uses the result to hold the drone steady or fight drift.

This gives the drone a sense of sideways movement using only what it can see below. It needs no satellite signal at all.

Why Pair It With a Rangefinder

Optical flow alone only measures how much the image shifts, in pixels. To turn that into real speed and distance, the flight controller also needs to know the drone's height.

A rangefinder is a small sonar or laser unit that points down. It measures height directly. Together, the two sensors let the flight controller work out true movement:

  • Higher up, the camera sees a wider patch of ground. The same pixel shift then means more real distance moved.
  • Closer to the ground, the same pixel shift means less real distance.

Without good height data, optical flow position hold becomes unreliable. The flight controller cannot scale what the camera sees.

Surface and Light Limits

Optical flow needs a clear, trackable pattern on the ground. This creates some real limits.

  • Surface texture matters. A patterned floor, grass, or carpet gives the sensor plenty to track. A plain surface, still water, or shiny flooring gives it very little.
  • Light matters just as much. Most sensors need steady, decent light to see the ground. Very dark rooms, hard shadows, or fast-changing light can confuse them.
  • Height has a working range. Fly too low, and the sensor sees too little detail per frame. Fly too high outdoors, and the ground detail can get too fine, or the rangefinder can run out of range.
  • Fast motion is harder to track. Quick, jerky moves can be harder for some sensors to follow than slow, steady flying.

Knowing these limits sets the right expectations. Optical flow position hold is rarely as steady as GPS in open sky.

Indoor Use Cases

Optical flow shines exactly where GPS does not work: indoors and other closed spaces.

  • Warehouse and indoor inspection drones use it to hold a steady spot for close-up work, with no satellite signal in sight.
  • Indoor filming and event flying gets a steadier hover during a shot, with no need for an outdoor GPS lock first.
  • Indoor training flights become easier for new pilots, since optical flow makes hovering more forgiving.

Outdoors, optical flow can also act as a helpful backup layer. It can steady the drone if GPS briefly weakens. It is not a full swap for GPS over long distances, though.

Setting It Up in ArduPilot

ArduPilot has built-in support for optical flow and rangefinder sensors. The exact steps depend on your hardware, but the general path looks like this:

  1. Wire the optical flow sensor and rangefinder to the flight controller. Follow the maker's pinout, usually over I2C or a serial port.
  2. Turn on optical flow support and pick the right sensor type in your ground station software, such as Mission Planner.
  3. Turn on and set up the rangefinder as its own sensor. Optical flow needs it for correct scaling.
  4. Run any calibration steps the maker lists. This often includes checking the lens is clean and level.
  5. Test first in a large, open, well-lit indoor space. Fly low and keep a spotter nearby, before you trust it for tighter flying.

For the wider picture on wiring sensors like this, alongside airspeed and compass gear, see this ArduPilot sensor setup guide. If you are still picking a firmware for your project, this comparison of Betaflight, INAV, and ArduPilot shows where optical flow and GPS fit into each one.

Optical Flow vs GPS: Choosing the Right Tool

Optical flow and GPS solve a similar problem, position hold, but in different settings.

FeatureOptical flowGPS
Works indoorsYesNo
Works over water or plain groundPoorlyYes
Needs a clear view of the skyNoYes
Typical accuracyDepends on height and surfaceA few meters (standard modules)

Many capable drones use both. GPS handles outdoor flying and long-range rescue. Optical flow adds steady, close-range hovering on top of it. If you have not added GPS yet, this guide on adding GPS to a drone and this GPS module comparison cover that side of the build.

FAQ

Can optical flow replace GPS completely?
Not for outdoor or long-range flying. It works well indoors or in GPS-denied spots, but GPS is still the better choice for open, outdoor flying and rescue.
Why does my optical flow sensor lose position hold over water?
Water is shiny and often has no stable pattern to track. That makes it one of the hardest surfaces for optical flow to read.
Does optical flow work at night?
Most sensors need decent light to see the ground. Performance drops in the dark unless the drone or the room has enough light.
Do I need both a rangefinder and an optical flow sensor?
Yes, for reliable results. The rangefinder gives the height data the flight controller needs to scale what the optical flow sensor sees.