bridgecommand / bc

Bridge Command ship simulator
https://www.bridgecommand.co.uk
Other
56 stars 24 forks source link

AIS class A reports over AIVDM #38

Closed antoine0183 closed 1 year ago

antoine0183 commented 1 year ago

This PR adds sending out navigational information of otherShips in the simulation over the network via AIVDM sentences in the form of AIS class A reports. This allows tracking other ships in a chart plotter such as OpenCPN as shown in the screenshot here.

ais-feature-example

Reports are generated periodically depending on the otherShip's speed (at 2, 6, 10 or 180 second intervals as defined in the standard). The heading and course over ground field both take the value of the heading since there isn't a separate cog value for otherShips. Rate of turn is not taken into account: the ROT field is left empty and turning ships do not send reports more frequently.

To allow for AIS reports to be sent as soon as they are ready and not only on a fixed NMEA_UPDATE_MS interval, this PR also includes a slight rework of the send loop: on every iteration of the main loop we check for new AIS or sensor reports and fill a message queue which is then cleared.

bridgecommand commented 1 year ago

Thanks very much, this is very useful. Now merged.