我是靠谱客的博主 清脆烧鹅,最近开发中收集的这篇文章主要介绍Moveit +Gazebo:搭建单臂机械臂仿真平台准备urdf/xacro文件Moveit setup assitant的配置controller的配置launch文件的编写,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

环境:Ubuntu20.04 ros-noetic

先放上效果展示:

 

 首先要先安装ROS 和 Moveit,ROS的安装就不说了,Moeit的安装参看官网教程

Getting Started — moveit_tutorials Noetic documentation

安装过程中,用到了命令:

rosdep update

最好在安装的时候能够科学上网

搭建单臂仿真平台主要分为4大步

        1.准备urdf/xacro文件

        2.通过moveit setup assistant进行配置

        3.controller的配置

        4.launch文件的编写

准备urdf/xacro文件

这里我采用了 panda机械臂的功能包,首先进行该功能包的安装,通过命令:

sudo apt install ros-noetic-franka-description

        安装好之后呢就可以在目录/opt/ros/noetic/share/franka_description下找到要用的panda机械臂模型的xacro相关文件,这里在进行第二步之前呢,还需要对panda机械臂的xacro文件进行一点点修改,修改的目的主要是使模型具有gazebo仿真的相关标签和数据,这里可以直接使用我修改完成的。(需要安装franka-description包)

建议在moveit的工作空间下,新建一个功能包放置相关文件,比如

我在 moveit_ws/src下新建了panda_dual_arms的功能包,在panda_dual_arms/robot_description下放置了下面的模型文件left_arm.urdf

