ROS学习笔记36(创建你的urdf文件)

1 创建一个树状结构

在这个教程中,我们将创建一个URDF文件,以描述如下图所示的机械结构:

ROS学习笔记36(创建你的urdf文件)_第1张图片

图中的这个机械结构是一个树状的结构,我们以一个很简单的,易于描述树状结构开始,因而并不用担心维度问题。

打开你最喜欢的编辑器,并且创建一个名为my_robot.urdf文件。


  
  
  
  

  
    
    
  

  
    
    
  

  
    
    
  

所以呢,创建一个这样的结构是很简单的。

不过现在让我们 确定下这个文件是否符合语法规则。

有这么一个简单的命令行工具可以用来检查urdf你的urdf文件,并告诉你这个文件是否符合语法规则。

这个命令行工具安装如下:

 $ sudo apt-get install liburdfdom-tools

现在可以检查,如下命令: 

$ rosmake urdfdom_model              # only needed if installed from source
$ check_urdf my_robot.urdf                    # hydro and later
$
$ # for older ROS distros, use the following commands
$ (see footnote at bottom of page for why above commands are different)
$ rosrun urdfdom check_urdf my_robot.urdf     # groovy
$ rosrun urdf_parser check_urdf my_robot.urdf # electric and fuerte
$ rosrun urdf check_urdf my_robot.urdf        # diamondback and earlier

注意上面的版本问题:

如果出现输出下面的那些内容,则代表没有问题。

---------- Successfully Parsed XML ---------------
root Link: link1 has 2 child(ren)
    child(1):  link2
    child(2):  link3
        child(1):  link4

ROS学习笔记36(创建你的urdf文件)_第2张图片

2 增加尺寸

现在我们已经拥有了一个树状结构,让我们给它增加合适的尺寸。

As you notice in the robot image, the reference frame of each link (in green) is located at the bottom of the link, and is identical to the reference frame of the joint. So, to add dimensions to our tree, all we have to specify is the offset from a link to the joint(s) of its children. 为了完成这些功能,我们给它们增加了完成这项任务。

如下所示:


现在我们已经拥有了一个树状结构,让我们给它增加合适的尺寸。

其实类似于确定子连杆相对于父连杆的位置和旋转角度,可以这么理解。完整的urdf文件如下:


  
  
  
  


  
    
    
    
  

  
    
    
    
  

  
    
    
    
  

 现更新你的urdf文件,并且进行检查。

ROS学习笔记36(创建你的urdf文件)_第3张图片

如果不报错的话,那么转移到下一步。

3 完成运动学模型

不过我们这里并没有定义节点的旋转。如果我们定义后,那么我们就拥有了一个定义完全的机器人动力学模型。我们现在做的就是给每个节点添加标签。The axis specifies the rotational axis in the local frame. 在xml文件中添加如下内容:

所以,加入joint绕着Y轴正向旋转,那么可以给xml添加如下的内容:


同样的,joint1也旋转,那么需要添加如下内容:


Note that it is a good idea to normalize the axis.

If we add this to all the joints of the robot, our URDF looks like this:


  
  
  
  

  
    
    
    
    
  

  
    
    
    
    
  

  
    
    
    
    
  

更新你的urdf文件,并且在命令行运动如下命令:

$ check_urdf my_robot.urdf

把图可视化 ,转化为pdf,

$ urdf_to_graphiz my_robot.urdf

使用pdf查看如下所示:

ROS学习笔记36(创建你的urdf文件)_第4张图片

ROS学习笔记36(创建你的urdf文件)_第5张图片

 

 

你可能感兴趣的:(ROS)