Example Script
Example Script
m
%
% This script demonstrates use of the MadgwickAHRS and MahonyAHRS algorithm
% classes with example data. ExampleData.mat contains calibrated gyroscope,
% accelerometer and magnetometer data logged from an AHRS device (x-IMU)
% while it was sequentially rotated from 0 degrees, to +90 degree and then
% to -90 degrees around the X, Y and Z axis. The script first plots the
% example sensor data, then processes the data through the algorithm and
% plots the output as Euler angles.
%
% Note that the Euler angle plot shows erratic behaviour in phi and psi
% when theta approaches �90 degrees. This due to a singularity in the Euler
% angle sequence known as 'Gimbal lock'. This issue does not exist for a
% quaternion or rotation matrix representation.
%
% Date Author Notes
% 28/09/2011 SOH Madgwick Initial release
% 13/04/2012 SOH Madgwick deg2rad function no longer used
% 06/11/2012 Seb Madgwick radian to degrees calculation corrected
%% Start of script
load('ExampleData.mat');
%% End of script