SDKPython SDK

Quick start

Automatically discover one Exo, subscribe to arm telemetry, and run it in the foreground.

Current version · 1.4.0

Quick start

With one Exo connected, the default SerialConnection() discovers the unique device automatically.

Minimal program

from qnbot_sdk import Sample, Sdk
from qnbot_sdk.exo import ExoConfig, ExoTelemetry

sdk = Sdk(devices=(ExoConfig(),))
exo = sdk.exo()
device = exo.device()

def print_telemetry(sample: Sample[ExoTelemetry]) -> None:
    print(sample.value.payload.left_arm.joint_positions_rad)

subscription = device.telemetry().subscribe(print_telemetry)
started = False
try:
    exo.start()
    started = True
    print("running; press Ctrl+C to stop")
    exo.run_forever()
except KeyboardInterrupt:
    pass
finally:
    subscription.unsubscribe()
    if started:
        exo.stop()
    exo.close()

Run

python quick_start.py

If discovery finds zero or multiple devices, call discover_exos() and then set SerialConnection(port=...). The SDK retains registered subscriptions until the scope closes. Keep the returned Subscription when you need to call unsubscribe() to stop one callback early while the SDK keeps running.

To pin the port, change the configuration to:

from qnbot_sdk import SerialConnection

config = ExoConfig(connection=SerialConnection(port="/dev/ttyUSB0"))

Windows uses actual ports such as COM3. To control several devices independently, assign each one a unique logical name and port; see Runtime modes.