SDKPython SDK

Haptics

Control fingertip haptics: setting, clearing and lifecycle constraints.

Current version · 1.4.0

Haptics

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:

FieldTypeRequired/DefaultDescription and constraints
strengthsdict[GloveFinger, int]Required, may be an empty mappingMapping 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:

Eventlatest() resultNotes
set() succeedsThe new vibration setting—
set() or clear() failsUnchangedA failure publishes no new state
clear() succeedsNoneNo additional callback sample is produced
stop(), e-stop, or connection lossNoneThe SDK updates the state to empty
After reconnectingStill NoneNot 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.