<?xml version="1.0" ?>
<robot name="left_arm">
  <link name="world"/>
  <joint name="left_base_to_world" type="fixed">
    <parent link="world"/>
    <child link="left_base"/>
    <origin rpy="0 0 0" xyz="0 0 0"/>
  </joint>
  <link name="left_base"/>
  <joint name="left_arm_joint_base" type="fixed">
    <parent link="left_base"/>
    <child link="left_arm_link0"/>
    <origin rpy="0 0 0" xyz="0 0 0"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link0">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link0.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link0.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="-0.041018 -0.00014 0.049974"/>
      <mass value="0.629769"/>
      <inertia ixx="0.00315" ixy="8.2904e-07" ixz="0.00015" iyy="0.00388" iyz="8.2299e-06" izz="0.004285"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link0_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link0_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link0"/>
    <child link="left_arm_link0_sc"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link1">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link1.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link1.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="0.003875 0.002081 -0.04762"/>
      <mass value="4.970684"/>
      <inertia ixx="0.70337" ixy="-0.000139" ixz="0.006772" iyy="0.70661" iyz="0.019169" izz="0.009117"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link1_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link1_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link1"/>
    <child link="left_arm_link1_sc"/>
  </joint>
  <joint name="left_arm_joint1" type="revolute">
    <origin rpy="0 0 0" xyz="0 0 0.333"/>
    <parent link="left_arm_link0"/>
    <child link="left_arm_link1"/>
    <axis xyz="0 0 1"/>
    <limit effort="87.0" lower="-2.8973" upper="2.8973" velocity="2.175"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.8973" soft_upper_limit="2.8973"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link2">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link2.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link2.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="-0.003141 -0.02872  0.003495"/>
      <mass value="0.646926"/>
      <inertia ixx="0.007962" ixy="-0.003925" ixz="0.010254" iyy="0.02811" iyz="0.000704" izz="0.025995"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link2_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link2_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link2"/>
    <child link="left_arm_link2_sc"/>
  </joint>
  <joint name="left_arm_joint2" type="revolute">
    <origin rpy="-1.5707963267948966 0 0" xyz="0 0 0"/>
    <parent link="left_arm_link1"/>
    <child link="left_arm_link2"/>
    <axis xyz="0 0 1"/>
    <limit effort="87.0" lower="-1.7628" upper="1.7628" velocity="2.175"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-1.7628" soft_upper_limit="1.7628"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link3">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link3.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link3.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="2.7518e-02 3.9252e-02 -6.6502e-02"/>
      <mass value="3.228604"/>
      <inertia ixx="0.037242" ixy="-0.004761" ixz="-0.011396" iyy="0.036155" iyz="-0.012805" izz="0.01083"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link3_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link3_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link3"/>
    <child link="left_arm_link3_sc"/>
  </joint>
  <joint name="left_arm_joint3" type="revolute">
    <origin rpy="1.5707963267948966 0 0" xyz="0 -0.316 0"/>
    <parent link="left_arm_link2"/>
    <child link="left_arm_link3"/>
    <axis xyz="0 0 1"/>
    <limit effort="87.0" lower="-2.8973" upper="2.8973" velocity="2.175"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.8973" soft_upper_limit="2.8973"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link4">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link4.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link4.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="-5.317e-02 1.04419e-01 2.7454e-02"/>
      <mass value="3.587895"/>
      <inertia ixx="0.025853" ixy="0.007796" ixz="-0.001332" iyy="0.019552" iyz="0.008641" izz="0.028323"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link4_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link4_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link4"/>
    <child link="left_arm_link4_sc"/>
  </joint>
  <joint name="left_arm_joint4" type="revolute">
    <origin rpy="1.5707963267948966 0 0" xyz="0.0825 0 0"/>
    <parent link="left_arm_link3"/>
    <child link="left_arm_link4"/>
    <axis xyz="0 0 1"/>
    <limit effort="87.0" lower="-3.0718" upper="-0.0698" velocity="2.175"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-3.0718" soft_upper_limit="-0.0698"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link5">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link5.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link5.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="-1.1953e-02 4.1065e-02 -3.8437e-02"/>
      <mass value="1.225946"/>
      <inertia ixx="0.035549" ixy="-0.002117" ixz="-0.004037" iyy="0.029474" iyz="0.000229" izz="0.008627"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link5_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link5_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link5"/>
    <child link="left_arm_link5_sc"/>
  </joint>
  <joint name="left_arm_joint5" type="revolute">
    <origin rpy="-1.5707963267948966 0 0" xyz="-0.0825 0.384 0"/>
    <parent link="left_arm_link4"/>
    <child link="left_arm_link5"/>
    <axis xyz="0 0 1"/>
    <limit effort="12.0" lower="-2.8973" upper="2.8973" velocity="2.61"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.8973" soft_upper_limit="2.8973"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link6">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link6.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link6.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="6.0149e-02 -1.4117e-02 -1.0517e-02"/>
      <mass value="1.666555"/>
      <inertia ixx="0.001964" ixy="0.000109" ixz="-0.001158" iyy="0.004354" iyz="0.000341" izz="0.005433"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link6_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link6_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_link6"/>
    <child link="left_arm_link6_sc"/>
  </joint>
  <joint name="left_arm_joint6" type="revolute">
    <origin rpy="1.5707963267948966 0 0" xyz="0 0 0"/>
    <parent link="left_arm_link5"/>
    <child link="left_arm_link6"/>
    <axis xyz="0 0 1"/>
    <limit effort="12.0" lower="-0.0175" upper="3.7525" velocity="2.61"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-0.0175" soft_upper_limit="3.7525"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_link7">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/link7.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/link7.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="1.0517e-02 -4.252e-03 6.1597e-02"/>
      <mass value="0.735522"/>
      <inertia ixx="0.012516" ixy="-0.000428" ixz="-0.001196" iyy="0.010027" iyz="-0.000741" izz="0.004815"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_link7_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_link7_sc_joint" type="fixed">
    <origin rpy="0 0 0.7853981633974483"/>
    <parent link="left_arm_link7"/>
    <child link="left_arm_link7_sc"/>
  </joint>
  <joint name="left_arm_joint7" type="revolute">
    <origin rpy="1.5707963267948966 0 0" xyz="0.088 0 0"/>
    <parent link="left_arm_link6"/>
    <child link="left_arm_link7"/>
    <axis xyz="0 0 1"/>
    <limit effort="12.0" lower="-2.8973" upper="2.8973" velocity="2.61"/>
    <safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-2.8973" soft_upper_limit="2.8973"/>
    <dynamics D="1" K="7000" damping="0.003" friction="0.0" mu_coulomb="0" mu_viscous="16"/>
  </joint>
  <link name="left_arm_link8"/>
  <joint name="left_arm_joint8" type="fixed">
    <origin rpy="0 0 0" xyz="0 0 0.107"/>
    <parent link="left_arm_link7"/>
    <child link="left_arm_link8"/>
  </joint>
  <joint name="left_arm_hand_joint" type="fixed">
    <parent link="left_arm_link8"/>
    <child link="left_arm_hand"/>
    <origin rpy="0 0 -0.7853981633974483" xyz="0 0 0"/>
  </joint>
  <!-- sub-link defining detailed meshes for collision with environment -->
  <link name="left_arm_hand">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/hand.dae"/>
      </geometry>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://franka_description/meshes/collision/hand.stl"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="-0.01 0 0.03"/>
      <mass value="0.73"/>
      <inertia ixx="0.001" ixy="0" ixz="0" iyy="0.0025" iyz="0" izz="0.0017"/>
    </inertial>
  </link>
  <!-- sub-link defining coarse geometries of real robot's internal self-collision -->
  <link name="left_arm_hand_sc">
  </link>
  <!-- fixed joint between both sub-links -->
  <joint name="left_arm_hand_sc_joint" type="fixed">
    <origin rpy="0 0 0"/>
    <parent link="left_arm_hand"/>
    <child link="left_arm_hand_sc"/>
  </joint>
  <!-- Define the hand_tcp frame -->
  <link name="left_arm_hand_tcp"/>
  <joint name="left_arm_hand_tcp_joint" type="fixed">
    <origin rpy="0 0 0" xyz="0 0 0.1034"/>
    <parent link="left_arm_hand"/>
    <child link="left_arm_hand_tcp"/>
  </joint>
  <link name="left_arm_leftfinger">
    <visual>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/finger.dae"/>
      </geometry>
    </visual>
    <!-- screw mount -->
    <collision>
      <origin rpy="0 0 0" xyz="0 18.5e-3 11e-3"/>
      <geometry>
        <box size="22e-3 15e-3 20e-3"/>
      </geometry>
    </collision>
    <!-- cartriage sledge -->
    <collision>
      <origin rpy="0 0 0" xyz="0 6.8e-3 2.2e-3"/>
      <geometry>
        <box size="22e-3 8.8e-3 3.8e-3"/>
      </geometry>
    </collision>
    <!-- diagonal finger -->
    <collision>
      <origin rpy="0.5235987755982988 0 0" xyz="0 15.9e-3 28.35e-3"/>
      <geometry>
        <box size="17.5e-3 7e-3 23.5e-3"/>
      </geometry>
    </collision>
    <!-- rubber tip with which to grasp -->
    <collision>
      <origin rpy="0 0 0" xyz="0 7.58e-3 45.25e-3"/>
      <geometry>
        <box size="17.5e-3 15.2e-3 18.5e-3"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <mass value="0.015"/>
      <inertia ixx="2.3749999999999997e-06" ixy="0" ixz="0" iyy="2.3749999999999997e-06" iyz="0" izz="7.5e-07"/>
    </inertial>
  </link>
  <link name="left_arm_rightfinger">
    <visual>
      <origin rpy="0 0 3.141592653589793" xyz="0 0 0"/>
      <geometry>
        <mesh filename="package://franka_description/meshes/visual/finger.dae"/>
      </geometry>
    </visual>
    <!-- screw mount -->
    <collision>
      <origin rpy="0 0 0" xyz="0 -18.5e-3 11e-3"/>
      <geometry>
        <box size="22e-3 15e-3 20e-3"/>
      </geometry>
    </collision>
    <!-- cartriage sledge -->
    <collision>
      <origin rpy="0 0 0" xyz="0 -6.8e-3 2.2e-3"/>
      <geometry>
        <box size="22e-3 8.8e-3 3.8e-3"/>
      </geometry>
    </collision>
    <!-- diagonal finger -->
    <collision>
      <origin rpy="-0.5235987755982988 0 0" xyz="0 -15.9e-3 28.35e-3"/>
      <geometry>
        <box size="17.5e-3 7e-3 23.5e-3"/>
      </geometry>
    </collision>
    <!-- rubber tip with which to grasp -->
    <collision>
      <origin rpy="0 0 0" xyz="0 -7.58e-3 45.25e-3"/>
      <geometry>
        <box size="17.5e-3 15.2e-3 18.5e-3"/>
      </geometry>
    </collision>
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <mass value="0.015"/>
      <inertia ixx="2.3749999999999997e-06" ixy="0" ixz="0" iyy="2.3749999999999997e-06" iyz="0" izz="7.5e-07"/>
    </inertial>
  </link>
  <joint name="left_arm_finger_joint1" type="prismatic">
    <parent link="left_arm_hand"/>
    <child link="left_arm_leftfinger"/>
    <origin rpy="0 0 0" xyz="0 0 0.0584"/>
    <axis xyz="0 1 0"/>
    <limit effort="100" lower="0.0" upper="0.04" velocity="0.2"/>
    <dynamics damping="0.3"/>
  </joint>
  <joint name="left_arm_finger_joint2" type="prismatic">
    <parent link="left_arm_hand"/>
    <child link="left_arm_rightfinger"/>
    <origin rpy="0 0 0" xyz="0 0 0.0584"/>
    <axis xyz="0 -1 0"/>
    <limit effort="100" lower="0.0" upper="0.04" velocity="0.2"/>
    <mimic joint="left_arm_finger_joint1"/>
    <dynamics damping="0.3"/>
  </joint>

  <gazebo reference="left_arm_joint1">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint1_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint1">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint1_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_joint2">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint2_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint2">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint2_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_joint3">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint3_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint3">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint3_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_joint4">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint4_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint4">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint4_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_joint5">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint5_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint5">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint5_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_joint6">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint6_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint6">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint6_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_joint7">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_joint7_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_joint7">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_joint7_motor">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>


  <gazebo reference="left_arm_finger_joint1">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_finger_joint1_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_finger_joint1">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_finger_joint1_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo reference="left_arm_finger_joint2">
    <!-- Needed for ODE to output external wrenches on joints -->
    <provideFeedback>true</provideFeedback>
  </gazebo>
  <transmission name="left_arm_finger_joint2_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_arm_finger_joint2">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_arm_finger_joint2_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <!-- load ros_control plugin -->
  <gazebo>
    <plugin filename="libgazebo_ros_control.so" name="gazebo_ros_control"/>
      <robotNamespace>/left_arm</robotNamespace>
  </gazebo>
</robot>

Moveit setup assitant的配置

详细的配置介绍和过程参考官方教程:MoveIt Setup Assistant — moveit_tutorials Noetic documentation

        这里我贴上我的配置过程,进行了自碰撞矩阵、规划组、姿态、末端执行器的配置,关于虚拟关节和被动关节以及控制器的环节跳过即可。

自碰撞矩阵,按照默认情况生成即可

规划组分为arm和hand 两个组,arm组名我这里是:left_arm添加如图下所示的joint,hand是:left_hand,添加如图下所示的links

这里我还配置了几个pose,主要方便后期的编程,各个pose包含的关节值:

ready:{0.0, -0.785, 0.0, -2.356, 0.0, 1.571, 0.785}.

open:0.035

close:0.0

 最后就是定义的末端执行器

 完成后会得到一个 我命名为 left_arm_moveit_config的功能包

在工作空间下重新 catkin build 并 source

通过命令 roslaunch left_arm_moveit_config demo.launch能够运行,并且能够通过rviz对及机械臂进行规划则没有问题。

controller的配置

首先是joint_state_controller,主要作用是发布机器人的关节状态和TF变换

在panda_dual_arms/config 下创建 joint_state_controller.yaml

joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50

然后是trajectory_controller,Moveit完成运动规划后输出接口是一个命名为FollowJointTrajectory的action,其中包含一系列规划好的路径点轨迹,Trajectory Controller的作用就是将这些信息转化成Gzebo中机器人需要输入的joint位置。

