新增了关于灵巧手的说明

This commit is contained in:
2026-09-20 09:57:55 +08:00
parent 58aa9e2964
commit 3ac6498bcb
+241 -4
View File
@@ -1,16 +1,16 @@
# wpz_LbotArm 接口说明
# weipz-Lbot_Bridge 接口说明
本工程当前使用 `src/officer_sdk/lbot_driver` 作为机器人网口连接和 ROS2 bridge。启动脚本为:
```bash
cd ~/workspace/wpz_LbotArm/scripts
cd ~/workspace/weipz-Lbot_Bridge/scripts
./lbot_arm_control.sh start
```
停止服务:
```bash
cd ~/workspace/wpz_LbotArm/scripts
cd ~/workspace/weipz-Lbot_Bridge/scripts
./lbot_arm_control.sh stop
```
@@ -111,7 +111,7 @@ ros2 topic echo /rosout
也可以查看启动脚本日志:
```bash
tail -f ~/workspace/wpz_LbotArm/log/lbot_arm_control.log
tail -f ~/workspace/weipz-Lbot_Bridge/log/lbot_arm_control.log
```
如果后续需要稳定给外部软件使用的完整健康状态快照,建议在 `SystemError.msg` 之外再新增 `RobotHealth.msg`,并在连接/重连逻辑、使能/急停服务回调中维护并周期发布该状态。需要修改的位置:
@@ -247,6 +247,235 @@ ros2 topic pub --once /robot1/right_hand/set_l20_joint std_msgs/msg/Int32MultiAr
"{data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}"
```
## Linker Hand L20 独立 CAN 控制
当前工程也集成了 `src/linker_hand_ros2_sdk`,用于在灵巧手单独接入域控 CAN 口时控制左右 L20 灵巧手,并获取关节状态和矩阵触觉合力反馈。
启动服务:
```bash
cd ~/workspace/weipz-Lbot_Bridge
./scripts/linker_hand_control.sh start
```
停止服务:
```bash
cd ~/workspace/weipz-Lbot_Bridge
./scripts/linker_hand_control.sh stop
```
查看状态:
```bash
./scripts/linker_hand_control.sh status
```
脚本当前会启动 `can0` 和 `can1`,波特率为 `1000000`。默认 launch 配置为:
```text
左手:can1,hand_type = left,hand_joint = L20
右手:can0,hand_type = right,hand_joint = L20
```
脚本会强制设置:
```text
ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
```
这样当前机器只发现本机 ROS 2 节点,避免同一局域网内旧的 `/linker_hand_sdk` 节点污染话题。
### 灵巧手控制话题
左手整手位置控制:
```text
/l20_left_hand_control_cmd
```
右手整手位置控制:
```text
/l20_right_hand_control_cmd
```
消息类型:
```text
sensor_msgs/msg/JointState
```
字段含义:
```text
position[] L20 目标关节位置数组,当前按 20 个 uint8 位置值使用,范围 0~255
velocity[] 可选速度数组;不需要设置速度时可以不填
effort[] 当前控制链路不使用
```
左手发布示例:
```bash
ros2 topic pub --once /l20_left_hand_control_cmd sensor_msgs/msg/JointState \
"{position: [205, 206, 230, 220, 226, 159, 127, 127, 32, 101, 80, 0, 0, 0, 0, 226, 254, 254, 248, 253]}"
```
右手发布示例:
```bash
ros2 topic pub --once /l20_right_hand_control_cmd sensor_msgs/msg/JointState \
"{position: [252, 147, 150, 136, 96, 255, 254, 202, 88, 0, 198, 0, 0, 0, 0, 254, 244, 241, 235, 211]}"
```
如果需要同时设置速度,可以填入 `velocity[]`:
```bash
ros2 topic pub --once /l20_right_hand_control_cmd sensor_msgs/msg/JointState \
"{position: [252, 147, 150, 136, 96, 255, 254, 202, 88, 0, 198, 0, 0, 0, 0, 254, 244, 241, 235, 211], velocity: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}"
```
注意:这里的 `position[]` 不是弧度,是 Linker Hand CAN 协议中的 0~255 位置值。
### 灵巧手状态反馈
左手状态:
```text
/l20_left_hand_state
```
右手状态:
```text
/l20_right_hand_state
```
消息类型:
```text
sensor_msgs/msg/JointState
```
字段含义:
```text
name[] 关节名称
position[] 当前 L20 关节位置反馈,0~255
velocity[] 当前 L20 速度/速度阈值反馈,按 SDK 原始值发布
effort[] 当前未填有效力矩,通常为 0
```
订阅示例:
```bash
ros2 topic echo /l20_left_hand_state
ros2 topic echo /l20_right_hand_state
```
### 灵巧手矩阵触觉合力反馈
左手触觉合力:
```text
/l20_left_hand_matrix_touch_mass
```
右手触觉合力:
```text
/l20_right_hand_matrix_touch_mass
```
消息类型:
```text
std_msgs/msg/Float32MultiArray
```
字段含义:
```text
data[0] thumb_mass,拇指矩阵触觉合力
data[1] index_mass,食指矩阵触觉合力
data[2] middle_mass,中指矩阵触觉合力
data[3] ring_mass,无名指矩阵触觉合力
data[4] little_mass,小指矩阵触觉合力
```
订阅示例:
```bash
ros2 topic echo /l20_left_hand_matrix_touch_mass
ros2 topic echo /l20_right_hand_matrix_touch_mass
```
完整矩阵触觉和点云话题也会发布:
```text
/l20_left_hand_matrix_touch
/l20_left_hand_matrix_touch_pc
/l20_right_hand_matrix_touch
/l20_right_hand_matrix_touch_pc
```
其中 `matrix_touch` 当前仍是 JSON 字符串,`matrix_touch_pc` 为 `sensor_msgs/msg/PointCloud2`。
### 灵巧手配置指令
配置指令话题:
```text
/l20_hand_setting_cmd
```
消息类型:
```text
std_msgs/msg/String
```
该话题用于向 SDK 发送设置类 JSON 指令,例如清故障、读取故障、设置电流等。一般控制整手位置不需要使用该话题。
### 灵巧手 rosbag 录制
`linker_hand_control.sh start` 会同时启动 rosbag 录制,`stop` 会停止录制。每满 1 小时自动切一个新包。
录制文件命名:
```text
/tmp/L20_Hand_YYYYmmdd_HHMMSS.mcap
```
录制话题:
```text
/l20_left_hand_control_cmd
/l20_left_hand_state
/l20_left_hand_matrix_touch_mass
/l20_right_hand_control_cmd
/l20_right_hand_state
/l20_right_hand_matrix_touch_mass
```
录制日志:
```bash
tail -f ~/workspace/weipz-Lbot_Bridge/log/linker_hand_rosbag.log
```
查看录包进程状态:
```bash
./scripts/linker_hand_control.sh status
```
回放示例:
```bash
ros2 bag play /tmp/L20_Hand_YYYYmmdd_HHMMSS.mcap
```
## 相关代码位置
反馈发布:
@@ -286,3 +515,11 @@ ROS 接口定义:
```text
src/officer_sdk/lbot_arm_interfaces/srv/MoveJ.srv
```
Linker Hand L20 独立 CAN 控制:
```text
src/linker_hand_ros2_sdk/linker_hand_ros2_sdk/linker_hand.py
src/linker_hand_ros2_sdk/launch/linker_hand_double.launch.py
scripts/linker_hand_control.sh
```