1, Requirements
Requirement 1: the measured value of RSSI is generated by the logarithmic path loss model. In order to reduce the error caused by fluctuation, its value can be obtained by averaging multiple measurements.
Requirement 2: the reference distance path loss and path loss factor in the log path loss model can be estimated by the measured values between the reference points.
Requirement 3: complete the RMSE curve comparison diagram between the ideal situation (the reference distance path loss and path loss factor are known) and the actual situation. The abscissa is the noise variance and the ordinate is RMSE.
2, Design
1.RSSI positioning principle
Using the known transmitting signal strength and the signal strength received by the receiving node, the loss in the transmission process is calculated, and the signal model is used to convert the loss into the distance between the target to be located and the known node.
Pd=Pd0-10nlg(d/d0)+ΞΎ
2. use the least square method to estimate the path loss and two position parameters in the received power
3. use TOALLOP algorithm to calculate unknown node coordinates
3, Code
TOALLOP:
function theta=TOALLOP(A,p,j) [m,~]=size(A); k=sum(A.^2,2); k1=k([1:j-1,j+1:m],:); %take out J line A1=A([1:j-1,j+1:m],:); %take out J line A2=A1-ones(m-1,1)*A(j,:); p1=p([1:j-1,j+1:m],:); %take out J line p2=p(j).^2*ones(m-1,1)-p1.^2-(k(j)*ones(m-1,1)-k1); theta=1/2*inv(A2'*A2)*A2'*p2; %Using the least square solution, the theta=theta';%Convert to( x,y)form
parameter_est:
function [pd0_est,n_est]=parameter_est(A,sigma) [m,~]=size(A); pd0=0; n=3; d=zeros(m,m); tt=5; sigma1=10^(sigma/10); h1=[]; G1=[]; for i=1:m for j=1:m if i~=j d(i,j)=norm(A(i,:)-A(j,:)); for k=1:tt prd(k)=pd0-10*n*log10(d(i,j))-sigma1*randn; end RSSI=mean(prd); d_distance=-10*log10(d(i,j)); h1=[h1;RSSI]; G1=[G1;d_distance]; end end end h=h1; [m1,~]=size(h); G=[ones(m1,1),G1]; x=inv(G'*G)*G'*h; pd0_est=x(1,1); n_est=x(2,1); end
Main function:
clear all; clc; BS1=[0,0]; BS2=[500,0]; BS3=[500,500]; BS4=[0,500]; MS=[100,100]; std_var=[0,2,4,6]; A=[BS1;BS2;BS3;BS4]; number=300; pd0=0; n=3; tt=20; % the number of RSSI measurement for each BS for j=1:length(std_var) error1=0; error2=0; std_var1=std_var(j); for i=1:number r1=A-ones(4,1)*MS; r2=(sum(r1.^2,2)).^(1/2); for k=1:tt rssi(:,k)=pd0-10*n*log10(r2)-10^(std_var1/10)*randn(4,1); end RSSI1=mean(rssi,2); % ideal situation r1=10.^((RSSI1-pd0)/(-10*n)); % real situation [p_est,n_est]=parameter_est(A,std_var1); r2=10.^((RSSI1-p_est)/(-10*n_est)); theta1=TOALLOP(A,r1,1); theta2=TOALLOP(A,r2,1); error1=error1+norm(MS-theta1)^2; error2=error2+norm(MS-theta2)^2; end RMSE1(j)=(error1/number)^(1/2); RMSE2(j)=(error2/number)^(1/2); end % plot plot(std_var,RMSE1,'-O',std_var,RMSE2,'-s') xlabel('The standard deviation of RSS measurement (db)'); ylabel('RMSE'); legend('Ideal','Real');
4, Results
tt=5
tt=10
tt=15
5, Conclusion
As shown in the above figure, the abscissa represents the standard deviation of RSSI, and the ordinate represents the root mean square error. Blue represents the ideal situation, and red represents the actual situation.
1. when the RSSI is small, the RMSE of the ideal situation and the actual situation is almost the same. 2. with the increase of RSSI, there is a gap between the ideal situation and the actual situation, and the gap begins to grow.
3. with the increase of tt (the number of anchor nodes), the RMSE values of both ideal and actual situations will decrease under a certain RSSI, that is, with the increase of the number of anchor nodes, the positioning accuracy will also increase.