<?xml version="1.0"?>

<robot name="turtlebot" xmlns:xacro="http://www.ros.org/wiki/xacro">
    
    <xacro:arg name="model" default="$(find turtlebot_description)/urdf/turtlebot.urdf.xacro"/>

    <xacro:include filename="$(find turtlebot_description)/urdf/turtlebot_gazebo.xacro"/>

    <link name = "base_footprint"/>

    <link name="base_link">
        <visual>
            <origin xyz="-0.2 0.2 -0.07" rpy="1.5708 0 0"/>
            <geometry>
                <mesh filename="package://turtlebot_description/meshes/bases/kubot_base.STL" scale="0.001 0.001 0.001"/>
            </geometry>
            <material name="light_black"/>
        </visual>

        <collision>
            <origin xyz="-0.064 0 0.047" rpy="0 0 0"/>
            <geometry>
            <box size="0.266 0.266 0.094"/>
            </geometry>
        </collision>

        <inertial>
            <origin xyz="0.0 0 0.0" rpy="0 0 0"/>
            <mass value="1.6329594e+00"/>
            <inertia ixx="8.7002718e-03" ixy="-4.7576583e-05" ixz="1.1160499e-04"
               iyy="8.6195418e-03" iyz="-3.5422299e-06"
               izz="1.4612727e-02"/>
            </inertial>
    </link>

    <link name="wheel_left_link">
        <visual>
            <origin xyz="0 0 0" rpy="1.57 0 0"/>
            <geometry>
                <mesh filename="package://turtlebot_description/meshes/wheels/left_tire.stl" scale="0.001 0.001 0.001"/>
            </geometry>
            <material name="dark"/>
        </visual>

        <collision>
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
            <cylinder length="0.018" radius="0.033"/>
            </geometry>
        </collision>

        <inertial>
            <origin xyz="0 0 0" />
            <mass value="2.8498940e-02" />
            <inertia ixx="1.1175580e-05" ixy="-4.2369783e-11" ixz="-5.9381719e-09"
               iyy="1.1192413e-05" iyz="-1.4400107e-11"
               izz="2.0712558e-05" />
            </inertial>
    </link>

    <link name="wheel_right_link">
        <visual>
            <origin xyz="0 0 0" rpy="1.57 0 0"/>
            <geometry>
                <mesh filename="package://turtlebot_description/meshes/wheels/right_tire.stl" scale="0.001 0.001 0.001"/>
            </geometry>
            <material name="dark"/>
        </visual>

        <collision>
            <origin xyz="0 0.001 0" rpy="0 0 0"/>
            <geometry>
            <cylinder length="0.018" radius="0.033"/>
            </geometry>
        </collision>

        <inertial><launch>
            <arg name="model" default="$(find turtlebot_description)/urdf/turtlebot.urdf.xacro"/>
            <param name="robot_description" command="$(find xacro)/xacro --inorder $(arg model)"/>
            <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher"/>
            <node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui"/>
            <node pkg="rviz" type="rviz" args="-d $(find turtlebot_description)/rviz/display.rviz"/>
        </launch>
        
            <origin xyz="0 0 0" />
            <mass value="2.8498940e-02" />
            <inertia ixx="1.1175580e-05" ixy="-4.2369783e-11" ixz="-5.9381719e-09"
               iyy="1.1192413e-05" iyz="-1.4400107e-11"
               izz="2.0712558e-05" />
            </inertial>
    </link>

    <link name="caster_back">
        

        <collision>
            <origin xyz="0 0.004 0" rpy="0 0 0"/>
            <geometry>
                <box size="0.030 0.009 0.020"/>
            </geometry>
        </collision>

        <inertial>
            <origin xyz="0 0 0" />
            <mass value="0.005" />
            <inertia ixx="0.001" ixy="0.0" ixz="0.0"
               iyy="0.001" iyz="0.0"
               izz="0.001" />
        </inertial>            
    </link>

    <link name="imu_link"/>

    <link name="base_scan">
        <visual>
            <origin xyz="0 0 0.0" rpy="0 0 0"/>
            <geometry>
                <mesh filename="package://turtlebot_description/meshes/sensors/lds.stl" scale="0.001 0.001 0.001"/>
            </geometry>
            <material name="dark"/>
        </visual>

        <collision>
            <origin xyz="0.015 0 -0.0065" rpy="0 0 0"/>
            <geometry>
                <cylinder length="0.0315" radius="0.045"/>
            </geometry>
        </collision>

        <inertial>
            <mass value="0.114" />
            <origin xyz="0 0 0" />
            <inertia ixx="0.001" ixy="0.0" ixz="0.0"
               iyy="0.001" iyz="0.0"
               izz="0.001" />
        </inertial>
    </link>

    <!-- <link name="camera_link">
        <collision>
        <origin xyz="0.005 0.011 0.013" rpy="0 0 0"/>
        <geometry>
            <box size="0.015 0.030 0.027"/>
        </geometry>
        </collision>
    </link>

    <link name="camera_rgb_frame"/>

    <link name="camera_rgb_optical_frame"/> -->

    <joint name="base_joint" type="fixed">
        <parent link="base_footprint"/>
        <child link="base_link" />
        <origin xyz="0.1 0 -0.01" rpy="0 0 0"/>
    </joint>

    <joint name="wheel_left_joint" type="continuous">
        <parent link="base_link"/>
        <child link="wheel_left_link"/>
        <origin xyz="0.0 0.144 0.023" rpy="-1.57 0 0"/>
        <axis xyz="0 0 1"/>
    </joint>

    <joint name="wheel_right_joint" type="continuous">
        <parent link="base_link"/>
        <child link="wheel_right_link"/>
        <origin xyz="0.0 -0.144 0.023" rpy="-1.57 0 0"/>
        <axis xyz="0 0 1"/>
    </joint>

    <joint name="caster_back_right_joint" type="fixed">
        <parent link="base_link"/>
        <child link="caster_back"/>
        <origin xyz="-0.177 0 -0.004" rpy="-1.57 0 0"/>
    </joint>



    <joint name="imu_joint" type="fixed">
        <parent link="base_link"/>
        <child link="imu_link"/>
        <origin xyz="0.0 0 0.068" rpy="0 0 0"/>
    </joint>

    <joint name="scan_joint" type="fixed">
        <parent link="base_link"/>
        <child link="base_scan"/>
        <origin xyz="-0.024 0 0.122" rpy="0 0 0"/> 
    </joint>

    <!-- <joint name="camera_joint" type="fixed">
        <origin xyz="0.073 -0.011 0.084" rpy="0 0 0"/>
        <parent link="base_link"/>
        <child link="camera_link"/>
    </joint>

    <joint name="camera_rgb_joint" type="fixed">
        <origin xyz="0.003 0.011 0.009" rpy="0 0 0"/>
        <parent link="camera_link"/>
        <child link="camera_rgb_frame"/>
    </joint>

    <joint name="camera_rgb_optical_joint" type="fixed">
        <origin xyz="0 0 0" rpy="-1.57 0 -1.57"/>
        <parent link="camera_rgb_frame"/>
        <child link="camera_rgb_optical_frame"/>
    </joint> -->
<!-- zzz -->
</robot>