资源简介
madgwick的传感器融合算法,matlab版本的
代码片段和文件信息
% Examplescript.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 ?0 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
addpath(‘quaternion_library‘); % include quaternion library
close all; % close all figures
clear; % clear all variables
clc; % clear the command terminal
%% Import and plot sensor data
load(‘ExampleData.mat‘);
figure(‘Name‘ ‘Sensor Data‘);
axis(1) = subplot(311);
hold on;
plot(time Gyroscope(:1) ‘r‘);
plot(time Gyroscope(:2) ‘g‘);
plot(time Gyroscope(:3) ‘b‘);
legend(‘X‘ ‘Y‘ ‘Z‘);
xlabel(‘Time (s)‘);
ylabel(‘Angular rate (deg/s)‘);
title(‘Gyroscope‘);
hold off;
axis(2) = subplot(312);
hold on;
plot(time Accelerometer(:1) ‘r‘);
plot(time Accelerometer(:2) ‘g‘);
plot(time Accelerometer(:3) ‘b‘);
legend(‘X‘ ‘Y‘ ‘Z‘);
xlabel(‘Time (s)‘);
ylabel(‘Acceleration (g)‘);
title(‘Accelerometer‘);
hold off;
axis(3) = subplot(313);
hold on;
plot(time Magnetometer(:1) ‘r‘);
plot(time Magnetometer(:2) ‘g‘);
plot(time Magnetometer(:3) ‘b‘);
legend(‘X‘ ‘Y‘ ‘Z‘);
xlabel(‘Time (s)‘);
ylabel(‘Flux (G)‘);
title(‘Magnetometer‘);
hold off;
linkaxes(axis ‘x‘);
%% Process sensor data through algorithm
AHRS = MadgwickAHRS(‘SamplePeriod‘ 1/256 ‘Beta‘ 0.1);
% AHRS = MahonyAHRS(‘SamplePeriod‘ 1/256 ‘Kp‘ 0.5);
quaternion = zeros(length(time) 4);
for t = 1:length(time)
AHRS.Update(Gyroscope(t:) * (pi/180) Accelerometer(t:) Magnetometer(t:)); % gyroscope units must be radians
quaternion(t :) = AHRS.Quaternion;
end
%% Plot algorithm output as Euler angles
% The first and third Euler angles in the sequence (phi and psi) become
% unreliable when the middle angles of the sequence (theta) approaches ?0
% degrees. This problem commonly referred to as Gimbal Lock.
% See: http://en.wikipedia.org/wiki/Gimbal_lock
euler = quatern2euler(quaternConj(quaternion)) * (180/pi); % use conjugate for sensor frame relative to Earth and convert to degrees.
figur
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3263 2012-11-06 19:00 Examplesc
文件 4678 2011-09-28 23:40 @MadgwickAHRS\MadgwickAHRS.m
文件 4718 2011-09-28 23:40 @MahonyAHRS\MahonyAHRS.m
文件 650 2011-09-27 16:52 quaternion_library\axisAngle2quatern.m
文件 965 2011-09-27 16:52 quaternion_library\axisAngle2rotMat.m
文件 938 2011-09-27 16:52 quaternion_library\euler2rotMat.m
文件 878 2011-09-27 16:52 quaternion_library\quatern2euler.m
文件 825 2011-09-27 16:52 quaternion_library\quatern2rotMat.m
文件 378 2011-09-27 16:52 quaternion_library\quaternConj.m
文件 661 2011-09-27 16:51 quaternion_library\quaternProd.m
文件 645 2011-09-27 16:51 quaternion_library\rotMat2euler.m
文件 1434 2011-09-27 16:51 quaternion_library\rotMat2quatern.m
文件 2465 2011-09-27 16:51 quaternion_library\Testsc
文件 101819 2011-09-24 13:39 ExampleData.mat
相关资源
- 单连杆系统独立PD控制和PD+重力补偿控
-
simuli
nk中的UWB和6轴imu融合算法程序 -
基于Simuli
nk的车辆行驶液压系统仿真 -
飞控simuli
nk仿真.zip - 优化的基于不定频滞环的SVPWM控制si
- 微机保护算法仿真.zip
- 24脉波整流仿真
-
SVPWM的simuli
nk仿真286115 -
simuli
nk的使用手册全 - 基于卡尔曼滤波的PID控制
-
Simuli
nk快速入门教程 -
基于SIMUli
nk的汽车发动机怠速模糊神 -
simuli
nk结构框图变成600dpi分辨率ti -
matlab心电信号分析与simuli
nk仿真成果 -
simuli
nk控制系统的设计方法-ch05a.p -
光伏发电最大功率点跟踪simuli
nk仿真 -
《Matlab Simuli
nk与控制系统仿真》. - 永磁同步电机矢量控制+MTPV+MTPA算法弱
-
混合动力simuli
nk模型 -
基础simuli
nk的多路时分复用系统仿真 -
基于simuli
nk的带有MPPT功的光伏电池 -
4.1基于Simuli
nk的图像、视频处理.z -
Simuli
nk的低通数字滤波器的仿真分析 -
基于Simuli
nk的DSB调制解调系统仿真 -
基于Simuli
nk的MFSK系统的仿真 -
基于Simuli
nk的模拟通信仿真 -
基于Simuli
nk的匹配滤波器设计 - Intelligent Control Design and MATLAB Simulati
-
基于matlab-simuli
nk的ESP硬件在环仿真 -
APF资料-APF、SVG simuli
nk源程使用说明
评论
共有 条评论