在panda_dual_arms/config trajectory_controller.yaml

left_arm_trajectory_controller:
    type: "position_controllers/JointTrajectoryController"
    joints:
        - left_arm_joint1
        - left_arm_joint2
        - left_arm_joint3
        - left_arm_joint4
        - left_arm_joint5
        - left_arm_joint6
        - left_arm_joint7
    constraints:
        goal_time: 0.6
        stopped_velocity_tolerance: 0.05
        left_arm_joint1: {trajectory: 0.1, goal: 0.1}
        left_arm_joint2: {trajectory: 0.1, goal: 0.1}
        left_arm_joint3: {trajectory: 0.1, goal: 0.1}
        left_arm_joint4: {trajectory: 0.1, goal: 0.1}
        left_arm_joint5: {trajectory: 0.1, goal: 0.1}
        left_arm_joint6: {trajectory: 0.1, goal: 0.1}
        left_arm_joint7: {trajectory: 0.1, goal: 0.1}
    stop_trajectory_duration: 0.5
    state_publish_rate:  25
    action_monitor_rate: 10

#notice that the grippers joint2 mimics joint1
#this is why it is not listed under the hand controllers

left_hand_controller:
    type: "effort_controllers/JointTrajectoryController"
    joints:
        - left_arm_finger_joint1
    gains:
        left_arm_finger_joint1:  {p: 50.0, d: 1.0, i: 0.01, i_clamp: 1.0}

