机械臂的组装——eye_in_hand

需求

使用大象机械臂,组装一个带有夹抓的机械臂带摄像头的

示例

在这里插入图片描述

代码实现

文件结构:
在这里插入图片描述

  • 280_pi带相机法兰部分:
<?xml version="1.0"?>
<robot  xmlns:xacro="http://www.ros.org/wiki/xacro" name="firefighter" >
	
<xacro:property name="width" value=".2" />


  <link name="g_base">
    <visual>
      <geometry>
        <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/G_base.dae"/>
      </geometry>
      <origin xyz = "0.0 0 -0.03" rpy = "0 0 1.5708"/>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/G_base.dae"/>
      </geometry>
      <origin xyz = "0.0 0 -0.03" rpy = "0 0 1.5708"/>
    </collision>
  </link>

  <link name="pump_box">
    <visual>
      <geometry>
        <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/pump_box.dae"/>
      </geometry>
      <origin xyz = "0.0 -0.15 -0.0" rpy = "1.5708 3.14159 0"/>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/pump_box.dae"/>
      </geometry>
      <origin xyz = "0.0 0 -0.03" rpy = "0 0 1.5708"/>
    </collision>
  </link>

  <link name="joint1">
    <visual>
      <geometry>
	     <!--- 0.0 0 -0.04  1.5708 3.14159-->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint1_pi.dae"/>
      </geometry>
    <origin xyz = "0.0 0 0 " rpy = " 0 0 0"/>
    </visual>
    <collision>
      <geometry>
	     <!--- 0.0 0 -0.04  1.5708 3.14159-->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint1_pi.dae"/>
      </geometry>
    <origin xyz = "0.0 0 0 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="joint2">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint2.dae"/>
      </geometry>
    <origin xyz = "0.0 0 -0.06096 " rpy = " 0 0 -1.5708"/>
    </visual>
      <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint2.dae"/>
      </geometry>
    <origin xyz = "0.0 0 -0.06096 " rpy = " 0 0 -1.5708"/>
    </collision>
  </link>


  <link name="joint3">
    <visual>
      <geometry>
       
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint3.dae"/>
      </geometry>
    <origin xyz = "0.0 0 0.03256 " rpy = " 0 -1.5708 0"/>
    </visual>
      <collision>
        <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint3.dae"/>
      </geometry>
    <origin xyz = "0.0 0 0.03256 " rpy = " 0 -1.5708 0"/>
    </collision>
  </link>


  <link name="joint4">
    <visual>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint4.dae"/>
      </geometry>
    <origin xyz = "0.0 0 0.03056 " rpy = " 0 -1.5708 0"/>
    </visual>
      <collision>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint4.dae"/>
      </geometry>
    <origin xyz = "0.0 0 0.03056 " rpy = " 0 -1.5708 0"/>
    </collision>
  </link>




