第二次重建了项目的手眼标定部分……有很多第一次记录遗漏的地方,在此补充。
一、JAKA机械臂末端位姿发布
此次我是自己写的节点发布,建议一开始新建工作空间的时候就引入roscpp,rospy,std_msgs。
$ catkin_create_pkg package_name depend1 depend2 depend3
$ catkin_create_pkg roscpp rospy std_msgs
发布末端位置前要先阅读JAKA官方说明手册中末端姿态读取部分,然后根据官方的说明写末端姿态发布节点。我的节点代码放在下面供大家参考:
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import jkrc
import rospy
import numpy as np
from geometry_msgs.msg import PoseStampeddef Path_Publish(): # 初始化节点rospy.init_node("publish_curunt_state")# 创建一个发布者,发布数据类型为PoseStampedpub = rospy.Publisher("/arm_pose", PoseStamped, queue_size=10)# 设置发布频率rate = rospy.Rate(10)while not rospy.is_shutdown():# 消息status = robot.get_tcp_position()rot_matrix = robot.rpy_to_rot_matrix([status[1][3], status[1][4], status[1][5]])qua_result = robot.rot_matrix_to_quaternion(rot_matrix[1])status_msg = PoseStamped()status_msg.header.frame_id = "joint_0"status_msg.header.stamp = rospy.Time.now()status_msg.pose.position.x = status[1][0] * 0.001status_msg.pose.position.y = status[1][1] * 0.001status_msg.pose.position.z = status[1][2] * 0.001status_msg.pose.orientation.w = qua_result[1][0]status_msg.pose.orientation.x = qua_result[1][1]status_msg.pose.orientation.y = qua_result[1][2]status_msg.pose.orientation.z = qua_result[1][3]# 发布消息# rospy.loginfo("Publishing Plan...")pub.publish(status_msg)# 按照循环频率延时rate.sleep()if __name__ == "__main__":robot = jkrc.RC("10.5.5.100")if robot is None:print("返回一个机器人对象失败")else:print("返回一个机器人对象")log_success = robot.login() # 登录if log_success[0] != 0:print("登录失败")else:print("登录成功")power_success = robot.power_on() # 上电if power_success[0] != 0:print("上电失败")else:print("上电成功")enable_success = robot.enable_robot()if enable_success[0] != 0:print("使能失败")else:print("使能成功")try:Path_Publish()except rospy.ROSInterruptException:pass
二、Realsense驱动和包的安装
关于realsense的安装,网上有很多例子,可以查询自己的ubuntu版本后搜索相关安装教程,我的是20.04,参考的教程为:
Ubuntu20.04+RealSense D435i_ubuntu20.04安装d435i-CSDN博客
但是实际上我的安装并不顺利,到下面一步都是没有问题的,看得到点云图(当然你要用手眼标定其实可能并不需要下面的库,下载aruco库就可以了,把realsense驱动装了就行应该??)。
不过在编译相关库的时候出现了如下的报错:
当时傻傻的按照提示用catkin_make_isolated和查看erro.log按照提示装thread,甚至花了80软妹币去淘宝找了个技术员(除了浪费我2小时啥都没解决。
后面查了很多博客,发现这个默认下载的是ROS2版本,我要下载ROS1版本的,打开下面的地址版本选择ros1即可。
https://github.com/IntelRealSense/realsense-ros/blob/ros1-legacy/README.md#installation-instructions
值得一提的是,使用命令:
roslaunch realsense2_camera rs_camera.launch
时,并不会有弹窗,需要手动打开rviz订阅相关话题才能看到图像。
三、Aruco库安装和使用
安装aruco_ros库的时候我参考的博客:
aruco_ros使用-CSDN博客
但实际上我在编译的时候也出现了类似的问题二中的问题,联系上面的经历,我立马去换了个aruco的版本(ubuntu20对应的是noetic),下载完了即可。
四、鱼香ROS的手眼标定包
具体包的使用看:
基于ROS的机械臂手眼标定-基础使用_鱼香ros手眼标定-CSDN博客
实际上他需要开三个节点,机械臂末端位姿发布节点、aruco识别位姿发布节点和手眼标定计算节点,注意改一下话题设置、aruco码ID等配置,即可,在我上一篇的博客里面已经说明,就不多赘述了。
JAKA+aruco+realsense+眼在手外的手眼标定_jaka标定-CSDN博客