Skip to main content

MQTT Real-Time Data API

General

The Koherent Grid MQTT API is used for subscribing to real-time data from Koherent Grids using the MQTT protocol.

Authentication

Authentication is required to subscribe to any MQTT topics included in this documentation. Basic authentication is used, meaning that the client has to provide a valid username and password when subscribing to a topic.

Client IDs

The client ID is an identifier used by MQTT for identifying individual subscribers. The id has to be a globally unique string, with a maximum length of 256 characters.

Topics

Depending on the Grid configuration, one or more of the topics described below will be available for subscription.

Position data v0 [deprecated]

warning

This topic is deprecated and will be removed in a future release. Please use the below v1 instead.

v0/measurement/<target_id>

Position data v1

v1/position/<target_id>

Subscribe to measurement data describing a target's position, orientation and the respective error estimates.

The + wildcard can be used for receiving data for all available targets:

v1/position/+

Data format

FieldTypeData typeDescription
timestamprequiredstringThe time of the measurement (ISO 8601 timestamp)
xrequiredfloat64Target x coordinate in meters
yrequiredfloat64Target y coordinate in meters
zrequiredfloat64Target z coordinate in meters
yawrequiredfloat64Target yaw angle in degrees
pitchrequiredfloat64Target pitch angle in degrees
rollrequiredfloat64Target roll angle in degrees
error_xrequiredfloat64Target x coordinate error estimate in meters
error_yrequiredfloat64Target y coordinate error estimate in meters
error_zrequiredfloat64Target z coordinate error estimate in meters
error_yawrequiredfloat64Target yaw angle error estimate in degrees
error_pitchrequiredfloat64Target pitch angle error estimate in degrees
error_rollrequiredfloat64Target roll angle error estimate in degrees

Data example

{
"timestamp": "2023-08-27T13:04:57.950255286Z",
"x": 20.08106231689453,
"y": -4.077945709228516,
"z": 0.578690528869289,
"yaw": 180.0592245782578,
"pitch": -0.189548754785755,
"roll": 10.07396251629481,
"error_x": 0.000022246194930630736,
"error_y": 0.00007646845915587619,
"error_z": 0.00024494959507137537,
"error_yaw": 0.0016238032660330646,
"error_pitch": 0.0024387806479353458,
"error_roll": 0.004775759538868442
}

Distance data

v1/distance/<target_id>

Subscribe to distance measurement data.

The + wildcard can be used for receiving data for all available target distances:

v1/distance/+

Data format

FieldTypeData typeDescription
timestamprequiredstringThe time of the measurement (ISO 8601 timestamp)
drequiredfloat64The distance in meters
error_drequiredfloat64The distance error estimate in meters

Data example

{
"timestamp": "2025-01-27T09:24:20.053378266Z",
"d": 12.828408363174582,
"error_d": 0.00031422923099173184
}

Examples

Subscribing to measurement data with Python using the Paho MQTT client.

Install the Paho client with:

pip3 install paho-mqtt~=2.1.0
note

A Python version >= 3.8 is required.

from paho.mqtt import client as mqtt_client
from paho.mqtt.enums import CallbackAPIVersion
from time import time

client = mqtt_client.Client(
client_id=f"example-client-{round(time())}",
callback_api_version=CallbackAPIVersion.VERSION2
)
client.username_pw_set("<username>", "<password>")
client.connect("<api_host>", <api_port>)

def on_message(client, userdata, msg):
print(f"[{msg.topic}]: {msg.payload.decode()}")

def on_connect(client, userdata, flags, rc, props):
client.subscribe("v1/position/+")

def on_disconnect(client, userdata, flags, rc, props):
if rc != 0:
print(f"Unexpected disconnect (reason code: {rc})")
print("Attempting auto-reconnect")

client.on_message = on_message
client.on_connect = on_connect
client.on_disconnect = on_disconnect
client.loop_forever()