<link name="joint5">
    <visual>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint5.dae"/>
      </geometry>
    <origin xyz = "0.0 0 -0.03356 " rpy = " 0 -1.5708 1.5708"/>
    </visual>
      <collision>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint5.dae"/>
      </geometry>
    <origin xyz = "0.0 0 -0.03356 " rpy = " 0 -1.5708 1.5708"/>
    </collision>
  </link>


  <link name="joint6">
    <visual>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint6.dae"/>
      </geometry>
    <origin xyz = "0 0.00 -0.038 " rpy = " 0 0 0"/>
    </visual>
      <collision>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint6.dae"/>
      </geometry>
    <origin xyz = "0 0.00 -0.038 " rpy = " 0 0 0"/>
    </collision>
  </link>


  <link name="joint6_flange">
    <visual>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint7.dae"/>
      </geometry>
    <origin xyz = "0.0 0 -0.012 " rpy = " 0 0 0"/>
    </visual>
      <collision>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/joint7.dae"/>
      </geometry>
    <origin xyz = "0.0 0 -0.012 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="camera_flange">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/camera_flange.dae"/>
      </geometry>
    <origin xyz = "0.024 -0.008 0.0 " rpy = " 0 3.14159 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/camera_flange.dae"/>
      </geometry>
    <origin xyz = "0.024 -0.008 0.0 " rpy = " 0 3.14159 0"/>
    </collision>
  </link>

  <link name="pump_head">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/pump_head.dae"/>
      </geometry>
    <origin xyz = "0.0 0.008 0.009 " rpy = " 1.5708 0 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_pi/pump_head.dae"/>
      </geometry>
    <origin xyz = "0.0 0.008 0.009 " rpy = " 1.5708 0 0"/>
    </collision>
  </link>



  <joint name="g_base_to_joint1" type="fixed">
    <axis xyz="0 0 0"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="g_base"/>
    <child link="joint1"/>
    <origin xyz= "0 0 0" rpy = "0 0 0"/>  
  </joint>

  <joint name="g_base_to_pump_box" type="fixed">
    <axis xyz="0 0 0"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="g_base"/>
    <child link="pump_box"/>
    <origin xyz= "0 0 0" rpy = "0 0 0"/>  
  </joint>

  <joint name="joint2_to_joint1" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="joint1"/>
    <child link="joint2"/>
    <origin xyz= "0 0 0.13956" rpy = "0 0 0"/>  
  </joint>


  <joint name="joint3_to_joint2" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="joint2"/>
    <child link="joint3"/>
    <origin xyz= "0 0 -0.001" rpy = "0 1.5708 -1.5708"/>  
  </joint>


  <joint name="joint4_to_joint3" type="revolute">
    <axis xyz=" 0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="joint3"/>
    <child link="joint4"/>
    <origin xyz= "  -0.1104 0 0   " rpy = "0 0 0"/>  
  </joint>


  <joint name="joint5_to_joint4" type="revolute">
    <axis xyz=" 0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="joint4"/>
    <child link="joint5"/>
    <origin xyz= "-0.096 0 0.06462" rpy = "0 0 -1.5708"/>  
  </joint>

  <joint name="joint6_to_joint5" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="joint5"/>
    <child link="joint6"/>
    <origin xyz= "0 -0.07318 0" rpy = "1.5708 -1.5708 0"/>  
  </joint>

  <joint name="joint6output_to_joint6" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/>
    <parent link="joint6"/>
    <child link="joint6_flange"/>
    <origin xyz= "0 0.0456 0" rpy = "-1.5708 0 0"/>  
  </joint>

  <joint name="joint6output_to_camera_flange" type="fixed">
    <!-- <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/> -->
    <parent link="joint6_flange"/>
    <child link="camera_flange"/>
    <!-- <origin xyz= "0 0.0 0" rpy = "-1.5708 0 0"/>   -->
    <origin xyz= "0 0 0.01" rpy = "1.579 0 0"/>  
  </joint>

  <joint name="joint6output_to_pump_head" type="fixed">
    <!-- <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-3.14" upper = "3.14159" velocity = "0"/> -->
    <parent link="camera_flange"/>
    <child link="pump_head"/>
    <!-- <origin xyz= "0 0.0 0" rpy = "-1.5708 0 0"/>   -->
    <origin xyz= "0 0 0.01" rpy = "-1.579 0 0"/>  
  </joint>

</robot>


  • 相机部分
<!-- 摄像头相关的 xacro 文件 -->
<robot name="my_camera" xmlns:xacro="http://wiki.ros.org/xacro">
    <!-- 摄像头属性 -->
    <xacro:property name="camera_length" value="0.01" /> <!-- 摄像头长度(x) -->
    <xacro:property name="camera_width" value="0.025" /> <!-- 摄像头宽度(y) -->
    <xacro:property name="camera_height" value="0.025" /> <!-- 摄像头高度(z) -->
    <xacro:property name="camera_x" value="0.05" /> <!-- 摄像头安装的x坐标 -->
    <xacro:property name="camera_y" value="0.005" /> <!-- 摄像头安装的y坐标 -->
    <xacro:property name="camera_z" value="0" /> <!-- 摄像头安装的z坐标:底盘高度 / 2 + 摄像头高度 / 2  -->

    <!-- 摄像头关节以及link -->
    <link name="camera">
        <visual>
            <geometry>
                <box size="${camera_length} ${camera_width} ${camera_height}" />
            </geometry>
            <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
            
        </visual>
    </link>

    <joint name="camera2camera_flange" type="fixed">
        <parent link="camera_flange" />
        <child link="camera" />
        <origin xyz="${camera_x} ${camera_y} ${camera_z}" />
    </joint>
</robot>
  • 自适应夹抓部分
<?xml version="1.0"?>
<robot  xmlns:xacro="http://www.ros.org/wiki/xacro" name="firefighter" >
	
<xacro:property name="width" value=".2" />



