Skip to content

ZeroMQ Access

One method of retrieving data programmatically from Navproc is using ZeroMQ messaging. Below is a section on the message formats and some examples in different languages that allow you to access this data. Some example channels you can subscribe to data from are:

  1. LODESTAR_SERIN: The raw seral message from the lodestar system
  2. NAV4D_GPS_MSG: The parsed ROV position messages received from the 4DNav system
  3. NAV4D_GPS_SERIN: The raw serial messages from the 4DNav system (ROV positions)
  4. NMEA_GPS_MSG: The parsed ship gps message
  5. NMEA_GPS_SERIN: The raw serial strings received from the ships GPS
  6. SEABIRD_CTD_MSG: The parsed CTD message from the ROV CTD
  7. SEABIRD_CTD_SERIN: The raw serial message from the ROV CTD
  8. SHIP_GYRO_MSG: The parsed ship gyro message
  9. SHIP_GYRO_SERIN: The raw serial message from the ships gyro
  10. UHS_SERIN: The raw serial message from the umbilical handling system
  11. VENTANA_CSP_MSG: The parsed message from the ROV Ventana control system (Rachel Carson only)
  12. VENTANA_CSP_SERIN: The raw serial string from the ROV Ventana (Rachel Carson only)

The various server hosts you can access are:

  1. Rachel Carson = coredata-rcsn.rc.mbari.org
  2. Rachel Carson Simulator = coredata-rcsn-sim.shore.mbari.org
  3. David Packard = coredata-dpkd.dp.mbari.org
  4. David Packard Simulator = coredata-dpkd-sim.shore.mbari.org

Message Format

The messages that come from the Navproc ZeroMQ proxy are multi-part messages and are of the format:

  1. Part one: Channel name
  2. Part two: Message type
  3. Part three: Message payload in JSON format

Here is an example:

  1. Part one: NMEA_GPS_MSG
  2. Part two: navproc/msg_t
  3. Part three:
{
    "lcm_channel": "NMEA_GPS_MSG",
    "message_type": "navproc/msg_t",
    "num_bools": 2,
    "num_integers": 2,
    "num_reals": 7,
    "num_strings": 3,
    "pub_id": "navproc-rcsn-sim.shore.mbari.org:nmea_gps(462980)",
    "pub_sequence": 294855,
    "pub_timestamp": 1740598273.0249748,
    "bool_list": [
        {
            "key": "gga_diff_mode",
            "value": 1
        },
        {
            "key": "gll_data_valid",
            "value": 1
        }
    ],
    "integer_list": [
        {
            "key": "gga_quality",
            "value": 2
        },
        {
            "key": "gga_nsats",
            "value": 9
        }
    ],
    "real_list": [
        {
            "key": "latitude",
            "value": 36.836911666666666
        },
        {
            "key": "longitude",
            "value": -121.83417
        },
        {
            "key": "gga_hdop",
            "value": 0.9
        },
        {
            "key": "gga_fix_age_seconds",
            "value": 118.27873063087463
        },
        {
            "key": "gll_fix_age_seconds",
            "value": 1740598272.8634295
        },
        {
            "key": "zda_utc_seconds",
            "value": 1733426954
        },
        {
            "key": "zda_fix_age_seconds",
            "value": 0
        }
    ],
    "string_list": [
        {
            "key": "sentence",
            "value": "$GPZDA,192914,05,12,2024,08,00*44\r\n"
        },
        {
            "key": "fix_time",
            "value": "19:29:14"
        },
        {
            "key": "zda_date_time",
            "value": "2024-12-05T19:29:14Z"
        }
    ]
}

Programmatic Access

Python

In order to use a Python client, you will need to install the zmq library by running pip install zmq. Once that is done, it's fairly straightforward to connect to the ZMQ proxy and start receiving the messages. Here is an example of some python that subscribes to all channels and prints out the three part message joined with a :.

Note

You will need to change the host parameter in the code below to point to the system you are interested in getting data from (see top of the document for server names)

# Import ZeroMQ module
import zmq

# Change these to point to your server and port
host = "coredata-dpkd.dp.mbari.org"
port = "5556"

# Creates a subscriber socket instance
context = zmq.Context()
socket = context.socket(zmq.SUB)

# Connects to a bound socket
socket.connect("tcp://{}:{}".format(host, port))

# Subscribes to all topics
socket.subscribe("")

# Receives a multipart message
while(True):
    the_response = socket.recv_multipart()
    string_rep = ""
    counter = 0
    for i in the_response:
        if counter > 0:
            string_rep += ":"
        string_rep += i.decode()
        counter += 1
    print(string_rep)

If you want to subscribe to a specific channel, simply put the channel name in the subscribe argument and you will only get those messages. For example, here is the code to get just the parsed ship GPS message

# Import ZeroMQ module
import zmq

# Change these to point to your server and port
host = "coredata-rcsn-sim.shore.mbari.org"
port = "5556"

# Creates a subscriber socket instance
context = zmq.Context()
socket = context.socket(zmq.SUB)

# Connects to a bound socket
socket.connect("tcp://{}:{}".format(host, port))

# Subscribes to all topics
socket.subscribe("NMEA_GPS_MSG")

# Receives a multipart message
while(True):
    the_response = socket.recv_multipart()
    string_rep = ""
    counter = 0
    for i in the_response:
        if counter > 0:
            string_rep += ":"
        string_rep += i.decode()
        counter += 1
    print(string_rep)