学习ROS笔记之Using A URDF In Gazebo

来源:互联网 发布:淘宝上卖包包靠谱的店 编辑:程序博客网 时间:2024/04/30 10:51

1,ROS中学习完URDF后,则来学习一下在仿真软件gazebo中如何使用URDF,http://gazebosim.org/wiki/Tutorials/1.9/Using_A_URDF_In_Gazebo

2,The Universal Robotic Description Format (URDF) is an XML file format used in ROS to describe all elements of a robot. To use a URDF file in Gazebo, some additional simulation-specific tags must be added to work properly with Gazebo. This tutorial explains the necessary steps to successfully use your URDF-based robot in Gazebo, saving you from having to create a separate SDF file from scratch and duplicating description formats. Under the hood, Gazebo will then convert the URDF to SDF automatically.普通机器人描述格式URDF是一个XML格式的文件使用在ROS中,用来描述机器人的元素。在gazebo中使用URDF,需要添加一些额外的特殊仿真的tag,这样才能在gazebo中更好的工作。本教材解释了一些在gazebo中使用URDF的必须步骤,让你不用额外要去创建一个SDF文件,在后台(在底层?)gazebo会自动将URDF转换为SDF。

3,background背景:

While URDFs are a useful and standardized format in ROS, they are lacking many features and have not been updated to deal with the evolving needs of robotics. URDF can only specify the kinematic and dynamic properties of a single robot in isolation. URDF can not specify the pose of the robot itself within a world. It is also not a universal description format since it cannot specify joint loops (parallel linkages), and it lacks friction and other properties. Additionally, it cannot specify things that are not robots, such as lights, heightmaps, etc.

On the implementation side, the URDF syntax breaks proper formatting with heavy use of XML attributes, which in turn makes URDF more inflexible. There is also no mechanism for backward compatibility.

尽管URDF是一个十分有用并且标准的格式在ROS中,但是它缺少许多特性,不能满足现在机器人的很多需求,URDF只能够指定一个简单机器人的动力学和运动学属性,不能指定指定在一个世界中的机器人自己的位置。由于它不能指定关节循环(?)并且缺少摩擦系数和其他的属性,它就不是一个通用的描述格式,它打破合适的格式,大量使用属性,使得URDF不灵活,也没有一个向后兼容的机制。

To deal with this issue, a new format called the Simulator Description Format (SDF) was created for use in Gazebo to solve the shortcomings of URDF. SDF is a complete description for everything from the world level down to the robot level. It is scalable, and makes it easy to add and modify elements. The SDF format is itself described using XML, which facilitates a simple upgrade tool to migrate old versions to new versions. It is also self-descriptive.

为了解决URDF的一些问题,一种新的仿真描述格式SDF出现,是在仿真软件GAZEBO中使用,它克服了URDF的不足,SDF是一个完全的描述格式,从世界层次到机器人层次,并且它是可扩展的,能够很容易添加和修改元素,SDF也是一种XML格式。

4,There are several steps to get a URDF robot properly working in Gazebo在GAZEBO中使用URDF的几个步骤:

required

  • An <inertia> element within each <link> element must be properly specified and configured.在link元素下必须添加inertia惯性元素

optional

  • Add a <gazebo> element for every <link>可以在link元素下添加gazebo元素
    • Convert visual colors to Gazebo format
    • Convert stl files to dae files for better textures
    • Add sensor plugins
  • Add a <gazebo> element for every <joint>可以在joint元素下添加gazebo元素
    • Set proper damping dynamics
    • Add actuator control plugins
  • Add a <gazebo> element for the <robot> element可以在robot元素下添加gazebo 元素
  • Add a <link name="world"/> link if the robot should be rigidly attached to the world/base_link如果robot要添加到世界中去,应该添加link--<link name ="world"/>
5,The <gazebo> Element重要元素

The <gazebo> element is an extension to the URDF used for specifying additional properties needed for simulation purposes in Gazebo. It allows you to specify the properties found in the SDF format that are not by default in the URDF format. None of the elements within a <gazebo> element are required because default values will be automatically included. There are three different types of <gazebo> elements - one for the <robot> tag, one for <link> tags, and one for <joint> tags.

gazebo元素是为了在gazebo中仿真使用的URDF的扩展添加的属性,它允许你指定一些在SDF中的属性能够在URDF中使用,这些属性是在URDF中没有定义的。这儿有三个带gazebo类型的元素,分别是robot,link,joint  tags

6,In this tutorial, we'll use a simple demo robot named RRBot.在这个教材中使用一个演示的机器人叫做RRBot来进行演示:

6.1注意rrbot_description包下的rrbot.xacro   rrbot.gazebo 和 materials.xacro,其中rrbot.xacro是xacro文件,其中还有两个额外的文件(比之在ROS中的URDF)的rrbot.gazebo和materials.xacro

<robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"       xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"       xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"       xmlns:xacro="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"       name="pr2" >
以上部分是上一节在ROS中的URDF中看到的,而在gazebo中的urdf文件中不需要,改成以下部分即可:
<robot name="rrbot" xmlns:xacro="http://www.ros.org/wiki/xacro">#All you need in your root element tag is the name of the robot and optionally the xml namespace for xacro在文件的根元素是robot的名字,和xml命名空间
6.2rigidly fixing a model to the world将模型固定在世界上(ROS中的URDF中不需要,如上面第四条)
  <!-- Used for fixing robot to Gazebo 'base_link' -->  <link name="world"/>  <joint name="fixed" type="fixed">    <parent link="world"/>    <child link="link1"/>  </joint>
建立一个link名称是world,还有一个joint类型为fixed,固定在world上,如果这个机器人是运动的,则不需要

6.3links

  <!-- Base Link -->  <link name="link1">    <collision>      <origin xyz="0 0 ${height1/2}" rpy="0 0 0"/>      <geometry>        <box size="${width} ${width} ${height1}"/>      </geometry>    </collision>    <visual>      <origin xyz="0 0 ${height1/2}" rpy="0 0 0"/>      <geometry>        <box size="${width} ${width} ${height1}"/>      </geometry>      <material name="orange"/>    </visual>    <inertial>      <origin xyz="0 0 1" rpy="0 0 0"/>      <mass value="1"/>      <inertia         ixx="1.0" ixy="0.0" ixz="0.0"         iyy="1.0" iyz="0.0"         izz="1.0"/>    </inertial>  </link>
<collision>和<visual>元素,这两个元素与ROS中的URDF中的一样,重点是在GAZEBO中这两个元素必须都要定义,在GAZEBO中如果不定义<visual>的话,GAZEBO中会认为你的links是不可视的

6.4 link下的material

<material name="orange"/>这是在GAZEBO中的URDF文件中的,其中orange在materials.xacro文件中有定义:
  <material name="orange">    <color rgba="${255/255} ${108/255} ${10/255} 1.0"/>  </material>但是这种指定link颜色的方法在GAZEBO中是不能用的,因为它采用的是ORGE材料脚本用来指定link的颜色和纹理(?),而GAZEBO中material tag 必须为每一个link指定:
  <gazebo reference="link1">    <material>Gazebo/Orange</material>  </gazebo>这个指定material部分是在rrbot.gazebo文件中定义的,你能在这个文件中找到link和material元素,有一些默认的能直接使用的materials在GAZEBO中,包括color和其他
6.5link下的inertial

inertial在GAZEBO中必须提供,且质量mass必须大于0,而且惯性主矩可以导致无限加速度在任何有限的扭矩下,一般要设定好主矩(ixx,iyy,izz)(可以去搜索惯量张性的定义来了解)

6.6gazebo元素为links设定

有很多,如material 材料,gravity重力,damping factor阻尼因素(即震荡因素) ,mu1,mu2摩擦因子,在rrbot.gazebo中的gazebo元素中可以为links设定:

  <gazebo reference="link2">    <mu1>0.2</mu1>    <mu2>0.2</mu2>    <material>Gazebo/Black</material>  </gazebo>
6.7joints

However, not all of the elements documented for URDF joints are applicable to Gazebo:并不是所有在ROS的URDF中的joint元素都适用于GAZEBO中

  • The <origin>, <parent> and <child> are required这三个元素是必须要的
  • <calibration> and <safety_controller> are ignored这两个元素可以忽略
  • In the <dynamics> tag, only the damping property is used在dynamics tag下,只能使用damping,比如在ROS的URDF中还有friction,dynamics是用来定义joints是如何运动的
  • All of properties in the <limit> tag are optional所有的limit元素中的变量都是可选的
  <joint name="joint2" type="continuous">    <parent link="link2"/>    <child link="link3"/>    <origin xyz="0 ${width} ${height2 - axel_offset*2}" rpy="0 0 0"/>     <axis xyz="0 1 0"/>    <dynamics damping="0.7"/>  </joint>
Notice the dynamics element with a viscous damping coefficient of 0.7 Nms/rad, damping is simply the amount of opposing force to any joint velocity (in this case torque per angular velocity) that is used to "slow" a moving joint towards rest.注意damping为0.7,阻尼damping是用一个相反的力量去控制任意节点,也就是用来减慢节点的运动,在GAZEBO中注意到damping为0.7Nms/rad的作用然后改动它为4,发现rrbot摆动得很慢,阻尼系数很大,相反,当改为0.1时,rrbot摆动得很快。

6.8转换URDF文件

With Gazebo installed, an easy tool exists to check if your URDF can be properly converted into a SDF. Simply run the following command:

  gzsdf print MODEL.urdf
用以上那条命令来将URDF文件转换为SDF文件。

6.9运行URDF文件

可以将URDF文件作为一个节点放在  .launch文件中来运行使用。


















0 0