launch文件的编写

launch文件的个部分内容都有注释,主要就是启动gazebo,启动moveit,启动上面的controller,启动rviz

<?xml version="1.0"?>
<launch>
        <!-- Run the main MoveIt executable with trajectory execution -->
        <include file="$(find left_arm_moveit_config)/launch/move_group.launch">
            <arg name="allow_trajectory_execution" value="true" />
            <arg name="moveit_controller_manager" value="ros_control" />
            <arg name="fake_execution_type" value="interpolate" />
            <arg name="info" value="true" />
            <arg name="debug" value="false" />
            <arg name="pipeline" value="ompl" />
            <arg name="load_robot_description" value="true" />
        </include>

    <!-- Launch empty Gazebo world -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="use_sim_time" value="true" />
        <arg name="gui" value="true" />
        <arg name="paused" value="false" />
        <arg name="debug" value="false" />
    </include>

        <param name="robot_description" command="$(find xacro)/xacro  '$(find panda_dual_arms)/robot_description/left_arm.urdf'" />
        <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen" args="-urdf -param robot_description -model left_arm" />

        <!-- Robot state publisher -->
        <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
            <param name="publish_frequency" type="double" value="50.0" />
            <param name="tf_prefix" type="string" value="" />
        </node>
        <!-- Joint state controller -->
        <rosparam file="$(find panda_dual_arms)/config/left_arm_joint_state_controller.yaml" command="load" />
        <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner"  args="joint_state_controller" respawn="false" output="screen" />

        <!-- Joint trajectory controller -->
        <rosparam file="$(find panda_dual_arms)/config/left_arm_trajectory_controller.yaml" command="load" />
        <node name="arms_trajectory_controller_spawner" pkg="controller_manager" type="spawner"  respawn="false" output="screen"  args="left_arm_trajectory_controller left_hand_controller" />
    
        <!-- Start moveit_rviz with the motion planning plugin -->
        <include file="$(find left_arm_moveit_config)/launch/moveit_rviz.launch">
            <arg name="rviz_config" value="$(find left_arm_moveit_config)/launch/moveit.rviz" />
        </include>
</launch>

参考:Multiple Robot Arms — moveit_tutorials Noetic documentation

最后

以上就是清脆烧鹅为你收集整理的Moveit +Gazebo:搭建单臂机械臂仿真平台准备urdf/xacro文件Moveit setup assitant的配置controller的配置launch文件的编写的全部内容,希望文章能够帮你解决Moveit +Gazebo:搭建单臂机械臂仿真平台准备urdf/xacro文件Moveit setup assitant的配置controller的配置launch文件的编写所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部