Moveit+Rviz+Gazebo机械臂仿真流程(踩坑记录)

概要

前期准备: 在Ubuntu20.04 与 noetic版本的ros中,反复试验好几天,还是没办法使gazebo动起来,采取以下版本,成功仿真

工具版本
Ubuntu18.04
Rosmelodic
ur3urdf
moveit功能包

整体流程

架构图

基于机械臂urdf文件生成xxx_moveit_config功能包,主要配置好三个部分即可完成仿真: Follow joint trajectory 、 Trajectory Controller 、 Joint state controller
在这里插入图片描述

通过 move_setup_assistant 生成功能包(功能包命名格式: xxx_moveit_config)

-命令: roslaunch ur3_moveit_config setup_assistant.launch (ur3是我自己的机械臂名称,可改为自己的)

  • 这里导入了创建好的moveit配置包(应根据自己的机械臂urdf文件,新建一个配置包):
    在这里插入图片描述

  • 碰撞检测
    在这里插入图片描述

  • 虚拟关节连接地面
    在这里插入图片描述

  • 规划组(重要,后续控制器用到,这里命名为manipulator)
    在这里插入图片描述- 自定义姿势
    在这里插入图片描述

  • ROS Control(重要,忽略末端爪子、被动关节):
    在这里插入图片描述

  • simulation(自动生成一个新的urdf,含有控制器和传动装置,在ur3文件夹下创建一个test_ur3.urdf,把自动生成的新urdf复制进去):

  • 在这里插入图片描述

<?xml version="1.0" encoding="utf-8" ?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com) 
     Commit Version: 1.6.0-4-g7f85cfe  Build Version: 1.6.7995.38578
     For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot name="ur3">
    <link name="world">  </link>

    <joint name="ground" type="fixed">
 	 <parent link="world"/>
         <child link="base_link"/>
    </joint>   

    <link name="base_link">
        <inertial>
            <origin xyz="2.105E-05 0.098059 -0.0036545" rpy="0 0 0" />
            <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/base_link.STL" />
            </geometry>
            <material name="">
                <color rgba="0.89804 0.91765 0.92941 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/base_link.STL" />
            </geometry>
        </collision>
    </link>

    <link name="link1">
        <inertial>
            <origin xyz="-6.5885E-06 0.055927 0.0072937" rpy="0 0 0" />
           <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link1.STL" />
            </geometry>
            <material name="">
                <color rgba="0.79216 0.81961 0.93333 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link1.STL" />
            </geometry>
        </collision>
    </link>

    <joint name="joint1" type="revolute">
        <origin xyz="0 0 0.0844" rpy="1.5708 0 -3.1416" />
        <parent link="base_link" />
        <child link="link1" />
        <axis xyz="1 0 0" />
        <limit lower="-3.14" upper="3.14" effort="150" velocity="1" />
    </joint>

    <link name="link2">  
        <inertial>
            <origin xyz="-2.6778E-06 0.060634 0.09327" rpy="0 0 0" />
            <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link2.STL" />
            </geometry>
            <material name="">
                <color rgba="0.79216 0.81961 0.93333 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link2.STL" />
            </geometry>
        </collision>
    </link>

    <joint name="joint2" type="revolute">
        <origin xyz="0 0.0675 0.05235" rpy="1.5708 0 -3.1416" />
        <parent link="link1" />
        <child link="link2" />
        <axis xyz="1 0 0" />
        <limit lower="-3.14" upper="3.14" effort="150" velocity="1" />
    </joint>

    <link name="link3"> 
        <inertial>
            <origin xyz="-0.0050453 -0.11121 3.4154E-06" rpy="0 0 0" />
            <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>

        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link3.STL" />
            </geometry>
            <material name="">
                <color rgba="1 1 1 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link3.STL" />
            </geometry>
        </collision>
    </link>

    <joint name="joint3" type="revolute">
        <origin xyz="0 -0.02535 0.24365" rpy="-1.5708 0 -1.5708" />
        <parent link="link2" />
        <child link="link3" />
        <axis xyz="1 0 0" />
        <limit lower="-3.14" upper="3.14" effort="150" velocity="1" />
    </joint>

    <link name="link4">
        <inertial>
            <origin xyz="0.0059208 -0.0007977 2.6694E-07" rpy="0 0 0" />
            <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>

        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link4.STL" />
            </geometry>
            <material name="">
                <color rgba="1 1 1 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link4.STL" />
            </geometry>
        </collision>
    </link>

    <joint name="joint4" type="revolute">
        <origin xyz="-0.0834 -0.213 0" rpy="-3.1416 0 0" />
        <parent link="link3" />
        <child link="link4" />
        <axis xyz="1 0 0" />
        <limit lower="-3.14" upper="3.14" effort="150" velocity="1" />
    </joint>

    <link name="link5">
        
