官术网_书友最值得收藏!

Explaining the URDF file

When we check the code, we can add a <robot> tag at the top of the description:

<?xml version="1.0"?>
<robot name="pan_tilt">

The <robot> tag defines the name of the robot that we are going to create. Here, we named the robot pan_tilt.

If we check the sections after the <robot> tag definition, we can see link and joint definitions of the pan and tilt mechanism:

  <link name="base_link">
    <visual>
      <geometry>
      <cylinder length="0.01" radius="0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="yellow">
        <color rgba="1 1 0 1"/>
      </material>
    </visual>
  </link>

The preceding code snippet is the base_link definition of the pan and tilt mechanism. The <visual> tag can describe the visual appearance of the link, which is shown on the robot simulation. We can define the link geometry (cylinder, box, sphere, or mesh) and the material (color and texture) of the link using this tag:

  <joint name="pan_joint" type="revolute">
    <parent link="base_link"/>
    <child link="pan_link"/>
    <origin xyz="0 0 0.1"/>
    <axis xyz="0 0 1" />
  </joint>

In the preceding code snippet, we define a joint with a unique name and its joint type. The joint type we used here is revolute and the parent link and child link are base_link and the pan_link respectively. The joint origin is also specified inside this tag.

Save the preceding URDF code as pan_tilt.urdf and check whether the urdf contains errors using the following command:

$ check_urdf pan_tilt.urdf

The check_urdf command will parse urdf and show an error, if any. If everything is OK, it will show an output as follows:

robot name is: pan_tilt
---------- Successfully Parsed XML ---------------
root Link: base_link has 1 child(ren)
 child(1): pan_link
 child(1): tilt_link

If we want to view the structure of the robot links and joints graphically, we can use a command tool called urdf_to_graphiz:

$ urdf_to_graphiz pan_tilt.urdf

This command will generate two files: pan_tilt.gv and pan_tilt.pdf. We can view the structure of this robot using following command:

$ evince pan_tilt.pdf

We will get the following output:

Figure 5 : Graph of joint and links in pan and tilt mechanism

主站蜘蛛池模板: 平原县| 大余县| 彰武县| 水城县| 玉田县| 福建省| 吉林省| 余江县| 依安县| 临城县| 洪洞县| 平江县| 衡阳县| 威海市| 怀仁县| 特克斯县| 静乐县| 松桃| 安宁市| 宁都县| 加查县| 拉萨市| 新余市| 观塘区| 哈尔滨市| 仪陇县| 焉耆| 尉犁县| 湖州市| 景宁| 沁水县| 鱼台县| 昌江| 财经| 通城县| 子洲县| 临清市| 湘潭市| 隆回县| 井冈山市| 双桥区|