First, the way to obtain the code

[Radar communication] based on MATLAB indirect Kalman filter IMU and GPS fusion

Access code 2: Open CSDN membership through the homepage of CSDN blog, and the code can be obtained by payment voucher and private letter bloggers.

Get the code 3: by subscribing to the paid column of purple Pole Shenguang blog, with payment voucher, private letter bloggers, can get this code.

Note: For CSDN membership, only one code can be obtained free of charge (valid within three days from the date of opening); Subscribe to the paid column of purple Pole Shenguang blog, you can get 2 copies of the code for free (valid for three days from the subscription date);

Ii. Introduction of IMU and GPS fusion

Theoretical knowledge Reference: Research on high precision positioning and attitude determination based on the fusion of measurable image and GPS/IMU

Three, some source code

%%*****************************************************************************************************%% clear; clc; % global attiCalculator; attiCalculator =AttitudeBase(a); step =0.01;
start_time = 0;
end_time = 50;
tspan = [start_time:step:end_time]'; N = length(tspan); Ar = 10; R = [Ar*sin(tspan) Ar*cos(tspan) 0.5*tspan.*tspan]; % Generate experimental trajectory data v = [Ar*cos(tSPAN) -Ar*sin(tspan) tspan]; acc_inertial = [-Ar*sin(tspan) -Ar*cos(tspan) ones(N,1)]; Atti = [0.1*sin(tspan) 0.1*sin(tspan) 0.1*sin(tspan)]; Datti = [0.1*cos(tspan) 0.1*cos(tspan) 0.1*cos(tspan)]; G = [0 0-9.8]';
gyro_pure = zeros(N,3);
acc_pure = zeros(N,3);
gps_pure= r;



a = wgn(N,1.1) /5;
b = zeros(N,1);
b(1) = a(1)*step; % Generates noiseless IMU datafor iter = 1:N
    A = attiCalculator.Datti2w(atti(iter,:));
    gyro_pure(iter,:) = Datti(iter,:)*A';
    cnb = attiCalculator.a2cnb(atti(iter,:));
    acc_pure(iter,:) = cnb*(acc_inertial(iter,:)' - g); % acc_pure(iter,:) = cnb*(acc_inertial(iter,:)');
end
% state0 = zeros(10.1);
% state0(7) = 1; % Accelerometer and gyroscope add noise acc_noise = acc_pure +randn(N,3) /10; % generates inertial and GPS measurements while adding noise gyro_noise = gyro_pure +randn(N,3) /10;
gps_noise=[zeros(N,1) gps_pure+randn(N,3) /10];
for i=1:10:N
    gps_noise(i,1) =1;
end
% acc_noise = acc_pure ;
% gyro_noise = gyro_pure;
state0 = zeros(16.1);
state0(2) = 10;
state0(4) = 10;
state0(7) = 1;

errorstate0=zeros(15.1); % error initial state assignment Cov=[0.01*ones(3.1);zeros(3.1);0.01*ones(3.1);zeros(3.1)];
Qc0=diag(Cov); % Initial noise variance Rc0=diag([0.01.0.01.0.01]); %GPS measurement noise error variance % Qc0=diag(zeros(12.1)); % Initial noise variance % Rc0=diag(zeros(3.1)); %GPS measurement noise error variance % can change the amount of input inertial element data with noise or without INS =InsSolver(Qc0,Rc0);
% [state,errorstate] = ins.imu2state(acc_pure,gyro_pure,gps_pure,state0,errorstate0,tspan,step,0);
[state,errorstate] = ins.imu2state(acc_noise,gyro_noise,gps_noise,state0,errorstate0,tspan,step,0);
%plot trajactory
figure(4)
plot3(r(:,1),r(:,2),r(:,3));
title('True track');
grid on;
figure(1);
plot3(state(:,1),state(:,2),state(:,3));
title('Filtered trajectory');
grid on;

% plot postion error
figure(2).subplot(1.3.1);
plot(tspan,state(:,1) - r(:,1));
grid on;
subplot(1.3.2);
plot(tspan,state(:,2) - r(:,2));
grid on;
subplot(1.3.3);
plot(tspan,state(:,3) - r(:,3));
grid on;

%convert quat to attitue angle
% fprintf('press any key to continue\n');
% pause(5);
newatti = zeros(N,3);

for i = 1:N
   newatti(i,:) = attiCalculator.cnb2atti(attiCalculator.quat2cnb(state(i,7:10)));
end

%plot attitute error
figure(3).subplot(1.3.1);
title('attitute angle error');
plot(tspan,newatti(:,1) - atti(:,1));
grid on;
subplot(1.3.2);
plot(tspan,newatti(:,2) - atti(:,2));
grid on;
subplot(1.3.3);
plot(tspan,newatti(:,3) - atti(:,3));
grid on;


Copy the code

4. Operation results

Matlab version and references

1 matlab version 2014A

2 Reference [1] Shen Zaiyang. Proficient in MATLAB Signal Processing [M]. Tsinghua University Press, 2015. [2] GAO Baojian, PENG Jinye, WANG Lin, PAN Jianshou. Signal and System — Analysis and Implementation using MATLAB [M]. Tsinghua University Press, 2020. [3] WANG Wenguang, WEI Shaoming, REN Xin. MATLAB Implementation of Signal Processing and System Analysis [M]. Publishing House of Electronics Industry, 2018. [4] LI Shufeng. MIMO Radar and 5G MIMO Communication Based on Completely Complementary Sequence [M]. Tsinghua University Press, 2021 [5] He You, Key. Radar Target Detection and Constant False Alarm Processing (2nd edition) [M]. Tsinghua University Press, 2011 [6] Zhang Xiaodong. High precision attitude determination based on GPS/IMU fusion with Measurable Image [J].