Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

NavState IMU EKF Tutorial

This tutorial shows how to use GTSAM’s NavState-specific EKF (NavStateImuEKF) with synthetic IMU data and occasional position measurements. You’ll learn:

  • How the predict step integrates IMU into a NavState increment and propagates covariance.

  • How to write a position measurement in the EKF’s local coordinates (the correct H = [0, R, 0]).

  • How to interpret the results with ±2σ uncertainty bands for yaw/pitch/roll, velocity, and position.

We simulate a simple motion and run the EKF end-to-end, then visualize estimates vs. ground truth along with uncertainty.

Open In Colab
Source

Background and setup

State: NavState X = (R, p, v) with rotation R ∈ SO(3), position p ∈ R^3, velocity v ∈ R^3.

  • EKF local coordinates are [δθ, δp_body, δv_body], i.e., position/velocity increments are expressed in the body frame.

  • For a world-position measurement z ≈ p_world, the linearized measurement Jacobian is H = [0, R, 0].

We’ll now define a simple scenario that provides ground truth and noise-free IMU to drive the predict step.

Source
Loading...

Simulate IMU and run the EKF

We integrate IMU in the predict step and occasionally update with a position measurement. The position Jacobian must be H = [0, R, 0] because EKF local coordinates use body-frame increments for p and v.

Plot Yaw/Pitch/Roll (degrees)

We show estimated angles with ±2σ bands and dashed ground truth. Ideally, the truth lies mostly within the shaded bands if covariances are well tuned.

Source
Loading...

Plot Velocity (m/s)

Velocity often benefits from frequent updates (e.g., GPS Doppler). Here we only have occasional position updates; expect velocity uncertainty to grow between updates and shrink slightly after them.

Source
Loading...

Plot Position (m)

Position updates should pull the estimate toward truth and reduce the ±2σ band. If divergence occurs, check:

  • H matches EKF local coords ([0, R, 0] for world-position).

  • Measurement noise R reflects your sensor.

  • Process noise (IMU) is not overconfident.

Source
Loading...