0

My goal is to implement algorithm for fine TDOA multilateration. I calculate the initial guess in a way similar to this answer (it holds that $D_i = D_0 + d_{0i}$ instead of $D_i = D_0 - d_{0i}$). However that answer and next answer suggest to use non-linear regression for fine localization. I have come up with a model

$d_{0i} + D_{0} = \sqrt{(x_i - X)^2 + (y_i - Y)^2} $

where

  • $d_{0i}$ is the distance difference between zeroth anchor and i'th anchor which is given
  • $D_0$ is the distance between zero'th anchor and tag to be found
  • $x_i$ and $y_i$ are coordinates of the i'th anchor that are given, and
  • $X$ and $Y$ are coordinates of the tag to be found.

This is how it looks on paper.

I would like to learn how I can use this model to get the final D0, X and Y coordinates. Any tips on how to implement this model/tips on resources is welcome - I guess I have to define a cost function (I don't know how to do that for this model) and then use some minimizer to get the results, but I may be wrong.

Possible
  • 15
  • 6
  • Have a look at https://math.stackexchange.com/questions/1338323/finding-an-unknown-location-with-known-distances-from-location/1338429#1338429 which is for $3D$ (very easy to adapt it for $2D$ - just remove the $z$). If you do not want regression, the first step will give you quite good results. – Claude Leibovici Jan 20 '20 at 11:28
  • @ClaudeLeibovici Can you help me with the function to minimize? I have tried $\sum{(\sqrt{(x_i - X)^2 + (y_i - Y)^2} - (D_0+d_{0i}))^2}$, but had no luck using Newton iterative method for finding the X,Y and D0 (it does not converge to anything, just flies all over the place). Thank you very much. – Possible Jan 23 '20 at 07:36
  • Also, is it enough if I don't use Netwon approach, but just some Unconstrained function minimizer? – Possible Jan 23 '20 at 09:39
  • Just wait ! I am writing my answer. Cheers :-) – Claude Leibovici Jan 23 '20 at 09:44
  • Please, let me know how it works for your problems. Cheers. – Claude Leibovici Jan 23 '20 at 10:20

1 Answers1

0

You want to minimize in the least square sense, $$\Phi=\frac12\sum_{i=1}^n \left(\sqrt{(x_i - X)^2 + (y_i - Y)^2}-(d_i+D)\right)^2$$ which is difficult unless you have good guesses.

To get them, consider the $n$ equations $$f_i=(x_i - X)^2 + (y_i - Y)^2-(d_i+D)^2=0$$ and build the $\frac {n(n-1)}2$ equations which, after expanding, write $$f_j-f_i=2(x_i-x_j) X+2(y_i-y_j) Y+2(d_i-d_j) D=(x_i^2-x_j^2)+(y_i^2-y_j^2)-(d_i^2-d_j^2)$$ and consider that this is a multilinear regression without intercept (very simple to solve using matrices).

So, after this preliminary step, we have the estimates of $(X,Y,D)$ and we could minimize $\Phi$. Naming $$r_i=\sqrt{(x_i - X)^2 + (y_i - Y)^2}-(d_i+D)\implies \Phi=\frac12\sum_{i=1}^n r_i^2$$ and then the equations to be solved are $$\frac{\partial \Phi}{\partial X}=\sum_{i=1}^n r_i \frac{\partial r_i}{\partial X}=0 \quad\qquad \frac{\partial \Phi}{\partial Y}=\sum_{i=1}^n r_i \frac{\partial r_i}{\partial Y}=0 \quad\qquad\frac{\partial \Phi}{\partial D}=\sum_{i=1}^n r_i \frac{\partial r_i}{\partial D}=0 $$ where $$\frac{\partial r_i}{\partial X}=\frac{X-x_i}{\sqrt{(x_i-X)^2+(y_i-Y)^2}}$$ $$\frac{\partial r_i}{\partial Y}=\frac{Y-y_i}{\sqrt{(x_i-X)^2+(y_i-Y)^2}}$$ $$\frac{\partial r_i}{\partial D}=-1$$ and to solve the three equations$$\frac{\partial \Phi}{\partial X}=\frac{\partial \Phi}{\partial Y}=\frac{\partial \Phi}{\partial D}=0$$ use Newton-Raphson method starting from the guesses $(X_0,Y_0,D_0)$ given by the preliminary step. To make life easier, use numerical derivatives.

