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

本系列教程作者:小鱼
公众号:鱼香ROS
QQ交流群:139707339
教学视频地址:小鱼的B站
完整文档地址:鱼香ROS官网
版权声明:如非允许禁止转载与商业用途。
公众号

基于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
  • 9
    点赞
  • 47
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
ROS单目手眼标定程序: 1. 安装ros-indigo-opencv3软件包,这个软件包提供了OpenCV的3.0版和各种OpenCV的工具。 2. 确认相机是否能够被ROS识别,并且能够成功的运行和捕捉图像。如果能够正常运行,可以使用usb_cam软件包来进行设置。 $ sudo apt-get install ros-indigo-usb-cam $ rosrun usb_cam usb_cam_node 3. 计算相机的内参矩阵,并从相机标定板上收集特定数量的棋盘格图片,这个步骤需要使用OpenCV。可以使用以下命令进行相机内参矩阵的计算: $ roscore $ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.025 image:=/usb_cam/image_raw camera:=/usb_cam 4. 使用手眼标定工具包,计算手眼关系。该工具包依赖于OpenCV的手眼标定算法,可以在openCV的contrib模块中找到。可以使用以下命令安装工具包: $ sudo apt-get install ros-indigo-moveit-ros-robot-interaction ros-indigo-moveit-ros-perception ros-indigo-moveit-ros-planning-interface $ sudo apt-get install ros-indigo-ros-control ros-indigo-ros-controllers $ cd catkin_ws/src/ $ git clone https://github.com/ethz-asl/kalibr.git $ cd kalibr $ git checkout $YOUR_TAG (这里需要输入kalibr的版本号) $ cd ~ && mkdir -p HandEyeCalibration_ws/src && cd HandEyeCalibration_ws/src $ cp -r ~/catkin_ws/src/kalibr/HandEyeCalibration . $ cp -r ~/catkin_ws/src/kalibr/example . $ cd ~/HandEyeCalibration_ws && catkin_make 5. 运行手眼标定程序。确保相机和机器人都启动,并且他们可以正常运行。在命令行中运行: $ cd ~/HandEyeCalibration_ws $ source devel/setup.bash $ roslaunch example kinect_vrep_handeye_calibration.launch 6. 将结果存储在ROS包中。 这里就一一进行说明,可能比较晦涩难懂,但是大致原理就是这样: 首先,需要安装ROS软件,并且准备好相机可以被ROS识别,并能够正常的捕捉图像。然后,使用OpenCV计算相机内参矩阵,并从相机标定板上收集特定数量的棋盘格图片。接下来,使用手眼标定工具包,计算手眼关系,并将结果存储在ROS包中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值