Attitude extended Kalman filter (EKF) with quaternions

An implementation of the EKF with quaternions. Simulation and Arduino Simulink code for MKR1000 or MKR1010 with IMU Shield
480 Downloads
Updated 9 Feb 2024

View License

An implementation of the EKF with quaternions and angular rate bias, coded inside a Matlab function in Simulink.
Two Simulink files are provided: a simulation with real IMU data and and Arduino Simulink code for MKR1000 with IMU Shield. You do not need an Arduino if you wish to run only the simulation.
The code is loosely based on what explained here https://thepoorengineer.com/en/ekf-impl/ (not written by me), a pdf with an explanation of the algorithm is provided (excerpt from my lecture notes in aircraft dynamics).
Try and see which values of the matrices R and Q give the best results.
Enjoy.

Cite As

Paolo Massioni (2026). Attitude extended Kalman filter (EKF) with quaternions (https://www.mathworks.com/matlabcentral/fileexchange/119583-attitude-extended-kalman-filter-ekf-with-quaternions), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022b
Compatible with R2022b
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.2

Updated pdf notice.

1.1

Improved the readability of the code. Added pdf notice on the algorithm.

1.0.2

Corrected description

1.0.1

Improved Arduino model

1.0.0