Device discovery & connection
Discover wired and wireless gloves, select fixed devices, and connect multiple gloves.
Device discovery & connection
Wired and Receiver wireless gloves both use GloveConfig. Connect the Receiver and turn on the gloves you need before creating Sdk; automatic discovery, fixed-port selection, and hand-side selection use the same configuration.
Device discovery
When you need to list devices before creating the Sdk, you can call discover_gloves():
from qnbot_sdk import SerialConnection
from qnbot_sdk.glove import GloveConfig, GloveTransportType, discover_gloves
devices = discover_gloves()
selected = next(
(device for device in devices
if device.transport_type in (GloveTransportType.SERIAL, GloveTransportType.RECEIVER_PEER)
and device.error is None and device.hand is not None),
None,
)
if selected is None:
raise RuntimeError("No usable glove found")
device_config = GloveConfig(
side=selected.hand,
connection=SerialConnection(port=selected.port),
)Commonly used fields:
| Commonly used field | Meaning |
|---|---|
port | Discovered serial port path |
transport_type | Transport type: serial for a wired glove, receiver_peer for a wireless glove |
hand | Successfully recognized left/right hand; may be None when recognition fails |
sn | Successfully read device SN |
error | Discovery error for that port; None on success |
For complete fields, types, and nullability behavior, see DiscoveredGlove and
GloveDiscoveryIssue.
The return value is a read-only tuple[DiscoveredGlove, ...]. When the port is occupied by another process, the device still appears in the results, port is retained, and it is identified by GloveDiscoveryErrorCode.PORT_BUSY. Use
error.code to determine the result; error.message is for display only.
The discovery result is a snapshot of the moment of the call. After devices are plugged or unplugged, call it again, then build the configuration from the port and hand of the selected record. For a complete runnable example, see discover_gloves.py.
Each online Receiver glove has its own receiver_peer record. Two records from one Receiver may share port; distinguish them by hand and sn. receiver_usb identifies a Receiver USB entry, not a selectable glove. The example selects the first usable glove; filter by the required hand or port when several candidates exist.
Single glove
With one glove, you do not need to specify a port or side. The default configuration selects it automatically:
from qnbot_sdk import Sdk
from qnbot_sdk.glove import GloveConfig
devices = (GloveConfig(),)
sdk = Sdk(devices=devices)A single GloveConfig() without a side requires exactly one unoccupied supported device. Fixed
selection is only needed when automatic discovery cannot work, see Connecting the device.
One glove means one usable glove endpoint, not one USB port. If both hands are online on a Receiver, specify side to select one; the other hand need not be online when unused.
Two gloves
When both hands are known, connection can be omitted for both:
from qnbot_sdk import Sdk, Side
from qnbot_sdk.glove import GloveConfig
devices = (
GloveConfig(side=Side.LEFT),
GloveConfig(side=Side.RIGHT),
)
sdk = Sdk(devices=devices)The SDK assigns directly wired gloves uniquely by side. Each glove is assigned at most once. Missing devices, ambiguous same-side candidates, or identity changes during SDK creation cause construction to fail.
When both gloves are on the same side (two right gloves, for example), use distinct logical names (at most one may be unnamed) and configure a different port or serial_number for each.
Multiple gloves
Each enabled glove must have a unique name/side pair. At most one glove on a given side may omit its name; give the others distinct nonempty names. Naming every same-side glove is recommended. Opposite sides may share a name and can be selected by combining name and side.
When connecting three or more gloves, at least two gloves are on the same side. To select each glove separately, set a unique name for each configuration and pin gloves on the same side with different port or serial_number values:
from qnbot_sdk import Sdk, SerialConnection, Side
from qnbot_sdk.glove import GloveConfig
devices = (
GloveConfig(
name="left-primary",
side=Side.LEFT,
connection=SerialConnection(port="/dev/ttyUSB0"),
),
GloveConfig(
name="left-backup",
side=Side.LEFT,
connection=SerialConnection(port="/dev/ttyUSB1"),
),
GloveConfig(
name="right",
side=Side.RIGHT,
connection=SerialConnection(port="/dev/ttyUSB2"),
),
)
sdk = Sdk(devices=devices)
glove = sdk.glove()
left_primary = glove.device(name="left-primary")name selects a glove and does not replace physical device locators. At most one glove on a given side may be unnamed. Two unnamed same-side declarations fail even with different ports. Selecting by side alone may still be ambiguous when several gloves share that side.
No physical glove, or integrating your own device? Both cases can feed external hand frames frame by frame, and they are read through the same paths as a physical glove. See External input for the configuration and frame constraints.
Connecting the device
Sdk construction completes device discovery and identity verification; start() establishes the continuously running connection and data streams, see Lifecycle. Use the connection options below when you need to pin a specific device.
A fixed port or serial number
Using a specified serial port:
from qnbot_sdk import SerialConnection, Side
from qnbot_sdk.glove import GloveConfig
device_config = GloveConfig(
name="primary",
side=Side.RIGHT,
connection=SerialConnection(port="/dev/ttyUSB0"),
)When the SDK can recognize the port as a supported wired directly connected glove and both port and side are explicitly provided,
the SDK still validates the device identity first. For older wired directly connected gloves that cannot report a device identity, the SDK continues to connect using the configured serial port and left/right hand and issues an "identity not verified" warning. Disconnection recovery retries only that port and cannot confirm whether the recovered device is still the same physical glove. Automatic discovery, providing only port, providing only side, selecting by
serial_number, and cases where the port type cannot be recognized still require device identity validation and cannot use this compatibility behavior.
Selecting by USB serial number:
SerialConnection(serial_number="YOUR-SERIAL-NUMBER")Automatic discovery can also be written explicitly:
SerialConnection(auto_discover=True)When set explicitly, exactly one of auto_discover=True, port, and serial_number must be
provided; baudrate is optional. If creating the Sdk already fails, start with Cannot find the device.
Wireless gloves (Receiver)
Connect the Receiver to the computer over USB and turn on the gloves you need. Declare one GloveConfig per glove and set connection.port to the Receiver port. Opposite hands can use the same port; the SDK shares the physical connection:
from qnbot_sdk import Sdk, SerialConnection, Side
from qnbot_sdk.glove import GloveConfig
receiver_port = "/dev/ttyACM0"
devices = (
GloveConfig(name="left", side=Side.LEFT,
connection=SerialConnection(port=receiver_port)),
GloveConfig(name="right", side=Side.RIGHT,
connection=SerialConnection(port=receiver_port)),
)
sdk = Sdk(devices=devices)Replace the example port with the actual Receiver port; keep only one declaration for single-hand use. Wired and wireless gloves can be mixed using their respective ports. See GloveConfig for port-sharing and identity requirements.
Use the same pose(), skeleton(), output(), and haptics() APIs after connection. Compatible wireless gloves provide raw IMU. See Common questions for offline gloves.
Select and inspect a device
Sdk construction completes device discovery and identity verification. Once it succeeds, select a GloveDevice from the configured gloves. Use that device for capture, status queries, and calibration; register continuous callbacks before start().
Direct gloves are allocated when the Sdk is created, as shown below:
Select a device
from qnbot_sdk import Side
glove = sdk.glove()
device = glove.device() # One configured glove
left = glove.device(side=Side.LEFT) # Select by side
primary = glove.device("left-primary") # Select by GloveConfig.name
named_left = glove.device("shared-name", side=Side.LEFT) # Combine name and sideNo match raises NotFoundSelectionError; multiple matches raise AmbiguousSelectionError. Give same-side gloves distinct GloveConfig.name values and select them by name.
For the scope of the selected device's start(), stop() and health(), see Core objects & lifecycle.
Selecting by name and side
For example, name the main left and right gloves primary and the backup left glove backup. The two left gloves need different names; for physical gloves, also pin them to different ports or serial numbers.
left = glove.device("primary", side=Side.LEFT)
right = glove.device("primary", side=Side.RIGHT)
backup = glove.device("backup")
source_id = left.source_idIn this three-glove configuration, primary alone matches both hands and left side alone matches two gloves, so both raise AmbiguousSelectionError. Name and side together select their intersection; no match raises NotFoundSelectionError.
Always read source_id from the selected device. Do not construct it from an SN, port, or name, or parse it to identify hardware; read get_device_info().canonical_sn for the serial number. A verified glove’s logical source follows its configured name and side, or its side when unnamed. Replacing hardware under the same name and side does not change that logical identifier to a new SN. This does not make old calibration valid for replacement hardware; see Migration.
device_selection.py demonstrates the selections above with three external gloves.
Inspect the device
device.get_device_info() returns the verified device information snapshot saved during SDK construction, including the serial number, device type, model, firmware version, hand, and hand source. It does not resend an identity command on each call.
| Identifier | How to obtain it | Purpose |
|---|---|---|
name | GloveConfig.name | Application-defined logical name used by glove.device(name) |
source_id | device.source_id | Stable logical routing identifier built from configured name and side |
canonical_sn | device.get_device_info().canonical_sn | Verified device serial number; do not derive it from a port or name |
transport_type | device.get_device_info().transport_type | serial for a wired glove; receiver_peer for a wireless glove |
For older wired firmware explicitly connected with port + side that cannot report identity, the SDK does not invent device information: get_device_info() raises UnavailableFeatureError, and capabilities requiring verified identity are unavailable.
source_id is not the hardware serial number. Read canonical_sn when hardware identity is required, and do not parse the source_id string format.