ubuntu系统下使用ros控制UR真实机械臂,逻辑清晰,亲测有效

梳理一下在ubuntu系统使用ros控制UR真实机械臂的思路,逻辑清晰,亲测有效,并记录踩过的坑。从0开始,使用ros控制真实UR机械臂。
环境:ubuntu18.04
ros版本:melodic
机械臂型号:UR5e

一:安装ubuntu18.04系统+ROS melodic
这个教程太多了,也可以参考我前面写的CSDN,这篇博客假设你已经成功安装ubuntu18.04系统+ROS melodic,这里不再赘述。

二:下载Universal_Robots_ROS_Driver驱动
说明&写在前面:下载Universal_Robots_ROS_Driver驱动的过程中,已经下载了universal_robot的相关包,不要再单独重复下载,不然后期编译工作空间的时候会报错。
虽然不用单独下载universal_robot包,但还是贴一下该包的官方网址,里面主要包括urdf等描述文件和官方配置好的moveit
网址:https://github.com/ros-industrial/universal_robot

a:Universal_Robots_ROS_Driver驱动下载地址:
https://github.com/UniversalRobots/Universal_Robots_ROS_Driver
按照README里的步骤安装即可。
这里贴一下安装流程:

# source global ros
$ source /opt/ros/<your_ros_version>/setup.bash

# create a catkin workspace
$ mkdir -p catkin_ws/src && cd catkin_ws

# clone the driver
$ git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver

# clone the description. Currently, it is necessary to use the melodic-devel branch.
$ git clone -b melodic-devel https://github.com/ros-industrial/universal_robot.git src/universal_robot

# install dependencies
$ sudo apt update -qq
$ rosdep update
$ rosdep install --from-paths src --ignore-src -y

# build the workspace
$ catkin_make

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

#号前面的是解释,终端执行$后的命令

驱动安装完成后,在工作空间的src文件夹下会有universal_robot和Universal_Robots_ROS_Driver两个文件,universal_robot就是前面提到的ur机械臂描述文件和moveit包,Universal_Robots_ROS_Driver就是ur机械臂和ros连接的驱动程序

三:在实体UR机器人安装URCap
URCap相当于UR机械臂可以被外部设备控制的一个插件,如果不安装的话,应该只能使用示教器控制机械臂。
a:下载URCap网址:
https://github.com/UniversalRobots/Universal_Robots_ROS_Driver/blob/master/ur_robot_driver/doc/install_urcap_cb3.md

b:根据文档提示For using the ur_robot_driver with a real robot you need to install the externalcontrol-x.x.x.urcap which can be found here,点击here
下载最新版本的URCap,我这里下载的是externalcontrol-1.0.5.urcap

c:将下载好的externalcontrol-1.0.5.urcap拷贝到U盘,然后U盘插入到UR的控制柜

d:打开UR5e机械臂,我们示教器面板的界面和官方文档不一样,我这里选择—右上角的三个横线—设置—系统----URCap—下面的+号—添加U盘的externalcontrol-1.0.5.urcap—打开该文件—重启机械臂

e:重启后,选择最上面的程序—URCap—External Control—我这里显示
Host IP:192.168.0.102
Custrom port:50002
依据此IP设置电脑ubuntu系统下的IP,端口为50002不用动。

四:UR机械臂和电脑IP设置
a:UR机械臂示教器IP设置
示教器右上角的三个横线—设置—系统—网络
网络:选择静态地址
ur机械臂IP地址 : 192.168.0.101
ur机械臂子网掩码: 255.255.255.0
默认网关:0.0.0.0
首选DNS服务器:0.0.0.0
备用DNS服务器:0.0.0.0
然后应用即可

b:电脑ubuntu系统下IP设置:
右上角设置–Network–Wired设置按钮—IPv4
手动设置manual
Address:192.168.0.102
Netmask: 255.255.255.0

此时UR机械臂和电脑IP均设置完毕,检测机械臂实体和电脑是否通讯:
打开终端,执行以下命令:

ping 192.168.0.101

这里ping的是机械臂IP,根据大家实际情况而定,若提示如下,则说明机械臂和电脑IP配置成功。
在这里插入图片描述
五:ubuntu系统下使用ros驱动UR5e机械臂
依旧参考官方文档:https://github.com/UniversalRobots/Universal_Robots_ROS_Driver
a:提取标定信息

$ roslaunch ur_calibration calibration_correction.launch robot_ip:=<robot_ip> target_filename:="${HOME}/my_robot_calibration.yaml"

这里的<robot_ip> 填写机械臂的IP

b:步骤一:终端1启动机器人驱动程序

cd UR_ws
source devel/setup.bash
roslaunch ur_robot_driver ur5e_bringup.launch robot_ip:=192.168.0.101

提示:
UR_ws是我的工作空间名字,根据你们情况修改,一般为catkin_ws;
ur5e是我们的机械臂型号,如果你的是ur3,则改为ur3;
robot_ip:=后面是自己的机械臂IP,根据实际情况修改。

c:步骤二:在机器人示教器上,点击【程序】,选择【URCaps】,然后【External Control】,teach-panent最下面三角号运行程序。之后可以看到运行驱动的终端显示:

在这里插入图片描述

d:步骤三:终端2启动moveit:

roslaunch ur5e_moveit_config moveit_planning_execution.launch limited:=true

e:步骤四:终端3启动rviz:

roslaunch ur5e_moveit_config moveit_rviz.launch config:=true

f:步骤五:rviz界面配置
Fixed Frame:base
Add:添加RobotModel,添加机械臂模型
ADD:添加MotionPlanning,添加规划界面,拖动小球可以plan机械臂的轨迹,excute机械臂执行运动。

切忌,实体机械臂执行运动时,手一定要放在示教器上的急停按钮,防止机械臂打到人或损坏机械臂。

在这里插入图片描述

完结~~~

猜你喜欢

转载自blog.csdn.net/Time_Memory_cici/article/details/130706760
今日推荐