机械臂末端执行器(夹爪)
1.hand_move - 手部移动
方法: ctrl.hand_move(value) / ctrl.hand_move(type, value)
C++ 签名:
bool hand_move(const std::vector<float> &value);// 使用 Init 时配置的默认手型bool hand_move(HandType type, const std::vector<float> &value);
参数:
type:手部类型,fd_robot::HandType枚举,默认取Options.hand_typeHandType::kLeft:左手HandType::kRight:右手HandType::kBoth:双手
value:手部控制值,std::vector<float>类型- RoHand(
HandBackend::kRohand):6 个 float 关节值 - Inspire(
HandBackend::kInspire):取首个整型开度值
- RoHand(
返回值:
bool:操作结果true:指令发送成功false:指令发送失败
使用示例:
注意: 手部驱动后端由 Options.hand_backend 决定(默认 HandBackend::kInspire)。RoHand 与 Inspire 的 value 取值规则不同,接口不可混用。
2.hand_stop - 手部停止
方法: ctrl.hand_stop(type) / ctrl.hand_stop()
C++ 签名:
bool hand_stop(HandType type);bool hand_stop();// 使用默认手型
参数:
type:手部类型,fd_robot::HandType枚举,指定停止哪只手,默认取Options.hand_typeHandType::kLeft:停止左手HandType::kRight:停止右手
返回值:
bool:操作结果true:指令发送成功false:指令发送失败
使用示例:
3.hand_get_current_pos - 获取手部位置/开度(同步读取)
方法: state.hand_get_current_pos(type, value)
C++ 签名: bool hand_get_current_pos(HandType type, std::vector<float> &value) const;
说明: 同步读取手部关节值或开度数组。
参数:
type:手部类型,fd_robot::HandType枚举(kLeft / kRight,一般不用 kBoth)value:出参,std::vector<float> &类型,返回手部关节值或开度数组
返回值:
bool:表示是否已有有效缓存数据true:已有数据,value有效false:尚无数据,value不可信
使用示例:
4.hand_sub_current_pos - 订阅手部位置(异步回调)
方法: state.hand_sub_current_pos(type, cb)
C++ 签名: SubscriptionId hand_sub_current_pos(HandType type, HandPosCallback cb); // cb: void(HandType, const std::vector<float>&)
参数:
type:手部类型,fd_robot::HandType枚举,订阅哪只手cb:回调函数,std::function<void(fd_robot::HandType, const std::vector<float>&)>类型HandType:标识哪只手std::vector<float>:关节值或开度数组
返回值:
SubscriptionId:订阅ID,类型为uint64_t。可用于后续取消订阅;空回调返回0(失败)
使用示例:
建议:
- 订阅的回调在线程池中执行,注意线程安全
- 无需接收位置更新时及时取消订阅,避免不必要的回调
- 可与
hand_get_current_pos同步读取配合使用
