SignalK / signalk-derived-data

Generates deltas for values derived from signalk values
Apache License 2.0
18 stars 31 forks source link

AIS CPA and TCPA calculation seem wrong #48

Closed mcdonaldajr closed 3 years ago

mcdonaldajr commented 4 years ago

derived data plug in calculating CPA as 14,588 and TCPA as 40,956. OpenCPN and SeaClear agree on CPA as 3.74NM and TCPA as 2hrs 48 minutes which I calculate at 6926 meters and 10,080 seconds. Have I misunderstood the units? Attached are the screenshots.

Screenshot 2020-05-01 at 19 20 22 Screenshot 2020-05-01 at 19 21 17

sbender9 commented 4 years ago

@joabakk do you have time to look into this?

mcdonaldajr commented 4 years ago

Here's the AIS sample data I was using to test. I also fed simulated position of my boat 23.47E, 37.07N to 23.56E, 37.21N moving at 0.1 knots Thanks for investigating. Anthony

nmea_data_sample.txt

joabakk commented 4 years ago

@sbender9 I will have a look

joabakk commented 4 years ago

@mcdonaldajr could you provide a sample file with your own gps positions as well? It is not so easy to simulate your boats movements and hit the calculations you were seeing. I think I found a bug, just need to be sure before I push it

joabakk commented 4 years ago

Hehe just spent an hour comparing the code with https://github.com/jaffadog/marine-cpa-tcpa/blob/master/app.js which it turns out, is copied from my code...

mcdonaldajr commented 4 years ago

Unfortunately, I simulated my GPA position using my laptop which has a GPS simulator on it, so I don't have a combined file. What I have done since then is use the CPN plugin ShipDriver as a source of GPS data. The only other thing I needed to do was use PathMapper signal K plugin to map navigation.speedThroughWater to navigation.speedOverGround as ShipDriver only simulates speedThoughWater. It is a shame that we can't slow down the reading from the AIS file to simulate real data coming in, as it just repeats rapidly in less than a minute, which is a bit confusing.

joabakk commented 4 years ago

OK, We will have to make a test case for this. I am incapacitated at the moment, but I had done some research into using UTM for calculations and to set up a straight example with parallel crossing vessels. It will have to wait.

joabakk commented 3 years ago

Tested to give same results as OpenCPN