您的位置:首页 > 其它

学习ROS笔记之URDF(部分)

2014-04-16 15:08 393 查看
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,名字属性要在这儿声明



<?xml version="1.0"?>
   2 <robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
   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   <!-- The following included files set up definitions of parts of the robot body -->


#一下文件建立了定义机器人的各个部分

#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   <!-- misc common stuff? -->
  10   <include filename="$(find pr2_description)/urdf/common.xacro" />


#PR2的手臂:肩膀,上臂,前臂


11   <!-- PR2 Arm -->
  12   <include filename="$(find pr2_description)/urdf/shoulder_v0/shoulder.urdf.xacro" />
  13   <include filename="$(find pr2_description)/urdf/upper_arm_v0/upper_arm.urdf.xacro" />
  14   <include filename="$(find pr2_description)/urdf/forearm_v0/forearm.urdf.xacro" />


#PR2的夹手


15   <!-- PR2 gripper -->
  16   <include filename="$(find pr2_description)/urdf/gripper_v0/gripper.urdf.xacro" />


#PR2的头


17   <!-- PR2 head -->
  18   <include filename="$(find pr2_description)/urdf/head_v0/head.urdf.xacro" />


#倾斜的激光


19   <!-- PR2 tilting laser mount -->
  20   <include filename="$(find pr2_description)/urdf/tilting_laser_v0/tilting_laser.urdf.xacro" />


#PR2的躯干


21   <!-- PR2 torso -->
  22   <include filename="$(find pr2_description)/urdf/torso_v0/torso.urdf.xacro" />


#PR2的身体



23   <!-- PR2 base -->
  24   <include filename="$(find pr2_description)/urdf/base_v0/base.urdf.xacro" />


#PR2的头部传感器


25   <!-- Head sensors -->
  26   <include filename="$(find pr2_description)/urdf/sensors/head_sensor_package.urdf.xacro" />


#PR2的照相机


27   <!-- Camera sensors -->
  28   <include filename="$(find pr2_description)/urdf/sensors/wge100_camera.urdf.xacro" />


#基本的仿真GAZEBO的插件


29   <!-- generic simulator_gazebo plugins for starting mechanism control, ros time, ros battery -->
  30   <include filename="$(find pr2_description)/gazebo/gazebo.urdf.xacro" />


#视觉用的材料


31   <!-- materials for visualization -->
  32   <include filename="$(find pr2_description)/urdf/materials.urdf.xacro" />
  33


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


  34   <!-- Now we can start using the macros included above to define the actual PR2 -->
  35


#首先定义macro


  36   <!-- The first use of a macro.  This one was defined in base.urdf.xacro above.
  37        A macro like this will expand to a set of link and joint definitions, and to additional
  38        Gazebo-related extensions (sensor plugins, etc).  The macro takes an argument, name,
  39        that equals "base", and uses it to generate names for its component links and joints
  40        (e.g., base_link).  The included origin block is also an argument to the macro.  By convention,
  41        the origin block defines where the component is w.r.t its parent (in this case the parent
  42        is the world frame). For more, see http://www.ros.org/wiki/xacro -->


#宏定义身体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   <xacro:pr2_base_v0 name="base" >
  44     <origin xyz="0 0 0.051" rpy="0 0 0" /> <!-- 5.1cm is the height of the base when wheels contact ground -->
  45   </xacro:pr2_base_v0>
  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   <xacro:pr2_torso_v0 name="torso_lift" parent="base_link">
  48     <origin xyz="-0.05 0 0.739675" rpy="0 0 0" />
  49   </xacro:pr2_torso_v0>
  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   <!-- The xacro preprocesser will replace the parameters below, such as ${cal_head_x}, with
  52        numerical values that were specified in common.xacro which was included above -->
  53   <xacro:pr2_head_v0 name="head" parent="torso_lift_link">
  54     <origin xyz="${cal_head_x}    ${cal_head_y}     ${0.3915+cal_head_z}"
  55             rpy="${cal_head_roll} ${cal_head_pitch} ${cal_head_yaw}" />
  56   </xacro:pr2_head_v0>
  57


#宏定义头部传感器pr2_head_sensor_package_v0


  58   <!-- Camera package: double stereo, prosilica -->
  59   <xacro:pr2_head_sensor_package_v0 name="sensor_mount" hd_name="high_def"
  60                            stereo_name="double_stereo"
  61                            parent="head_plate_frame">
  62     <origin xyz="0.0 0.0 0.0" rpy="0 0 0" />
  63   </xacro:pr2_head_sensor_package_v0>
  64


#宏定义倾斜的激光器pr2_tilting_laser_v0


  65   <xacro:pr2_tilting_laser_v0 name="laser_tilt" parent="torso_lift_link" laser_calib_ref="-0.35">
  66     <origin xyz="0.1 0 0.235" rpy="0 0 0" />
  67   </xacro:pr2_tilting_laser_v0>
  68


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


  69   <!-- This is a common convention, to use a reflect parameter that equals +-1 to distinguish left from right -->
  70   <xacro:pr2_shoulder_v0 side="r" reflect="-1" parent="torso_lift_link">
  71     <origin xyz="0.0 -0.188 0.0" rpy="0 0 0" />
  72   </xacro:pr2_shoulder_v0>
  73   <xacro:pr2_upper_arm_v0 side="r" reflect="-1" parent="r_upper_arm_roll_link"/>
  74   <xacro:pr2_forearm_v0 side="r" reflect="-1" parent="r_forearm_roll_link"/>
  75


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


  76   <xacro:pr2_gripper_v0 side="r" parent="r_wrist_roll_link"
  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     <origin xyz="0 0 0" rpy="0 0 0" />
  88   </xacro:pr2_gripper_v0>
  89


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


  90   <xacro:pr2_shoulder_v0 side="l" reflect="1" parent="torso_lift_link">
  91     <origin xyz="0.0 0.188 0.0" rpy="0 0 0" />
  92   </xacro:pr2_shoulder_v0>
  93   <xacro:pr2_upper_arm_v0 side="l" reflect="1" parent="l_upper_arm_roll_link"/>
  94   <xacro:pr2_forearm_v0 side="l" reflect="1" parent="l_forearm_roll_link"/>
  95


#宏定义左夹手


  96   <xacro:pr2_gripper_v0 side="l" parent="l_wrist_roll_link"
  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     <origin xyz="0 0 0" rpy="0 0 0" />
 108   </xacro:pr2_gripper_v0>
 109


#前臂凸轮


 110   <!-- Forearm Cam (Hand approximated values) -->
 111   <xacro:wge100_camera_v0 name="l_forearm_cam" image_format="L8" image_topic_name="l_forearm_cam/image_raw"
 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     <origin xyz=".15 0 .07" rpy="${ M_PI/2} ${-45*M_PI/180} 0" />
 117   </xacro:wge100_camera_v0>
 118   <xacro:wge100_camera_v0 name="r_forearm_cam" image_format="L8" image_topic_name="r_forearm_cam/image_raw"
 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     <origin xyz=".15 0 .07" rpy="${-M_PI/2} ${-45*M_PI/180} 0" />
 124   </xacro:wge100_camera_v0>
 125
 126 </robot>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: