Search code examples
python-3.xrssjupyter-labmontecarlotrilateration

Finding Positions Using Trilateration and Filtering them using Monte Carlo Theorem In Python / Jupyter Lab


I'm very new in Python. Recently I've just started using Jupyter Lab. So, I have collected a RSS feed value in Excel CSV File. I want to apply the **trilateration **formula in it to find the position. But I've absolute no idea how I can do this. Can anyone help me regarding the fact? so the data is collected like the picture attached. enter image description here

The collected data sample is also given below.

https://aiubedu60714-my.sharepoint.com/:x:/g/personal/18-36632-1_student_aiub_edu/EZx44mosc7pInAsxAFX5J1wBylO7rmtmxNqW8SIAXRoIyw?e=92L8v8

and i also want to try the monte carlo theorem to find the accuracy value.

It would be very much appreciated you guide me the full procedure.


Solution

  • I haven't used the monte carlo theorem, but to use trilateration in this case, you'll first need to convert the RSS values to distance using the Signal Propagation Path Loss Formula:

    def rss_to_meters(rss: float, c: float, phi: float) -> float:
        return Math.Log10(10, (c - rss) / (10 * phi))
    

    where c is the average RSS measured at one meter distance between the sending and receiving antenna. In my case it was usually close to -50dB. And phi is the path loss exponent, a value between 1 and 4, where 4 is a environment with lots of noise (e.g. lots furniture). 3 may be a good guess in many cases.

    Since RSSI fluctuates a lot, it's best if the rss fed into this method is an average from multiple samples. You are still unlikely to get an accurate prediction using the trilateration formula, but here it is:

    def get_a(d2: float, d3: float, x2: float, x3: float, y2: float, y3: float) -> float:
        return ((d2 ** d2 - d3 ** d3) - (x2 ** x2 - x3 ** x3) - (y2 ** y2 - y3 ** y3)) / 2
    
    def get_b(d1, d2, x1, x2, y1, y2) -> float:
        return ((d2 ** d2 - d1 ** d1) - (x2 ** x2 - x1 ** x1) - (y2 ** y2 - y1 ** y1)) / 2
    
    def get_position_y(a: float, b: float, x1: float, x2: float, x3: float, y1: float, y2: float, y3: float) -> float:
        return (b * (x3 - x2) - a * (x1 - x2) ) / ( (y1 - y2) * (x3 - x2) - (y3 - y2) * (x1 - x2) )
    
    def get_position_x(a: float, y: float, y3: float, y2: float, x3: float, x2: float) -> float:
        return (a - (y * (y3 - y2) ) ) / (x3 - x2)
    

    You should select the three closest anchor points to do the computation, since RSS fluctuates more at longer distances. d1 represent the distance between between the unknown node at (x, y) and the first anchor point at (x1, y1). So you'll also need to know the 2D-coordinate of each anchor point (or "topic" from your image). You get the final coordinate (x, y) by using get_position_x() and get_position_y(). a and b are not significant, just intermittent steps to compute the x and y coordinates.

    This trilateration approach was derived from the following paper: https://ieeexplore.ieee.org/document/1391018

    Generally RSS combined with trilateration algorithm yield extremely poor localization accuracy because of how noisy the RSS measurements are, even after calculating the average RSS. Trilateration requires good distance approximations to function properly. A better alternative would be to use the "modified weighted centroid localization" algorithm as presented in this paper: https://ieeexplore.ieee.org/document/4447528 . This algorithm is generally more forgiving when using noisy RSS samples.