- Mastering ROS for Robotics Programming
- Lentin Joseph
- 291字
- 2021-07-30 10:03:24
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
- DevOps for Networking
- 深入理解Java7:核心技術與最佳實踐
- C#實踐教程(第2版)
- Node Cookbook(Second Edition)
- 圖數據庫實戰
- HTML+CSS+JavaScript網頁設計從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- PrimeFaces Blueprints
- .NET 4.0面向對象編程漫談:應用篇
- Java Web開發教程:基于Struts2+Hibernate+Spring
- Go語言編程之旅:一起用Go做項目
- Elasticsearch實戰(第2版)
- Scratch 3.0少兒積木式編程(6~10歲)
- Visual Basic程序設計
- Maya Programming with Python Cookbook
- C#網絡程序開發(第二版)