Files
ros_contorl/docs/HANDEYE.md
T
2026-10-09 14:51:03 +08:00

83 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 手眼标定
两种装法,两块板,两台相机,两份结果。**禁止混用**:
| 模式 | 相机 | 板 | 板怎么摆 | 结果文件 | `T_4x4` 含义 |
|------|------|----|----------|----------|--------------|
| `eye_in_hand` | 腕部 D405 | A5,内角点 8×11,15 mm | 板放台面不动 | `handeye/results/<臂号>_eye_in_hand.yaml` | 相机 → 法兰 |
| `eye_to_hand` | 顶置 D435 | A4,内角点 11×8,20 mm | **板装到法兰上** | `handeye/results/<臂号>_d435_eye_to_hand.yaml` | 相机 → 这条臂的基座 |
| 臂 | 眼在手上结果 | 眼在手外结果 | 示教关节 | 工作目录 |
|----|--------------|--------------|----------|----------|
| 89 左 | `89_eye_in_hand.yaml` | `89_d435_eye_to_hand.yaml` | `poses/89_<模式>.yaml` | `tmp/89/` |
| 91 右 | `91_eye_in_hand.yaml` | `91_d435_eye_to_hand.yaml` | `poses/91_<模式>.yaml` | `tmp/91/` |
目录结构、按键、稳定性参数见 `handeye/README.md`。棋盘尺寸只改
`config/site.yaml` → `handeye.boards.<模式>`(内角点 = 方格数 − 1)。
没配过的模式会被 `run_handeye.sh` 当场拦下,不会静默用另一块板的尺寸。
## 眼在手上(腕部 D405 + A5 板)
`teach`(RDK 软拖拽)与 `run_real.sh` **互斥**。全程带同一 `--arm`。
```bash
# 1) 停掉 run_real.sh 和视觉伺服
# 2) 示教 8–12 个姿态(棋盘清晰、占画面 30–70%,姿态拉开)
bash ~/ros2/scripts/run_handeye.sh --arm 89 teach
# 窗口:d=拖拽 Enter=拍照 q=结束(窗口只显示画面,不做棋盘检测)
# 接着采、不清空旧点: teach --append
# 3) 写入该臂 handeye/poses/89_eye_in_hand.yaml
bash ~/ros2/scripts/run_handeye.sh --arm 89 merge
# 4) 再开实机 + 腕部相机,棋盘不要动
bash ~/ros2/scripts/run_real.sh --arm 89
bash ~/ros2/scripts/run_camera_d405.sh --arm 89 --preview
bash ~/ros2/scripts/run_handeye.sh --arm 89 calibrate
```
91 把 `--arm 89` 改成 `--arm 91`。
## 眼在手外(顶置 D435 + A4 板)
物理摆法与上面**反过来**:相机固定,板跟着臂动。板若还摆在台面上,
`target→camera` 不变,方程退化(解不出来或解出垃圾)。
```bash
# 1) 把 A4 板刚性固定在法兰 / 夹爪上(夹在正中间,标定过程不要松)
# 2) 起臂 + 顶置相机(两个终端,常驻)
bash ~/ros2/scripts/run_real.sh --arm 89
bash ~/ros2/scripts/run_camera_d435.sh --preview
# 3) 采点:推着臂走,让板在 D435 画面里出现在不同位置、不同角度
# teach 与 run_real.sh 互斥 —— 用 RDK 拖拽前先停掉 run_real.sh
bash ~/ros2/scripts/run_handeye.sh --arm 89 teach --mode eye_to_hand --points 12
# 4) 合并 + 自动走点求解(此时再开 run_real.sh + D435)
bash ~/ros2/scripts/run_handeye.sh --arm 89 merge --mode eye_to_hand
bash ~/ros2/scripts/run_real.sh --arm 89
bash ~/ros2/scripts/run_camera_d435.sh --preview
bash ~/ros2/scripts/run_handeye.sh --arm 89 calibrate --mode eye_to_hand
```
查看当前模式选中的板 / 相机 / 文件:
```bash
bash ~/ros2/scripts/run_handeye.sh --arm 89 show --mode eye_to_hand
```
应看到 `camera=d435`、`board 11x8 inner, square=0.02 m`、
结果路径 `handeye/results/89_d435_eye_to_hand.yaml`。不是这三样就停,
不要带着错配置开标定。
## 结果怎么用
- **眼在手上**:`visual_servo.launch.py` / `stage2_locate.launch.py` /
`gauge_assembly.launch.py` 读 `paths.handeye_file`,发布
`{法兰}` → `{腕部相机}_color_optical_frame`。`servo_node` 用同一份 T
做 `hover` / `lookat`。换结果后**重启**对应节点。
- **眼在手外**:`gauge_assembly.launch.py` 按
`handeye/results/<臂号>_<相机>_eye_to_hand.yaml` 自己找,发布
`{基座}` → `{手外相机}_color_optical_frame`。S03 粗定位查的就是这条 TF。
**不要**改 `paths.handeye_file` 去指向它 —— 那会把腕部精拍定位的 TF 换掉。