文章目录
- 介绍
- minitaur urdf解析
- base_chassis_link
- chassis right
- motor
- upper_leg
- lower_leg
- 注意
介绍
URDF全称为Unified Robot Description Format,中文可以翻译为“统一机器人描述格式”。与计算机文件中的.txt文本格式、.jpg图像格式等类似,URDF是一种基于XML规范、用于描述机器人结构的格式。根据该格式的设计者所言,设计这一格式的目的在于提供一种尽可能通用(as general as possible)的机器人描述规范。URDF创造的机器人模型包含的内容有:
- 连杆 link
- 关节 joint
- 运动学参数 axis
- 动力学参数 dynamics
- 可视化模型 visual
- 碰撞检测模型 collision
minitaur urdf解析
base_chassis_link
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>link <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>base_chassis_link<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token comment"><!--物理型状--></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span>..第一个长方体.<span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span>..2..<span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span>..3..<span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token comment"><!-- 设置碰撞--></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span>...<span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span>...<span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span>...<span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token comment"><!--设置属性例如质量,惯量--></span> <span class="token tag"><span class="token punctuation"><</span>inertial<span class="token punctuation">></span></span>...<span class="token tag"><span class="token punctuation"></</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>link<span class="token punctuation">> </span></span> </code>
效果如下:
chassis right
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>link <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>chassis_right<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token comment"><!--motor支架--></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span> .... <span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span>.... <span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span> ....<span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>inertial<span class="token punctuation">></span></span>.... <span class="token tag"><span class="token punctuation"></</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>link<span class="token punctuation">></span></span> </code>
要添加一个joint约束位置,不然会报错
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>joint <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>chassis_right_center<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>fixed<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>axis <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 0 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>parent <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>base_chassis_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>child <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>chassis_right<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>origin <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>-0.0872665 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0 -0.10 0.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>limit <span class="token attr-name">effort</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span> <span class="token attr-name">velocity</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>joint_properties <span class="token attr-name">damping</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">friction</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>joint<span class="token punctuation">></span></span> </code>
chassis left 同理
motor
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>link <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>motor_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>mesh <span class="token attr-name">filename</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>tmotor3.obj<span class="token punctuation">"</span></span> <span class="token attr-name">scale</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1 1 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>material <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>white<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>color <span class="token attr-name">rgba</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1 1 1 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>material<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>cylinder <span class="token attr-name">length</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.026<span class="token punctuation">"</span></span> <span class="token attr-name">radius</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0434<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>mass <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.25<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>inertia <span class="token attr-name">ixx</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span> <span class="token attr-name">ixy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">ixz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">iyy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span> <span class="token attr-name">iyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">izz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>link<span class="token punctuation">></span></span></code> <code class="prism language-markup has-numbering"> </code>
<joint name="motor_front_rightR_joint" type="continuous">
<axis xyz="0 0 1"/>
<parent link="chassis_right"/>
<child link="motor_front_rightR_link"/>
<origin rpy="1.57075 0 0" xyz="0.21 -0.025 0"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
上述为右边电机,其余位置安装同理
upper_leg
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>link <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>upper_leg_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>box <span class="token attr-name">size</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>.01 0.01 .11<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>material <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>grey<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>color <span class="token attr-name">rgba</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.65 0.65 0.75 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>material<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>box <span class="token attr-name">size</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>.01 0.01 .11<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>mass <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.05<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>inertia <span class="token attr-name">ixx</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span> <span class="token attr-name">ixy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">ixz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">iyy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span> <span class="token attr-name">iyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">izz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>link<span class="token punctuation">> </span></span> </code>
注意对于upper_leg左右关节命名不一样,但其实是同一类型关节,这里涉及到minitaur仿真环境中的一些设置
右
<code class="prism language-markup has-numbering"> <span class="token tag"><span class="token punctuation"><</span>joint <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>hip_front_rightR_link<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>fixed<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>axis <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 0 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>parent <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>motor_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>child <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>upper_leg_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>origin <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>-1.57075 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0 0.06 -0.015<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>limit <span class="token attr-name">effort</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span> <span class="token attr-name">velocity</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>joint_properties <span class="token attr-name">damping</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">friction</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>joint<span class="token punctuation">> </span></span> </code>
左
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>joint <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>motor_front_rightL_link<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>fixed<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>axis <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 0 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>parent <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>motor_front_rightL_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>child <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>upper_leg_front_rightL_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>origin <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>-1.57075 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0 0.06 -0.015<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>limit <span class="token attr-name">effort</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span> <span class="token attr-name">velocity</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>joint_properties <span class="token attr-name">damping</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">friction</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>joint<span class="token punctuation">> </span></span> </code>
lower_leg
<code class="prism language-markup has-numbering"><span class="token tag"><span class="token punctuation"><</span>link <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>lower_leg_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>contact<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>stiffness <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>10000<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>damping <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>10<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>lateral_friction <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>contact<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>origin <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 0 .1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>box <span class="token attr-name">size</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>.01 0.01 .2<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>material <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>grey<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>color <span class="token attr-name">rgba</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.65 0.65 0.75 1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>material<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>visual<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>origin <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 0 .1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>box <span class="token attr-name">size</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>.01 0.01 .2<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>geometry<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>collision<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>mass <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.05<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>inertia <span class="token attr-name">ixx</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span> <span class="token attr-name">ixy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">ixz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">iyy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span> <span class="token attr-name">iyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">izz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>1.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>inertial<span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"></</span>link<span class="token punctuation">> </span></span> </code>
lower_leg的关节以knee开头命名,joint类型为revolute的需要加入限制,不加模型会报错
<code class="prism language-markup has-numbering"> <span class="token tag"><span class="token punctuation"><</span>joint <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>knee_front_rightR_link<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>revolute<span class="token punctuation">"</span></span><span class="token punctuation">></span></span> <span class="token tag"><span class="token punctuation"><</span>axis <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 1 0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>parent <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>upper_leg_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>child <span class="token attr-name">link</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>lower_leg_front_rightR_link<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>origin <span class="token attr-name">rpy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0 0 0<span class="token punctuation">"</span></span> <span class="token attr-name">xyz</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0 0.01 .055<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>limit <span class="token attr-name">effort</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span> <span class="token attr-name">velocity</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>100<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"><</span>joint_properties <span class="token attr-name">damping</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span> <span class="token attr-name">friction</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>0.0<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span> <span class="token tag"><span class="token punctuation"></</span>joint<span class="token punctuation">> </span></span> </code>
注意
link和joint都配置好后大概就是这个四脚朝天的样子了(图一),但是建模其实还没有完成,因为各个关节都是开环的(不是并联机构),简单来说就是这时候的minitaur足端是分离的(图二) urdf部分的使命已经结束了,并联机构部分我们需要在bullet里面添加约束才能实现,使用createConstraint()
<code class="prism language-python has-numbering">self<span class="token punctuation">.</span>_pybullet_client<span class="token punctuation">.</span>createConstraint<span class="token punctuation">(</span> self<span class="token punctuation">.</span>quadruped<span class="token punctuation">,</span> self<span class="token punctuation">.</span>_joint_name_to_id<span class="token punctuation">[</span><span class="token string">"knee_"</span> <span class="token operator">+</span> leg_position <span class="token operator">+</span> <span class="token string">"R_link"</span><span class="token punctuation">]</span><span class="token punctuation">,</span> self<span class="token punctuation">.</span>quadruped<span class="token punctuation">,</span> self<span class="token punctuation">.</span>_joint_name_to_id<span class="token punctuation">[</span><span class="token string">"knee_"</span> <span class="token operator">+</span> leg_position <span class="token operator">+</span> <span class="token string">"L_link"</span><span class="token punctuation">]</span><span class="token punctuation">,</span> self<span class="token punctuation">.</span>_pybullet_client<span class="token punctuation">.</span>JOINT_POINT2POINT<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">,</span> KNEE_CONSTRAINT_POINT_RIGHT<span class="token punctuation">,</span> KNEE_CONSTRAINT_POINT_LEFT<span class="token punctuation">) </span> </code>
图一