Skip to main content

Allan Variance Analyzer

Efficient Tool for Allan Variance Analysis

This library provides tools for performing Allan Variance Analysis on IMU data in order to calibrate the IMU parameters. This is done by computing the Angle Random Walk (ARW), Bias Instability and Gyro Random Walk for the gyroscope, and Velocity Random Walk (VRW), Bias Instability and Accel Random Walk for the accelerometer.

While plenty of libraries exist for this purpose, this library stands out for its immense efficiency, use of pure Python (no bindings or compilation needed), and ease of use, while being fully unit tested for ease-of-mind when adopting it for your use case.

Faster

The popular allan_variance_ros package (written in C++), when run on the example imu_simulation.bag takes:

611.90s user 204.06s system 96% cpu 14:06.21 total

Our library takes:

40.64s user 2.04s system 91% cpu 46.558 total

which is a 15x speed improvement!

Easier

  • There is no ROS dependency! But still useable within ROS.
  • Since this library is written completely in Python, you can simply do import allan_variance_analyzer to use it.
  • pip installable.
  • Outputs an imu.yaml file following the Kalibr format.

Collecting IMU Data

Please follow the below steps to collect the data needed to calibrate the IMU.

  1. Place your IMU on some damped surface and record your IMU data to the file format of your choice. Please be sure to record at least 3 hours of data. The longer the sequence, the more accurate the results.

  2. Recommended Reorganize messages by timestamp.

  3. Define an interface for reading the data file and loading it as a Tx6 numpy array where T is the number of data samples and we have 3-dimensional gyroscrope and 3-dimensional accelerometer data.

  4. Create a configuration YAML file which specifies the IMU rate (Hz) and the measure rate (Hz) which is the rate at which data is measured/subsampled. You can add additional parameters for your particular interface. An example config file is availabe in config/sim.yaml.

  5. Run Allan Variance computation tool. Please see analyze_rosbag.py for an example script using ROS bag data.

  6. The result is a generated imu.yaml file in the Kalibr format.

Example Data

We use the 3 hour log of a Realsense D435i IMU with timestamps already re-arranged, as provided by raabuchanan.

Our library automatically generates a Kalibr compatible file as imu.yaml:

# Accelerometer
accelerometer_noise_density: 0.006308226052016165 
accelerometer_random_walk: 0.00011673723527962174 

# Gyroscope
gyroscope_noise_density: 0.00015198973532354657 
gyroscope_random_walk: 2.664506559330434e-06 

update_rate: 400.0 # Make sure this is correct

IMU Noise Simulator

Thanks to @kekeliu-whu who contributed an IMU noise simulator is based on the Kalibr IMU noise model. You can generate a rosbag of simulated IMU noise and run allan_variance_ros to verify the tool is working. As shown in PR https://github.com/ori-drs/allan_variance_ros/pull/24 accuracy is quite good.

To generate simulated noise

rosrun allan_variance_ros imu_simulator [path_to_output_bag_file] [path_to_simulation_config_file]

A simulation config file is provided in allan_variance_ros/config/simulation/imu_simulator.yaml

To test Allan Variance ROS on simulated rosbag

rosrun allan_variance_ros allan_variance [path_to_folder_containing_bag] [path_to_config_file]

A config file is provided in allan_variance_ros/config/sim.yaml

Additional Example bags

Some additional rosbags of real IMU data for different sensors is available here. Thanks to Patrick Geneva.

Author

Varun Agrawal

If you use this package for academic work, please consider using the citation below:

@software{AllanVarianceAnalyzer,
  author       = {Varun Agrawal},
  title        = {Fast Allan Variance Analysis},
  year         = {2026},
  version      = {1.0.1},
  url          = {https://github.com/varunagrawal/allan_variance}
}

References

Local Development

We use uv to manage the project.

To run unit tests:

uv run pytest

To run an example script:

uv run python scripts/analyze_rosbag.py config/sim.yaml imu_simulation.bag

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

allan_variance_analyzer-1.0.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

allan_variance_analyzer-1.0.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file allan_variance_analyzer-1.0.2.tar.gz.

File metadata

  • Download URL: allan_variance_analyzer-1.0.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for allan_variance_analyzer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 906cd333617dc8574134a1943bc52a8489b75d7e61c4965281967bf12def5d63
MD5 902728f836dca2f29d274f2f6bc7d067
BLAKE2b-256 be7b3e52233235b0feec8a3040c7cfff5dc5c0c438e76520dc77fb2569c4420d

See more details on using hashes here.

File details

Details for the file allan_variance_analyzer-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for allan_variance_analyzer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 342ffb1165c503d5ef8c39d95b85b4284372f0398024c05f4181c6640288884e
MD5 4e718e753c89baa281bee7e0422050cb
BLAKE2b-256 e7b3531dd0db2078aefb24c7037a45f9ada3b705967046504d399886872a1251

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page