Haptics
Control fingertip haptics: setting, clearing and lifecycle constraints.
Haptics
Read first: Device discovery & connection
Setting and clearing vibration
Call device.haptics() to get the fingertip vibration control entry point; after calling start(), you can set fingertip vibration. Each GloveFinger corresponds to one fingertip vibration motor:
from qnbot_sdk import Sdk
from qnbot_sdk.glove import GloveFinger, Haptics
from qnbot_sdk.glove import GloveConfig
sdk = Sdk(devices=(GloveConfig(),))
glove = sdk.glove()
try:
haptics = glove.device().haptics()
glove.start()
haptics.set(
Haptics(
{
GloveFinger.THUMB: 80,
GloveFinger.INDEX: 40,
}
)
)
latest = haptics.latest()
if latest is not None:
print(latest.value.strengths)
haptics.clear()
finally:
glove.close()device.haptics() is used to control each fingertip's vibration motor and read the vibration output state. Haptics is used both as the input to set() and as the state value obtained by latest() and subscriptions:
| Field | Type | Required/Default | Description and constraints |
|---|---|---|---|
strengths | dict[GloveFinger, int] | Required, may be an empty mapping | Mapping from fingers to vibration intensity; supports THUMB, INDEX, MIDDLE, RING, PINKY; the intensity must be an integer in 0..100; fingers not listed are not included in the current vibration setting |
For the complete fields and types, see Haptics.
Reading the current setting
latest() returns the vibration setting currently saved by the SDK, not a hardware execution receipt:
| Event | latest() result | Notes |
|---|---|---|
set() succeeds | The new vibration setting | — |
set() or clear() fails | Unchanged | A failure publishes no new state |
clear() succeeds | None | No additional callback sample is produced |
stop(), e-stop, or connection loss | None | The SDK updates the state to empty |
| After reconnecting | Still None | Not replayed automatically; call set() again if needed |
An empty state only indicates that the SDK currently has no vibration setting, and does not guarantee that disconnected hardware has received zero output.
Constraints and reference
The intensity must be an integer in the range 0..100. For a complete example, see
haptics.py.