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…

632 ·GitHub
这是什么?INSLIB 是一个可移植的 C 语言库,用于 3D 导航状态估计,通过卡尔曼滤波将 IMU 数据与 GNSS/GPS、气压计、磁力计等传感器融合,应用于无人机、机器人、汽车和航空航天项目。
这是开箱即用的应用还是需要编译进我自己项目的库?它是一个纯 C11 库,无堆分配、无操作系统依赖、无外部依赖,适合编译进固件或桌面程序;同时附带用于后处理和标定的 Python 辅助脚本和 GUI 应用。
怎么把它跑起来?用 C11 编译器和 make 构建核心库,然后用 inspostgui.py 图形界面或 replay.py 命令行工具,处理由各传感器 CSV 文件和一个 config.yaml 组成的数据集。
使用这些工具需要安装 Python 吗?核心 C 库本身零依赖,但 Python 绑定、绘图工具和参考板卡工具需要 Python 虚拟环境。
接传感器时最大的坑是什么?IMU 处理毫不留情:未标定的磁力计、不匹配的坐标系、非单调的时间戳,或未设置的 GNSS 天线杆臂,都会悄悄破坏解算结果;README 列出了十几条这类常见错误。
它只能在单片机上运行,还是也能在桌面上运行?两者都可以——代码没有操作系统依赖,也没有堆分配,因此既能跑在裸机嵌入式目标上,也能跑在普通台式电脑上,并使用 32 位浮点运算来避免对双精度 FPU 的需求。
用这个库 GNSS 定位精度能达到多少?通过 NTRIP/RTCM 使用 RTK 可以达到约 1 厘米精度,u-blox SPARTN/PointPerfect 能达到 3-6 厘米,而在兼容的 u-blox X20 接收机上,Galileo HAS 无需任何改正订阅就能达到 10 厘米以内的精度。
代码是 AI 写的吗?不是,核心库和 KFCore 滤波器由一位在该领域有 20 年经验的工程师设计和编写;只有部分文档看起来涉及 AI 辅助。
它支持哪些传感器和数据输入?它融合 IMU 加速度计/陀螺仪数据、GNSS/GPS 接收机、双天线 GNSS 罗盘、磁力计、气压计、动作捕捉系统、OBD-II 里程计和零速/零转检测器,可通过 UDP 接收实时数据或读取录制的 CSV 日志。
我可以用真实的飞行或行车数据来验证结果吗?可以,仓库链接了真实世界的数据集(带动捕真值的 Crazyflie 无人机、旋翼机 MEMS 与 FOG 对比、汽车 GNSS 中断日志、行人试验),以及与 ArduPilot 的 EKF3、武汉大学的 kfgins 和 MATLAB Navigation Toolbox 的对比。
Creator
jnz
Size
132.4 MB
Stars
632
Age
1mo
Commits · 90 Days