当前位置: 首页 > news >正文

如何使用URDF搭建双臂UR移动机器人,并在RViz中可视化

一、背景

现记录一下如何使用URDF搭建双臂UR移动机器人,并在RViz中可视化。

系统:ubunt18.04
ros:melodic
工作空间:UR_ws

写在前面:我使用的是比较麻烦的方法,也就是将两台UR3e的URDF与移动底盘的URDF写到一起了,然后通过display将一个特别长的mobiledualarm.urdf使用RVIZ可视化,所以模块化不是很好,但文章的最后也会介绍一种模块化比较好的方法。

所需材料:
1、移动底盘的URDF模型,路径为:/home/dlut/UR_ws/src/mobiledual0/urdf/mobiledual0.urdf

2、UR3e机械臂URDF,因为最新的UR机械臂ros包中的机器人模型都是使用xacro描述,所以我先将ur3e.xacro转为ur3e.urdf,参见我之前的博客
机器人xacro文件转换成urdf文件方法,并在rviz可视化

小Tip
UR5的RVIZ可以看到黑色的电源线,UR3e就看不到
黑色电源线指向Y轴,垂直向上的为Z轴,通过右手定则确定X轴

切记:电源线指向Y轴,所以对应与base坐标系,而不是base_link坐标系!!!!
在这里插入图片描述

二、使用URDF搭建双臂UR移动机器人

/home/dlut/UR_ws/src/universal_robot/ur_description/urdf路径下创建mobiledualarm.urdf,完整代码如下:

