学习ROS笔记之URDF(部分)

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   

#PR2的手臂:肩膀,上臂,前臂
 11   
  12   
  13   
  14   

#PR2的夹手
 15   
  16   

#PR2的头
 17   
  18   

#倾斜的激光
 19   
  20   

#PR2的躯干
 21   
  22   

#PR2的身体

 23   
  24   

#PR2的头部传感器
 25   
  26   

#PR2的照相机
 27   
  28   

#基本的仿真GAZEBO的插件
 29   
  30   

#视觉用的材料
 31   
  32   
  33 

#现在我们可以使用包含以上文件的macros来定义实际的PR2

  34   
  35 

#首先定义macro

  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 

#宏定义躯干pr2_torso_v0

#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 

#${}的参数在common.xacro文件中就进行了定义,在使用时会用common.xaroc中的值进行替换

#宏定义头部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 

#宏定义头部传感器pr2_head_sensor_package_v0

  58   
  59   
  60                            stereo_name="double_stereo" 
  61                            parent="head_plate_frame">
  62     
  63   
  64 

#宏定义倾斜的激光器pr2_tilting_laser_v0

  65   
  66     
  67   
  68 

#宏定义双肩,上臂和前臂,用参数reflect为-1和+1来分别表示左肩和右肩,左上臂和右上臂,左前臂和右前臂

  69   
  70   
  71     
  72   
  73   
  74   
  75 

#宏定义右夹手,注意使用到了math,即${}里面使用了算数符号

  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 

#宏定义左肩,左上臂,左前臂,注意用参数reflect=1来表示

  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 

你可能感兴趣的:(ROS)