瑞星 发表于 2024-7-17 03:50:09

ROS-机器臂——从零构建机器人模型

URDF建模

https://i-blog.csdnimg.cn/direct/c49fedc49bbe4f82ba03a424259d7efb.png
URDF

URDF,全称为 Unified Robot Description Format(统一机器人描述格式),是一种用于描述机器人多少结构和运动学属性的标准文件格式。URDF 文件通常用于机器人模仿、路径规划、控制算法开辟和可视化等范畴,特别是在 ROS(Robot Operating System)环境中非常常见。
URDF 建模主要关注以下方面:
Link(链接):表示机器人中的刚体部门,如机器人的手臂、腿或任何静态部件。每个链接都有自己的惯性属性,如质量和转动惯量,以及多少外形,如碰撞体(colliders)和视觉表示(visuals)。
Joint(关节):描述链接之间的连接方式,包括关节范例(如revolute旋转关节、prismatic直线关节等)、关节轴线、限定条件(如关节限位)和动力学属性(如摩擦力)。
Inertial(惯性):描述链接的质量和转动惯量等物理属性。
Collision(碰撞):用于物理模仿和碰撞检测的多少外形,通常较为简单。
Visual(视觉):用于渲染和可视化的多少外形,可能比碰撞外形更复杂,以提供更真实的外貌。
Material(材质):界说颜色和纹理,用于视觉表示。
Actuator(实行器):描述驱动关节的装备,如电机或液压缸的属性。
Transmissions(传动装置):界说实行器如何影响关节的运动。
Gazebo Plugins(Gazebo 插件):用于在 Gazebo 模仿器中扩展机器人的行为,如传感器模型。
URDF 建模过程涉及创建和配置上述组件,以准确地反映机器人的结构和动力学。URDF 文件通常是 XML 格式的,可以通过文本编辑器手动编写,也可以使用工具辅助生成。
URDF 与 DH 参数(Denavit-Hartenberg 参数)有接洽,DH 参数用于描述关节间的相对位置和方向,而 URDF 可以基于这些参数来构建机器人的结构模型。然而,URDF 提供了更为丰富和详细的描述,包括多少外形、物理属性和传感器信息等。
机器人组成

https://i-blog.csdnimg.cn/direct/c2aa7daa439a4258aca39baecefb351f.png
内部关系

https://i-blog.csdnimg.cn/direct/95e7ba09a30b442898d15f3ff7c71087.png
Links 与 Joints

https://i-blog.csdnimg.cn/direct/747fbbe86bdf4d01bac8a972122223fc.png
Links

https://i-blog.csdnimg.cn/direct/e2ccd2695ff34be3a2e65bfe1f3c5f88.png
Joint

https://i-blog.csdnimg.cn/direct/5b40804a7af845ba9fa6e46f69f651ec.png
UDRF建模弊端

https://i-blog.csdnimg.cn/direct/76b259c04a224c0ea34d5268eb77c518.png
xacro模型文件

https://i-blog.csdnimg.cn/direct/9e242719f452453fb7bf3ed137488012.png
常量界说与使用

https://i-blog.csdnimg.cn/direct/21e7a0c6f65d4e3da19393753dd07151.png
数学计算

https://i-blog.csdnimg.cn/direct/a804507906754a34aef2eb133275d6af.png
宏界说、宏调用

https://i-blog.csdnimg.cn/direct/7ba9b272e2364db581e60e0bea544386.png
文件包罗

https://i-blog.csdnimg.cn/direct/4b088b37a16b4badac9c1b87bc4ad8ef.png
界说排版

https://i-blog.csdnimg.cn/direct/67f1d5325d104d56ad9e9e4ec8c1f604.png
launch文件

https://i-blog.csdnimg.cn/direct/2d930058a76a40fcb5162c5a3468820d.png
#三维模型导出URDF
网上找到UR3机器臂的资源,把 “.step” 后缀结尾的文件,在solidwork中打开如图

https://i-blog.csdnimg.cn/direct/39acdc08db484a88bf77890e04b9388f.png
link和joint的配置

https://i-blog.csdnimg.cn/direct/f81c1e47754c47f9a12ae773db50f546.png
生成模型功能包

https://i-blog.csdnimg.cn/direct/f1b94e152b584b3f937c549ec00e080f.png
测试修改bug

https://i-blog.csdnimg.cn/direct/3067e317b5de464880e496d822767e31.png
结果展示

https://i-blog.csdnimg.cn/direct/1d6f6eb83646427a93e520bf8f48308e.png
solid works

SolidWorks 是一款广泛使用的三维 CAD 软件,主要用于机器筹划。要将 SolidWorks 的模型转换为 URDF(Unified Robot Description Format)格式,用于机器人仿真和控制,你需要一个插件大概工具来辅助这个过程。虽然 SolidWorks 自己并不直接支持 URDF 格式,但有一些第三方插件可以实现这一功能,比如 sw2urdf。
选择哪一款 SolidWorks 版本对于 URDF 转换而言,主要取决于以下几点:
插件兼容性:确保你所选择的 SolidWorks 版本与你打算使用的 URDF 插件兼容。差别的插件可能支持差别版本的 SolidWorks。
功能需求:如果你的模型非常复杂,可能需要使用更高版本的 SolidWorks,由于较新版本每每包罗更多功能和改进的性能,这可以帮助你更高效地创建和管理复杂的装配体。
硬件要求:SolidWorks 的高版本通常需要更强的硬件配置。如果您的计算机硬件不敷强大,可能会影响软件运行的流畅性和稳固性。
允许本钱:SolidWorks 差别版本的代价差别,且功能也有差别。你需要评估本钱效益,选择最适合你预算和需求的版本。
技术支持:较新的 SolidWorks 版本通常会获得更好的技术支持和更新。
用户熟悉度:如果你已经熟悉某个版本的 SolidWorks,除非有特别的功能需求,否则继续使用熟悉的版本可能会更加高效。
对于 URDF 导出而言,关键在于找到一个稳固且功能全面的插件,它能够准确地将你的 SolidWorks 模型转换为 URDF 文件。sw2urdf 插件能够处置惩罚 SolidWorks 的零件和装配体,主动识别关节范例、变动和轴,这对于 URDF 建模是非常重要的。
目录架构

