更新UWB-AOA的解算框架

This commit is contained in:
UP管理员 2025-04-23 11:27:10 +08:00
parent 0221786589
commit 70fc3668a3
6 changed files with 195 additions and 0 deletions

View File

@ -0,0 +1,24 @@
function [ aoa ] = CalUWBAOA(pdoa)
Lambda = 3e8/6.5e9; % UWB
D_M = 0.0208; % 线
aoa = zeros(length(pdoa),1);
for ii=1:length(pdoa)
if pdoa(ii) < -180.0
pdoa(ii)=pdoa(ii)+ 360.0;
elseif pdoa(ii) > 180.0
pdoa(ii)=pdoa(ii)-360.0;
end
phase_m = pdoa(ii) * (Lambda/360.0);
% 线线
% coef=[-14205, 419, 4.59, 0.8361,0];
% phase_m = coef(1)+coef(2)*phase_m+coef(3)*phase_m^2+coef(4)*phase_m^3+coef(5)*phase_m^4;
alfa = phase_m / D_M;
if alfa < -1
alfa = -1;
elseif alfa > 1
alfa = 1;
end
aoa(ii)=asind(alfa);
end
end

View File

@ -0,0 +1,38 @@
function [ filtered ] = OutlierFilter( data )
init_count = 0;
init_flag = 0;
filtered = zeros(1, length(data));
filtered(1) = data(1);
for i = 2:length(data)
%
if(abs(data(i) - data(i-1)) < 30 && init_flag == 0)
filtered(i) = data(i);
init_count = init_count + 1;
if(init_count >= 5)
init_flag = 1;
end
continue;
end
%
if(init_flag == 0)
filtered(i) = data(i);
continue;
end
%
filtered(i) = data(i);
%
if(abs(filtered(i) - filtered(i - 1)) > 40)
% ,
dif1 = abs(data(i) + filtered(i - 1));
%
if(dif1 < 20)
filtered(i) = -data(i);
else
%
filtered(i) = filtered(i-1);
end
end
end
end

View File

@ -0,0 +1 @@
# UWB-AOA 位置解算框架

Binary file not shown.

View File

@ -0,0 +1,18 @@
function filtered_data = firstOrderFilter(data, alpha)
%
if ~isvector(data)
error('Data input must be a vector.');
end
if alpha < 0 || alpha > 1
error('Alpha must be between 0 and 1.');
end
%
filtered_data = zeros(size(data));
filtered_data(1) = data(1); %
%
for i = 2:length(data)
filtered_data(i) = alpha * filtered_data(i - 1) + (1 - alpha) * data(i);
end
end

View File

@ -0,0 +1,114 @@
clc;
clear;
close all;
filename = 'combined_data14.xlsx';
% Excel
data = readtable(filename);
VR_X = str2double(data.VR_X);
VR_Y = str2double(data.VR_Y);
VR_Z = str2double(data.VR_Z);
Dist = data.D;
raw_pdoa = data.P;
UWB_X = data.Xcm;
UWB_Y = data.Ycm;
pdoa_offset = 0.0;
Lambda = 3e8/6.5e9; % UWB
D_M = 0.0208; % 线
raw_pdoa = raw_pdoa - pdoa_offset;
% PDOA
pdoa = OutlierFilter(raw_pdoa);
% PDOA
figure
plot(raw_pdoa);hold on
plot(pdoa);
legend('PDOA','PDOA');
title('PDOA');
xlabel('Time'); % X
ylabel(' '); % Y
pdoa_filtered = firstOrderFilter(pdoa, 0.9);
% PDOA
figure
plot(pdoa);hold on
plot(pdoa_filtered);
legend('PDOA','PDOA');
title('PDOA');
xlabel('Time'); % X
ylabel(' '); % Y
dist_filtered = firstOrderFilter(Dist, 0.9);
figure
plot(Dist);hold on
plot(dist_filtered);
legend('','');
title('');
xlabel('Time'); % X
ylabel(' '); % Y
% pdoaAOA
aoa = CalUWBAOA(pdoa);
% AOA
aoa_filtered = CalUWBAOA(pdoa_filtered);
% AOA
figure
plot(aoa);hold on
plot(aoa_filtered);
legend('AOA ','AOA');
title('AOAPODA');
xlabel('Time'); % X
ylabel('Angle (°)'); % Y
filter_x = dist_filtered .* sin(aoa_filtered / 180 * pi) / 100;
filter_y = dist_filtered .* cos(aoa_filtered / 180 * pi) / 100;
% % AOA
% figure
% plot(UWB_X/100,UWB_Y/100);hold on
% plot(filter_x,filter_y);
% plot(-VR_X,-VR_Z);
% legend(' ','','lighthouse');
% title('');
% xlabel('X(m)'); % X
% ylabel('Y(m)'); % Y
% lighthouse
angle_degrees = 90; % 90
angle_radians = deg2rad(angle_degrees); %
%
R = [cos(angle_radians) -sin(angle_radians); sin(angle_radians) cos(angle_radians)];
x_l = -VR_X;
y_l = -VR_Z;
points = [x_l'; y_l'];
rotated_points = R * points;
% x y
x_lr = rotated_points(1, :)' + 1.0;
y_lr = rotated_points(2, :)' + 0.8;
n = 500;
% AOA
figure
plot(filter_x(1:n),filter_y(1:n),'b.');hold on
plot(x_lr(1:n),y_lr(1:n));
legend('','lighthouse');
title('');
xlabel('X(m)'); % X
ylabel('Y(m)'); % Y
err_x = mean(abs(filter_x -x_lr));
err_y = mean(abs(filter_y -y_lr));
fprintf('UWBLighthouse Error X: %.2f m,Y: %.2f m\n',err_x,err_y);