<!-- ===================link======================================= -->
  <link name="gripper_base">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_base.dae"/>
      </geometry>
    <origin xyz = "0.0 0.0077 -0.012" rpy = " 0 0 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_base.dae"/>
      </geometry>
    <origin xyz = "0.0 0.0077 -0.012 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="gripper_left1">
    <visual>
      <geometry>
       <!--- 0.0 0 -0.04 -->
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_left1.dae"/>
      </geometry>
    <origin xyz = "0.039 -0.0133 -0.012 " rpy = " 0 0 0"/>
    <!-- <origin xyz = "0.0 0 -0.012 " rpy = " 0 0 0"/> -->
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_left1.dae"/>
      </geometry>
        <origin xyz = "-0.039 -0.0133 -0.012 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="gripper_left2">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_left2.dae"/>
      </geometry>
    <origin xyz = "0.005 -0.0195 -0.012 " rpy = " 0 0 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_left2.dae"/>
      </geometry>
        <origin xyz = "-0.005 -0.0195 -0.012 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="gripper_left3">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_left3.dae"/>
      </geometry>
    <origin xyz = "0.012 0.0025 -0.012 " rpy = " 0 0 0"/>
    <!-- <origin xyz = "0.0 0 0 " rpy = " 0 0 0"/> -->

    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_left3.dae"/>
      </geometry>
    <origin xyz = "0.012 0.0025 -0.012" rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="gripper_right1">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_right1.dae"/>
      </geometry>
    <origin xyz = "-0.039 -0.0133 -0.012 " rpy = " 0 0 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_right1.dae"/>
      </geometry>
        <origin xyz = "-0.039 -0.0133 -0.012 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="gripper_right2">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_right2.dae"/>
      </geometry>
    <origin xyz = "-0.005 -0.0195 -0.012 " rpy = " 0 0 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_right2.dae"/>
      </geometry>
        <origin xyz = "-0.005 -0.0195 -0.012 " rpy = " 0 0 0"/>
    </collision>
  </link>

  <link name="gripper_right3">
    <visual>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_right3.dae"/>
      </geometry>
    <origin xyz = "-0.012 0.0025 -0.012 " rpy = " 0 0 0"/>
    </visual>
    <collision>
      <geometry>
       <mesh filename="package://mycobot_description/urdf/mycobot_280_m5/gripper_right3.dae"/>
      </geometry>
    <origin xyz = "-0.012 0.0025 -0.012" rpy = " 0 0 0"/>
    </collision>
  </link>

<!-- ==============================joint====================================== -->
  <joint name="grisp2camera_flange" type="fixed">
        <parent link="camera_flange" />
        <child link="gripper_base" />
        <origin xyz="0 0.031 0" rpy="0  1.57 0" />
  </joint>
  
  <joint name="gripper_controller" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-0.7" upper = "0.15" velocity = "0"/>
    <parent link="gripper_base"/>
    <child link="gripper_left3"/>
    <origin xyz= "-0.012 0.005 0" rpy = "0 0 0"/> 
  </joint>

  <joint name="gripper_base_to_gripper_left2" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-0.8" upper = "0.5" velocity = "0"/>
    <parent link="gripper_base"/>
    <child link="gripper_left2"/>
    <origin xyz= "-0.005 0.027 0" rpy = "0 0 0"/> 
    <mimic joint="gripper_controller" multiplier="1.0" offset="0" />
  </joint>

  <joint name="gripper_left3_to_gripper_left1" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-0.5" upper = "0.5" velocity = "0"/>
    <parent link="gripper_left3"/>
    <child link="gripper_left1"/>
    <origin xyz= "-0.027 0.016 0" rpy = "0 0 0"/> 
    <mimic joint="gripper_controller" multiplier="-1.0" offset="0" />
  </joint>

  <joint name="gripper_base_to_gripper_right3" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-0.15" upper = "0.7" velocity = "0"/>
    <parent link="gripper_base"/>
    <child link="gripper_right3"/>
    <origin xyz= "0.012 0.005 0" rpy = "0 0 0"/> 
    <mimic joint="gripper_controller" multiplier="-1.0" offset="0" />
  </joint>

  <joint name="gripper_base_to_gripper_right2" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-0.5" upper = "0.8" velocity = "0"/>
    <parent link="gripper_base"/>
    <child link="gripper_right2"/>
    <origin xyz= "0.005 0.027 0" rpy = "0 0 0"/> 
    <mimic joint="gripper_controller" multiplier="-1.0" offset="0" />
  </joint>

  <joint name="gripper_right3_to_gripper_right1" type="revolute">
    <axis xyz="0 0 1"/>
    <limit effort = "1000.0" lower = "-0.5" upper = "0.5" velocity = "0"/>
    <parent link="gripper_right3"/>
    <child link="gripper_right1"/>
    <origin xyz= "0.027 0.016 0" rpy = "0 0 0"/> 
    <mimic joint="gripper_controller" multiplier="1.0" offset="0" />
  </joint>

</robot>


*顶层xacro文件组合部分


<!-- 组合带摄像头法兰的机械臂、摄像头、夹抓 -->
<robot name="arm_with_camera" xmlns:xacro="http://wiki.ros.org/xacro">

        <!-- 摄像头模块 -->
    <xacro:include filename="model_01_camera.xacro" />

            <!-- 带摄像头法兰的机械臂 -->
    <xacro:include filename="model_02_mycobot_280.xacro" />

            <!-- 夹抓模块 -->
    <xacro:include filename="model_03_grisp.xacro" />

           
</robot>
  • launch文件

<launch>
    <!-- 使用xacro进行组装 -->
    <!--模型加载-->

    <param name="robot_description" command="$(find xacro)/xacro $(find urdf_learn)/urdf/top.xacro" />

    


    <!--关节状态节点发布-->
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
    <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" />

    <!--机器人状态发布-->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>

    <!--rvize 节点-->
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find mycobot_description)/launch/default.rviz" />

</launch>

总结

再机械臂上加入夹抓等模块,关键注意其位置即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值