Skip to main content
Developers/使用指南

触觉数据帧

从实时输出到自定义采集循环,理解通道、序号与时间戳。

On this page

发现设备端口

list_ports() 返回可用串口路径列表。多设备环境中,请选择对应设备的路径,不要默认第一个端口就是目标设备。

Python
from imprintx.glove import list_ports

for port in list_ports():
    print(port)

实时数据流

stream(port=None, callback=None, duration=None) 支持控制台输出或自定义回调。指定 duration 可以限制采集时长;回调数据结构请以安装版本的接口定义为准。

Python
from imprintx import glove

glove.stream(duration=5.0)

自定义采集循环

TouchGlove 提供显式的设备连接、流控制与批量读取。以下示例扫描端口、同步设备时钟,并读取五通道帧批次。

Python
from imprintx.glove import TouchGlove, list_ports
import time

ports = list_ports()
if not ports:
    raise RuntimeError("No device found")

with TouchGlove(port=ports[0]) as device:
    print("Device SN:", device.get_sn())
    device.sync_rtc()
    device.start()
    try:
        while True:
            for frame in device.poll():
                print(frame.channel, frame.seq_id,
                      frame.timestamp_us, frame.image.shape)
            time.sleep(0.01)
    finally:
        device.stop()

帧信息与时间同步

时间戳用于理解采集时序;跨设备同步质量还取决于采集系统配置,不由字段存在本身保证。

字段 / 方法说明
frame.channel通道编号
frame.seq_id帧序号
frame.timestamp_us微秒时间戳
frame.image.shape图像数组形状
sync_rtc() / query_rtc()同步 / 查询设备 RTC

零点标定与稠密场

calibrate_baseline(duration_sec=1.0) 重新标定零点。get_dense_fields() 返回形状为 (5, 32, 32, 3) 的五通道三维位移 / 力场。调用条件与模型配置以所用版本为准。