This should work.

  • Thank you very much, I am now soaking that in. I understood how to do the initial guess, but I did stupid mistake where I was trying to calculate the roots of Φ instead of dΦ/dX, etc... I am new to nonlinear algebra, and my goal was to come up with a way to make our trilateration more accurate (so I have to do it under time constraints and don't have much time to explore this field on my own). In future, however, I will definitely study it closer, as it looks very interesting. Thank you for the answer again, I am now trying to implement it in octave. – Possible Jan 23 '20 at 10:27
  • Sorry to bother, but I can't get it to work. I calculate the Y as $Y_{n+1} = Y_{n} - \frac{\frac{∂Φ}{∂Y}}{\frac{∂^2Φ}{∂Y^2}}$, yet it does not converge. Here is my octave code just in case https://pastebin.com/p8SF3eqc . – Possible Jan 23 '20 at 11:28
  • First question : did you solve the preliminary step ? What you wrote is not correst. You must transform each equation into a linear equation in the three variables and solve simultaneously. I shall work your problm. – Claude Leibovici Jan 23 '20 at 11:51
  • I solved the prelimary step exactly as you described in other program, and I simply copied the resulting X,Y and D0 variables into this program. Also, isn't that equation that comes into matrix supposed to end with minus rather than plus?: $-(d_i^2 - d_j^2)$ . I did this on paper and I got different signs before these two variables. – Possible Jan 23 '20 at 12:02
  • @Possible. You are correct ! I had a typo in the formula. Can you give me the results of the preliminary step ? – Claude Leibovici Jan 23 '20 at 12:24
  • $X = -2.0189; Y = -4.7015; D0 = 3.47714;$ and original data = [ 7, -4.8, -0.65, 2.26; 94, -6.9, -3.00, 2.56; 98, -6.9, 0.00, 3.84; 99, 0.0, 0.00, 2.45; 100, 0.0, -4.6, 0;

    ]; where first column is anchor id, second is X coordinate, third is Y coordinate, and last is $d_{0i}$. Thanks.

    – Possible Jan 23 '20 at 12:25
  • If I am not mistaken, the final result should be $X=-2.234$, $Y=-4.200$, $D=2.279$. – Claude Leibovici Jan 23 '20 at 12:30
  • For me it converged in 5-6 iterations and I got the following results: X = -2.2503, Y = -4.2240, D0 = 2.2956, not sure why they are different, but that's good enough, and they loosely match what I have calculated using unconstrained function minimizer. Thanks for your help, nice to have it finally implemented. – Possible Jan 25 '20 at 10:58
  • No, you are correct, it's X=−2.234 , Y=−4.200, D=2.279. Probably used floating point with not enough precision or had a mistake in the formula somewhere. – Possible Jan 25 '20 at 21:00
  • To be fair, the method for calculating initial guess is not very precise and does not work nicely with small errors and small spaces (e.g. I was trying this with UWB TDoA, std. dev. is about 15 cms and the area is 2*6m) or when there are only 3 anchors. Try for example { x: 23.55071, y: 0.83093, d0i: 0 }, { x: 23.16599, y: 6.5044, d0i: 0.97 }, { x: 24.42134, y: 6.56795, d0i: 1 }, which is one of the many (30%) measurements that initial guess was tens of meters away, which resulted in Newton method getting stuck in local minimum (most of the 30% measurements had at least 4 anchors). – Possible Jun 22 '20 at 08:35
  • The local minimum was 300 meters away from the actual placement, and additional step between initual guess and final newton iterative approach is needed (I will write answer soon). This method (with modified model eq.) works very well for TOF, but not so well for TDoA. – Possible Jun 22 '20 at 08:36