ROS ur10机械臂添加140夹爪
系统版本:Ubuntu20.04
Ros版本:noetic
Moveit版本:moveit-noetic
参考博客:
++ur3+robotiq ft sensor+robotiq 2f 140配置rviz仿真环境_有末端力传感器的仿真环境-CSDN博客++
++UR5机械臂仿真实例(三)1 末端添加robotiq夹爪 [ubuntu20.04+ROSnoetic+gazebo11]_ros机械臂中添加夹具-CSDN博客++
前提条件:ros系统,Moveit环境,Gazebo仿真环境运行正确
ROS+Moveit!+Rviz配置流程:
ROS系统&Moveit!安装指南:
++1.2.4 安装 ROS · Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程++
01 安装UR工具包与驱动
source /opt/ros/melodic/setup.bash
mkdir -p ur_ws/src && cd ur_ws
下载fmauch_universal_robot(注意分支)
git clone -b calibration_devel https://github.com/fmauch/universal_robot.git src/fmauch_universal_robot
下载Universal_Robots_ROS_Driver驱动
git clone https://github.com/UniversalRobots/Universal_Robots_ROS_Driver.git src/Universal_Robots_ROS_Driver
更新 -qq代表除非报错,否则不输出
sudo apt update -qq
sudo apt-get upgrade
更新依赖(这一步需要有梯子,不然可能会超时,超时执行下一步即可,只要一开始安装ros时执行成功过即可)
rosdep update
安装依赖 -y表示出现 y/N选项 直接执行y
rosdep install --from-paths src --ignore-src -y
编译
catkin_make
激活当前工作空间,并写入
echo "source ~/ur_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
02 仿真测试
启动gazebo
注意是ur10_bringup.launch,而不是ur10.launch
roslaunch ur_gazebo ur10_bringup.launch
启动move it规划
roslaunch ur10_moveit_config ur10_moveit_planning_execution.launch sim:=true
启动rviz
注意后面要给出rviz_config的地址
roslaunch ur10_moveit_config moveit_rviz.launch rviz_config:=$(rospack find ur10_moveit_config)/launch/moveit.rviz
03 连接夹爪与机械臂
1.下载robotiq工具包
git clone https://github.com/jr-robotics/robotiq.git src/robotiq
2.修改ur.xacro模型
ur_description/urdf/ur.xacro中添加以下代码(注意xacro:include标签应在文件首)
<!--继承robotiq_arg2f_140宏-->
<xacro:include filename="$(find robotiq_2f_140_gripper_visualization)/urdf/robotiq_arg2f_140_macro.xacro"/>
<!--调用robotiq_arg2f_140,加入夹爪的link和joint-->
<xacro:robotiq_arg2f_140
prefix=""
transmission_hw_interface="$(arg transmission_hw_interface)"
/>
- 断开夹爪与base_link连接
注释与修改
robotiq-noetic-devel/robotiq_2f_140_gripper_visualization/urdf/robotiq_arg2f_140_macro.xacro中base_link连接
195<!--link name="${prefix}base_link"/-->
197<parent link="${prefix}tool0" />
- 启动测试
catkin_make
source devel/setup.bash
roslaunch ur_description view_ur10.launch

