<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

    <xacro:include filename="wheel.xacro" />

    <link name="base_link">
    </link>

    <!-- CHASSIS LINK -->

    <joint name="chassis_joint" type="fixed">
        <parent link="base_link"/>
        <child link="chassis"/>
        <origin xyz="0 0 0"/>
    </joint>

    <link name="chassis">
        <visual>
            <origin xyz="0 0 0.035"/>
            <geometry>
                <box size="${base_length} ${base_width} 0.07"/>
            </geometry>
            <material name="white"/>
        </visual>
        <collision>
            <origin xyz="0 0 0.035"/>
            <geometry>
                <box size="${base_length} ${base_width} 0.07"/>
            </geometry>
        </collision>
        <xacro:inertial_box mass="3.3" x="${base_length}" y="${base_width}" z="0.07">
            <origin xyz="0 0 0.035" rpy="0 0 0"/>
        </xacro:inertial_box>
    </link>

    <gazebo reference="chassis">
        <material>Gazebo/White</material>
    </gazebo>


  <!-- Steerable front wheels -->
  <xacro:front_wheel_lr 
    name="front_right"
    parent="base"
    reflect="-1"
    wheel_radius="${wheel_radius}"
    wheel_thickness="${wheel_thickness}" 
    wheel_mass="${wheel_mass}" 
    steer_radius="${steer_radius}"
    steer_thickness="${steer_thickness}" 
    steer_mass="${steer_mass}" 
    base_length="${base_length}"
    base_width="${base_width}"
    axle_offset="${axle_offset}"
    steer_height="${wheel_radius+steer_offset}">
  </xacro:front_wheel_lr>
  <xacro:front_wheel_lr
    name="front_left"
    parent="base"
    reflect="1"
    wheel_radius="${wheel_radius}"
    wheel_thickness="${wheel_thickness}"
    wheel_mass="${wheel_mass}" 
    steer_radius="${steer_radius}"
    steer_thickness="${steer_thickness}" 
    steer_mass="${steer_mass}" 
    base_length="${base_length}"
    base_width="${base_width}"
    axle_offset="${axle_offset}"
    steer_height="${wheel_radius+steer_offset}">
  </xacro:front_wheel_lr>

  <!-- Rear wheels -->
  <xacro:rear_wheel_lr
    name="rear_right"
    parent="base"
    reflect="-1"
    wheel_radius="${wheel_radius}"
    wheel_thickness="${wheel_thickness}"
    wheel_mass="${wheel_mass}">
    <origin xyz="${-base_length/2+axle_offset} ${-base_width/2-axle_offset} 0" rpy="${-90 * deg_to_rad} 0 0"/>
  </xacro:rear_wheel_lr>
  <xacro:rear_wheel_lr
    name="rear_left"
    parent="base"
    reflect="1"
    wheel_radius="${wheel_radius}"
    wheel_thickness="${wheel_thickness}"
    wheel_mass="${wheel_mass}">
    <origin xyz="${-base_length/2+axle_offset} ${+base_width/2+axle_offset} 0" rpy="${-90 * deg_to_rad} 0 0"/>
  </xacro:rear_wheel_lr>
    

</robot>