Advertisement
Guest User

R2D2.xacro

a guest
May 14th, 2017
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 13.76 KB | None | 0 0
  1. <?xml version="1.0" ?>
  2. <robot name="r2d2" xmlns:xacro="http://ros.org/wiki/xacro">
  3.  
  4.  
  5.   <xacro:property name="torso_m" value="10.0"/>
  6.   <xacro:property name="torso_len" value="0.6"/>
  7.   <xacro:property name="torso_rad" value="0.2"/>
  8.  
  9.   <xacro:property name="leg_m" value="5"/>
  10.   <xacro:property name="leg_x" value="0.6"/>
  11.   <xacro:property name="leg_y" value="0.1"/>
  12.   <xacro:property name="leg_z" value="0.2"/>
  13.  
  14.   <xacro:property name="base_m" value="2"/>
  15.   <xacro:property name="base_x" value="0.4"/>
  16.   <xacro:property name="base_y" value="0.1"/>
  17.   <xacro:property name="base_z" value="0.1"/>
  18.  
  19.   <xacro:property name="wheel_m" value="0.4"/>
  20.   <xacro:property name="wheel_rad" value="0.035"/>
  21.   <xacro:property name="wheel_len" value="0.1"/>
  22.  
  23.   <xacro:property name="head_m" value="2"/>
  24.   <xacro:property name="head_rad" value="0.2"/>
  25.  
  26.   <xacro:property name="box_m" value="1"/>
  27.   <xacro:property name="box_l" value="0.08"/>
  28.  
  29.   <xacro:property name="mu1" value="0.9"/>
  30.   <xacro:property name="mu2" value="0.9"/>
  31.   <xacro:property name="kp" value="10000000.0"/>
  32.   <xacro:property name="kd" value="1.0"/>
  33.  
  34.   <xacro:macro name="sphere_inertial" params="radius mass">
  35.     <inertial>
  36.       <mass value="${mass}" />
  37.       <origin xyz="0 0 0" />
  38.       <inertia ixx="${0.4 * mass * radius * radius}" ixy="0.0" ixz="0.0"
  39.               iyy="${0.4 * mass * radius * radius}" iyz="0.0"
  40.               izz="${0.4 * mass * radius * radius}" />
  41.     </inertial>
  42.   </xacro:macro>
  43.  
  44.   <xacro:macro name="cylinder_inertial" params="radius length mass">
  45.     <inertial>
  46.       <mass value="${mass}" />
  47.       <origin xyz="0 0 0" />
  48.       <inertia ixx="${0.0833333 * mass * (3 * radius * radius + length * length)}" ixy="0.0" ixz="0.0"
  49.               iyy="${0.0833333 * mass * (3 * radius * radius + length * length)}" iyz="0.0"
  50.               izz="${0.5 * mass * radius * radius}" />
  51.     </inertial>
  52.   </xacro:macro>
  53.  
  54.   <xacro:macro name="box_inertial" params="x y z mass">
  55.     <inertial>
  56.       <mass value="${mass}" />
  57.       <origin xyz="0 0 0" />
  58.       <inertia ixx="${0.0833333 * mass * (y*y + z*z)}" ixy="0.0" ixz="0.0"
  59.               iyy="${0.0833333 * mass * (x*x + z*z)}" iyz="0.0"
  60.               izz="${0.0833333 * mass * (x*x + y*y)}" />
  61.     </inertial>
  62.   </xacro:macro>
  63.  
  64.   <material name="blue">
  65.     <color rgba="0 0 0.8 1"/>
  66.   </material>
  67.  
  68.   <material name="black">
  69.     <color rgba="0 0 0 1"/>
  70.   </material>
  71.  
  72.   <material name="white">
  73.     <color rgba="1 1 1 1"/>
  74.   </material>
  75.  
  76.   <link name="base_link">
  77.     <visual>
  78.       <geometry>
  79.         <cylinder length="${torso_len}" radius="${torso_rad}"/>
  80.       </geometry>
  81.       <material name="blue"/>
  82.     </visual>
  83.     <collision>
  84.       <geometry>
  85.         <cylinder length="${torso_len}" radius="${torso_rad}"/>
  86.       </geometry>
  87.     </collision>
  88.     <xacro:cylinder_inertial radius="${torso_rad}" length="${torso_len}" mass="${torso_m}"/>
  89.   </link>
  90.  
  91.   <link name="right_leg">
  92.     <visual>
  93.       <geometry>
  94.         <box size="${leg_x} ${leg_y} ${leg_z}"/>
  95.       </geometry>
  96.       <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  97.       <material name="white"/>
  98.     </visual>
  99.     <collision>
  100.       <geometry>
  101.         <box size="${leg_x} ${leg_y} ${leg_z}"/>
  102.       </geometry>
  103.       <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  104.     </collision>
  105.     <xacro:box_inertial x="${leg_x}" y="${leg_y}" z="${leg_z}" mass="${leg_m}"/>
  106.   </link>
  107.  
  108.   <joint name="base_to_right_leg" type="fixed">
  109.     <parent link="base_link"/>
  110.     <child link="right_leg"/>
  111.     <origin xyz="0 -0.22 0.25"/>
  112.   </joint>
  113.  
  114.   <link name="right_base">
  115.     <visual>
  116.       <geometry>
  117.         <box size="${base_x} ${base_y} ${base_z}"/>
  118.       </geometry>
  119.       <material name="white"/>
  120.     </visual>
  121.     <collision>
  122.       <geometry>
  123.         <box size="${base_x} ${base_y} ${base_z}"/>
  124.       </geometry>
  125.     </collision>
  126.     <xacro:box_inertial x="${base_x}" y="${base_y}" z="${base_z}" mass="${base_m}"/>
  127.   </link>
  128.  
  129.   <joint name="right_base_joint" type="fixed">
  130.     <parent link="right_leg"/>
  131.     <child link="right_base"/>
  132.     <origin xyz="0 0 -0.6"/>
  133.   </joint>
  134.  
  135.   <link name="right_front_wheel">
  136.     <visual>
  137.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  138.       <geometry>
  139.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  140.       </geometry>
  141.       <material name="black"/>
  142.     </visual>
  143.     <collision>
  144.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  145.       <geometry>
  146.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  147.       </geometry>
  148.     </collision>
  149.     <xacro:cylinder_inertial radius="${wheel_rad}" length="${wheel_len}" mass="${wheel_m}" />
  150.  
  151.   </link>
  152.  
  153.   <joint name="right_front_wheel_joint" type="continuous">
  154.     <axis rpy="0 0 0" xyz="0 1 0"/>
  155.     <parent link="right_base"/>
  156.     <child link="right_front_wheel"/>
  157.     <origin rpy="0 0 0" xyz="0.133333333333 0 -0.085"/>
  158.   </joint>
  159.  
  160.   <!-- This block provides the simulator (Gazebo) with information on a few additional
  161.    physical properties. See http://gazebosim.org/tutorials/?tut=ros_urdf for more-->
  162.   <gazebo reference="right_front_wheel">
  163.     <mu1 value="${mu1}"/>
  164.     <mu2 value="${mu2}"/>
  165.     <kp value="${kp}"/>
  166.     <kd value="${kd}"/>
  167.     <fdir1>0 1 0</fdir1>
  168.     <material>Gazebo/Grey</material>
  169.   </gazebo>
  170.  
  171.   <!-- This block connects the wheel joint to an actuator (motor), which informs both
  172.    simulation and visualization of the robot -->
  173.   <transmission name="right_front_wheel_trans">
  174.     <type>transmission_interface/SimpleTransmission</type>
  175.     <actuator name="right_front_wheel_motor">
  176.       <mechanicalReduction>1</mechanicalReduction>
  177.     </actuator>
  178.     <joint name="right_front_wheel_joint">
  179.       <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  180.     </joint>
  181.   </transmission>
  182.  
  183.   <link name="right_back_wheel">
  184.     <visual>
  185.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  186.       <geometry>
  187.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  188.       </geometry>
  189.       <material name="black"/>
  190.     </visual>
  191.     <collision>
  192.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  193.       <geometry>
  194.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  195.       </geometry>
  196.     </collision>
  197.     <xacro:cylinder_inertial radius="${wheel_rad}" length="${wheel_len}" mass="${wheel_m}" />
  198.   </link>
  199.  
  200.   <joint name="right_back_wheel_joint" type="continuous">
  201.     <axis rpy="0 0 0" xyz="0 1 0"/>
  202.     <parent link="right_base"/>
  203.     <child link="right_back_wheel"/>
  204.     <origin rpy="0 0 0" xyz="-0.133333333333 0 -0.085"/>
  205.   </joint>
  206.  
  207.   <!-- This block provides the simulator (Gazebo) with information on a few additional
  208.    physical properties. See http://gazebosim.org/tutorials/?tut=ros_urdf for more-->
  209.   <gazebo reference="right_back_wheel">
  210.     <mu1 value="${mu1}"/>
  211.     <mu2 value="${mu2}"/>
  212.     <kp value="${kp}"/>
  213.     <kd value="${kd}"/>
  214.     <fdir1>0 1 0</fdir1>
  215.     <material>Gazebo/Grey</material>
  216.   </gazebo>
  217.  
  218.   <!-- This block connects the wheel joint to an actuator (motor), which informs both
  219.    simulation and visualization of the robot -->
  220.  
  221.   <transmission name="right_back_wheel_trans">
  222.     <type>transmission_interface/SimpleTransmission</type>
  223.     <actuator name="right_back_wheel_motor">
  224.       <mechanicalReduction>1</mechanicalReduction>
  225.     </actuator>
  226.     <joint name="right_back_wheel_joint">
  227.       <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  228.     </joint>
  229.   </transmission>
  230.  
  231.   <link name="left_leg">
  232.     <visual>
  233.       <geometry>
  234.         <box size="${leg_x} ${leg_y} ${leg_z}"/>
  235.       </geometry>
  236.       <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  237.       <material name="white"/>
  238.     </visual>
  239.     <collision>
  240.       <geometry>
  241.         <box size="${leg_x} ${leg_y} ${leg_z}"/>
  242.       </geometry>
  243.       <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  244.     </collision>
  245.   <xacro:box_inertial x="${leg_x}" y="${leg_y}" z="${leg_z}" mass="${leg_m}"/>
  246.   </link>
  247.  
  248.   <joint name="base_to_left_leg" type="fixed">
  249.     <parent link="base_link"/>
  250.     <child link="left_leg"/>
  251.     <origin xyz="0 0.22 0.25"/>
  252.   </joint>
  253.  
  254.   <link name="left_base">
  255.     <visual>
  256.       <geometry>
  257.         <box size="${base_x} ${base_y} ${base_z}"/>
  258.       </geometry>
  259.       <material name="white"/>
  260.     </visual>
  261.     <collision>
  262.       <geometry>
  263.         <box size="${base_x} ${base_y} ${base_z}"/>
  264.       </geometry>
  265.     </collision>
  266.     <xacro:box_inertial x="${base_x}" y="${base_y}" z="${base_z}" mass="${base_m}"/>
  267.   </link>
  268.  
  269.   <joint name="left_base_joint" type="fixed">
  270.     <parent link="left_leg"/>
  271.     <child link="left_base"/>
  272.     <origin xyz="0 0 -0.6"/>
  273.   </joint>
  274.  
  275.   <link name="left_front_wheel">
  276.     <visual>
  277.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  278.       <geometry>
  279.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  280.       </geometry>
  281.       <material name="black"/>
  282.     </visual>
  283.     <collision>
  284.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  285.       <geometry>
  286.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  287.       </geometry>
  288.     </collision>
  289.   <xacro:cylinder_inertial radius="${wheel_rad}" length="${wheel_len}" mass="${wheel_m}" />
  290.   </link>
  291.  
  292.   <joint name="left_front_wheel_joint" type="continuous">
  293.     <axis rpy="0 0 0" xyz="0 1 0"/>
  294.     <parent link="left_base"/>
  295.     <child link="left_front_wheel"/>
  296.     <origin rpy="0 0 0" xyz="0.133333333333 0 -0.085"/>
  297.   </joint>
  298.  
  299.   <!-- This block provides the simulator (Gazebo) with information on a few additional
  300.    physical properties. See http://gazebosim.org/tutorials/?tut=ros_urdf for more-->
  301.   <gazebo reference="left_front_wheel">
  302.     <mu1 value="${mu1}"/>
  303.     <mu2 value="${mu2}"/>
  304.     <kp value="${kp}"/>
  305.     <kd value="${kd}"/>
  306.     <fdir1>0 1 0</fdir1>
  307.     <material>Gazebo/Grey</material>
  308.   </gazebo>
  309.  
  310.   <!-- This block connects the wheel joint to an actuator (motor), which informs both
  311.    simulation and visualization of the robot -->
  312.   <transmission name="left_front_wheel_trans">
  313.     <type>transmission_interface/SimpleTransmission</type>
  314.     <actuator name="left_front_wheel_motor">
  315.       <mechanicalReduction>1</mechanicalReduction>
  316.     </actuator>
  317.     <joint name="left_front_wheel_joint">
  318.       <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  319.     </joint>
  320.   </transmission>
  321.  
  322.   <link name="left_back_wheel">
  323.     <visual>
  324.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  325.       <geometry>
  326.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  327.       </geometry>
  328.       <material name="black"/>
  329.     </visual>
  330.     <collision>
  331.       <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  332.       <geometry>
  333.         <cylinder length="${wheel_len}" radius="${wheel_rad}"/>
  334.       </geometry>
  335.     </collision>
  336.   <xacro:cylinder_inertial radius="${wheel_rad}" length="${wheel_len}" mass="${wheel_m}" />
  337.   </link>
  338.  
  339.   <joint name="left_back_wheel_joint" type="continuous">
  340.     <axis rpy="0 0 0" xyz="0 1 0"/>
  341.     <parent link="left_base"/>
  342.     <child link="left_back_wheel"/>
  343.     <origin rpy="0 0 0" xyz="-0.133333333333 0 -0.085"/>
  344.   </joint>
  345.  
  346.   <!-- This block provides the simulator (Gazebo) with information on a few additional
  347.    physical properties. See http://gazebosim.org/tutorials/?tut=ros_urdf for more-->
  348.   <gazebo reference="left_back_wheel">
  349.     <mu1 value="${mu1}"/>
  350.     <mu2 value="${mu2}"/>
  351.     <kp value="${kp}"/>
  352.     <kd value="${kd}"/>
  353.     <fdir1>0 1 0</fdir1>
  354.     <material>Gazebo/Grey</material>
  355.   </gazebo>
  356.  
  357.   <!-- This block connects the wheel joint to an actuator (motor), which informs both
  358.    simulation and visualization of the robot -->
  359.   <transmission name="left_back_wheel_trans">
  360.     <type>transmission_interface/SimpleTransmission</type>
  361.     <actuator name="left_back_wheel_motor">
  362.       <mechanicalReduction>1</mechanicalReduction>
  363.     </actuator>
  364.     <joint name="left_back_wheel_joint">
  365.       <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  366.     </joint>
  367.   </transmission>
  368.  
  369.   <link name="head">
  370.     <visual>
  371.       <geometry>
  372.         <sphere radius="${head_rad}"/>
  373.       </geometry>
  374.       <material name="white"/>
  375.     </visual>
  376.     <collision>
  377.       <geometry>
  378.         <sphere radius="${head_rad}"/>
  379.       </geometry>
  380.     </collision>
  381.     <xacro:sphere_inertial radius="${head_rad}" mass="${head_m}"/>
  382.   </link>
  383.  
  384.   <joint name="head_swivel" type="continuous">
  385.     <parent link="base_link"/>
  386.     <child link="head"/>
  387.     <axis xyz="0 0 1"/>
  388.     <origin xyz="0 0 0.3"/>
  389.     <limit effort="30" velocity="1.0"/>
  390.     <dynamics damping="0.0" friction="0.0"/>
  391.   </joint>
  392.  
  393.   <!-- This block connects the head_swivel joint to an actuator (motor), which informs both
  394.  simulation and visualization of the robot -->
  395.   <transmission name="head_swivel_trans">
  396.     <type>transmission_interface/SimpleTransmission</type>
  397.     <actuator name="$head_swivel_motor">
  398.       <mechanicalReduction>1</mechanicalReduction>
  399.     </actuator>
  400.     <joint name="head_swivel">
  401.       <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
  402.     </joint>
  403.   </transmission>
  404.  
  405.   <link name="box">
  406.     <visual>
  407.       <geometry>
  408.         <box size="${box_l} ${box_l} ${box_l}"/>
  409.       </geometry>
  410.       <material name="blue"/>
  411.       <origin xyz="-0.04 0 0"/>
  412.     </visual>
  413.     <collision>
  414.       <geometry>
  415.         <box size="${box_l} ${box_l} ${box_l}"/>
  416.       </geometry>
  417.     </collision>
  418.   <xacro:box_inertial x="${box_l}" y="${box_l}" z="${box_l}" mass="${box_m}"/>
  419.   </link>
  420.  
  421.   <joint name="tobox" type="fixed">
  422.     <parent link="head"/>
  423.     <child link="box"/>
  424.     <origin xyz="0.1814 0 0.1414"/>
  425.   </joint>
  426.  
  427.   <!-- Gazebo plugin for ROS Control -->
  428.   <gazebo>
  429.     <plugin filename="libgazebo_ros_control.so" name="gazebo_ros_control">
  430.       <robotNamespace>/</robotNamespace>
  431.     </plugin>
  432.   </gazebo>
  433. </robot>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement