matlabmathgeometrytrilateration

Find Position based on signal strength (intersection area between circles)


I'm trying to estimate a position based on signal strength received from 4 Wi-Fi Access Points. I measure the signal strength from 4 access points located in each corner of a square room with 100 square meters (10x10). I recorded the signal strengths in a known position (x, y) = (9.5, 1.5) using an Android phone. Now I want to check how accurate can a multilateration method be under the circumstances. Using MATLAB, I applied a formula to calculate distance using the signal strength. The following MATLAB function shows the application of the formula:

    function [ d_vect ] = distance( RSS )
    % Calculate distance from signal strength
    result = (27.55 - (20 * log10(2400)) + abs(RSS)) / 20;

    d_vect = power(10, result);

    end

The input RSS is a vector with the four signal strengths measured in the test point (x,y) = (9.5, 1.5). The RSS vector looks like this:

    RSS =

    -57.6000
    -60.4000
    -44.7000
    -54.4000

and the resultant vector with all the estimated distances to each access points looks like this:

   d_vect =

   7.5386
   10.4061
   1.7072
   5.2154

Now I want to estimate my position based on these distances and the access points position in order to find the error between the estimated position and the known position (9.5, 1.5). I want to find the intersection area (In order to estimate a position) between four circles where each access point is the center of one of the circles and the distance is the radius of the circle.

I want to find the grey area as shown in this image : http://www.biologycorner.com/resources/venn4.gif


Solution

  • I found an answear that solved perfectly the question. It is explained in detail in this link:

    https://gis.stackexchange.com/questions/40660/trilateration-algorithm-for-n-amount-of-points

    I also developed some MATLAB code for the problem. Here it goes:

    Estimate distances from the Access Points:

    function [ d_vect ] = distance( RSS )
        result = (27.55 - (20 * log10(2400)) + abs(RSS)) / 20;
        d_vect = power(10, result);
    end
    

    The trilateration function:

    function [] = trilat( X, d, real1, real2 )
    cla
    circles(X(1), X(5), d(1), 'edgecolor', [0 0 0],'facecolor', 'none','linewidth',4); %AP1 - black
    circles(X(2), X(6), d(2), 'edgecolor', [0 1 0],'facecolor', 'none','linewidth',4); %AP2 - green
    circles(X(3), X(7), d(3), 'edgecolor', [0 1 1],'facecolor', 'none','linewidth',4); %AP3 - cyan 
    circles(X(4), X(8), d(4), 'edgecolor', [1 1 0],'facecolor', 'none','linewidth',4); %AP4 - yellow
    axis([0 10 0 10])
    hold on
    tbl = table(X, d);
    d = d.^2;
    weights = d.^(-1);
    weights = transpose(weights);
    beta0 = [5, 5];
    modelfun = @(b,X)(abs(b(1)-X(:,1)).^2+abs(b(2)-X(:,2)).^2).^(1/2);
    mdl = fitnlm(tbl,modelfun,beta0, 'Weights', weights);
    b = mdl.Coefficients{1:2,{'Estimate'}}
    scatter(b(1), b(2), 70, [0 0 1], 'filled')
    scatter(real1, real2, 70, [1 0 0], 'filled')
    hold off
    

    end

    Where,

    X: matrix with APs coordinates

    d: distance estimation vector

    real1: real position x

    real2: real position y