<?xml version="1.0" encoding="utf-8"?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from ur3e.xacro                     | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<robot name="ur3e_robot"><!--Base UR robot series xacro macro.NOTE: this is NOT a URDF. It cannot directly be loaded by consumersexpecting a flattened '.urdf' file. See the top-level '.xacro' for that(but note: that .xacro must still be processed by the xacro command).For use in '.launch' files: use one of the 'load_urX.launch' conveniencelaunch files.This file models the base kinematic chain of a UR robot, which then getsparameterised by various configuration files to convert it into a UR3(e),UR5(e), UR10(e) or UR16e.NOTE: the default kinematic parameters (ie: link lengths, frame locations,offets, etc) do not correspond to any particular robot. They are defaultsonly. There WILL be non-zero offsets between the Forward Kinematics resultsin TF (ie: robot_state_publisher) and the values reported by the TeachPendant.For accurate (and robot-specific) transforms, the 'kinematics_parameters_file'parameter MUST point to a .yaml file containing the appropriate values forthe targetted robot.If using the UniversalRobots/Universal_Robots_ROS_Driver, follow the stepsdescribed in the readme of that repository to extract the kinematiccalibration from the controller and generate the required .yaml file.Main author of the migration to yaml configs: Ludovic Delval.Contributors to previous versions (in no particular order):- Felix Messmer- Kelsey Hawkins- Wim Meeussen- Shaun Edwards- Nadia Hammoudeh Garcia- Dave Hershberger- G. vd. Hoorn- Philip Long- Dave Coleman- Miguel Prada- Mathias Luedtke- Marcel Schnirring- Felix von Drigalski- Felix Exner- Jimmy Da Silva- Ajit Krisshna N L- Muhammad Asif Rana--><!--NOTE: the macro defined in this file is NOT part of the public API of thispackage. Users CANNOT rely on this file being available, or stored inthis location. Nor can they rely on the existence of the macro.--><transmission name="shoulder_pan_trans"><type>transmission_interface/SimpleTransmission</type><joint name="shoulder_pan_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="shoulder_pan_motor"><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="shoulder_lift_trans"><type>transmission_interface/SimpleTransmission</type><joint name="shoulder_lift_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="shoulder_lift_motor"><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="elbow_trans"><type>transmission_interface/SimpleTransmission</type><joint name="elbow_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="elbow_motor"><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="wrist_1_trans"><type>transmission_interface/SimpleTransmission</type><joint name="wrist_1_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="wrist_1_motor"><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="wrist_2_trans"><type>transmission_interface/SimpleTransmission</type><joint name="wrist_2_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="wrist_2_motor"><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="wrist_3_trans"><type>transmission_interface/SimpleTransmission</type><joint name="wrist_3_joint"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="wrist_3_motor"><mechanicalReduction>1</mechanicalReduction></actuator></transmission><!-- links: main serial chain --><link name="base_link"/><link name="base_link_inertia"><visual><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/base.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/base.stl"/></geometry></collision><inertial><mass value="2.0"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.0030531654454" ixy="0.0" ixz="0.0" iyy="0.0030531654454" iyz="0.0" izz="0.005625"/></inertial></link><link name="shoulder_link"><visual><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/shoulder.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/shoulder.stl"/></geometry></collision><inertial><mass value="2.0"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.0080931634294" ixy="0.0" ixz="0.0" iyy="0.0080931634294" iyz="0.0" izz="0.005625"/></inertial></link><link name="upper_arm_link"><visual><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.12"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/upperarm.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.12"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/upperarm.stl"/></geometry></collision><inertial><mass value="3.42"/><origin rpy="0 1.57079632679 0" xyz="-0.121825 0.0 0.12"/><inertia ixx="0.0217284832211" ixy="0.0" ixz="0.0" iyy="0.0217284832211" iyz="0.0" izz="0.00961875"/></inertial></link><link name="forearm_link"><visual><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.027"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/forearm.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.027"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/forearm.stl"/></geometry></collision><inertial><mass value="1.26"/><origin rpy="0 1.57079632679 0" xyz="-0.1066 0.0 0.027"/><inertia ixx="0.00654456758217" ixy="0.0" ixz="0.0" iyy="0.00654456758217" iyz="0.0" izz="0.00354375"/></inertial></link><link name="wrist_1_link"><visual><!-- TODO: Move this to a parameter --><origin rpy="1.57079632679 0 0" xyz="0 0 -0.104"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/wrist1.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 0" xyz="0 0 -0.104"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/wrist1.stl"/></geometry></collision><inertial><mass value="0.8"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.002084999166" ixy="0.0" ixz="0.0" iyy="0.002084999166" iyz="0.0" izz="0.00225"/></inertial></link><link name="wrist_2_link"><visual><origin rpy="0 0 0" xyz="0 0 -0.08535"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/wrist2.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="0 0 0" xyz="0 0 -0.08535"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/wrist2.stl"/></geometry></collision><inertial><mass value="0.8"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.002084999166" ixy="0.0" ixz="0.0" iyy="0.002084999166" iyz="0.0" izz="0.00225"/></inertial></link><link name="wrist_3_link"><visual><origin rpy="1.57079632679 0 0" xyz="0 0 -0.0921"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/wrist3.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 0" xyz="0 0 -0.0921"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/wrist3.stl"/></geometry></collision><inertial><mass value="0.35"/><origin rpy="0 0 0" xyz="0.0 0.0 -0.02"/><inertia ixx="0.00013626661216" ixy="0.0" ixz="0.0" iyy="0.00013626661216" iyz="0.0" izz="0.0001792"/></inertial></link><!-- joints: main serial chain --><joint name="base_link-base_link_inertia" type="fixed"><parent link="base_link"/><child link="base_link_inertia"/><!-- 'base_link' is REP-103 aligned (so X+ forward), while the internalframes of the robot/controller have X+ pointing backwards.Use the joint between 'base_link' and 'base_link_inertia' (a dummylink/frame) to introduce the necessary rotation over Z (of pi rad).--><origin rpy="0 0 3.14159265359" xyz="0 0 0"/></joint><joint name="shoulder_pan_joint" type="revolute"><parent link="base_link_inertia"/><child link="shoulder_link"/><origin rpy="0 0 0" xyz="0 0 0.15185"/><axis xyz="0 0 1"/><limit effort="56.0" lower="-6.28318530718" upper="6.28318530718" velocity="3.14159265359"/><dynamics damping="0" friction="0"/></joint><joint name="shoulder_lift_joint" type="revolute"><parent link="shoulder_link"/><child link="upper_arm_link"/><origin rpy="1.570796327 0 0" xyz="0 0 0"/><axis xyz="0 0 1"/><limit effort="56.0" lower="-6.28318530718" upper="6.28318530718" velocity="3.14159265359"/><dynamics damping="0" friction="0"/></joint><joint name="elbow_joint" type="revolute"><parent link="upper_arm_link"/><child link="forearm_link"/><origin rpy="0 0 0" xyz="-0.24355 0 0"/><axis xyz="0 0 1"/><limit effort="28.0" lower="-3.14159265359" upper="3.14159265359" velocity="3.14159265359"/><dynamics damping="0" friction="0"/></joint><joint name="wrist_1_joint" type="revolute"><parent link="forearm_link"/><child link="wrist_1_link"/><origin rpy="0 0 0" xyz="-0.2132 0 0.13105"/><axis xyz="0 0 1"/><limit effort="12.0" lower="-6.28318530718" upper="6.28318530718" velocity="6.28318530718"/><dynamics damping="0" friction="0"/></joint><joint name="wrist_2_joint" type="revolute"><parent link="wrist_1_link"/><child link="wrist_2_link"/><origin rpy="1.570796327 0 0" xyz="0 -0.08535 -1.75055776238e-11"/><axis xyz="0 0 1"/><limit effort="12.0" lower="-6.28318530718" upper="6.28318530718" velocity="6.28318530718"/><dynamics damping="0" friction="0"/></joint><joint name="wrist_3_joint" type="revolute"><parent link="wrist_2_link"/><child link="wrist_3_link"/><origin rpy="1.57079632659 3.14159265359 3.14159265359" xyz="0 0.0921 -1.88900257663e-11"/><axis xyz="0 0 1"/><limit effort="12.0" lower="-6.28318530718" upper="6.28318530718" velocity="6.28318530718"/><dynamics damping="0" friction="0"/></joint><!-- ROS-Industrial 'base' frame: base_link to UR 'Base' Coordinates transform --><link name="base"/><joint name="base_link-base_fixed_joint" type="fixed"><!-- Note the rotation over Z of pi radians: as base_link is REP-103aligned (ie: has X+ forward, Y+ left and Z+ up), this is neededto correctly align 'base' with the 'Base' coordinate system ofthe UR controller.--><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><parent link="base_link"/><child link="base"/></joint><!-- ROS-Industrial 'flange' frame: attachment point for EEF models --><link name="flange"/><joint name="wrist_3-flange" type="fixed"><parent link="wrist_3_link"/><child link="flange"/><origin rpy="0 -1.57079632679 -1.57079632679" xyz="0 0 0"/></joint><!-- ROS-Industrial 'tool0' frame: all-zeros tool frame --><link name="tool0"/><joint name="flange-tool0" type="fixed"><!-- default toolframe: X+ left, Y+ up, Z+ front --><origin rpy="1.57079632679 0 1.57079632679" xyz="0 0 0"/><parent link="flange"/><child link="tool0"/></joint><linkname="carbase_link"><inertial><originxyz="-0.0140111046811873 -0.330409001171163 -0.018140368676531"rpy="0 0 0" /><massvalue="76.2642102199291" /><inertiaixx="0.972296954133458"ixy="-0.000515756621916056"ixz="-0.00353288568959439"iyy="1.50934157151189"iyz="-0.00286721103188841"izz="0.879992661015933" /></inertial><visual><originxyz="0 0 0"rpy="0 0 0" /><geometry><meshfilename="package://mobiledual0/meshes/carbase_link.STL" /></geometry><materialname=""><colorrgba="1 1 1 1" /></material></visual><collision><originxyz="0 0 0"rpy="0 0 0" /><geometry><meshfilename="package://mobiledual0/meshes/carbase_link.STL" /></geometry></collision></link><linkname="carzero_Link"><inertial><originxyz="-1.63363273751604E-06 -3.7029008717604E-06 -0.00390801617468592"rpy="0 0 0" /><massvalue="0.128076565751948" /><inertiaixx="0.000250652352757893"ixy="1.42284195681717E-08"ixz="-1.92457822817621E-11"iyy="0.000161503892530106"iyz="-4.36237731444375E-11"izz="0.0004107608466446" /></inertial><visual><originxyz="0 0 0"rpy="0 0 0" /><geometry><meshfilename="package://mobiledual0/meshes/carzero_Link.STL" /></geometry><materialname=""><colorrgba="1 1 1 1" /></material></visual><collision><originxyz="0 0 0"rpy="0 0 0" /><geometry><meshfilename="package://mobiledual0/meshes/carzero_Link.STL" /></geometry></collision></link><jointname="joint1"type="fixed"><originxyz="0.163999999999972 -0.212101076872553 0.111375924854946"rpy="0 -0.785398163397473 1.5707963267949" /><parentlink="carbase_link" /><childlink="carzero_Link" /><axisxyz="0 0 0" /></joint><linkname="carzero2_Link"><inertial><originxyz="-1.63363273940342E-06 3.70290087184366E-06 -0.00409198382531417"rpy="0 0 0" /><massvalue="0.128076565751948" /><inertiaixx="0.000250652352757893"ixy="-1.42284195686405E-08"ixz="1.92457822953147E-11"iyy="0.000161503892530106"iyz="-4.36237731693912E-11"izz="0.000410760846644599" /></inertial><visual><originxyz="0 0 0"rpy="0 0 0" /><geometry><meshfilename="package://mobiledual0/meshes/carzero2_Link.STL" /></geometry><materialname=""><colorrgba="1 1 1 1" /></material></visual><collision><originxyz="0 0 0"rpy="0 0 0" /><geometry><meshfilename="package://mobiledual0/meshes/carzero2_Link.STL" /></geometry></collision></link><jointname="joint2"type="fixed"><originxyz="0 0.327999999999944 0.000183967650620315"rpy="0 0 0" /><parentlink="carzero_Link" /><childlink="carzero2_Link" /><axisxyz="0 0 0" /></joint><joint name="right_arm_attach" type="fixed"><child link="base_link" /><parent link="carzero2_Link" /><origin xyz="0 0.0 0" rpy="0 0 0" /></joint> <!-- links: main serial chain --><link name="base_link1"/><link name="base_link_inertia1"><visual><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/base.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/base.stl"/></geometry></collision><inertial><mass value="2.0"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.0030531654454" ixy="0.0" ixz="0.0" iyy="0.0030531654454" iyz="0.0" izz="0.005625"/></inertial></link><link name="shoulder_link1"><visual><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/shoulder.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/shoulder.stl"/></geometry></collision><inertial><mass value="2.0"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.0080931634294" ixy="0.0" ixz="0.0" iyy="0.0080931634294" iyz="0.0" izz="0.005625"/></inertial></link><link name="upper_arm_link1"><visual><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.12"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/upperarm.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.12"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/upperarm.stl"/></geometry></collision><inertial><mass value="3.42"/><origin rpy="0 1.57079632679 0" xyz="-0.121825 0.0 0.12"/><inertia ixx="0.0217284832211" ixy="0.0" ixz="0.0" iyy="0.0217284832211" iyz="0.0" izz="0.00961875"/></inertial></link><link name="forearm_link1"><visual><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.027"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/forearm.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 -1.57079632679" xyz="0 0 0.027"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/forearm.stl"/></geometry></collision><inertial><mass value="1.26"/><origin rpy="0 1.57079632679 0" xyz="-0.1066 0.0 0.027"/><inertia ixx="0.00654456758217" ixy="0.0" ixz="0.0" iyy="0.00654456758217" iyz="0.0" izz="0.00354375"/></inertial></link><link name="wrist_1_link1"><visual><!-- TODO: Move this to a parameter --><origin rpy="1.57079632679 0 0" xyz="0 0 -0.104"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/wrist1.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 0" xyz="0 0 -0.104"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/wrist1.stl"/></geometry></collision><inertial><mass value="0.8"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.002084999166" ixy="0.0" ixz="0.0" iyy="0.002084999166" iyz="0.0" izz="0.00225"/></inertial></link><link name="wrist_2_link1"><visual><origin rpy="0 0 0" xyz="0 0 -0.08535"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/wrist2.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="0 0 0" xyz="0 0 -0.08535"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/wrist2.stl"/></geometry></collision><inertial><mass value="0.8"/><origin rpy="0 0 0" xyz="0 0 0"/><inertia ixx="0.002084999166" ixy="0.0" ixz="0.0" iyy="0.002084999166" iyz="0.0" izz="0.00225"/></inertial></link><link name="wrist_3_link1"><visual><origin rpy="1.57079632679 0 0" xyz="0 0 -0.0921"/><geometry><mesh filename="package://ur_description/meshes/ur3e/visual/wrist3.dae"/></geometry><material name="LightGrey"><color rgba="0.7 0.7 0.7 1.0"/></material></visual><collision><origin rpy="1.57079632679 0 0" xyz="0 0 -0.0921"/><geometry><mesh filename="package://ur_description/meshes/ur3e/collision/wrist3.stl"/></geometry></collision><inertial><mass value="0.35"/><origin rpy="0 0 0" xyz="0.0 0.0 -0.02"/><inertia ixx="0.00013626661216" ixy="0.0" ixz="0.0" iyy="0.00013626661216" iyz="0.0" izz="0.0001792"/></inertial></link><!-- joints: main serial chain --><joint name="base_link-base_link_inertia1" type="fixed"><parent link="base_link1"/><child link="base_link_inertia1"/><!-- 'base_link' is REP-103 aligned (so X+ forward), while the internalframes of the robot/controller have X+ pointing backwards.Use the joint between 'base_link' and 'base_link_inertia' (a dummylink/frame) to introduce the necessary rotation over Z (of pi rad).--><origin rpy="0 0 3.14159265359" xyz="0 0 0"/></joint><joint name="shoulder_pan_joint1" type="revolute"><parent link="base_link_inertia1"/><child link="shoulder_link1"/><origin rpy="0 0 0" xyz="0 0 0.15185"/><axis xyz="0 0 1"/><limit effort="56.0" lower="-6.28318530718" upper="6.28318530718" velocity="3.14159265359"/><dynamics damping="0" friction="0"/></joint><joint name="shoulder_lift_joint1" type="revolute"><parent link="shoulder_link1"/><child link="upper_arm_link1"/><origin rpy="1.570796327 0 0" xyz="0 0 0"/><axis xyz="0 0 1"/><limit effort="56.0" lower="-6.28318530718" upper="6.28318530718" velocity="3.14159265359"/><dynamics damping="0" friction="0"/></joint><joint name="elbow_joint1" type="revolute"><parent link="upper_arm_link1"/><child link="forearm_link1"/><origin rpy="0 0 0" xyz="-0.24355 0 0"/><axis xyz="0 0 1"/><limit effort="28.0" lower="-3.14159265359" upper="3.14159265359" velocity="3.14159265359"/><dynamics damping="0" friction="0"/></joint><joint name="wrist_1_joint1" type="revolute"><parent link="forearm_link1"/><child link="wrist_1_link1"/><origin rpy="0 0 0" xyz="-0.2132 0 0.13105"/><axis xyz="0 0 1"/><limit effort="12.0" lower="-6.28318530718" upper="6.28318530718" velocity="6.28318530718"/><dynamics damping="0" friction="0"/></joint><joint name="wrist_2_joint1" type="revolute"><parent link="wrist_1_link1"/><child link="wrist_2_link1"/><origin rpy="1.570796327 0 0" xyz="0 -0.08535 -1.75055776238e-11"/><axis xyz="0 0 1"/><limit effort="12.0" lower="-6.28318530718" upper="6.28318530718" velocity="6.28318530718"/><dynamics damping="0" friction="0"/></joint><joint name="wrist_3_joint1" type="revolute"><parent link="wrist_2_link1"/><child link="wrist_3_link1"/><origin rpy="1.57079632659 3.14159265359 3.14159265359" xyz="0 0.0921 -1.88900257663e-11"/><axis xyz="0 0 1"/><limit effort="12.0" lower="-6.28318530718" upper="6.28318530718" velocity="6.28318530718"/><dynamics damping="0" friction="0"/></joint><!-- ROS-Industrial 'base' frame: base_link to UR 'Base' Coordinates transform --><link name="base1"/><joint name="base_link-base_fixed_joint1" type="fixed"><!-- Note the rotation over Z of pi radians: as base_link is REP-103aligned (ie: has X+ forward, Y+ left and Z+ up), this is neededto correctly align 'base' with the 'Base' coordinate system ofthe UR controller.--><origin rpy="0 0 3.14159265359" xyz="0 0 0"/><parent link="base_link1"/><child link="base1"/></joint><!-- ROS-Industrial 'flange' frame: attachment point for EEF models --><link name="flange1"/><joint name="wrist_3-flange1" type="fixed"><parent link="wrist_3_link1"/><child link="flange1"/><origin rpy="0 -1.57079632679 -1.57079632679" xyz="0 0 0"/></joint><!-- ROS-Industrial 'tool0' frame: all-zeros tool frame --><link name="tool01"/><joint name="flange-tool01" type="fixed"><!-- default toolframe: X+ left, Y+ up, Z+ front --><origin rpy="1.57079632679 0 1.57079632679" xyz="0 0 0"/><parent link="flange1"/><child link="tool01"/></joint><joint name="left_arm_attach" type="fixed"><child link="base_link1" /><parent link="carzero_Link" /><origin xyz="0 0.0 0" rpy="0 0 0" /></joint> </robot>

整个代码的逻辑就是将两台UR机械臂的URDF与移动底盘的URDF整合到一起,需要注意的三个地方是
1、因为两个UR3e机械臂的URDF模型在同一个文件下,所以需要重命名第二个机械臂的所以关节和连杆的名称,避免重复。我把左臂所有关节和连杆名称的后面都加了一个1,左臂代码为520-768行;右臂代码为1-358行;移动底盘代码360-511行

2、除了简单的将三部分的urdf复制到一起,我还额外创建了两个关节,用于连接左臂和移动底盘、以及连接右臂和移动底盘。
以右臂为例,具体为:

  <joint name="right_arm_attach" type="fixed"><child link="base_link" /><parent link="carzero2_Link" /><origin xyz="0 0.0 0" rpy="0 0 0" /></joint> 

3、如果报错Failed to find root link: Two root links found: [base_link1] and [carbase_link]
那是因为:robot_state_publisher在处理URDF时发现两个根链接(base_link和carbase_link),导致无法构建TF树。ROS要求URDF只有一个根链接(即没有父链接的链接),否则会报“Failed to find root link”错误。
所以第2步就是解决办法,新建一个关节,将机械臂的base_link与小车的carzero2_Link串联到一起。

三、RViz可视化

单臂可视化:

cd UR_ws
source devel/setup.bash
roslaunch ur_description view_ur3e.launch

