Gyroscope bias and drift
Understand the two kinds of error in a gyroscope reading, why they behave differently when you integrate the reading over time, and which sensor device to use when you need the correction guaranteed.
A gyroscope measures angular velocity, not orientation. To get orientation from it you integrate the reading over time, and integration accumulates whatever error the reading contains. Two kinds of error matter, and they grow differently: bias grows in proportion to time, and noise grows much more slowly.
This page explains bias and noise, which of the Input System's gyroscope devices removes the bias, and the terms you encounter in platform documentation. For the devices themselves and the platforms that support them, refer to Supported sensors reference.
Bias and noise
Bias is an offset added to every reading. A device lying still on a table reports a small non-zero rotation, because the offset is present whether or not the device moves. Bias changes slowly with temperature and over the life of the hardware, so it behaves like a constant over the timescale of a single session.
Noise is random fluctuation around the true value. Successive readings scatter above and below it.
The difference matters when you integrate. Bias adds the same error to every sample, so the accumulated angle error grows in proportion to the time you integrate over. Noise scatters in both directions and partly cancels, so its accumulated error grows in proportion to the square root of that time. Over any useful window, bias dominates.
To put a scale on it, a bias of 0.5 degrees per second produces around 30 degrees of accumulated error after one minute of integration, regardless of whether the device moved. Noise of a similar per-sample magnitude contributes a small fraction of that.
Removing the bias therefore removes the dominant source of drift. It doesn't remove drift altogether: noise and any error remaining in the platform's own correction still accumulate.
Which device removes the bias
The Input System reports angular velocity in radians per second through two devices:
| Device | Bias |
|---|---|
Gyroscope |
Removal depends on the platform. Some platforms report the corrected value and some report the sensor value as it is. |
BiasCorrectedGyroscope |
Always removed. |
Use Gyroscope when you read the value directly and platform-based differences don't affect you. For example, use Gyroscope to rotate content while the user turns the device. Use BiasCorrectedGyroscope when the correction has to be there on every platform, for example when you integrate the reading.
BiasCorrectedGyroscope is only present on platforms that can supply a corrected value, so check for it before you use it:
if (BiasCorrectedGyroscope.current != null)
InputSystem.EnableDevice(BiasCorrectedGyroscope.current);
On some platforms the corrected value comes from a fused sensor pipeline that combines the gyroscope with other sensors. Enabling BiasCorrectedGyroscope starts that pipeline, which uses more power than the gyroscope alone, so enable it only while you need it. For how to enable and disable sensors, refer to Query sensors in code.
Terminology
Platform documentation and hardware datasheets use several terms for these ideas, and some of them are easy to misread.
| Term | Meaning |
|---|---|
| Bias | The offset added to every reading. Also called offset, or zero-rate offset in datasheets. |
| Noise | Random fluctuation around the true value. |
| Drift | The accumulated error you get by integrating a reading over time. Some platform documentation uses the same word for the slow change in bias itself. |
| Calibration | The process a platform uses to estimate the bias to subtract it. |
| Bias-corrected | The bias has been estimated and subtracted. Also refer to unbiased, below. |
| Uncalibrated | The bias hasn't been subtracted. It doesn't mean the sensor is faulty or unusable. |
| Unbiased | Reads as an absence of bias, but platform documentation uses it to mean the bias has been subtracted, which is the same as bias-corrected. |