1,学习ROS官网上URDF的最后一部分为UnderstandingPR2URDF,http://wiki.ros.org/urdf/Tutorials/UnderstandingPR2URDF
2,主要分析
3,pr2.urdf.xacro
#The root element for the XML must be robot with aname attribute. XML namespaces are declared here——XML的根元素必须是robot,且带有一个名字属性ns,名字属性要在这儿声明
2
3 xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
4 xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
5 xmlns:xacro="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
6 name="pr2" >
7
8
#Include files containing xacro macros for inidividual robot components. This is like including a header file in C: it sets up a bunch of definitions but doesn't actually call any of them
包括了一些文件包含机器人单独的各个部分,就如C语言中的头文件,它建立起来一系列定义但是并有调用所有的功能
#常见的参数宏定义
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#PR2的身体
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#宏定义身体pr2_base_v0的方位origin tag
#Now we actually use the macros defined above. Here, we define PR2's base, using thexacro:pr2_base_v0 macro, with name parameter equal to "base" and anorigin parameter block. After running the original file through the xacro preprocessor, this element will be replaced with a rather long URDF definition of the base and its components.现在我们来实际使用上面定义的macro,这儿我们首先定义PR2的身体,使用xacro:pr2_base_v0宏,带着一个名字参数,这个参数等同与base,和一个origin参数块,通过xacro预处理器后,这些元素将会用一个相当长的URDF的基本块和组成块定义(?)
43
44
45
46
#Similarly, we define the PR2 torso, using the xacro:pr2_torso_v0 macro, which can be found in the included file pr2_description/urdf/torso_v0/torso.urdf.xacro.同样的我们定义PR2的躯干,使用宏xacro:pr2_torso_v0,这个宏能够在同一包下的urdf文件中找到
47
48
49
50
#宏定义头部pr2_head_v0
#Next we use xacro:pr2_head_v0 macro. It can be found in the included filepr2_description/urdf/head_v0/head.urdf.xacro. Note that rather than hardcoded numbers for the origin, we're using constants (that were defined in the calibration file included above:pr2_description/urdf/common.xacro).我们定义宏xacro:pr2_head_v0,能够在head.urdf.xacro文件中找到,注意与其在origin中加入硬编码的数字,我们使用的常量参数,这些定义能够在common.xacro文件中找到
51
53
54
55 rpy="${cal_head_roll} ${cal_head_pitch} ${cal_head_yaw}" />
56
57
58
59
60 stereo_name="double_stereo"
61 parent="head_plate_frame">
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 screw_reduction="${4.0/1000.0}"
78 gear_ratio="${(729.0/25.0)*(22.0/16.0)}"
79 theta0="${3.6029*M_PI/180.0}"
80 phi0="${29.7089*M_PI/180.0}"
81 t0="${-0.1914/1000.0}"
82 L0="${37.5528/1000.0}"
83 h="${0.0/1000.0}"
84 a="${68.3698/1000.0}"
85 b="${43.3849/1000.0}"
86 r="${91.5/1000.0}" >
87
88
89
90
91
92
93
94
95
96
97 screw_reduction="${4.0/1000.0}"
98 gear_ratio="${(729.0/25.0)*(22.0/16.0)}"
99 theta0="${3.6029*M_PI/180.0}"
100 phi0="${29.7089*M_PI/180.0}"
101 t0="${-0.1914/1000.0}"
102 L0="${37.5528/1000.0}"
103 h="${0.0/1000.0}"
104 a="${68.3698/1000.0}"
105 b="${43.3849/1000.0}"
106 r="${91.5/1000.0}" >
107
108
109
110
111
112 camera_info_topic_name="l_forearm_cam/camera_info"
113 parent="l_forearm_roll_link" hfov="90" focal_length="320"
114 frame_id="l_forearm_cam_frame" hack_baseline="0"
115 image_width="640" image_height="480">
116
117
118
119 camera_info_topic_name="r_forearm_cam/camera_info"
120 parent="r_forearm_roll_link" hfov="90" focal_length="320"
121 frame_id="r_forearm_cam_frame" hack_baseline="0"
122 image_width="640" image_height="480">
123
124
125
126