<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:macro name="wheel" params="name parent radius thickness *origin">
    <link name="${name}_link">
      <inertial>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <mass value="1"/>
        <inertia ixx="0.2" ixy="0" ixz="0" iyy="0.2" iyz="0" izz="0.2"/>
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <cylinder radius="${wheel_radius}" length="${thickness}"/>
        </geometry>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <cylinder radius="${wheel_radius}" length="${thickness}"/>
        </geometry>
      </collision>
    </link>

    <joint name="${name}_joint" type="continuous">
      <parent link="${parent}_link"/>
      <child link="${name}_link"/>
      <xacro:insert_block name="origin"/>
      <axis xyz="0 0 1"/>
    </joint>

    <!-- Transmission is important to link the joints and the controller -->
    <transmission name="${name}_joint_trans" type="SimpleTransmission">
      <actuator name="${name}_joint_motor"/>
      <joint name="${name}_joint"/>
      <mechanicalReduction>1</mechanicalReduction>
      <motorTorqueConstant>1</motorTorqueConstant>
    </transmission>

    <gazebo reference="${name}_link">
      <material>Gazebo/Red</material>
    </gazebo>
  </xacro:macro>
</robot>
