dump1090 icon indicating copy to clipboard operation
dump1090 copied to clipboard

Fix CPR bugs

Open mutability opened this issue 10 years ago • 5 comments

This fixes a number of CPR decoding bugs that affect global surface position decoding, and relative position decoding of both surface and airborne positions.

It would manifest as:

  • picking the wrong quadrant for surface positions for receivers that were close to a 90 degree boundary. e.g. my receiver is at 0.15E and decodes surface positions from 0.17E OK. However if I move my receiver location to 0.15W then the same surface positions are decoded completely wrong (almost 90 degrees wrong).
  • picking the wrong latitude or longitude zone (+/- 1 zone) when doing relative decoding for some combinations of position data and reference location. This would result in errors of up to 6 degrees. This is mitigated because dump1090 only does relative decoding when global didn't work, and the errors can only usually occur when an aircraft moves across a zone boundary.
  • relative decoding using receiver position hardly ever working unless you happened to be near (0N,0E) because it was sanity-checking against the wrong reference location

The fixes are derived from my experimental branch here: https://github.com/mutability/dump1090/tree/experimental The experimental branch has some test code for these cases. It's difficult to backport without invasive changes, as the old CPR code isn't very unit-test-friendly.

mutability avatar Jan 12 '15 16:01 mutability

There is a standalone version of the CPR code that these changes are based on, plus tests, at https://github.com/mutability/dump1090/blob/experimental/cpr.c.

mutability avatar Jan 12 '15 19:01 mutability

A side effect of fixing relative CPR so that it works when using the receiver location as the basis, is that I actually start hitting the 180NM ambiguity:

screenshot from 2015-01-12 20 22 58

Here I suspect I got a few position packets while the plane was over Belgium at about 200NM, but not enough for a global CPR. Relative CPR put it out in the Irish Sea rather than over Belgium, and then updated from there as positions came in intermittently. Once I got enough positions to do global CPR it snapped over to the correct location.

So with these fixes we may well need another knob to control when relative CPRs are allowed, as 200NM+ range is not uncommon.

mutability avatar Jan 12 '15 20:01 mutability

when i put the code in use i was getting planes from the other side of the world so there is something wrong with it

steel101 avatar Mar 22 '15 20:03 steel101

This code has been successfully used for months in dump1090-mutability; the error is probably in how you merged or configured it. For example, giving dump1090 a wildly wrong receiver location would cause initial positions resolved via relative CPR to be way out.

If you think you have a specific case that is failing, please add a test demonstrating the problem against the CPR tests here: https://github.com/mutability/dump1090/blob/master/cprtests.c

mutability avatar Mar 22 '15 20:03 mutability

ok thank you i think i fixed it it is now in my code and working

steel101 avatar Mar 22 '15 20:03 steel101