Ubuntu20.04+ROS 进行机械臂抓取仿真:环境搭建(一)
目录
一、从官网上下载UR机械臂
二、给UR机械臂添加夹爪
三、报错解决
本文详细介绍如何在Ubuntu20.04+ROS环境中为Universal Robots的UR机械臂添加夹爪。首先从官方和第三方源下载必要的软件包,包括UR机械臂驱动、夹爪插件和相关依赖。然后,针对gazebo版本不匹配的问题,替换夹爪文件中的旧版API,并修改夹爪和机械臂的urdf配置文件。接着,更新launch文件以包含夹爪控制器,并进行编译。然后解决依赖缺失的问题。最后,运行启动文件。
一、从官网上下载UR机械臂
首先构建工程:
mkdir -p catkin_ws/src
cd catkin_ws/src
在终端中进入src目录输入下面几串代码:
git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver
git clone -b calibration_devel https://github.com/fmauch/universal_robot.git src/fmauch_universal_robot
git clone https://github.com/ros-industrial/ur_msgs.git src/ur_msgs
catkin_make
二、给UR机械臂添加夹爪
(1)从官网上下载的UR机械臂是没有夹爪的,需要自己添加夹爪。
git clone https://github.com/DH-Robotics/dh_gripper_ros.git src/dh_gripper_ros
夹爪下载完之后再进行编译,这时候会报错,因为下载的夹爪文件中程序调用的时Gazebo7中的 API,而在gazebo9时函数已经被改写,有的函数已经不存在。因此需要将部分文件替换成gazebo11的版本:
https://github.com/roboticsgroup/roboticsgroup_gazebo_plugins.git
将这个下载下来的roboticsgroup_gazebo_plugins替换掉原有路径:dh_robotics_ag95_gripper/dh_robotics_ag95_simulation/roboticsgroup_gazebo_plugins 的这个包。
2)在刚刚下载好的dh_robotics_ag95_gripper文件中进行操作
dh_robotics_ag95_gripper/dh_robotics_ag95_description/urdf/dh_robotics_ag95_gripper.xacro,然后将下面几段代码注释掉并保存:
/
true
然后打开机械臂文件:打开fmauch_universal_robot/ur_description/urdf,复制ur5.xacro文件并重命名为ur5_dh.xacro;并且添加下面几行代码:
打开fmauch_universal_robot/ur_description/launch,复制load_ur5.launch并且重命名为load_ur5.launch,将下面代码替代原来的代码:
继续在这一个launch文件夹下复制view_ur5.launch,并且重命名为view_ur5_dh.launch,替换为以下内容:
找到ur_gazebo/launch,复制ur5_bringup.launch并且重命名为ur5_bringup_dh.launch,修改为以下内容:
最后进行编译一下,运行 roslaunch ur_description view_ur5_dh.launch
三、报错解决
此时,如果顺利的话就结束了,但是,有的朋友会发现打开的rviz界面如下:
可以看到机械臂模型发生报错,找到终端查看错误,会发现报错如下:
这是因为joint_state_publisher_gui
和 robot_state_publisher
也是 ROS 包的一部分,确保它们已正确安装,执行:
sudo apt install ros-noetic-joint-state-publisher ros-noetic-joint-state-publisher-gui ros-noetic-robot-state-publisher
然后重新编译,解决问题:
参考:
大佬