Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

L6 灵巧手

快速开始

from linkerbot import L6

with L6(side="left", interface_name="can0") as hand:
    # 设置角度
    hand.angle.set_angles((10, 20, 30, 40, 50, 60))

    # 读取角度
    data = hand.angle.get_blocking(timeout_ms=500)
    print(data.angles)

构造参数

参数类型说明
side"left" | "right"左手或右手
interface_namestrCAN 接口名,如 "can0"
interface_typestrCAN 接口类型,默认 "socketcan"。Windows 用法参考 CAN 总线 文档

关节说明

索引名称标识
0拇指弯曲thumb_flex
1拇指侧摆thumb_abd
2食指index
3中指middle
4无名指ring
5小指pinky

功能模块

模块说明文档
hand.angle关节角度控制与读取angle
hand.speed运动速度控制speed
hand.torque扭矩控制torque
hand.force_sensor力传感器数据force-sensor
hand.temperature温度监测temperature
hand.current电流监测current
hand.fault故障检测与清除fault
hand.version设备版本信息version

统一流式读取

L6 提供统一的事件流接口,通过 hand.stream()hand.start_polling() 获取所有传感器数据。初始化时会自动以默认间隔启动轮询(角度 60 Hz、力传感器 30 Hz),无需手动调用 start_polling()

from linkerbot import L6
from linkerbot.hand.l6 import SensorSource, AngleEvent, TemperatureEvent

with L6(side="left", interface_name="can0") as hand:
    # 可同时指定多个传感器及各自的轮询间隔(秒)
    # 再次调用 start_polling() 会覆盖之前的设置
    hand.start_polling({SensorSource.ANGLE: 0.05, SensorSource.TEMPERATURE: 1.0})

    for event in hand.stream():
        match event:
            case AngleEvent(data=ad):
                print(f"角度:{ad.angles.to_list()}")
            case TemperatureEvent(data=td):
                print(f"温度:{td.temperatures.to_list()}")

    hand.stop_polling()
    hand.stop_stream()

SensorSource 可选值及默认频率

说明默认频率
SensorSource.ANGLE角度60 Hz
SensorSource.TORQUE扭矩不默认轮询
SensorSource.TEMPERATURE温度不默认轮询
SensorSource.CURRENT电流不默认轮询
SensorSource.FAULT故障不默认轮询
SensorSource.FORCE_SENSOR力传感器30 Hz

快照

获取所有传感器最新缓存数据:

snap = hand.get_snapshot()
print(snap.angle)  # AngleData | None
print(snap.temperature)  # TemperatureData | None