ttlappalainen / NMEA0183

Library for handling NMEA0183 messages
69 stars 44 forks source link

NMEA0183 Library Extension for encoding AIS #13

Open ronzeiller opened 4 years ago

ronzeiller commented 4 years ago

Do not know if this is the right place for this: Is it somewhere already, or are there any plans, or is there somebody working on NMEA2000 AIS PGNs converting to "NMEA" !AIVDM sentences yet?

ronzeiller commented 4 years ago

Hi Timo,

So I have started an Addendum to NMEA0183 library for AIS encoding from parsed N2k values from ParseN2kPGN129038, which is Type 1: Position Report Class A to start with:

https://github.com/ronzeiller/NMEA0183/tree/ais-development Edit: AIS is now made as separated Add On and not within the NMEA0183 Library https://github.com/ronzeiller/NMEA0183-AIS

Even if it is far from a Pull Request, it is working code. I will try to code an example for Arduino, which is extra work, because I am using Atom/PlatformIO.

Before I continue with encoding other sentences, would you like to have a look and comment on the code?

ronzeiller commented 4 years ago

~~Example: https://github.com/ronzeiller/NMEA0183/tree/ais-development/Examples/NMEA2000ToNMEA0183AIS added.~~

One Issue I found: the COG is not correct. Have to figure out what the ParseN2kPGN129038 is delivering, degrees or radiant?

Because I now for sure, that this ferry boat was sailing COG around 260°... :-)

IMG_0184s

I got from N2kParser:

Name Value --> AIS Value REPEAT = 0 --> 0 UserID = 238991940 --> 238991940 NavStatus = 0 --> 0 ROT = 0.00 --> 0 SOG = 5.81 --> 58 Accuracy = 0 --> 0 Longitude = 15.23 --> 9136800 --> 0000100010110110101010100000 Latitude = 44.08 --> 26449399 --> 001100100111001010111110111 COG = 4.75 --> 47 Heading = 1.45 --> 1 RAIM = 0 !AIVDM,1,1,,A,13SrrA000r15eE0I>Euh;h3h0000*5B

ttlappalainen commented 4 years ago

4.75 rad = 272 deg.

I checked and it should be right on ParseN2kPGN129038 and returns radians.

I tried to keep all units in SI, but unfortunately originally did not fix that to lat/lon, which are in degrees. There are also some other inconsistense. All angles except lat/lon should be in radians.

ronzeiller commented 4 years ago

Type 1 Class A Position Report should work now with all units corrected.

ronzeiller commented 4 years ago

Working NMEA0183 Library Add On for converting: NMEA2000 PGN 129038 => AIS CLASS A Position Report, Message Type 1 NMEA2000 PGN 129039 => AIS Class B Position Report, Message Type 18 NMEA2000 PGN 129794 => AIS Class A Ship Static and Voyage related data, Message Type 5 NMEA2000 PGN 129809 => AIS Class B "CS" Static Data Report, making a list of UserID (MMSI) and Ship Names used for Message 24 Part A NMEA2000 PGN 129810 => AIS Class B "CS" Static Data Report, Message 24 Part A+B

can be found here: https://github.com/ronzeiller/NMEA0183-AIS

There is lot's to might be improved.... So any suggestions and/or Pull Requests are welcome.