https://i-blog.csdnimg.cn/direct/506c51ca768e4664a2599f8c52c9e8bb.png
相关文件

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)

project(UR3)

find_package(catkin REQUIRED)

catkin_package()

find_package(roslaunch)

foreach(dir config launch meshes urdf)
        install(DIRECTORY ${dir}/
                DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir})
endforeach(dir)

package.xml

<package format="2">
<name>UR3</name>
<version>1.0.0</version>
<description>
    <p>URDF Description package for UR3</p>
    <p>This package contains configuration data, 3D models and launch files
for UR3 robot</p>
</description>
<author>TODO</author>
<maintainer email="TODO@email.com" />
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<depend>roslaunch</depend>
<depend>robot_state_publisher</depend>
<depend>rviz</depend>
<depend>joint_state_publisher_gui</depend>
<depend>gazebo</depend>
<export>
    <architecture_independent />
</export>
</package>
display.launch

<launch>
<arg
    name="model" />
<param
    name="robot_description"
    textfile="$(find UR3)/urdf/UR3.urdf" />

<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" />

<node
    name="rviz"
    pkg="rviz"
    type="rviz"
    args="-d $(find UR3)/urdf.rviz" />
</launch>
gazebo.launch

<launch>
<include
    file="$(find gazebo_ros)/launch/empty_world.launch" />
<node
    name="tf_footprint_base"
    pkg="tf"
    type="static_transform_publisher"
    args="0 0 0 0 0 0 base_link base_footprint 40" />
<node
    name="spawn_model"
    pkg="gazebo_ros"
    type="spawn_model"
    args="-file $(find UR3)/urdf/UR3.urdf -urdf -model UR3"
    output="screen" />
<node
    name="fake_joint_calibration"
    pkg="rostopic"
    type="rostopic"
    args="pub /calibrated std_msgs/Bool true" />
</launch>
ur3.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-g7f85cfeBuild Version: 1.6.7995.38578
   For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot
name="UR3">
<link
    name="base_link">
    <inertial>
      <origin
      xyz="2.105E-05 0.098059 -0.0036545"
      rpy="0 0 0" />
      <mass
      value="1.371" />
      <inertia
      ixx="0.0018288"
      ixy="4.4582E-07"
      ixz="-2.0556E-07"
      iyy="0.0019082"
      iyz="0.00013405"
      izz="0.0017646" />
    </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.75521" />
      <inertia
      ixx="0.0010675"
      ixy="-9.4953E-08"
      ixz="1.0255E-07"
      iyy="0.00090525"
      iyz="-0.00013058"
      izz="0.00099003" />
    </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="100"
      velocity="1" />
</joint>
<link
    name="link2">
    <inertial>
      <origin
      xyz="-2.6778E-06 0.060634 0.09327"
      rpy="0 0 0" />
      <mass
      value="1.6559" />
      <inertia
      ixx="0.0025822"
      ixy="-8.909E-08"
      ixz="1.019E-07"
      iyy="0.002419"
      iyz="-9.301E-05"
      izz="0.0016021" />
    </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="100"
      velocity="1" />
</joint>
<link
    name="link3">
    <inertial>
      <origin
      xyz="-0.0050453 -0.11121 3.4154E-06"
      rpy="0 0 0" />
      <mass
      value="0.96204" />
      <inertia
      ixx="0.0010146"
      ixy="4.5981E-05"
      ixz="6.2628E-08"
      iyy="0.00054242"
      iyz="-4.3697E-08"
      izz="0.0010724" />
    </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="100"
      velocity="1" />
</joint>
<link
    name="link4">
    <inertial>
      <origin
      xyz="0.0059208 -0.0007977 2.6694E-07"
      rpy="0 0 0" />
      <mass
      value="0.32519" />
      <inertia
      ixx="0.00019459"
      ixy="1.8337E-05"
      ixz="1.3898E-10"
      iyy="0.00019909"
      iyz="1.2329E-09"
      izz="0.00022621" />
    </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="100"
      velocity="1" />
</joint>
<link
    name="link5">
    <inertial>
      <origin
      xyz="0.0059208 0.00079771 -2.3761E-07"
      rpy="0 0 0" />
      <mass
      value="0.32519" />
      <inertia
      ixx="0.00019459"
      ixy="-1.8338E-05"
      ixz="-2.0382E-10"
      iyy="0.00019909"
      iyz="1.211E-09"
      izz="0.00022621" />
    </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="100"
      velocity="1" />
</joint>
<link
    name="link6">
    <inertial>
      <origin
      xyz="4.7334E-10 0.00010334 -0.021073"
      rpy="0 0 0" />
      <mass
      value="0.11536" />
      <inertia
      ixx="4.2469E-05"
      ixy="1.5688E-12"
      ixz="1.7329E-12"
      iyy="4.2681E-05"
      iyz="1.0324E-07"
      izz="5.9067E-05" />
    </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="100"
      velocity="1" />
</joint>
</robot>

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: ROS-机器臂——从零构建机器人模型