API referenceQnbot Exo PlusPython

Data channels

Channels & subscriptions

Current version · 1.4.0

Device telemetry, device status, and haptics state use Core channels. Each Sample carries the value, sequence, and timing metadata.

ReadChannel[T]

A read-only data channel returned by a device or Skeleton data accessor. Samples use the Sample wrapper.

ReadChannel[T].latest()

Reads the most recent piece of data without waiting.

Type

ReadChannel.latest() -> Sample[T] | None

Returns

Sample[T] | None. See Sample[T].

Details

  • Call conditions: The owning object is not closed.
  • Does not wait for new data; returns an empty value when no sample exists.

Each call reads the snapshot currently retained by the channel; it does not wait for the next frame. Use next() to wait once, or subscribe() to process data continuously.

Errors

  • Close errors.

Example

These snippets use an already selected device.

sample = device.telemetry().latest()
if sample is not None:
    print(sample.sequence, sample.value)

Complete example: telemetry.py.

ReadChannel[T].subscribe()

Executes the callback each time new data is received.

Type

ReadChannel.subscribe(callback: Callable[[Sample[T]], object]) -> Subscription

Parameters

  • callback: Callable[[Sample[T]], object], required

Returns

Subscription.

Details

  • Call conditions: Recommended to register before start.

The callback receives a Sample[T]; sample.value holds the actual data. Keep callbacks short, and do not synchronously unsubscribe from inside that subscription’s callback.

Errors

  • Parameter or close errors.

Example

These snippets use an already selected device. Register the subscription before starting the device.

def on_pose(sample):
    print(sample.sequence, sample.value)

subscription = device.telemetry().subscribe(on_pose)

Complete example: telemetry.py.

ReadChannel[T].next()

Asynchronously wait for the next sample.

Type

async ReadChannel.next() -> Sample[T]

Returns

Sample[T]. See Sample[T].

Details

  • Call conditions: While the owning object is running.
  • Asynchronously waits for one Sample[T] and can be cancelled. Use async for for continuous reading.

Errors

  • Cancellation, close or data stream errors.

Example

Start the owning device first, then call this async function from an asyncio application.

async def read_once(channel):
    sample = await channel.next()
    print(sample.sequence, sample.value)

Related Core example (Glove): async_runtime.py.

ReadChannel[T].__aiter__()

Read new samples through asynchronous iteration.

Type

ReadChannel.__aiter__() -> AsyncIterator[Sample[T]]

Returns

AsyncIterator[Sample[T]]. See Sample[T].

Example

Start the owning device first, then call this async function from an asyncio application.

async def read_samples(channel):
    async for sample in channel:
        print(sample.sequence, sample.value)

Related Core example (Glove): async_runtime.py.

ReadChannel[T].with_config()

Create a channel view with a subscription delivery policy.

Type

ReadChannel.with_config(config: SubscriptionConfig) -> ReadChannel[T]

Parameters

  • config: SubscriptionConfig, required

Returns

ReadChannel[T]. See ReadChannel[T].

Details

  • Call conditions: Before subscribe() or async iteration.
  • Returns a new read view sharing the same source; leaves the original channel, existing subscriptions, and computation rates unchanged.

The configuration affects only subsequent subscribe() calls and async iteration on that view. It leaves latest() and one-shot next() unchanged.

Errors

  • Parameter or close errors.

Example

These snippets use an already selected device. on_pose is an application-defined callback.

from qnbot_sdk import SubscriptionConfig

pose = device.telemetry().with_config(
    SubscriptionConfig.latest(max_rate_hz=30)
)
subscription = pose.subscribe(on_pose)

Related Core example (Glove): subscription_config.py.

Subscription

Returned by subscribe() to represent a callback subscription. Closing the owning scope reclaims remaining subscriptions.

Subscription.unsubscribe()

Stops one callback early.

Type

Subscription.unsubscribe() -> None

Returns

None.

Details

  • Call conditions: When the SDK keeps running but the callback is no longer needed.
  • Use only to stop a callback early. Do not synchronously unsubscribe from inside that subscription’s own callback.

Errors

  • Synchronous unsubscription inside the callback is not safe.

Example

channel is an existing read channel whose device has started, and on_sample is an application callback. Stop early from the application thread, not synchronously from inside this subscription’s own callback.

import time

subscription = channel.subscribe(on_sample)
time.sleep(0.5)
subscription.unsubscribe()

Related Core example (Glove): subscription_config.py.

SubscriptionConfig

The max_rate_hz delivery period includes callback processing time; only the remainder of the period is waited, rather than a full period after processing. The first available sample is delivered immediately. Scheduling jitter can vary individual intervals, so this is not a fixed sampling frequency. async for uses the same timing rule.

Defines delivery for a subscription view used through with_config(). It affects subsequent subscriptions, not latest(), next(), existing subscriptions, or SDK/algorithm computation rates.

SubscriptionConfig.latest()

Deliver only the newest value in each pacing interval.

Type

SubscriptionConfig.latest(max_rate_hz: float | None = None) -> SubscriptionConfig

Parameters

  • max_rate_hz: defaults to None with no delivery rate cap; a supplied value must be positive and finite.

Details

  • Call conditions: Configuring callbacks or async iteration.

Errors

  • Invalid rate.

Example

from qnbot_sdk import SubscriptionConfig

config = SubscriptionConfig.latest(max_rate_hz=30)

Related Core example (Glove): subscription_config.py.

SubscriptionConfig.fifo()

Use a bounded ordered queue; drop the oldest item when full.

Type

SubscriptionConfig.fifo(capacity: int, max_rate_hz: float | None = None) -> SubscriptionConfig

Parameters

  • capacity: required and positive; a full queue discards the oldest pending value.
  • max_rate_hz: defaults to None with no delivery rate cap; a supplied value must be positive and finite.

Details

  • Call conditions: Configuring callbacks or async iteration.

Errors

  • Invalid capacity or rate.

Example

from qnbot_sdk import SubscriptionConfig

config = SubscriptionConfig.fifo(capacity=128, max_rate_hz=30)

Related Core example (Glove): subscription_config.py.

Sample[T]

latest() and next() obtain a Sample[T]; subscribe() returns a Subscription, and the registered callback receives a Sample[T]. T is a concrete data type such as ExoTelemetry, ExoStatus or ExoHaptics; value holds that data, and the remaining fields describe the SDK publish sequence and time.

Fields

Fields

FieldTypeNullableDescription
valueTNoCurrent business data
sequenceintNoMonotonically increasing SDK sequence number within the same kind of data
source_timefloat | NoneYesData source time; None when the data source does not provide it
observed_atfloatNoThe time when the SDK received the data

Neither source_time nor observed_at is a system calendar time.