背景如题
参考:https://blog.csdn.net/weixin_37806591/article/details/119387696
https://blog.csdn.net/Dawn_yc/article/details/114791755#t6
主要参考连接一,就是在电脑上安装ros驱动,驱动真实ur两大步骤
实现:
一、 安装UR的ROS驱动
按照github官网的教程,安装universal robot ros driver
(参考:https://github.com/UniversalRobots/Universal_Robots_ROS_Driver
https://blog.csdn.net/weixin_44715231/article/details/114796006
https://blog.csdn.net/Dawn_yc/article/details/114791755#t6
https://blog.csdn.net/zxxxiazai/article/details/103568577
https://blog.csdn.net/weixin_37806591/article/details/119387696)
要确保不能有universal_rbot的包,不然报错:重复的包
主要就是输入一下命令:
# cd to the catkin_ws folder
# clone the driver
$ git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver
# clone fork of the description. This is currently necessary, until the changes are merged upstream.
$ git clone -b calibration_devel https://github.com/fmauch/universal_robot.git src/fmauch_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
遇到的问题
在执行这一系列指令时,遇到了很多问题:
- sudo apt update报错:GPG key的问题
(解决办法参考:https://blog.csdn.net/qq_40114620/article/details/108050702)
// F42ED6FBAB17C654是根据你报错那一行确定的
sudo gpg --keyserver keyserver.ubuntu.com --recv F42ED6FBAB17C654
sudo gpg --export --armor F42ED6FBAB17C654 | sudo apt-key add -
- rosdep问题,这个众所周知的网络问题,不能科学上网,就跳过吧
- catkin_make报错:
(1)一开始是报错:Cmake Error,
(解决办法参考https://blog.csdn.net/java__97/article/details/119219661)
具体来说就是缺少依赖包,所以解决办法就是缺啥补啥
sudo apt-get install ros-melodic-PACKAGE
这里面的PACKAGE是根据你的报错来定的,也就是Config.cmake前面的那一串,比如:
我这里报错缺少,ur_client_libraryConfig.cmake,那么我的PACKAGE就是ur-client-library。
注意这里的包的名称,里面是短划线,报错的信息里面是下划线。
(2)没有包依赖的错误后,在build过程中,再次报错
(参考 https://blog.csdn.net/Mike_69/article/details/117926590
https://blog.csdn.net/gyxx1998/article/details/118153079)
还是缺少包ur_msgs
# 在catkin_ws目录下
git clone https://github.com/ros-industrial/ur_msgs.git src/ur_msgs
然后再次catkin_make编译通过
注:参考连接第二种,提到会有ur_msgs重复的问题,暂时没遇到。
4. source问题
具体表现为:
这里报错原因是我设置了自己默认的shell是zsh
所以source命令应该改为
source devel/setup.zsh
二、仿真测试
参照:https://blog.csdn.net/zxxxiazai/article/details/103568577 中的仿真测试一节
#打开终端,启动
roslaunch ur_gazebo ur5e_bringup.launch
#打开新终端
roslaunch ur5e_moveit_config ur5e_moveit_planning_execution.launch sim:=true
#再打开一个新终端
roslaunch ur5e_moveit_config moveit_rviz.launch config:=true
- 第一步就报错
RLException:ur5.launch is neither a launch file in package [ur_gazebo] nor is [ur_gazebo] a launch file name
the trackback for the exception was written to the log file
emmm~~很好,文件名写错了
正常来说这个问题是catkin_make之后,没有source setup的问题
我这次犯错是把包里的文件名写错了 - 第三步执行完后,打开rviz,报错fixed frame [map] does not exist
参考https://blog.csdn.net/weixin_42591529/article/details/104856516
在global options的fixed frame中选择base_link,报错消失 - 然后发现rviz中没有机械臂,主要是没有添加motion planning的topic
点击add,添加motion planning的topic,则机械臂出现 - 在motion planning的面板中,随便选了两个位置,点击plan and execute,发现提示
原来是planning group那个地方选择的是endeffector,改成manipulator就好了
三、连接ur5e实体机器人
- 在实体UR机器人端安装 externalcontrol-1.0.5.urcap
(1)首先,从Universal_Robots_ROS_Driver/ur_robot_driver/resources下载externalcontrol-1.0.4.urcap,然后用自己的U盘拷贝到UR机器人。
(2)打开 示教器->open->installation,
在这个地方新建文件夹,把上述urcap文件拷进新建的文件夹。
然后在settings中设置URCaps,如图所示,按照步骤添加刚才的urcap文件
添加后,点击右下角的restart,重启机械臂
(3)然后在program中创建新程序,把external control放进程序树中,点击save->save program as,起个新名字externalcontrol.urp
(4)上一步完成后,会在installation里面多出一个选项,URCaps
接下来就是配置电脑和机器人的网络,这两个的网址需要在同一网段
1)先配置external control的网址:
这里external control是指电脑的ip
在这里把host ip设置为电脑的ip就行
2)然后 ,设置机械臂的网址
同样是在settings中找到network,选择静态网址,然后把ip设成跟电脑的在同一网段,
完成配置后,ping一下,保证物理连接没有问题
2. 用ros驱动真实ur5e机器人
(1)点击左下角电源按钮,启动机械臂
(2)打开电脑终端,启动机器人驱动程序
roslaunch ur_robot_driver ur5e_bringup.launch limited:=true robot_ip:=192.168.1.104
# [reverse_port=REVERSE_PORT] "reverse_port" default="50001"
# limited:=true限制机器人关节运动范围 [-pi,pi],否则为 [-2pi, 2pi]
(3)在示教器上,run->load program->externalcontrol.urp,右下角选择open,然后在屏幕底部,点击三角形的开始按钮
此时可以在终端看到下列信息:
[ 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.
(4)启动moveit和rviz,注意启动顺序不能变。
# 新终端启动moveit
roslaunch ur5e_moveit_config ur5e_moveit_planning_execution.launch limited:=true
# 新终端启动rviz
roslaunch ur5e_moveit_config moveit_rviz.launch config:=true
然后就可以使用rviz控制实物UR5e机器人了
(主要参考:https://blog.csdn.net/zxxxiazai/article/details/103568577)