lemmingapex / trilateration

Solves a formulation of n-D space trilateration problem using a nonlinear least squares optimizer
MIT License
398 stars 106 forks source link

Odd behaviour when "triangulating" using two beacons. #10

Closed classicman92 closed 7 years ago

classicman92 commented 7 years ago

Hello. Thank you for your enormous work.

I'm sorry if this sounds dumb, I've managed to get your library working and when I call your function NonLinearLeastSquaresSolver() and feed it the positions and the distances values, it outputs the centroid coordinates as it's supposed to do. What looks suspicious to me is that given two beacons, the output centroid seems to be closer to the beacon that has the biggest distance from the phone.

For example, if the input values for the position of the beacons are (810,960) and (810,1440) and the distance values are 22 and 2 respectively, the output of the function is (810,1048), and that's closer to the beacon that had the bigger distance (22).

Am I missing something?

Thank you in advance.

lemmingapex commented 7 years ago

The example you provided is not well formed. The two circles you provided do not intersect. (Plot them, they aren't even close.) The output of trilateration is the common intersection of all the circles.

This is library provides trilateration methods (https://en.wikipedia.org/wiki/Trilateration or multilateration) not triangulation methods (https://en.wikipedia.org/wiki/Triangulation).

What are you trying to do?

classicman92 commented 7 years ago

Thank you. I was under the wrong impression that the library would work even without intercepting circles. That's probably because when I tried it with two beacons at equal distance from the phone (with the two circles not intercepting), the output centroid would sit in the middle of the two beacons, so I just wrongly assumed it was working fine even if the two circles were far apart.

What I'm trying to do is getting a rough estimation of the position of a smartphone inside a room using RSSI data from six beacons from Nordic placed in known spots inside the room. I have developed an android app that is able to get the RSSI-generated distances from the beacons using the AltBeacon library, and I was hoping to feed this data to your algoritm to get an estimate of the position. Until now I've only tested two beacons.

Thank you again.