【数据融合】拓展卡尔曼滤波IMU和GPS数据融合【含Matlab源码 1600期】

在这里插入图片描述

⛄一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【数据融合】基于matlab拓展卡尔曼滤波IMU和GPS数据融合【含Matlab源码 1600期】
点击上面蓝色字体,直接付费下载,即可。

获取代码方式2:
付费专栏Matlab信号处理(初级版)

备注:
点击上面蓝色字体付费专栏Matlab信号处理(初级版),扫描上面二维码,付费29.9元订阅海神之光博客付费专栏Matlab信号处理(初级版),凭支付凭证,私信博主,可免费获得1份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:1份本博客上传CSDN资源代码

⛄二、部分源代码

%for testing
clc
clear
close all

pauseLen = 0;

%%Initializations
%TODO: load data here
data = load(‘lib/IMU_GPS_GT_data.mat’);
IMUData = data.imu;
GPSData = data.gpsAGL;
gt = data.gt;

addpath([cd, filesep, ‘lib’])
initialStateMean = eye(5);
initialStateCov = eye(9);
deltaT = 1 / 30; %hope this doesn’t cause floating point problems

numSteps = 500000;%TODO largest timestamp in GPS file, divided by deltaT, cast to int

results = zeros(7, numSteps);
% time x y z Rx Ry Rz

% sys = system_initialization(deltaT);
Q = blkdiag(eye(3)(0.35)^2, eye(3)(0.015)^2, zeros(3));
%IMU noise characteristics
%Using default values from pixhawk px4 controller
%https://dev.px4.io/v1.9.0/en/advanced/parameter_reference.html
%accel: first three values, (m/s2)2
%gyro: next three values, (rad/s)^2

filter = filter_initialization(initialStateMean, initialStateCov, Q);

%IMU noise? do in filter initialization

IMUIdx = 1;
GPSIdx = 1;
nextIMU = IMUData(IMUIdx, 😃; %first IMU measurement
nextGPS = GPSData(GPSIdx, 😃; %first GPS measurement

%plot ground truth, raw GPS data

% plot ground truth positions
plot3(gt(:,2), gt(:,3), gt(:,4), ‘.g’)
grid on
hold on
% plot gps positions
% plot3(GPSData(:,2), GPSData(:,3), GPSData(:,4), ‘.b’)
axis equal
axis vis3d

counter = 0;
MAXIGPS = 2708;
MAXIIMU = 27050;
isStart = false;

for t = 1:numSteps
currT = t * deltaT;
if(currT >= nextIMU(1)) %if the next IMU measurement has happened
% disp(‘prediction’)
filter.prediction(nextIMU(2:7));
isStart = true;
IMUIdx = IMUIdx + 1;
nextIMU = IMUData(IMUIdx, 😃;
% plot3(filter.mu(1, 5), filter.mu(2, 5), filter.mu(3, 5), ‘or’);
end
if(currT >= nextGPS(1) & isStart) %if the next GPS measurement has happened
% disp(‘correction’)
counter = counter + 1;
filter.correction(nextGPS(2:4));
GPSIdx = GPSIdx + 1;
nextGPS = GPSData(GPSIdx, 😃;
plot3(nextGPS(2), nextGPS(3), nextGPS(4), ‘.r’);
% plot3(filter.mu(1, 5), filter.mu(2, 5), filter.mu(3, 5), ‘ok’);
% plotPose(filter.mu(1:3, 1:3), filter.mu(1:3, 5), filter.mu(1:3,4));

end
results(1, t) = currT;
results(2:4, t) = filter.mu(1:3, 5); %just position so far

% plot3(results(2, t), results(3, t), results(4, t), ‘or’);
% disp(filter.mu(1:3, 1:3));
if pauseLen == inf
pause;
elseif pauseLen > 0
pause(pauseLen);
end
if IMUIdx >= MAXIIMU || GPSIdx >= MAXIGPS
break
end
end
plot3(results(2,:), results(3,:), results(4,:), ‘.b’);
% xlim([-10 10]);
% ylim([-10 10]);
xlabel(‘x, m’);
ylabel(‘y, m’);
zlabel(‘z, m’);

%% Evaluation
gps_score = evaluation(gt, GPSData)

results_eval = results.';
score = 0;
estimation_idx = 1;
count = 0;
for i = 2:length(gt)
score = score + norm(gt(i, 2:4) - results_eval(30 * (i-1), 2:4)) ^ 2;
count = count + 1;
end
count
score = sqrt(score / count)

%% Function

⛄三、运行结果

在这里插入图片描述

⛄四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.

3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab领域

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值