本系列教程作者:小鱼
公众号:鱼香ROS
QQ交流群:139707339
教学视频地址:​​小鱼的B站​​ 完整文档地址:​​鱼香ROS官网​​ 版权声明:如非允许禁止转载与商业用途。
基于ROS的机械臂手眼标定-常见错误排查_handeye


基于ROS的机械臂手眼标定-常见错误排查

大家好,我是小智,之间开源了关于手眼标定的一个项目,但在使用过程中,可能会遇到一些问题,趁着五一放假,收集了一些常见的问题列一下,如果有其他问题可以提出。

开源地址


github: ​​https://github.com/aiotrobot/handeye-calib​​​ gitee: ​​https://gitee.com/ohhuo/handeye-calib​​​


机械臂位姿 手眼标定程序 相机中标定板位姿 末端与相机位姿关系

本教程一共包含五个部分:

如果上述程序使用过程中遇到问题,可以参考:

如果你对手眼标定原理感兴趣,可以参考以下文章:

一、缺少库错误

1 缺少程序中所引用的坐标转换库transforms3d

Traceback (most recent call last):
File "/home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py", line 5, in <module>
import transforms3d as tfs
ImportError: No module named transforms3d
[base_hand_on_eye_calib-2] process has died [pid 4313, exit code 1, cmd /home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py __name:=base_hand_on_eye_calib __log:=/home/nature/.ros/log/3c7dc26a-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2.log].
log file: /home/nature/.ros/log/3c7dc26a-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2*.log

解决方法

pip install transforms3d

2 缺少格式化库

Traceback (most recent call last):
File "/home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py", line 10, in <module>
from tabulate import tabulate
ImportError: No module named tabulate
[base_hand_on_eye_calib-2] process has died [pid 5223, exit code 1, cmd /home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py __name:=base_hand_on_eye_calib __log:=/home/nature/.ros/log/770e569c-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2.log].
log file: /home/nature/.ros/log/770e569c-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2*.log

解决方法

pip install tabulate

二、OpenCv相关错误

1. OpenCv版本错误问题

手眼标定所采用的opencv版本必须是4.1以上的,为什么呢?因为低版本是没有手眼标定函数的。

Traceback (most recent call last):
File "/home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py", line 11, in <module>
from handeye_calibration_backend_opencv import HandeyeCalibrationBackendOpenCV
File "/home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/handeye_calibration_backend_opencv.py", line 17, in <module>
class HandeyeCalibrationBackendOpenCV(object):
File "/home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/handeye_calibration_backend_opencv.py", line 22, in HandeyeCalibrationBackendOpenCV
'Tsai-Lenz': cv2.CALIB_HAND_EYE_TSAI,
AttributeError: 'module' object has no attribute 'CALIB_HAND_EYE_TSAI'
[base_hand_on_eye_calib-2] process has died [pid 5329, exit code 1, cmd /home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py __name:=base_hand_on_eye_calib __log:=/home/nature/.ros/log/84e7ed28-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2.log].
log file: /home/nature/.ros/log/84e7ed28-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2*.log

解决方式

a.查看当前的opencv位置
nature@nature:~$ python
Python 2.7.17 (default, Feb 27 2021, 15:10:58)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__file__
'/usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so'
b.备份当前的opencv
sudo mv  /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so  /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so.back
c.重新安装opencv

记得指定好系统的版本

nature@nature:~$ pip install opencv-python==4.1.0.25
Collecting opencv-python==4.1.0.25
Downloading https://files.pythonhosted.org/packages/77/30/36c3f0644fa9f42d92f079b972e990a5874c1fc2b2c0e9656eb88bb8d6dc/opencv_python-4.1.0.25-cp27-cp27mu-manylinux1_x86_64.whl (26.6MB)
100% |████████████████████████████████| 26.6MB 50kB/s
Collecting numpy>=1.11.1 (from opencv-python==4.1.0.25)
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/3a/5f/47e578b3ae79e2624e205445ab77a1848acdaa2929a00eeef6b16eaaeb20/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0MB)
100% |████████████████████████████████| 17.0MB 70kB/s
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.16.6 opencv-python-4.1.0.25

三、运行时python版本错误

问题

运行时采用python2版本,如果你的终端默认python版本是python3,请做一下切换。

process[base_hand_on_eye_calib-2]: started with pid [4249]
File "/home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py", line 57
print str("\n"+tabulate(data,headers="firstrow") + "\n")
^
SyntaxError: invalid syntax
[base_hand_on_eye_calib-2] process has died [pid 4249, exit code 1, cmd /home/nature/code/learn/handeye-calib/src/handeye-calib/src/handeye/base_hand_on_eye_calib.py __name:=base_hand_on_eye_calib __log:=/home/nature/.ros/log/0c7bef56-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2.log].
log file: /home/nature/.ros/log/0c7bef56-abee-11eb-8f61-a0afbd1aaefa/base_hand_on_eye_calib-2*.log

解决方式

比如使用conda的环境的,可以使用conda deactivate 进行环境退出。

conda deactivate