<inertial>
            <origin xyz="0.0059208 0.00079771 -2.3761E-07" rpy="0 0 0" />
            <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>

        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link5.STL" />
            </geometry>
            <material name="">
                <color rgba="1 1 1 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link5.STL" />
            </geometry>
        </collision>
    </link>
    <joint name="joint5" type="revolute">
        <origin xyz="0 0.0834 0" rpy="0 0 -1.5708" />
        <parent link="link4" />
        <child link="link5" />
        <axis xyz="1 0 0" />
        <limit lower="-3.14" upper="3.14" effort="150" velocity="1" />
    </joint>

    <link name="link6">
        
<inertial>
            <origin xyz="4.7334E-10 0.00010334 -0.021073" rpy="0 0 0" />
            <mass value="0.00001" />
            <inertia ixx="10.0" iyy="0.0" izz="0.0" ixy="10.0" ixz="0.0" iyz="10.0" />
        </inertial>

        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link6.STL" />
            </geometry>
            <material name="">
                <color rgba="1 1 1 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="package://ur3/meshes/link6.STL" />
            </geometry>
        </collision>
    </link>

    <joint name="joint6" type="revolute">
        <origin xyz="0 -0.0409 0" rpy="1.5708 0.2207 3.1416" />
        <parent link="link5" />
        <child link="link6" />
        <axis xyz="1 0 0" />
        <limit lower="-3.14" upper="3.14" effort="150" velocity="1" />
    </joint>
    
  <transmission name="trans_joint1">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="joint1">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="joint1_motor">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
    <transmission name="trans_joint2">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="joint2">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="joint2_motor">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
    <transmission name="trans_joint3">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="joint3">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="joint3_motor">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
    <transmission name="trans_joint4">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="joint4">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="joint4_motor">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
    <transmission name="trans_joint5">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="joint5">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="joint5_motor">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
    <transmission name="trans_joint6">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="joint6">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
        </joint>
        <actuator name="joint6_motor">
            <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>


    <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/</robotNamespace>
        </plugin>
    </gazebo>
</robot>
  • 工作空间文件分布
    在这里插入图片描述
  • ur3
    在这里插入图片描述
  • ur3_moveit_config
    在这里插入图片描述

roscontrollers.yaml

# Simulation settings for using moveit_sim_controllers
moveit_sim_hw_interface:
  joint_model_group: manipulator
  joint_model_group_pose: home
# Settings for ros_control_boilerplate control loop
generic_hw_control_loop:
  loop_hz: 300
  cycle_time_error_threshold: 0.01
# Settings for ros_control hardware interface
hardware_interface:
  joints:
    - joint1
    - joint2
    - joint3
    - joint4
    - joint5
    - joint6
  sim_control_mode: 1  # 0: position, 1: velocity
# Publish all joint states
# Creates the /joint_states topic necessary in ROS
# 以下是三个控制器的配置
joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 50


 # controller_lsit(控制器管理列表): 用于配置  follow_joint_trajectory 
controller_list: 
  - name: manipulator_controller      # 这里是 ros_control 控制器的名称
    action_ns: follow_joint_trajectory   # action server
    type: FollowJointTrajectory
    default: true   # moveit默认控制器
    joints:
    - joint1
    - joint2
    - joint3
    - joint4  
    - joint5
    - joint6

 # action client  ,名称与 控制器列表中的名称一一对应,才能正常通信
manipulator_controller:   
  type: position_controllers/JointTrajectoryController
  joints:
    - joint1
    - joint2
    - joint3  
    - joint4
    - joint5
    - joint6
   # pid参数设置
  /gazebo_ros_control:
   pid_gains:
    joint1:
      p: 100.0
      d: 0.01
      i: 10.0
      i_clamp: 1
    joint2:
      p: 100.0
      d: 0.01
      i: 10.0
      i_clamp: 1
    joint3:
      p: 100.0
      d: 0.01
      i: 10.0
      i_clamp: 1
    joint4:
      p: 100.0
      d: 0.01
      i: 10.0
      i_clamp: 1
    joint5:
      p: 100.0
      d: 0.01
      i: 10.0
      i_clamp: 1
    joint6:
      p: 100.0
      d: 0.01
      i: 10.0
      i_clamp: 1

修改 ur3_moveit_config 下的 demo_gazebo.launch中,下图第28行,改为上面新建的test_ur3.urdf所在路径

在这里插入图片描述

启动仿真

roslaunch ur3_moveit_config demo_gazebo.launch
在这里插入图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值