Jetson AGX Xavier避坑指南(四)—— ubuntu18.04 ros-melodic 安装 ur_robot_driver,驱动真实的 ur5 机器人

接上篇Jetson AGX Xavier避坑指南(三)——环境搭建1.(python3、pip、virtualenv、ros)

1. 安装 ur_robot_driver

根据最新通告Announcement: Universal Robots launches ROS driver,ros发布了受UR官方支持的驱动程序ur_robot_driver,并宣布弃用ur_driver和ur_modern_driver。不过ur_robot_driver仅适用于控制器版本CB3 (with software version >= 3.7) 和e-Series (software >= 5.1)。

本文参考官方github文档Universal_Robots_ROS_Driver,采用源码编译的方式进行安装。

驱动包依赖于 ROS-Industrial Universal Robot meta-package universal_robot,官方教程里用的是项目贡献者fmuach开源的calibration_devel版本

jetson AGX Xavier的Linux系统版本为18.04,对应的ros版本为melodic。上篇已经创建了虚拟环境rosRL(可忽略), 并用脚本setupCatkinWorkspace.sh创建了工作空间ur5
如果采用pc+ros kinetic,可以参考: ROS下使用moveit控制UR机械臂,moveit驱动真实机械臂

workon rosRL  # 进入虚拟环境
# 安装依赖
sudo apt-get install ros-melodic-moveit  # 安装MoveIt 此步可忽略
cd ur5
# clone the driver
$ git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver

# clone fork of the description to use the calibration feature  # -b表示下载分支
$ git clone -b calibration_devel https://github.com/fmauch/universal_robot.git src/fmauch_universal_robot

# install dependencies
$ sudo apt update -qq  # -qq 不输出信息,错误除外
$ rosdep update
$ rosdep install --from-path src --ignore-src -y  #-y 表示[yes/no]的问题选择yes

# build the workspace
$ catkin_make

# activate the workspace (ie: source it)
$ source devel/setup.bash

如果,报错
ModuleNotFoundError: No module named ‘rospkg’
Invoking “make -j4 -l4” failed

pip install rospkg  # 安装缺少的module
catkin_make  # 重新build
source devel/setup.bash

安装完成。rospack list 查看是否包含ur功能包。

注意
source devel/setup.bash只在当前终端生效,每次打开其他终端时都要重新source,这样比较麻烦。 解决方法:gedit ~/.bashrc,打开.bashrc文件,在文件底部添加source ~/path/to/ur5/devel/setup.bash,保存退出即可。

参考:
Universal_Robots_ROS_Driver
UR5的安装与配置
ImportError: No module named rospkg

2. 仿真测试

#打开终端,启动
roslaunch ur_gazebo ur5.launch
#打开新终端
roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch sim:=true
#再打开一个新终端
roslaunch ur5_moveit_config moveit_rviz.launch config:=true

拖动ur5的末端,按plan可以规划路径,按execute可以使UR5运动,在gazebo上也可以看到相同的运动效果。
在这里插入图片描述

3. 驱动真实的ur机器人

3.1 安装externalcontrol

参考:Universal_Robots_ROS_Driver/ur_robot_driver/doc/install_urcap_cb3.md

要在真正的机器人上使用ur_robot_driver,需要在ur机器人上安装externalcontrol-1.0.urcap,该文件位于Universal_Robots_ROS_Driver/ur_robot_driver的resources文件夹内。注意:要安装此URCap,要求PolyScope的版本不得低于3.7

安装步骤

  1. 用U盘将此文件拷贝至机器人示教器的programs文件夹。

  2. 在欢迎屏幕上,选择Setup Robot,然后选择URCaps进入URCaps安装屏幕。
    在这里插入图片描述

  3. 单击底部的小加号以打开文件选择器。 在此处,可以看到存储在机器人程序文件夹或插入的USB驱动器中的所有urcap文件。 选择并打开externalcontrol-1.0.urcap文件,然后单击打开。 现在,您的URCaps视图应在活动的URCaps列表中显示External Control,点击右下角重启机器人。
    在这里插入图片描述

  4. 重新启动后,选择为机器人编程,在安装设置部分中找到External Control 。 然后设置外部PC的IP地址,本文设置为192.168.1.101 。请注意,机器人和外部PC必须位于同一网络中,理想情况下,彼此之间应直接连接,以最大程度地减少网络干扰。 自定义端口现在应该保持不变。
    在这里插入图片描述

  5. 要使用新的URCap,请创建一个新程序并将External Control程序节点插入到程序树中。在这里插入图片描述

  6. 重新点击命令按钮,则会看到在安装中输入的设置。 检查它们是否正确,然后将程序保存,可以将程序命名为external_control.urp。 现在机器人可以与此驱动程序一起使用了。(注,图中 Host IP 应为前文设置的 192.168.1.101)
    在这里插入图片描述

3.2 网络配置

设置机器人静态IP. 设置机器人 ——> 设置网络菜单
IP地址: 192.168.1.2
子网掩码:255.255.255.0
如果机器人似乎没有正确获取网络配置,请尝试重启控制器。

测试网络连接:

ping 192.168.1.2  #IP_OF_THE_ROBOT

会看到如下输出:
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.518 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.259 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.282 ms
如果没有发生任何事情或引发错误,则无法从计算机访问机器人。

3.3 用ros驱动真实的ur5机器人

参考:Getting Started with a Universal Robot and ROS-Industrial
警告:请将手放在急停按钮旁边,以防发生意外。

  1. 网线连接机器人和电脑,启动机器人。
  2. 打开电脑终端,启动机器人驱动程序。
