Ubuntu16.04下基于ROS控制Robotiq_2f_85_gripper

一、实验设备

操作系统:Ubuntu 16.04
夹爪型号:Robotiq 2f-85
转换线:RS485转USB

二、Robotiq功能包安装与编译

1.下载Robotiq功能包

上Github 寻找相应功能包 :https://github.com/ros-industrial/robotiq/tree/kinetic-devel                   

我们使用的是 kinetic 版本

可手动下载,也可终端敲指令,个人喜欢手动下载,可视化操作,记得解压放到工作空间中 src 文件夹即可

cd catkin_ws/src/
git clone https://github.com/ros-industrial/robotiq.git

下载的功能包中包含了二指夹爪,三指夹爪,力传感器,通信相关的文件,可保留与实验相关的文件,删去其他文件。

2.编译Robotiq相应功能包

#安装依赖
rosdep install robotiq_modbus_rtu 

sudo apt-get install ros-kinetic-soem


#编译功能包

#切换到工作空间中
cd ~/catkin_ws/  

#依次编译功能包,编译过程中缺少依赖报错,安装相应依赖    
catkin_make -DCATKIN_WHITELIST_PACKAGES="robotiq_2f_85_gripper_visualization"   

第一次编译出现状态正常,但不能建立相应的 build 文件,可能是直接下载的文件命名有问题,直接下载的文件名为 robotiq-kinetic-devel ,中间的 “-” 是中文字符,将其修改成 “_” 即可通过。

3.robotiq_2f_85_gripper_visualization

Rviz 中查看夹爪

roslaunch robotiq_2f_85_gripper_visualization test_2f_85_model.launch

终端中出现两段橙黄色字段;针对这两段描述,进行修改:

xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order

解决方法:在读取xacro文件时,需要添加 --inorder 。

 [WARN] [1622542545.143980]: The 'use_gui' parameter was specified, which is deprecated.  We'll attempt to find and run the GUI, but if this fails you should install the 'joint_state_publisher_gui' package instead and run that.  This backwards compatibility option will be removed in Noetic.

 解决方法:用 joint_state_publisher_gui 替换原本的 joint_state_publisher ,然后删除launch中对use_gui的设置。若没有安装 joint_state_publisher_gui ,使用如下命令安装:

sudo apt-get install ros-kinetic-joint-state-publisher-gui

4.robotiq_2f_gripper_control 

这里主要介绍三个在官方教程中提到的文件。

4.1 Robotiq2FGripperRtuNode.py

官方教程上,通过该文件与夹爪连接

#The Gripper status is published on the topic named 'Robotiq2FGripperRobotInput'
pub = rospy.Publisher('Robotiq2FGripperRobotInput', inputMsg.Robotiq2FGripper_robot_input)

#The Gripper command is received from the topic named 'Robotiq2FGripperRobotOutput'
rospy.Subscriber('Robotiq2FGripperRobotOutput', outputMsg.Robotiq2FGripper_robot_output, gripper.refreshCommand)

从该文件中,可以看到:
第一段,不断查询抓手状态并发送。
第二段,用来接受用户输入的抓手控制信息,通过回调函数转给夹手。

4.2 Robotiq2FGripperStatusListener.py

该文件用来监听夹爪状态

4.3 Robotiq2FGripperSimpleController.py

向抓手输出控制信息

三、连接Robotiq_2f_85_gripper

1. 连接Robotiq_2f_85_gripper的接线

因之前 Robotiq_2f_85_gripper 通过示教器进行控制,电线已经接好了,其中两根 24V 的电源线接在 UR 控制柜中的 24V、0V 端口,两根控制信号线,一根屏蔽线通过 RS485 转 USB 线接在 UR 控制柜内部的 USB 接口。我们只需将该 USB 线从控制柜引出,接在计算机上即可。

2. 修改、配置串口

可参考我们的串口设置博客 串口在ros中的使用

#提供权限
#YOURUSERNAME 计算机用户名
sudo usermod -a -G dialout YOURUSERNAME

#查看连接的串口
dmesg | grep tty

 一般均为 ttyUSB0 ,可以根据显示的串口信息修改后面的命令。

确保夹爪能与计算机正常通信。

3. 控制夹爪

3.1启动夹爪驱动程序节点

roscore
rosrun robotiq_2f_gripper_control Robotiq2FGripperRtuNode.py /dev/ttyUSB0

 此时,夹爪上的指示灯由红色变为蓝色,表明夹爪可以正常工作了。

3.2 启动Robotiq_2f_85_gripper简单控制器节点

rosrun robotiq_2f_gripper_control Robotiq2FGripperSimpleController.py

终端中会出现一些操作提示

我们先要 (r键)reset 重置夹爪,然后 (a键)activate 激活夹爪,再进行其他操作

可以输入 o 或 c 执行张开闭合动作;

输入 0-255 的数字,0 是开合到最大位置,255 是完全关闭,回车后电爪即可执行;

可以输入 f 或 l 控制夹爪动作的快慢;

输入 i 增加夹取力;

输入 d 减小夹取力。

3.3 启动Robotiq_2f_85_gripper状态监听器节点

rosrun robotiq_2f_gripper_control Robotiq2FGripperStatusListener.py

可通过终端查看到夹爪当前的位置信息,电流大小等 

参考链接

1.  http://wiki.ros.org/robotiq 

2.  http://wiki.ros.org/robotiq/Tutorials/Control%20of%20a%202-Finger%20Gripper%20using%20the%20Modbus%20RTU%20protocol%20%28ros%20kinetic%20and%20newer%20releases%29

3.  https://blog.csdn.net/weixin_42268975/article/details/105151377?spm=1001.2014.3001.5501

4.https://blog.csdn.net/qq_33007107/article/details/96170248

 

Guess you like

Origin blog.csdn.net/qq_34935373/article/details/117445613