Optical Flow Sensor
1,474 words · 8 min read · 5 sources
An optical flow sensor is a small downward-facing camera that measures how fast the ground slides past it. Combined with a height reading from a rangefinder, that tells a drone or robot its own sideways speed, so it can hold position indoors or anywhere GPS is unavailable.
Also in:Español
Look down from a moving train and the ground streams past: the faster the train, the faster the stream. Now climb higher and the same speed looks slower. An optical flow sensor does exactly this with a tiny camera pointed at the floor. It measures how fast the picture is sliding, a second sensor measures the height, and together they give the robot its real speed over the ground.
🎯 Quick challenge
A drone's optical flow sensor reports the same flow rate at 1 m and at 4 m above the ground. Which is true?
An optical flow sensor is a small downward-facing camera that measures how fast the ground slides past it. On its own that only gives an angle per second; add a height reading from a rangefinder and the robot knows its real sideways speed in metres per second. Drones use it to hover in place without GPS (indoors, underground, under bridges), and the same idea is what lets an optical computer mouse track its movement across the desk.
This page is about the sensor hardware and how robots use it. For the underlying computer-vision idea (Lucas–Kanade, dense vs sparse flow), see optical flow.
Start here: the view from a train window
Look down from a moving train and the ground rushes past. Two things change how fast it seems to move:
- Speed. A faster train makes the ground stream faster.
- Height. Climb higher and the same speed looks slower: from a plane window, the ground seems to crawl.
An optical flow sensor sees only the first part, the apparent motion, measured as an angle per second. It cannot tell "fast and high" from "slow and low". That is why every flight-controller guide pairs it with a distance sensor: PX4's setup calls for "a downward facing camera and a downward facing distance sensor (preferably a LiDAR)" (PX4: Optical Flow).
How it works
- Take pictures, very fast. A small image sensor photographs the ground many times a second. The original open-hardware PX4FLOW camera, for example, has a 752×480 sensor and computes flow "on a 4x binned and cropped area at 400 Hz" (PX4FLOW docs).
- Compare each frame with the last. On-board processing finds how far the texture shifted between frames. Chips such as the PixArt PMW3901 do this internally: PX4 describes it as "an optical flow ASIC that computes the flow internally and provides a difference in pixels between each frame", a tracking sensor "similar to what you would find in a computer mouse" (PX4: PMW3901).
- Turn pixels into angles. Knowing the lens, the pixel shift becomes an angular rate. PX4 treats the integrated flow values as "angular measurements (radians)", not distances (PX4: Optical Flow).
- Remove the robot's own rotation. If the drone tilts, the ground appears to move even when the drone stays put. A gyroscope measures that rotation so it can be subtracted. ArduPilot's calibration checks exactly this: you roll and pitch the vehicle by about ±15° and check that the flow reading follows the rotation measured by the gyro (ArduPilot: setup).
- Multiply by height. What is left is translational flow. Multiply by the height from the rangefinder and you have ground speed.
- Fuse it. The flight controller's estimator (EKF2 in PX4, EKF3 in ArduPilot) blends that velocity with the IMU and other sensors into one estimate of the vehicle's motion (PX4; ArduPilot).
The one equation
For a sensor looking straight down at flat ground from height h:
ground speed ≈ (flow rate − rotation rate) × height
with the rates in radians per second and the height in metres. A residual flow of 0.5 rad/s at 2 m means about 1 m/s; the same 0.5 rad/s at 6 m means about 3 m/s.
The same relationship sets the sensor's speed limit. Because the sensor can only track a limited angular rate, the fastest measurable speed grows with height: the PX4FLOW documentation gives 2.4 m/s at 1 m and 7.2 m/s at 3 m with its 16 mm lens (PX4FLOW docs).
Common optical flow sensors
| Sensor | What it is | Height reading | Source |
|---|---|---|---|
| PX4FLOW | Open-hardware smart camera (2013), documented in older PX4 releases: 752×480 MT9V034 sensor, 168 MHz Cortex-M4F, on-board gyro, input for a sonar | Sonar input on board | PX4 docs |
| PMW3901 boards | Mouse-style flow chip "adapted to work between 80 mm and infinity"; sold on breakouts from Bitcraze, CubePilot (HereFlow), Holybro, Thone and others | Some boards include a distance sensor, some need an external one | PX4 docs |
| CAN flow modules | PX4 lists ARK Flow, ARK Flow MR, Holybro H-Flow and Agam FloRange, connected over DroneCAN | Built-in lidar distance sensor | PX4 docs |
| ADNS3080 (archived) | An optical-mouse sensor with a lens, once used on early ArduPilot copters; now "no longer supported" | Not on the sensor itself | ArduPilot docs |
For PMW3901 boards without their own rangefinder, PX4 says an external one is required, and recommends one for the others because their built-in range is "quite limited"; it suggests about 4 m of range for indoor flight and 10 m or more outdoors (PX4: PMW3901).
Where you'll see it
- Small drones flying indoors. Position hold where there is no GPS signal. In ArduPilot you can set the EKF to take horizontal velocity from optical flow (
EK3_SRC1_VELXY = 5) with no position source at all (ArduPilot). - Anywhere GPS is denied. PX4 frames the use case as flying "in buildings, underground, or in any other GNSS-denied environment" (PX4).
- Your desk. An optical mouse uses the same principle, pointed at the desk. The archived ArduPilot ADNS3080 sensor was literally a mouse sensor fitted with a lens (ArduPilot).
Limits
- It needs texture and light. A plain white floor, still water or darkness gives the camera nothing to track. ArduPilot's calibration procedure asks for "a textured surface and good lighting" (ArduPilot), and its archived mouse-sensor page notes that sensor "only works in well lit environments" (ArduPilot ADNS3080).
- It is only as good as the height. A wrong rangefinder reading gives a wrong speed. A copter flying on flow alone in Loiter or PosHold will not climb above the rangefinder's maximum (
RNGFNDx_MAX) in ArduPilot (ArduPilot). - High altitude gets wobbly. PX4 warns that the low resolution of common flow sensors "can cause slow oscillations when hovering at a high altitude above ground (> 20m)" (PX4).
- It measures velocity, not position. Position is velocity added up over time, so small errors accumulate into drift. For position over long runs, robots add visual odometry, SLAM or GPS.
- It assumes flat ground. The "× height" step treats the ground as a flat plane under the sensor; slopes, steps and tall grass break that assumption.
Going deeper: setting one up
The details differ by flight stack, but the same four things always matter:
- Mounting and orientation. Flow modules are usually mounted near the centre of the vehicle, looking straight down; PX4 sets the orientation with
SENS_FLOW0_ROT(PX4: PMW3901) and an off-centre lens position withSENS_FLOW0_POS_X/Y/Z(PX4: Optical Flow). - Enable fusion. PX4 enables optical flow fusion in EKF2 with
EKF2_OF0_CTRL(PX4); ArduPilot selects flow as a velocity source with theEK3_SRCparameters (ArduPilot). - Calibrate the scale. Rock the vehicle in roll and pitch and compare flow with gyro. If they disagree, adjust the scale:
FLOW_FXSCALER/FLOW_FYSCALERin ArduPilot (which also offers an in-flight calibration switch),SENS_FLOW0_SCALEin PX4 (ArduPilot; PX4). - Check the rangefinder too. A wrong height gives a wrong speed even when the flow itself is fine, so ArduPilot's troubleshooting list starts with checking that the rangefinder works (ArduPilot).
For the research origin of low-cost metric flow cameras, the PX4FLOW paper is Honegger, Meier, Tanskanen and Pollefeys, An Open Source and Open Hardware Embedded Metric Optical Flow CMOS Camera for Indoor and Outdoor Applications, ICRA 2013 (cited in the PX4FLOW docs).
Why it matters
GPS is unavailable indoors and unreliable under bridges and close to buildings, and an IMU on its own drifts because small errors add up over time. A cheap flow sensor plus a rangefinder gives a small robot a direct measurement of its own speed, which is often the difference between a drone that hovers calmly in a room and one that slowly slides into the wall.
Common questions
What does an optical flow sensor do on a drone?
It looks at the ground and measures how fast the image moves. With the drone's height from a rangefinder and its rotation from a gyroscope, the flight controller turns that into ground speed, which lets the drone hold its position without GPS.
Why does an optical flow sensor need a rangefinder?
Because the sensor only measures an angle per second. The same image motion can mean slow flight close to the ground or fast flight high up. Multiplying by the measured height gives the real speed in metres per second.
Does an optical flow sensor work in the dark or over water?
Usually not well. It needs visible texture to track, so dark rooms, glossy or plain floors and calm water make the reading unreliable. ArduPilot's guide asks for a textured surface and good lighting when calibrating.
Related
Optical flow · Visual odometry · IMU · Time-of-flight sensor · Sensor fusion · Drone
Next: the course path
Five free courses, from zero to your own robot design
Short videos with a quiz after each one, a final activity and a certificate per course.
See the course path →Plain English. Free. Unsubscribe in one click.
Keep going
Optical Flow
Optical flow is the pattern of apparent motion between video frames — the per-pixel arrows showing which way t…
ConceptVisual Odometry in Robotics
Visual odometry estimates a robot's motion from camera images alone. Powers ARCore, ARKit, and the navigation …
ConceptIMU (Inertial Measurement Unit)
An IMU is a chip that measures how fast something is accelerating and rotating. It is what lets a robot — or a…
Last updated · 2026-11-22
- Optical Flow — PX4 User Guide (main) →
- PMW3901-Based Flow Sensors — PX4 User Guide →
- PX4FLOW Smart Camera — PX4 User Guide (v1.13), citing Honegger, Meier, Tanskanen & Pollefeys, ICRA 2013 →
- Optical Flow Sensor Testing and Setup — ArduPilot Copter documentation →
- ARCHIVED: Mouse-based Optical Flow Sensor (ADNS3080) — ArduPilot documentation →
Spotted something off? Report an error →