【音源定位】球面散乱データ補間法/尤度推定ハイブリッド球面補間/最尤(SI / ML)マイクアレイ音源定位

1.ソフトウェアバージョン

MATLAB2021a

2.このアルゴリズムの理論的知識ポイント

球面散乱データ内挿法/最尤推定SI/ML

マイクアレイ音源定位

3.アルゴリズム固有の理論

この部分のプログラムは次のとおりです。

理論のこの部分は次のようになります。

このホワイトペーパーの最終的なアルゴリズムは次のとおりです。

4.コアコードの一部

clc;
clear;
close all;
warning off;
addpath 'func\'
 
load data\11_11_2KHz24cm_8cmArray.mat


x      = data;

figure(1);
plot(x(10000:12000,1),'b-o');hold on;
plot(x(10000:12000,2),'r-o');hold on;
plot(x(10000:12000,3),'k-o');hold on;
plot(x(10000:12000,4),'m-o');hold on;
plot(x(10000:12000,5),'b-s');hold on;
plot(x(10000:12000,6),'r-s');hold on;
plot(x(10000:12000,7),'k-s');hold on;
plot(x(10000:12000,8),'m-s');hold on;
legend('1','2','3','4','5','6','7','8');

[R,C]  = size(x);
M      = min(R,C); %阵元数目
N      = length(x);  
x_1    = x(1:N,:);
Delay  = zeros(M-1,1);
s_rate = 200000;
Fc     = 200e3;
LEN    = 2*N-1;%增加精度
CUT    = round(0.1*LEN);
%先计算标准值时刻位置
fft_x1           = fft(x_1(:,1),LEN);
fft_x1           = fft(x_1(:,1),LEN);
conj_x1          = conj(fft_x1);
Sxy              = fft_x1.*conj_x1;
Cxy              = fftshift(ifft(Sxy.*hamming(max(size(Sxy)))));
[Vmx0,location0] = max(abs(Cxy(CUT:end-CUT)));
 
for i = 1:M-1
    fft_x1         = fft(x_1(:,1),LEN);
    fft_xi         = fft(x_1(:,i+1),LEN);
    conj_x1        = conj(fft_x1);
    Sxy            = fft_xi.*conj_x1;
    Cxy            = fftshift(ifft(Sxy.*hamming(max(size(Sxy)))));
    [Vmx,location] = max(abs(Cxy(CUT:end-CUT)));

    %绝对值
    d1             = abs(location-location0);
    %真实值
    d2             = location-location0;
    %计算得到采样点间隔
    Delay1(i)      = d1;
    Delay2(i)      = d2;
end
 
%根据间隔,计算时间和距离延迟
times1 = Delay1./Fc;
dist1  = times1*345;
times2 = Delay2./Fc;
dist2  = times2*345;

disp('采样点个数延迟:');
Delay1
Delay2

disp('采样时间延迟:');
times1
times2

disp('采样距离延迟:');

dist1
dist2

save Gcc.mat Delay1  Delay2 times1 times2 dist1 dist2



%**************************************************************************
%**************************************************************************
%**************************************************************************
clear;
xs_src_actual   = [0]   ; 
ys_src_actual   = [0.32]; 
xi              = [0 0.08 0.16 0.24 0    0.08 0.16 0.24]; 
yi              = [0 0    0    0    0.08 0.08 0.08 0.08]; 
%调用前面的延迟估计
load Gcc.mat
%根据路程差计算声源
%number of Monte Carlo runs
nRun            = 100; 
%uncomment one of them
%turn off ML calculation 
bML             = 1;
%calculate corresponding range Rs
Rs_actual       = sqrt(xs_src_actual.^2 + ys_src_actual.^2);
bearing_actual  = [xs_src_actual; ys_src_actual]/Rs_actual; 
%number of sensor (>4)
temp            = size(xi); 
nSen            = temp(1,2); 
%RD noise (Choose 1)
Noise_Factor    = eps; % noise std = Std_Norm * (source distance). 
%we expect bigger noise variance for larger distance.
Noise_Var       =(Noise_Factor*Rs_actual)^2;
%Functions
%Random Process 
for k=1:nRun, % Monte Carlo Simulation
    Xi     = [xi' yi'];
    Di     = sqrt((xi-xs_src_actual).^2 + (yi-ys_src_actual).^2); 
    locSen = [xi' yi'];
    %using N sensors 
    for i=1:nSen-1
        d(i,1)     = Di(i+1)-Di(1);
        %噪声
        delta(i,1) = dist1(i);
        s(i,:)     = [xi(i+1) yi(i+1)];  
        Alpha_noise= (bearing_actual + randn(2,1)/15);
    end
    %set to identity matrix for unweighted case
    w               = eye(nSen-1); 
    Sw              =(s'*w*s)^(-1)*s'*w; 
    Ps              = s*Sw; 
    Ps_ortho        = eye(nSen-1)-Ps;
    %SI method 
    Rs_SI_cal       = 0.5*(d'*Ps_ortho*w*Ps_ortho*delta)/(d'*Ps_ortho*w*Ps_ortho*d);
    %Calculate Xs for SI method
    Xs_row_SI       = 0.5*Sw*(2*Rs_SI_cal*d-delta); 
    Xs_SI(k,:)      = [Xs_row_SI.*Alpha_noise]';
    Rs_SI(k,:)      = sqrt(Xs_SI(k,1)^2 + Xs_SI(k,2)^2);
    bearing_SI(k,:) = Xs_SI(k,:)/Rs_SI(k,:);
    %Maximum Likelihood Method
    if (bML==1)
        %As value obtained from SI as starting guess 
        x0      = Xs_SI(k,:);
        %x0 = [0 ys_src_actual 0]; % Starting guess
        %LevenbergMarquardt 
        options = optimset('Algorithm','Levenberg-Marquardt'); %LM
        x       = lsqnonlin(@mlobjfun,x0,[],[],options,locSen,Noise_Var,d); 
        Xs_ML(k,:)      = x;
        Rs_ML(k,:)      = sqrt(Xs_ML(k,1)^2+Xs_ML(k,2)^2);
        bearing_ML(k,:) = Xs_ML(k,:)/Rs_ML(k,:); 
    end
    %Calculate bias (i.e., errors) for source location, range and bearing 
    %SI 
    bias_Xs_SI(k,1) = Xs_SI(k,1) - xs_src_actual; 
    bias_Xs_SI(k,2) = Xs_SI(k,2) - ys_src_actual; 
    %ML
    if (bML==1)
        bias_Xs_ML(k,1) = Xs_ML(k,1)-xs_src_actual; 
        bias_Xs_ML(k,2) = Xs_ML(k,2)-ys_src_actual; 
    end
end

clc;


figure;

bias_Rs_SI = Rs_SI-Rs_actual;
bias_bearing_SI = 180/pi*acos(bearing_SI*bearing_actual);

if (bML==1)
bias_Rs_ML=Rs_ML-Rs_actual;
bias_bearing_ML = 180/pi*acos(bearing_ML*bearing_actual); 
end

meanxs_SI=mean(bias_Xs_SI(:,1)); 
meanys_SI=mean(bias_Xs_SI(:,2)); 
meanrs_SI=mean(bias_Rs_SI); 
meanbear_SI=mean(bias_bearing_SI);

vect_mean_SI=[meanxs_SI;meanys_SI;meanrs_SI;meanbear_SI];

%ML
if (bML==1)
meanxs_ML=mean(bias_Xs_ML(:,1)); 
meanys_ML=mean(bias_Xs_ML(:,2)); 
meanrs_ML=mean(bias_Rs_ML); 
meanbear_ML=mean(bias_bearing_ML); 
vect_mean_ML=[meanxs_ML;meanys_ML;meanrs_ML;meanbear_ML]; 
end

% Calculate Variance = E[(a - mean)^2]
% ----------------------------------------------------- 
varxs_SI=var(bias_Xs_SI(:,1)); 
varys_SI=var(bias_Xs_SI(:,2)); 
varrs_SI=var(bias_Rs_SI); 

varbear_SI=var(bias_bearing_SI);
vect_var_SI=[varxs_SI;varys_SI;varrs_SI;varbear_SI];

%ML
if (bML==1)
    varxs_ML=var(bias_Xs_ML(:,1)); 
    varys_ML=var(bias_Xs_ML(:,2)); 
    varrs_ML=var(bias_Rs_ML); 
    varbear_ML=var(bias_bearing_ML);

    vect_var_ML=[varxs_ML;varys_ML;varrs_ML;varbear_ML]; 
end

% Calculate second moment (RMS)= sqrt {E[a^2]} = sqrt {mean^2 + variance} 
% ----------------------------------------------------- 
rmsxs_SI=sqrt(mean(bias_Xs_SI(:,1)).^2+varxs_SI); 
rmsys_SI=sqrt(mean(bias_Xs_SI(:,2)).^2+varys_SI); 
rmsrs_SI=sqrt(mean(bias_Rs_SI).^2+varrs_SI); 
rmsbear_SI=sqrt(mean(bias_bearing_SI).^2+varbear_SI);

vect_rms_SI=[rmsxs_SI;rmsys_SI;rmsrs_SI;rmsbear_SI];

%ML
if (bML==1) 
    rmsxs_ML=sqrt(mean(bias_Xs_ML(:,1)).^2+varxs_ML); 
    rmsys_ML=sqrt(mean(bias_Xs_ML(:,2)).^2+varys_ML); 
    rmsrs_ML=sqrt(mean(bias_Rs_ML).^2+varrs_ML); 
    rmsbear_ML=sqrt(mean(bias_bearing_ML).^2+varbear_ML);

    vect_rms_ML=[rmsxs_ML;rmsys_ML;rmsrs_ML;rmsbear_ML]; 
end

% Calculate Cramer Rao Bound 
%
cov_mat=Noise_Var.*(0.5*ones(length(d))+0.5*eye(length(d)));

for i=1:length(d)
    a1=[xs_src_actual-locSen(i+1,1) ys_src_actual-locSen(i+1,2)];
    a2=sqrt((xs_src_actual-locSen(i+1,1))^2+(ys_src_actual-locSen(i+1,2))^2);
    b1=[xs_src_actual-locSen(1,1) ys_src_actual-locSen(1,2)];
    b2=sqrt((xs_src_actual-locSen(1,1))^2+(ys_src_actual-locSen(1,2))^2); 
    jacobian(i,:)= (a1/a2)-(b1/b2);
end

fisher=jacobian'*inv(cov_mat)*jacobian;

crlb= trace(fisher^-1); % compare with MSE of Rs

% ----------------------------------------------------- 
% Generate Plots
% -----------------------------------------------------

% hfig1=figure;
if (bML==1)
plot(xi, yi,'bv',Xs_SI(:,1), Xs_SI(:,2),'mo',Xs_ML(:,1), Xs_ML(:,2), 'kd'); % plot both SI and ML
hold on
plot(xs_src_actual, ys_src_actual,'rs','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',6); % plot both SI and ML

else
plot(xi, yi,'bv', xs_src_actual, ys_src_actual, 'r^', Xs_SI(:,1), Xs_SI(:,2), 'mo'); % plot just SI only
end

title('Sensor and Source Location');
str1=sprintf('[Xs, Ys, Zs, Rs, Bearing], Noise Std = %s*Rs',Noise_Factor); 
str2=sprintf('SI Method');
str3=sprintf('RMS = [%s, %s, %s, %s, %s]', rmsxs_SI, rmsys_SI,rmsrs_SI, rmsbear_SI);
str4=sprintf('Mean = [%s, %s, %s, %s, %s]', meanxs_SI, meanys_SI,meanrs_SI, meanbear_SI);
str5=sprintf('Variance = [%s, %s, %s, %s, %s]', varxs_SI, varys_SI,varrs_SI, varbear_SI);
if (bML==1)
str6=sprintf('ML Method');
str7=sprintf('RMS = [%s, %s, %s, %s, %s]', rmsxs_ML, rmsys_ML,rmsrs_ML, rmsbear_ML);
str8=sprintf('Mean = [%s, %s, %s, %s, %s]', meanxs_ML, meanys_ML, meanrs_ML, meanbear_ML);
str9=sprintf('Variance = [%s, %s, %s, %s, %s]', varxs_ML, varys_ML, varrs_ML, varbear_ML);
str=sprintf('%s \n%s \n%s \n%s \n%s \n%s \n%s \n%s \n%s', str1, str2, str3, str4,str5, str6, str7, str8, str9);
legend('sensor location', 'calculated source location(SI)','calculated source location (ML)','actual source location ' );
else
str=sprintf('%s \n%s \n%s \n%s \n%s \n%s \n%s \n%s \n%s', str1, str2, str3, str4,str5);
legend('sensor location', 'actual source location', 'calculated source location (SI)');
end


xlabel('Distance (metres) in X direction'); 
ylabel('Distance (metres) in Y direction');

% generate results output files 
fid = fopen('results.txt','w');

for k=1:nRun, 
    fprintf(fid,'%e\t%e\t%e\t%e\n',bias_Xs_SI(k,1),bias_Xs_SI(k,2), bias_Rs_SI(k), bias_bearing_SI(k)); 
end
fprintf(fid,'\n%e\t %e\t %e\t %e\t %e\n', meanxs_SI, meanys_SI, meanrs_SI, meanbear_SI);
fprintf(fid,'%e\t %e\t %e\t %e\t %e\n', varxs_SI, varys_SI, varrs_SI, varbear_SI);
fprintf(fid,'%e\t %e\t %e\t %e\t %e\n', rmsxs_SI, rmsys_SI, rmsrs_SI, rmsbear_SI);

fclose(fid);
axis([-0.1,0.35,-0.05,0.5]);

5.シミュレーションのデモンストレーション

 6.このアルゴリズムに関する論文を書くというアイデア

時間遅延の最初の部分

      8つのマイクアレイで正弦波音源信号のグループを収集します。マイクの位置がわかります。このように、同じ音源に対して、異なるマイクによって収集された信号には遅延があります。音源の1つを次のように取得します。参考までに、GCCを使用してください-PHAT法で7つの時間遅延を得ることができます。音の伝播速度がわかっている場合、到着の7つの範囲差を得ることができます。

2番目の部分は音源の位置を推定します

       音源の位置は距離差で推定できます。ハイブリッド球面補間/最尤(SI / ML)推定法(球面散乱データ補間法/最尤推定)の2つの方法を使用すると、音源座標、式、MATLABコードの文献が利用可能です。

7.参考文献

[1] Wang Lili、XuYingxiang。散乱データに基づく球面自然スプライン補間法[J]。Journalof Chengdu Institute of Information Engineering、2012、27(5):5。

8.関連するアルゴリズムのトピックとアプリケーション

マイクのポジショニング

マイクアレイ

音源定位

A36-04

おすすめ

転載: blog.csdn.net/ccsss22/article/details/123621256