· Course overview

Indoor Positioning on Your DEXI

How a drone holds position indoors, where GPS cannot reach. The four sensors that make a hover work, how they combine, and the ways they fail without telling you.

11 lessons · 84 minutes · DEXI-3 and DEXI-5 · PX4 · Updated September 2026
A DEXI quadcopter hovering in place beside a translucent copy of itself several body-lengths away, joined by a thin line. The solid aircraft is where the drone is. The ghost is where the IMU alone believes it is.
The drone has not moved. The ghost is where its own accelerometers and gyroscopes believe it is, after less than a minute of working alone.

Outdoors a drone knows where it is because a GPS receiver tells it. Indoors nothing tells it. The aircraft has to work its position out from four sensors that each measure something other than position: an inertial measurement unit that feels acceleration and rotation, a barometer that reads air pressure, a downward distance sensor that reports how far away the surface below is, and an optical flow sensor that watches the floor slide past.

None of those is a position sensor. A hover indoors is what you get when an estimator combines all four, decides moment to moment which of them to believe, and integrates the result. This course is about that machinery: what each sensor measures, the one multiplication that turns two of them into a velocity, and why the most dangerous failure in the set is the one that never raises a fault.

Why the IMU is not enough on its own

The obvious idea is to skip the other sensors entirely. An accelerometer measures acceleration. Integrate it once for speed and again for distance, and you have a position. It is the way inertial navigation is described in every introduction to the subject, and on a small drone it fails within seconds.

Sit a drone on a table, perfectly still, and let it estimate its own position from the IMU alone. After one second the estimate is off by a few centimeters. After ten seconds, by half a meter. After a minute it is eighteen meters away, and the aircraft has not moved. Integrating twice squares the problem: a steady acceleration error of 0.01 m/s², which is a good sensor, becomes eighteen meters of position error in sixty seconds.

Time sitting stillEstimated position error
1 seconda few centimeters
10 secondshalf a meter
1 minute18 meters

Nothing is broken. The drone has not moved. The estimate has left the room.

The same thing, live. Press Run and watch the ghost leave. Add a degree of tilt and watch how much faster it goes. Open it full size.

Tilt matters more than the sensor's own error. An accelerometer does not measure movement through space, it measures gravity plus movement, so finding the movement means subtracting gravity, and subtracting gravity means knowing exactly which way is down. One degree of tilt error leaks 0.17 m/s² of imaginary sideways acceleration into the estimate. That is 8.5 meters of position error in ten seconds, roughly seventeen times what the bias alone produced. Knowing which way up you are and knowing where you are turn out to be the same problem.

The IMU is still indispensable. Over a tenth of a second it is fast, smooth and close to perfect, and nothing else on the aircraft reacts as quickly. It just cannot be left alone with the estimate for longer than that. Everything else in this course exists to keep correcting it.

The four sensors, and what each one measures

Inertial measurement unit

Accelerometer and gyroscope, sampled a few hundred times a second. Measures the aircraft's own motion and its attitude. Excellent over a fraction of a second, useless over a minute.

Barometer

Measures air pressure, which is converted to an altitude. It never loses signal and never needs a surface below, and it also responds to weather, to a door opening, and to the aircraft's own downwash in a small room. It gives you a smooth altitude, not an accurate one.

Downward distance sensor

Measures the distance to whatever is directly underneath: the floor, a table, a person walking through the shot. Accurate and fast within its range. Outside that range, or on glass, water or a polished floor, it returns something that is not the distance to the floor, and rarely says so.

Optical flow

A small downward camera comparing each picture of the floor with the last and reporting how far the image shifted. That shift is an angle, in radians per second, not a speed.

The one equation that defines a flow system

Hover one meter above a tiled floor and slide sideways by ten centimeters. The tiles sweep a certain distance across the sensor's view. Now hover at two meters and slide the same ten centimeters. The tiles look half as big, so they sweep across half as much of the view. Same movement, different reading. That is why flow is an angular rate, and why it is useless until you multiply it by the height above the ground:

v = ωflow × h
horizontal speed = measured angular flow rate × height above the ground
the same textured floor 1 meter up 1.0 m sees a lot move 2 meters up 2.0 m sees half as much SAME 10 cm drift different flow reading

Drift 10 cm at one meter and the floor sweeps across a big slice of the view. Drift the same 10 cm at two meters and it sweeps across half as much.

Because it is a multiplication, a height error does not add to the velocity error, it scales it. A height that is 10 percent low gives a velocity that is 10 percent low, and the aircraft under-corrects and drifts steadily away. A height that is 10 percent high gives a velocity that is 10 percent high, and the aircraft over-corrects and can oscillate. No filter averages that out, because nothing about the reading looks unusual. It is confidently, consistently wrong by exactly that ratio for as long as the height is wrong.

So the distance sensor is not an accessory to the flow sensor. It is inside the multiplication. A flow system with a bad height source is a flow system with a bad velocity, and a drone that holds position badly for reasons that have nothing to do with its camera.

The failure worth studying

Put those pieces together and you get the failure mode that matters most on any aircraft holding station on flow and a distance sensor.

The distance sensor stops reading and reports its minimum, a few centimeters, which is exactly what it reports sitting on the floor. If the estimator is configured to take its height from that sensor, the height estimate follows it down. That believed height is now below the minimum height at which optical flow is allowed to contribute, so flow is gated out. Height and horizontal position vanish in the same instant, the position controller has no valid setpoints left, and the aircraft falls back to a blind landing. From the ground, a drone that was hovering calmly descends and lands itself, and nothing reports a fault.