双臂可视化:

cd UR_ws
source devel/setup.bash
roslaunch ur_description display.launch

其中display.launch完整代码如下:

<launch><argname="model" /><paramname="robot_description"textfile="$(find ur_description)/urdf/mobiledualarm.urdf" /><nodename="joint_state_publisher_gui"pkg="joint_state_publisher_gui"type="joint_state_publisher_gui" /><nodename="robot_state_publisher"pkg="robot_state_publisher"type="robot_state_publisher" /><nodename="rviz"pkg="rviz"type="rviz"args="-d $(find ur_description)/urdf.rviz" />
</launch>

四、效果展示

在这里插入图片描述

五、模块化方法(供参考)

这里我重建创建了一个工作空间:DualUR_ws

六、在URDF中给UR机械臂添加robotiq—85夹爪

夹爪相关程序下载链接:https://github.com/ros-industrial/robotiq
我是把所有的URDF集成到一起了。

1、将robotiq—85的xacro转为URDF
2、仔细分析各个关节和连杆的关系
3、在末端执行器的中间添加一个虚拟坐标系
<!--right endeffector coordinate--><link name="endeffector"/><joint name="endeffector_tool" type="fixed"><origin rpy="0 0 0" xyz="0 0 0.15"/><parent link="tool0"/><child link="endeffector"/></joint>
4、效果展示