roslaunch ur_robot_driver ur5_bringup.launch limited:=true robot_ip:=192.168.1.2 
# [reverse_port=REVERSE_PORT] "reverse_port" default="50001" 
#  limited:=true限制机器人关节运动范围 [-pi,pi],否则为 [-2pi, 2pi]
  1. 示教器,运行程序 —> 文件 —> 加载程序 —> 选择3.1 节保存的external_control.urp程序,打开—>运行。
    可以看到终端显示:
    [ INFO] : Robot mode is now POWER_ON
    [ INFO] : Robot mode is now IDLE
    [ INFO] : Robot mode is now RUNNING
    [ INFO]: Robot requested program
    [ INFO]: Sent program to robot
    [ INFO]: Robot ready to receive control commands.
  2. 启动moveit和rviz,注意启动顺序不能变。
# 新终端启动moveit  
roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch limited:=true
# 新终端启动rviz
roslaunch ur5_moveit_config moveit_rviz.launch config:=true

然后就可以拖动rviz中的ur5的末端,plan然后execute控制真实的UR5运动。注意观察plan的运行轨迹,慎防撞击。

3.4 补充内容:ur_calibration 提取标定信息

为了提高正向和逆向运动学精度,每个UR机器人在出厂前都进行了标定。ur_calibration 是 Universal_Robots_ROS_Driver 中的一个功能包,能够提取机器人出厂标定的运动学参数,并更改 ur_description 包的配置文件以获取正确的URDF模型。
尽管使用此驱动程序控制机器人不是必须执行此步骤,但强烈建议您这样做,因为否则末端执行器的位置可能会出现厘米级偏差。

启动ur机器人,确保网络正常链接。然后启动节点 calibration_correction 。该节点直接从机器人提取标定信息,将其保存到.yaml文件中:

roslaunch ur_calibration calibration_correction.launch robot_ip:=192.168.1.2 \
target_filename:="${HOME}/ur5/src/fmauch_universal_robot/ur_description/config/ur5_calibration.yaml"

robot_ip 是机器人的IP地址, target_filename 是保存标定结果的绝对路径。
此时启动机器人驱动程序时就可以加载标定参数了:

roslaunch ur_robot_driver ur5_bringup.launch robot_ip:=192.168.1.2 \
kinematics_config:="${HOME}/ur5/src/fmauch_universal_robot/ur_description/config/ur5_calibration.yaml"

如果该文件中的参数与机器人参数不匹配,驱动程序将在启动过程中将会报错,但仍然可用。

3.5 补充内容:用rqt_joint_trajectory_controller GUI 控制机器人关节

在github下载 rqt_joint_trajectory_controller packages,建议将其放到 ur5/src/ 或 ur5/src/ros_controllers 文件夹。重新编译工作空间:

cd ur5
catkin_make  # build the workspace

然后启动机器人

# 新终端启动机器人驱动程序
roslaunch ur_robot_driver ur5_bringup.launch robot_ip:=192.168.1.2 \
  kinematics_config:="${HOME}/ur5/src/fmauch_universal_robot/ur_description/config/ur5_calibration.yaml"
# 打开一个新终端,启动 rqt_joint_trajectory_controller 节点:
rosrun rqt_joint_trajectory_controller rqt_joint_trajectory_controller

rqt_joint_trajectory_controller
注意:慎重拖动横条,超出 joints 的运动范围机器人会抱死。

4. 曾经踩过的坑

4.1. 报错: [ERROR] : Action client not connected: /follow_joint_trajectory

解决:找到/ur5_moveit_config/config/controllers.yaml 文件,name: 后添加 scaled_pos_joint_traj_controller

4.1.2 坑中之坑:上述修改方法会导致用gazebo仿真时报错
roslaunch ur_gazebo ur5.launch
roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch limited:=true sim:=true
此时会报错: [ERROR] :Action client not connected: scaled_pos_traj_controller/follow_joint_trajectory
导致gazebo无法执行excuse
解决:保留源文件中的 - name:""
在文件后面添加:

- name: scaled_pos_traj_controller
    action_ns:  follow_joint_trajectory
    type: FollowJointTrajectory
    joints:
      - shoulder_pan_joint
      - shoulder_lift_joint
      - elbow_joint
      - wrist_1_joint
      - wrist_2_joint
      - wrist_3_joint

4.1.3 坑中之坑——最新坑 2020年08月更新
最近重装了ur_robot_driver 包,连接真是机器人运行roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch,发现报错[ERROR] :Action client not connected: scaled_pos_joint_traj_controller/follow_joint_trajectory
原因:scaled_pos_traj_controller 已经更新为 scaled_pos_joint_traj_controller
故需将 1.2 节中的 scaled_pos_traj_controller 全部改为scaled_pos_joint_traj_controller
参考:Not able to control the UR10e, issue with controllers #55

4.2.报错:Can’t accept new action goals. Controller is not running.

解决:正确安装设置external control, 并在启动ur5_bringup.launch后,在示教器运行external_control.urp程序。
参考: Can’t accept new action goals #4

示教器运行external_control.urp报错: the connection to the remote pc could not be established
解决:是因为pc端还没有启动ur5_bringup.launch驱动程序,按3.3节顺序启动即可。

4.3. 报错:Variable ‘tool_digital_output_mask’ is currently controlled by another RTDE client. The input recipe can’t be used as configured

由于安装了onrobot RG2 的 urcap, 故有此报错。删除 rg2 的 urcap 可解除报错。
如果不删 rg2 的 urcap,可以 找到 ur_robot_driver/resources/rtde_inpup_recipe.txt 文件
删除
tool_digital_output_mask
tool_digital_output

参考:tool_digital_output_mask is currently controlled by another RTDE client #239

待更:配置实时系统

猜你喜欢

转载自blog.csdn.net/zxxxiazai/article/details/103568577