Why the sensor cannot know it is wrong. It times a pulse of light to whatever is underneath and reports the distance. Slide a crate under it and the reading changes, though the aircraft has not moved. Open it full size.

None of the built in checks catch it, and not because of a bug. A wrong but well formed reading is not a driver error. The value is still changing slightly, so it is not stuck. And the consistency check compares the rate of change of the range against a vertical velocity that the range itself is driving, so a sensor is being checked against a number derived from that same sensor. It will always agree with itself. The height estimate converges onto the bad reading, the innovation goes to zero, and every diagnostic built on innovation reports perfect health.

Nor does the sensor's own quality field save you. One family of flow modules in common use defines its status byte as 0 for unavailable and 245 for available. That is the whole vocabulary. A quality threshold set to 50 looks like a confidence level and behaves as a pass or fail flag, because any threshold between 1 and 244 does exactly the same thing. You can tell which kind you have without a datasheet: plot the quality field from a flight log, and if it only ever takes two values, it is a flag wearing the costume of a scale.

The check that does work has to come from outside the filter, and the course ends by building it.

The mode ladder, and the recovery drill

Flight modes are not arbitrary names. Each one is defined by the sensors it leans on, which is why they fail in a predictable order.

ModeNeedsWhat happens when a sensor fails
StabilizeIMU onlyKeeps flying. Everything else is built on top of it.
AltitudeIMU and a height sourceHolds height, drifts sideways. Survives a flow failure.
PositionIMU, height and flowNeeds the lot. Lose height or flow and it degrades or gives up.
Stabilize IMU Altitude IMU + height Position IMU + height + flow most help most control

Each rung adds a sensor, and with it a way to fail.

That ordering is the recovery drill. Position misbehaving, switch to Altitude. Altitude misbehaving, switch to Stabilize. Every step down removes a sensor the aircraft depends on and hands authority back to you, which is why a pilot who can fly Stabilize can always recover.

What you will be able to do

Course outline

1. What the Sensors Measure
1Why the IMU Needs Help
2The Barometer Measures Weather
3The Rangefinder Measures Whatever Is Below
4Optical Flow Measures an Angle
2. Making a Hover
5The Scale Chain
6Height: Blending Baro and Range
7The Terrain State
3. Trusting It, and Not
8How the Drone Decides What to Believe
9When a Sensor Fails Quietly
4. Indoors and Out
10GPS and Flow Are Opposites
11Choosing the Right Tool

Who this is for

Anyone flying or building a small drone that has to hold position without GPS: a classroom aircraft indoors, a research platform in a lab, an inspection drone under a roof. The lessons use the DEXI-3 and DEXI-5 running PX4 as the working examples and name real parameters, so you can go from a lesson to your own aircraft without translating. Nothing here is specific to one part number, and the reasoning applies to any flight stack that fuses flow with a distance sensor.

DEXI-3DEXI-5
IMUsTwo different onesA matched pair
MagnetometerNone fittedYes, on the flight controller
Flow and distance sensorA separate module underneathBuilt into the flight controller

The course compares the two architectures rather than the parts, because the reasoning outlives any one module.

No math beyond multiplication is needed. Some flying experience helps, because several lessons describe behavior you will recognize from having watched it happen.

Take the course

Indoor Positioning on Your DEXI is part of Flight Deck on the DroneBlocks platform. Start a free trial and the whole course opens, along with everything else on the platform.

Start your free trial 14 days. No credit card.

Common questions

Why does a drone drift indoors even with optical flow?

Optical flow reports an angular rate, not a speed. The flight controller turns it into a speed by multiplying by the height above the ground, so the velocity is only as good as the height. A height that is 10 percent low produces a velocity that is 10 percent low, and the aircraft under-corrects and walks away. Drift also comes from a floor with too little texture to match, from tilt, and from low light.

Does optical flow work in the dark?

No. A flow sensor is a small camera matching one picture of the floor against the next, and it needs a fast shutter to do that without blur. Too little light and the match fails. The downward distance sensor usually needs light of its own kind as well, so darkness tends to take out height and horizontal position together.

What is the difference between an optical flow sensor and a rangefinder?

They answer different questions. Optical flow watches the floor slide past and reports how fast the world is rotating past the lens, in radians per second. A rangefinder reports how far away the surface below is, in meters. Neither is a position sensor. Multiplied together they give a horizontal velocity, which the flight controller integrates into a position.

Can you fly a drone indoors using GPS?

Not reliably. A roof attenuates the signal and the walls reflect it, so the receiver either loses the fix or reports a confident position that is meters from the truth. Indoors the aircraft needs sensors that watch the immediate surroundings instead, which is what optical flow, a distance sensor and, for exact placement, visual markers are for.

Why did my drone land itself while it was hovering normally?

A common cause is a downward distance sensor that has stopped reading and is reporting its minimum value, which looks identical to sitting on the floor. The height estimate follows it down, that believed height falls under the minimum height for optical flow, flow is gated out, and the aircraft loses horizontal position and height at the same moment. It then descends. No fault is reported, because a wrong but well formed reading is not an error.

What height does optical flow work at?

Between a minimum set in the flight controller, which defaults to 8 centimeters, and whatever the downward distance sensor can still read, which on a small indoor aircraft is a few meters. Below the minimum flow is switched off deliberately. Above the sensor's range the height term in the velocity calculation is no longer trustworthy, so the velocity is not either.

Related courses