SDKC++ SDK

震动反馈

设置与清除指尖震动反馈。

当前版本 · 1.4.0

震动反馈

设置与清除震动

通过 device.haptics() 设置或清除每个手指的震动强度:

auto haptics = device.haptics();
haptics.set(qnbot::Haptics{{
    {qnbot::GloveFinger::thumb, 80},
    {qnbot::GloveFinger::index, 40},
}});

if (const auto latest = haptics.latest()) {
    std::cout << latest->sequence << '\n';
}

haptics.clear();

读取当前设置

latest() 反映 SDK 当前保存的震动设置,不是硬件执行回执:

事件latest() 的结果说明
set() 成功新的震动设置—
set() 或 clear() 失败不变失败不发布新状态
clear() 成功std::nullopt不产生额外的 callback 样本
stop()、e-stop 或连接中断std::nulloptSDK 将状态更新为空
恢复连接后仍为 std::nullopt不会自动重放,需要时重新调用 set()

空状态只表示 SDK 当前没有震动设置,不保证断连硬件已经收到零输出。

约束与参考

输入和返回字段见 Haptics。

强度范围是 0..100。external connection 不支持 haptics,写入会被拒绝。应用应在停止或关闭前清除不再需要的震动设置。