Advertisement
Guest User

Untitled

a guest
Mar 6th, 2020
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 7.25 KB | None | 0 0
  1. <?xml version="1.0"?>
  2. <robot name="balancing" xmlns:xacro="http://ros.org/wiki/xacro">
  3.  
  4. <!-- Robot shape -->
  5. <xacro:property name="W_weight" value="0.05"/>
  6. <xacro:property name="W_l" value="0.027"/>
  7. <xacro:property name="W_diam" value="0.065"/>
  8.  
  9. <xacro:property name="base_w" value="0.15"/>
  10. <xacro:property name="base_h" value="0.2"/>
  11. <xacro:property name="base_l" value=".04"/>
  12. <xacro:property name="base_weight" value="0.2"/>
  13.  
  14. <xacro:property name="battery_w" value="0.09"/>
  15. <xacro:property name="battery_h" value="0.03"/>
  16. <xacro:property name="battery_l" value=".04"/>
  17. <xacro:property name="battery_weight" value="0.15"/>
  18.  
  19. <xacro:property name="Mot_l" value="0.07"/>
  20. <xacro:property name="Mot_diam" value="0.025"/>
  21. <xacro:property name="Mot_weight" value="0.1"/>
  22.  
  23. <!-- IMU -->
  24. <xacro:property name="noise" value="0.0"/>
  25.  
  26. <!-- DIFFERENTIAL DRIVE -->
  27. <xacro:property name="update_rate" value="20"/>
  28. <xacro:property name="torque" value="20"/>
  29.  
  30.  
  31. <!-- WHEEL -->
  32.   <xacro:macro name="wheel" params="side parent x y z">
  33.     <joint name="wheel_${side}_joint" type="continuous">
  34.       <origin xyz="${x} ${y} ${z}" rpy="0 0 0" />
  35.       <parent link="${parent}"/>
  36.       <child link="wheel_${side}_link" />
  37.       <axis xyz="0 1 0"/>
  38.     </joint>
  39.  
  40.     <link name="wheel_${side}_link">
  41.       <inertial>
  42.         <mass value="${W_weight}" />
  43.         <origin xyz="0 0 0" rpy="1.57075 0 0" />
  44.         <inertia ixx="${(W_l * W_l + W_diam * W_diam) * W_weight /12.0}" ixy="0.0" ixz="0.0"
  45.          iyy="${(W_l * W_l + W_diam * W_diam) * W_weight /12.0}" iyz="0.0"
  46.          izz="${W_weight/8.0 * W_diam * W_diam}" />
  47.       </inertial>
  48.  
  49.       <visual>
  50.         <origin xyz="0 0 0" rpy="1.57075 0 0" />
  51.         <geometry>
  52.              <cylinder length="${W_l}" radius="${W_diam/2}"/>
  53.         </geometry>
  54.       </visual>
  55.  
  56.       <collision>
  57.         <origin xyz="0 0 0" rpy="1.57075 0 0" />
  58.         <geometry>
  59.           <cylinder length="${W_l}" radius="${W_diam/2}"/>
  60.         </geometry>
  61.       </collision>
  62.     </link>
  63.  
  64.   <gazebo reference="wheel_${side}_link">
  65.     <mu1>0.7</mu1>
  66.     <mu2>0.7</mu2>
  67.     <kp>10000</kp>
  68.     <kd>10000</kd>
  69.     <material>Gazebo/Black</material>
  70.   </gazebo>
  71.   </xacro:macro>
  72.  
  73.  
  74. <!-- MOTOR -->
  75.   <xacro:macro name="motor" params="side parent x y z">
  76.     <joint name="motor_${side}_joint" type="fixed">
  77.       <origin xyz="${x} ${y} ${z}" rpy="0 0 0" />
  78.       <parent link="${parent}"/>
  79.       <child link="motor_${side}_link" />
  80.     </joint>
  81.  
  82.     <link name="motor_${side}_link">
  83.       <inertial>
  84.         <mass value="${Mot_weight}" />
  85.         <origin xyz="0 0 0" rpy="1.57075 0 0" />
  86.         <inertia ixx="${(Mot_l * Mot_l + Mot_diam * Mot_diam) * Mot_weight /12.0}" ixy="0.0" ixz="0.0"
  87.          iyy="${(Mot_l * Mot_l + Mot_diam * Mot_diam) * Mot_weight /12.0}" iyz="0.0"
  88.          izz="${Mot_weight/8.0 * Mot_diam * Mot_diam}" />
  89.       </inertial>
  90.  
  91.  
  92.       <visual>
  93.         <origin xyz="0 0 0" rpy="1.57075 0 0" />
  94.         <geometry>
  95.           <cylinder length="${Mot_l}" radius="${Mot_diam/2}"/>
  96.         </geometry>
  97.       </visual>
  98.  
  99.       <collision>
  100.         <origin xyz="0 0 0" rpy="1.57075 0 0" />
  101.         <geometry>
  102.           <cylinder length="${  Mot_l}" radius="${Mot_diam/2}"/>
  103.         </geometry>
  104.       </collision>
  105.     </link>
  106.  
  107.   <gazebo reference="motor_${side}_link">
  108.     <mu1>0.7</mu1>
  109.     <mu2>0.7</mu2>
  110.     <kp>10000</kp>
  111.     <kd>10000</kd>
  112.     <material>Gazebo/Gray</material>
  113.   </gazebo>
  114.   </xacro:macro>
  115.  
  116.   <xacro:macro name="battery" params="parent x y z">
  117.     <link name="battery_link">
  118.  
  119.       <inertial>
  120.         <mass value="${battery_weight}" />
  121.         <origin xyz="0 0 0.0" />
  122.         <inertia ixx="${(battery_w * battery_w + battery_h * battery_h) * battery_weight /12.0}" ixy="0.0" ixz="0.0"
  123.          iyy="${(battery_h * battery_h + battery_l * battery_l) * battery_weight /12.0}" iyz="0.0"
  124.          izz="${(battery_w * battery_w + battery_l * battery_l) * battery_weight /12.0}" />
  125.       </inertial>
  126.  
  127.       <visual>
  128.         <origin xyz="0 0 0" />
  129.         <geometry>
  130.              <box size="${battery_l} ${battery_w} ${battery_h}"/>
  131.         </geometry>
  132.       </visual>
  133.  
  134.       <collision>
  135.         <origin xyz="0 0 0" />
  136.         <geometry>
  137.              <box size="${battery_l} ${battery_w} ${battery_h}"/>
  138.         </geometry>
  139.       </collision>
  140.     </link>
  141.  
  142.   <gazebo reference="battery_link">
  143.     <mu1>0.3</mu1>
  144.     <mu2>0.3</mu2>
  145.     <kp>10000</kp>
  146.     <kd>10000</kd>
  147.     <material>Gazebo/Green</material>
  148.   </gazebo>
  149.  
  150.     <joint name="battery_joint" type="fixed">
  151.       <origin xyz="${x} ${y} ${z}" rpy="0 0 0" />
  152.       <parent link="${parent}"/>
  153.       <child link="battery_link" />
  154.     </joint>
  155.   </xacro:macro>
  156.  
  157.  
  158.  
  159.     <link name="base_link">
  160.  
  161.       <inertial>
  162.         <mass value="${base_weight}" />
  163.         <origin xyz="0 0 0" />
  164.         <inertia ixx="${(base_w * base_w + base_h * base_h) * base_weight /12.0}" ixy="0.0" ixz="0.0"
  165.          iyy="${(base_h * base_h + base_l * base_l) * base_weight /12.0}" iyz="0.0"
  166.          izz="${(base_w * base_w + base_l * base_l) * base_weight /12.0}" />
  167.       </inertial>
  168.  
  169.  
  170.       <visual>
  171.         <origin xyz="0 0 0" />
  172.         <geometry>
  173.              <box size="${base_l} ${base_w} ${base_h}"/>
  174.         </geometry>
  175.       </visual>
  176.  
  177.       <collision>
  178.         <origin xyz="0 0 0" />
  179.         <geometry>
  180.              <box size="${base_l} ${base_w} ${base_h}"/>
  181.         </geometry>
  182.       </collision>
  183.     </link>
  184.  
  185.   <gazebo reference="base_link">
  186.     <mu1>0.3</mu1>
  187.     <mu2>0.3</mu2>
  188.     <kp>10000</kp>
  189.     <kd>10000</kd>
  190.     <material>Gazebo/White</material>
  191.   </gazebo>
  192.  
  193.    
  194.    <xacro:motor parent="base_link" side="dx" x="0" y="0.04" z="-${(base_h+Mot_diam)/2}"/>
  195.    <xacro:wheel parent="motor_dx_link" side="dx" x="0" y="0.05" z="0"/>
  196.     <xacro:motor parent="base_link" side="sx" x="0" y="-0.04" z="-${(base_h+Mot_diam)/2}"/>
  197.     <xacro:wheel parent="motor_sx_link" side="sx" x="0" y="-0.05" z="0"/>
  198.     <xacro:battery parent="base_link" x="0" y="0" z="${(base_h + battery_h)/2}"/>
  199.  
  200.  
  201.  
  202. <!--  SENSORS -->
  203.   <gazebo>
  204.     <plugin name="imu_plugin" filename="libgazebo_ros_imu.so">
  205.       <alwaysOn>true</alwaysOn>
  206.       <bodyName>base_link</bodyName>
  207.       <topicName>imu</topicName>
  208.       <serviceName>imu_service</serviceName>
  209.       <gaussianNoise>${noise}</gaussianNoise>
  210.       <updateRate>20.0</updateRate>
  211.     </plugin>
  212.   </gazebo>
  213.  
  214.  
  215. <!-- DIFFERENTIAL DRIVE -->
  216. <gazebo>
  217.   <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
  218.     <legacyMode>false</legacyMode>
  219.     <alwaysOn>true</alwaysOn>
  220.     <updateRate>${update_rate}</updateRate>
  221.     <leftJoint>wheel_dx_joint</leftJoint>
  222.     <rightJoint>wheel_sx_joint</rightJoint>
  223.     <wheelSeparation>0.2</wheelSeparation>
  224.     <wheelDiameter>${W_diam}</wheelDiameter>
  225.     <torque>${torque}</torque>
  226.     <commandTopic>cmd_vel</commandTopic>
  227.     <odometryTopic>odom</odometryTopic>
  228.     <odometryFrame>odom</odometryFrame>
  229.     <robotBaseFrame>base_link</robotBaseFrame>
  230.  
  231.     <wheelTorque>${torque}</wheelTorque>
  232.     <wheelAcceleration>20</wheelAcceleration>
  233.     <publishWheelJointState>true</publishWheelJointState>
  234.     <publishOdomTF>true</publishOdomTF>
  235.     <publishWheelTF>true</publishWheelTF>
  236.  
  237.  
  238.   </plugin>
  239. </gazebo>
  240.  
  241.  
  242. </robot>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement