INSLIB README

The project's README from github.com/jnz/INSLIB. As one markdown file: README.md.

INSLIB

CI codecov

INSLIB Logo

A portable C library for 3D navigation state estimation. Mail: [email protected]

Example Video

Dead Reckoning

Example video of pure inertial tracking with a TDK ICM-45686 low-cost Inertial Measurement Unit (IMU)

Overview

INSLIB is a portable C library for 3D navigation state estimation. Its core is a set of Kalman filters fusing measurements from an inertial measurement unit (IMU) with GNSS/GPS measurements, barometer, magnetometer, local position references, absolute yaw references, scalar ground speed and zero-velocity / zero-rotation information.

Typical use cases:

The core library is written in pure C (C11), has no external dependencies and is optimized for embedded microcontrollers. A useful collection of Python helper programs and GUI apps are included in this repository.

Features

Library Architecture Block Diagram

Block diagram

Post Processing Quickstart

Post processing GUI screenshot

inspostgui.py is a GUI to post-process measurements: pick a dataset directory (CSVs + config.yaml), tweak its settings, and replay it.

sh python/setup_venv.sh               # one-time (also runs `make pylib`)
. env.sh                              # activate the venv (POSIX/git-bash, any OS)
python3 python/inspostgui.py datasets/fog

.csv Data Format

The input format is plain CSV, one file per sensor. First item is a common t_us timestamp in microseconds. IMU example:

# t_us, gyr_frd_x [rad/s], gyr_frd_y [rad/s], gyr_frd_z [rad/s], acc_frd_x [m/s^2], acc_frd_y [m/s^2], acc_frd_z [m/s^2]
0,-0.0016361766,-1.39143679e-08,-0.000272652038,-0.114920214,0.191539065,-9.84495283
50003,-0.0016361766,-1.39143679e-08,-0.000272652038,-0.114920214,0.191539065,-9.84495283
100005,-0.000272652038,-0.000272707696,0.000818123087,-0.0861961461,0.248990132,-9.7587816

GNSS/magnetometer/barometer/speed .csv files follow the same pattern. Example files:

config.yaml

A dataset directory with CSV files carries one config.yaml that tells the filter how to run: aiding mode, sensor noise, lever arms, which channels are enabled. Two annotated examples to start from: doc/example_conf/config_basic.yaml (GNSS+IMU+baro+mag) and doc/example_conf/config_local_inertial.yaml (GNSS-free, pure inertial dead-reckoning). The keys are documented in doc/INSLIB_manual.pdf, section "Dataset configuration: config.yaml".

replay.py Command Line Post-Processing Version

replay.py is the command line counterpart to the inspostgui.py Python GUI above.

sh python/setup_venv.sh               # one-time (also runs `make pylib`)
. env.sh                              # activate the venv (POSIX/git-bash, any OS)
python3 python/replay.py datasets/fog --plot --plot-out /tmp/plots.pdf

Example PDF plot output from replay.py:

PDF Plots

Google Earth .kml output is also possible with --kml output.kml:

Google Earth kml Screenshot

GNSS Latency Estimation

GNSS Latency Estimation

GNSS receivers report data with some latency (transmission, internal processing, filtering) but receiver and configuration dependent. inspostgui.py and replay.py measure the real value for a specific configuration: IMU + barometric altitude has near-zero latency, cross-correlating its vertical velocity against the GNSS-reported vertical velocity around a real climb/descent results in a lag with a sharp correlation peak (see the plot above).

Example for a u-blox X20P receiver delay estimation:

python3 python/replay.py datasets/pedestrian/07_outdoor_only/ --estimate-gnss-delay

Live Data Quickstart

Live data flow

insrcv listens for UDP packets with sensor measurements. The packet format is documented in tools/inslib_protocol.md. Any process that sends this protocol format can feed it on UDP port 29800 (default). Output goes to PlotJuggler (UDP :9870, JSON) and optionally in MAVLink format (UDP :14550).

make insrcv
./build/insrcv --mavlink   # run and wait for UDP sensor input

In action, fusing a live Galileo HAS-corrected GNSS fix:

Galileo HAS

Tutorials

Documentation

GNSS inputs

Supported sensors

Real world data sets

(Not all datasets have an absolute ground truth available, e.g. the ArduPilot dataset is comparing the INSLIB solution with the ArduPilot solution)

Setup

The core C library only needs a C11 compiler and make (see Quickstart above). The Python bindings, plotting and reference-board tools additionally need a virtual environment:

sh python/setup_venv.sh      # one-time (Windows: python\setup_venv.bat)
. env.sh                     # activate the venv (POSIX/git-bash, any OS)

Directory Structure

📂 inslib/
├── Makefile              # Build: make test, make insrcv, ...
├── src/                  # Core library (.c/.h), no heap, no OS dependencies
│   └── nav_suite.h       # Main header: INS + AHRS + baro_alt wrapper
├── KFCore/               # Submodule: linear algebra, UDU/Bierman-Thornton filter
├── tests/                # Unit/integration tests
├── datasets/             # Real-world + simulated replay datasets
├── tools/                # C/Python reference board tools: calibration, GUI
├── python/               # Python bindings, plotting, replay harness
├── magneticmodel/        # WMM lookup table
├── doc/                  # Documentation, Doxygen, images
└── tutorial/             # Minimal C + Python usage examples

Reference Hardware

All tools (tools/) speak an open (UBX-based) protocol, documented in tools/inslib_protocol.md.

The reference board is a low-cost and ready-to-use development module (IMU, u-blox GNSS receiver, magnetometer, barometer) for running INSLIB on real hardware with pre-calibrated sensors. It implements the protocol above and is ready to use out of the box. Its firmware itself is not public, get in touch if you're interested in a collaboration with my university institute or in getting a unit.

Image of reference hardware

Building your own sensor suite is also possible, an example conf (mid 2026 sensor landscape):

Sensor Example part Notes
IMU TDK InvenSense ICM-45686, Bosch BMI563/BMI570, Analog Devices ADIS16505 or Murata SCH16T-K10
Magnetometer MEMSIC MMC5603NJ or ST LIS3MDL
Barometer Bosch BMP581 or TE MS5611
GNSS receiver u-blox F9P or X20 X20-series has L1/L2/L5 support and Galileo HAS decoding

Reference Board Calibration GUI

Calibration GUI

IMU/Magnetometer-Calibration + Housing-Alignment, user-friendly GUI for the reference board. The GUI allows an easy calibration of the sensor hardware for bias, scale and misalignment without the need for an expensive calibration environment like robotic arms, except for a controlled temperature environment. The sensor must be placed still for a few seconds in a variety of different orientations on a stable surface:

Calibration

Sensor Management GUI

Live-Control center for reference INS board

Screenshot

Screenshot 2

Reference Board Command Line Tools

Common Pitfalls

IMU sensor processing is unforgiving: it is not enough to get one thing right, the whole chain (timestamps, axis conventions, calibration, filtering, etc.) has to line up properly. A list of common mistakes:

AI Use

References

INSLIB (jnz/INSLIB)

Searching Database…

627 ·GitHub
What is this?INSLIB is a portable C library for 3D navigation state estimation that fuses IMU data with GNSS/GPS, barometer, magnetometer and other sensors through Kalman filters, used in drones, robotics, cars and aerospace projects.
Is this a ready-to-use app or a library I build into my own project?It is a pure C11 library with no heap, OS or external dependencies, meant to be compiled into firmware or desktop code; Python helper scripts and GUI apps for post-processing and calibration are bundled alongside it.
How do I get it running?Build the core library with a C11 compiler and make, then process a dataset of per-sensor CSV files plus a config.yaml using the inspostgui.py GUI or the replay.py command-line tool.
Do I need Python installed to use the tools?The core C library itself has zero dependencies, but the Python bindings, plotting tools and reference-board utilities require a Python virtual environment.
What's the biggest gotcha when wiring up sensors?IMU processing is unforgiving: an uncalibrated magnetometer, mismatched coordinate frames, non-monotonic timestamps, or an unset GNSS antenna lever arm will all silently corrupt the solution; the README lists over a dozen such common mistakes.
Does it run only on microcontrollers, or on a desktop too?Both — the code has no OS dependencies and no heap allocation, so it runs on bare-metal embedded targets as well as a regular desktop computer, using 32-bit float math to avoid needing a double-precision FPU.
How accurate can GNSS positioning get with this library?With RTK via NTRIP/RTCM you can reach about 1 cm accuracy, u-blox SPARTN/PointPerfect gives 3-6 cm, and Galileo HAS on compatible u-blox X20 receivers gives sub-10 cm accuracy without any correction subscription.
Was the code written by AI?No, the core library and KFCore filter were designed and written by a human with 20 years of experience in the field; only parts of the documentation appear to involve AI assistance.
What sensors and data feeds does it support?It fuses IMU accelerometer/gyroscope data, GNSS/GPS receivers, dual-antenna GNSS compasses, magnetometers, barometers, motion-capture systems, OBD-II odometry and zero-velocity/zero-rotation detectors, taking live data over UDP or recorded CSV logs.
Can I validate results against real flight or driving data?Yes, the repo links real-world datasets (Crazyflie UAV with mocap ground truth, rotorcraft MEMS-vs-FOG comparison, car GNSS-outage logs, pedestrian trials) along with comparisons to ArduPilot's EKF3, Wuhan University's kfgins, and MATLAB's Navigation Toolbox.
Creator
jnz
Size
130.9 MB
Stars
627
Age
1mo
Commits · 90 Days