While ancient and modern mariners alike look up to the stars for direction, oceanographers look to the sea. Our research in particular involves moving with the water wherever it may happen to take us since we want to measure how a patch of water develops and changes over time.

On my latest cruise I found myself put into the role of de facto computer tech in charge of the navigation program we use for our scientific gear. Throughout the cruise two pieces of gear are nearly constantly in the water (the sediment trap and the drifter array), and in order for our science to work we need to be within a few hundred meters (less than a mile) from them at all times. This requires up-to-date GPS fixes and a reliable system for relaying these fixes to the bridge.

Historically we’ve used a custom piece of Matlab programing to read out the GPS coordinates and to provide a visual map of where the gear is relative to the ship. Although the Matlab program would freeze up from time to time and require a restart, it provided the necessary information in a convenient package. This works, at least most of the time, until you get a captain who wants it done their way. Our captain was over it and wanted us to come up with a new solution of providing locations and the task fell to me. So enter NMEA.

The National Marine Electronics Association (NMEA) writes up specifications on how computers and electronics should communicate with one another aboard ships. By ensuring a single standard, ship captains can be sure that the data they’re receiving are accurate and reliable regardless of what combination or brands their navigational systems use.

The standard that NMEA came up with allows all these systems to communicate using standard NMEA sentences which are encoded messages that contain information such as the longitude and latitude of the ship. For example, here are a few taken from this wonderful site:

The first one is a GPS fix location including the full 3D location and accuracy information, the second contains information about the physical GPS signal (which satellites were used for the above), and the last sentence provides waypoint information including position and its name.

For our tracking program I only needed to figure out how to encode my own GPGGA sentences (the position ones) since that is all we care about.  With some Googling and a whole lot of help from online sources I get this script working which reads in the latitude and longitude of the drifter, computes the NMEA sentence and broadcasts it on the network.

While the script may look complicated, it’s pretty straightforward.

The script will broadcast the current drift location, but it will do so as if the ship and the drifter were one. So instead of telling the navigational computer “the drifter is at location X” we are broadcasting that “the ship is at position X”. To fix this, we actually have to resort to another, even more obfuscating encoding called AIS.

Just as NMEA is used for within ship communication, AIS is used for between ship communications and essentially consists of NMEA sentences repackaged for radio transmission.  Here is an example AIS sentence

Although the idea is similar to NMEA, the level of encoding is more complex and, to be honest, I am still a bit lost in the details of it. But nevertheless, Google and online forums proved helpful is developing the following (hack of a) script that takes latitude and longitude of the drifter and broadcasts it via AIS sentences.

Now what this script does is tell the navigation computer “Hey, drifter1 is at position X”. Although far from perfect, the script did work reliably for the duration of the cruise (about a month) and it allowed me to get some well needed sleep once in a while.