Uncertainty of PX4 altitude measurement

Hi,

Do you know the uncertainty of the altitude (AGL) measurement of PX4?

I suppose that the altitude is computed starting from barometer, GPS and IMU data, but I couldn’t find anywhere the uncertainty of the altitude measurement. I know it can change according to the place and conditions where the drone is used, but I would like to know the order of magnitude of it. Does anyone know it?

Are you using some kind of lidar or other AGL measurement device? If not, the AGL is actually altitude-above-home, rather than actual altitude above the current ground elevation.

Generally, altitude above home is broken down into offset bias and resolution.
This is anecdotal, but both GPS and barometer altitude can drift 1-2 meters every hour. These are the sources of direct altitude measurement, dictating the offset confidence.
Resolution is pretty good, and is dictated mostly by the EKF performance. I’d say that withing a short time frame your UAV can tell its altitude withing 1-2cm of accuracy. Controlling its altitude to that accuracy is a different topic altogether.

Thank you for all information!

My question was related to altitude-above-home, therefore, with the use of barometer and GPS.
The reason of my question is that I need to understand the accuracy of barometer+GPS+accelerometer altitude to decide if I need to buy a lidar to better control the altitude for my application.

Are you sure about the accuracy of 1-2 cm you are saying? Is it robust respect to environement conditions or pressure variations given by movements of the drone? I suspect that the accuracy could be lower. The raw data comining from barometer and GPS are for sure with much lower accuracy, but I don’t really know how they are filtered.

A lidar will not help you maintain an accurate Altitude-Above-Home. And Altitude-Above-Home will drift with GPS constellation motion and barometric conditions during flight.
I would guesstimate a drift of a few meters over a multi-hour flight.

Your best bet is to get an RTK GPS pair, if you plan to fly within a few kilometers. This will get you <10cm accuracy.

Jumping in here — and I might be off since I don’t have your full log/params, but this matches a confusion I’ve run into recently :grinning_face:

When we talk about “uncertainty of PX4 altitude”, it really helps to first pin down which “altitude” signal we mean, because PX4/EKF2 has a few that look similar but have different semantics:

  • EKF2 vertical state: vehicle_local_position.z / z_valid (typically NED frame, and usually “height reference” dependent)

  • HAGL / terrain-related: dist_bottom / distance_sensor (rangefinder-based, if present and fused/used)

  • Global altitude: GNSS altitude (often noisier, different reference datum)

  • Baro altitude: smooth but drifting / sensitive to pressure changes and airflow

So the “uncertainty” can come from at least two layers:

  1. Estimator-side uncertainty (EKF2)
    EKF2 maintains variances/innovations and will gate measurements if innovation ratios blow up. Even if a sensor is publishing data, it may be down-weighted or gated, which changes what you perceive as “altitude quality” over time.

  2. Control-side interpretation
    Depending on mode and controller config (e.g. MPC_ALT_MODE, terrain following, etc.), the controller might be tracking local z while you’re mentally thinking height above ground. That mismatch alone can make things feel “uncertain” even when the estimator is consistent.

One thing that caught me before: a distance sensor can be present, but its fusion/use is conditional (speed/height/quality gates), so the system can silently switch between “range helps a lot” and “range effectively not in the loop”. Without looking at fused flags/innovations, it’s hard to tell.

I’m still piecing this together (so happy to be corrected), but I wrote up the “semantics + priority + gating” angle and the relevant code-path observations in this GitHub issue:
https://github.com/PX4/PX4-Autopilot/issues/26226

If you (or anyone following the thread) has a short log and the key params (height ref + range gating + alt mode), it’d be super helpful to compare the estimator variances/innovations there and then summarize back here once it’s clearer what’s expected vs what’s happening.