lemmingapex / trilateration

Solves a formulation of n-D space trilateration problem using a nonlinear least squares optimizer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trilateration package with DWM1000

werty37 opened this issue · comments

commented

Hi,

I am trying to use your library in Processing(processing.org) for doing trilateration of a tag. The setup uses 3 Anchors and 1 Tag using dwm1000 modules and ESP.

I am getting the two way ranging distance of each anchor with the tag and passing it to Processing to do localization.

The two way ranging data has distance from the anchor, and signal strength. Now how do I pass these values to the trilateration package?

Are there any examples? If I can get this to work, I can contribute a Processing interface to visualise the trilateration data.

Thanks

Hi,
everything you ask is shown in the readme file.

You initialize the locations of your anchors (2-dimensional in this example )
double[][] positions = new double[][] { { 5.0, -6.0 }, { 13.0, -15.0 }, { 21.0, -3.0 }, { 12.4, -21.2 } };
and another array for the measured distances from each anchor to the tag:
double[] distances = new double[] { 8.06, 13.97, 23.32, 15.31 };

Afterwards you siply call

NonLinearLeastSquaresSolver solver = new NonLinearLeastSquaresSolver(new TrilaterationFunction(positions, distances), new LevenbergMarquardtOptimizer());
Optimum optimum = solver.solve();

// the answer
double[] centroid = optimum.getPoint().toArray();

Where centroid is your trilterated position.

You don't need the signal strength for trilateration. The RSSI is used to estimate the distances - which you already have.

commented

Thank you. I understood the distances array. I am receiving the distance of the tag from each anchor which i would have to feed into the distances array.

But i was wondering how to provide positions of the anchors.

You initialize the locations of your anchors (2-dimensional in this example )
double[][] positions = new double[][] { { 5.0, -6.0 }, { 13.0, -15.0 }, { 21.0, -3.0 }, { 12.4, -21.2 } };

How do i feed the positions of the anchors. What do these numbers in the above code mean. For eg; 5.0, -6.0

The anchors are placed 10 to 12 ft from the ground. There are a total of 3 Anchors.

Ok it seems the problem are the basics of trilateration. You can read an introduction here.

In short you have a number of anchors which should be placed at fixed locations. This shouldn't change for multiple measurements in the same room.
For each time you want to trilaterate your location you have to define the measured distance to each anchor.
So what you have is a double[][] array defining the n-dimensional locations of each of your anchors.
The given example was for a 2-dimensional case only. This means that each entry in the array is a combination of x and y coordinates. In the example values can be negative because the coordinate system origin is the center of the room.
The concept of the arrays is that you define each anchor with the following format:
{ width (=x), height (=y), depth (=z) }
E. g. the first entry in the array { 5.0, -6.0 } defines :
x = 5 ft
y = -6 ft
for the first anchor. (the z-coordinate is not given)

Things you should consider about this:

  • The dimensions must be consistent within your setup. E. g. if you define the anchor coordinates in meters, you also have to define the measured distances in meters
  • For 3-dimensional localization (you spoke about height..) you require at least 4 anchors. With 3 anchors you can only use 2-dimensional trilateration. Just take this as a given fact - the explanation would take a bit.

The anchors are placed 10 to 12 ft from the ground. There are a total of 3 Anchors.

This is the z-coordinate only. You have to define excplicit x,y,z for each of you anchors.

commented

Thank your for the detailed explanation. Please let me know if I am getting it right.

In my particular case, the room dimensions are 20 meters breadth and 40 meters length. I believe the height of the anchors are irrelevant in my case since I am doing only 2D trilateration. So I would have to take X as 20 and Y as 40. Or if I were to take the midpoint of the lengths of the wall as 0. I would have X ranging from -10 to +10 and Y ranging from -20 to +20. So these becomes Cartesian coordinates.

So if I were to place anchor ONE at 1.5 in X and -20 at Y, I would have to feed the following:

double[][] positions = new double[][] { { 1.5, -20.0 }, { X(A2), Y(A2) }, { X(A3), Y(A3)};

X(A2), Y(A2) and X(A3), Y(A3) being XY of Anchor TWO and THREE respectively. The DWM1000 returns distances in centimetres which I will convert to meters and feed to

double distances[]

Is my understanding correct? Or have I gone totally wrong. Thanks for your patience.

Thats correct.

commented

Thank you @kburfi