在这里插入图片描述
图中姿态对应的关节角度为:
在这里插入图片描述


http://www.mrgr.cn/news/100224.html

相关文章:

  • 【MySQL】MySQL索引与事务
  • 【计算机视觉】CV实战项目 - 基于YOLOv5的人脸检测与关键点定位系统深度解析
  • 张 LLM提示词拓展16中方式
  • 【中级软件设计师】函数调用 —— 传值调用和传地址调用 (附软考真题)
  • 【计算机视觉】CV实践项目- 基于PaddleSeg的遥感建筑变化检测全解析:从U-Net 3+原理到工程实践
  • Python-Agent调用多个Server-FastAPI版本
  • 小刚说C语言刷题——1565成绩(score)
  • Lesar: 面向 Lustre/Scade 语言的形式化模型检测工具
  • Nginx 反向代理,啥是“反向代理“啊,为啥叫“反向“代理?而不叫“正向”代理?
  • 语音合成之五语音合成中的“一对多”问题主流模型解决方案分析
  • 新!在 podman-machine-default 中安装 CUDA、cuDNN、Anaconda、PyTorch 等并验证安装
  • MiniMind模型的web交互功能初试
  • C# 综合示例 库存管理系统7 主界面(FormMain)
  • Shell脚本-for循环应用案例
  • 链表系列一>两两交换链表中的结点
  • Android Studio开发中Application和Activity生命周期详解
  • wordpress1
  • 如何实现Android屏幕和音频采集并启动RTSP服务?
  • 7.11 Python CLI开发实战:API集成与异步处理核心技术解析
  • github把自己的jar包发送到maven中央仓库