检查能否正常移动夹爪与机械臂
04 配置gazebo仿真环境
1.修改模型关节连接关系
"世界"连接到"机械臂基类",添加夹爪 机械臂末关节链接至"夹爪基类"
修改文件:ur_gazebo/urdf/ur.xacro
<link name="world"/>
<joint name="world_joint" type="fixed">
<parent link="world"/>
<child link="base_link"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
</joint>
倒数第二行添加如下
<xacro:include filename="$(find robotiq_2f_140_gripper_gazebo)/urdf/robotiq_arg2f_140_macro.xacro" />
<!-- parameters -->
<xacro:arg name="transmission_hw_interface" default="hardware_interface/EffortJointInterface"/>
<xacro:robotiq_arg2f_140_gazebo
prefix=""
transmission_hw_interface="$(arg transmission_hw_interface)"/>
<joint name="robotiq_hand_joint" type="fixed">
<parent link="wrist_3_link"/>
<child link="robotiq_arg2f_base_link"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
</joint>
2.修改关节与运动控制插件
Robotiq2f140 gripper有被动关节(Mimic Joint),标准Gazebo不支持Mimic关节仿真, 所以需要安装一个插件。在一、实现rviz中ur5与robotiq85的连接和控制的基础上,下载plugins,然后catkin_make编译。
cd ~/catkin_ws/src
git clone ++GitHub - roboticsgroup/roboticsgroup_gazebo_plugins: Collection of small gazebo plugins for ROS++
cd ~/catkin_ws
catkin_make
打开robotiq_2f_140_gripper_gazebo/urdf/robotiq_arg2f_140_macro.xacro,修改以下两处。
将插件名字改为"libroboticsgroup_gazebo_mimic_joint_plugin.so";
<plugin filename="libroboticsgroup_gazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_140_1">
<plugin filename="libroboticsgroup_gazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_140_2">
<plugin filename="libroboticsgroup_gazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_140_3">
<plugin filename="libroboticsgroup_gazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_140_4">
<plugin filename="libroboticsgroup_gazebo_mimic_joint_plugin.so" name="${prefix}mimic_robotiq_140_5">
将100行左右这段代码注释掉。因为在fmauch_universal_robot/ur_gazebo/urdf/ur_macro.xacro中已经添加了这个插件,不再重复添加。
<!--
Inject Gazebo ROS Control plugin, which allows us to use ros_control
controllers to control the virtual robot hw.
-->
<!--<gazebo>-->
<!--<plugin name="ros_control" filename="libgazebo_ros_control.so">-->
<!--</plugin>-->
<!--</gazebo>-->
3.加载控制器参数
打开robotiq_2f_140_gripper_gazebo/config/
robotiq_2f_140_gripper_controllers.yaml
修改gripper_controller的类型和关节。
增添以下代码
gripper_controller:
type: effort_controllers/JointTrajectoryController
gains:
finger_joint: {p: 10, d: 0.1, i: 1, i_clamp: 1}
joints:
- finger_joint
action_monitor_rate: 20
goal_tolerance: 0.002
max_effort: 100
stall_velocity_threshold: 0.001
stall_timeout: 1.0
4.ur5_bringup.launch 中修改 controllers 参数值
修改 ur_gazebo/launch 中 ur10_bringup.launch 启动三个控制器:关节状态发布、机械臂关节控制、夹爪关节控制。
<arg name="controllers" default="joint_state_controller pos_joint_traj_controller gripper_controller" doc="Controllers that are activated by default."/>
此处曾因与后面Moveti!配置命名空间不一致导致严重bug
可以先不修改,文档最后有详细说明
启动测试
到这一步应该可以在gazebo里面看到加了夹爪的模型了。
cd ~/catkin_ws/
catkin_makesource devel/setup.bash
roslaunch ur_gazebo ur10_bringup.launch
(gazebo启动流程launch->ur.xacro->ur_macro.xacro&robotiq_arg2f_140_macro.xacro->config/controllers->启动)
可能的错误:
1.Failed to find root link: Two root links found: [base_link] and [world]
原因:根节点过多
解决方法:将robotiq_arg2f_140.xacro或ur.xacro中其中一个的worldlink模块注释掉就可以解决
2.gazebo--SpawnModel: Failure - model name mrobot already exists.解决办法
原因:用gazebo打开机器人模型后,保存了world,此时的新world比原world多了机器人模型mrobot,所以重新运行launch时提示名字为mrobot的模型已经存在与world中
解决办法:将gazebo_ros功能包中的empty_world.launch复制到自己的功能包中,并把world_name的参数值改成保存后的world地址,运行empty_world.launch,将里面的机器人模型删除再重新保存即可。
由于 gazebo 的特性,每一次加载后模型都会保存到 world ,当模型加载位置有模型时不会覆盖而是不加载,所以在调试时每次关闭 gazebo 前要删除加载的模型
05 配置Moveit!运控平台
前置工作:因为Moveit!生成模型时不接受空参数或地址,所以我们要对机械臂模型加载模块进行修改
将fmauch_universal_robot/ur_gazebo/urdf/ur.xacro中的
<xacro:arg name="joint_limit_params" default=""/>
<xacro:arg name="physical_params" default=""/>
<xacro:arg name="kinematics_params" default=""/>
<xacro:arg name="visual_params" default=""/>
改为
<xacro:arg name="joint_limit_params" default="$(find ur_description)/config/ur10/joint_limits.yaml"/>
<xacro:arg name="physical_params" default="$(find ur_description)/config/ur10/physical_parameters.yaml"/>
<xacro:arg name="kinematics_params" default="$(find ur_description)/config/ur10/default_kinematics.yaml"/>
<xacro:arg name="visual_params" default="$(find ur_description)/config/ur10/visual_parameters.yaml"/>
1.开始配置
roslaunch moveit_setup_assistant setup_assistant.launch
(1)选择模型文件

(2)自动设置碰撞矩阵

(3)设置虚拟关节

(4)设置规划组


(5)添加joints


(6)夹爪不需要运动学求解器
(7)设置自定义姿势
(8)设置末端执行器

(9)assive Joints被动关节

(10)Controllers控制器
首先,点击Auto Add FollowJointsTrajectoryControllers For Each Planning Group自动生成controllers。
为了实现moveit对gazebo中机械臂的控制,我们需要确保命名空间一致,即控制器名称要统一。参考fmauch_universal_robot/ur_gazebo/config/ur10_controllers.yaml,设置两个controllers的Name和Type。

(11)模拟
对仿真源文件的等价修改,跳过
(12)3D感知
暂时不需要,跳过
(13)作者署名
略
(14)生成config文件

结果演示

可能存在的问题:
命名空间不一致
修改位置ur_control.launch.xml
<arg name="controllers" default="joint_state_controller manipulator_controller gripper_controller"/>
<arg name="stopped_controllers" default="manipulator_controller gripper_controller"/>
ur10_bringup.launch
<arg name="controllers" default="joint_state_controller manipulator_controller gripper_controller" doc="Controllers that are activated by default."/>
<arg name="stopped_controllers" default="joint_group_pos_controller" doc="Controllers that are initally loaded, but not started."/>
绝大部分控制失败都是由命名空间不一致引起的,此处应重点注意排查