<?xml version="1.0" ?>
<robot xmlns:xacro="http://wiki.ros.org/xacro">
  <xacro:include filename="$(find fanuc_resources)/urdf/common_materials.xacro"/>

  <xacro:macro name="fanuc_lrmate200ic5h" params="prefix">
    <!-- links: main serial chain -->
    <link name="${prefix}base_link">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/visual/base_link.stl" />
        </geometry>
        <xacro:material_fanuc_gray24 />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/collision/base_link.stl" />
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_1">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/visual/link_1.stl" />
        </geometry>
        <xacro:material_fanuc_yellow />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/collision/link_1.stl" />
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_2">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/visual/link_2.stl" />
        </geometry>
        <xacro:material_fanuc_yellow />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/collision/link_2.stl" />
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_3">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic5h/visual/link_3.stl" />
        </geometry>
        <xacro:material_fanuc_yellow />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic5h/collision/link_3.stl" />
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_4">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/visual/link_5.stl" />
        </geometry>
        <xacro:material_fanuc_yellow />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/collision/link_5.stl" />
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_5">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/visual/link_6.stl" />
        </geometry>
        <xacro:material_fanuc_black />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <mesh filename="package://fanuc_lrmate200ic_support/meshes/lrmate200ic/collision/link_6.stl" />
        </geometry>
      </collision>
    </link>

    <!-- joints: main serial chain -->
    <joint name="${prefix}joint_1" type="revolute">
      <origin xyz="0 0 0.330" rpy="0 0 0" />
      <parent link="${prefix}base_link" />
      <child link="${prefix}link_1" />
      <axis xyz="0 0 1" />
      <limit effort="0" lower="-2.9671" upper="2.9671" velocity="6.1087" />
    </joint>
    <joint name="${prefix}joint_2" type="revolute">
      <origin xyz="0.075 0 0" rpy="0 0 0" />
      <parent link="${prefix}link_1" />
      <child link="${prefix}link_2" />
      <axis xyz="0 1 0" />
      <limit effort="0" lower="-1.0472" upper="2.4435" velocity="6.1087" />
    </joint>
    <joint name="${prefix}joint_3" type="revolute">
      <origin xyz="0 0 0.300" rpy="0 0 0" />
      <parent link="${prefix}link_2" />
      <child link="${prefix}link_3" />
      <axis xyz="0 -1 0" />
      <limit effort="0" lower="-2.4784" upper="4.0143" velocity="6.9813" />
    </joint>
    <joint name="${prefix}joint_4" type="revolute">
      <origin xyz="0.320 0 0.075" rpy="0 0 0" />
      <parent link="${prefix}link_3" />
      <child link="${prefix}link_4" />
      <axis xyz="0 -1 0" />
      <limit effort="0" lower="-2.0944" upper="2.0944" velocity="7.8540" />
    </joint>
    <joint name="${prefix}joint_5" type="revolute">
      <origin xyz="0.080 0 0" rpy="0 0 0" />
      <parent link="${prefix}link_4" />
      <child link="${prefix}link_5" />
      <axis xyz="-1 0 0" />
      <limit effort="0" lower="-6.285" upper="6.285" velocity="12.5664" />
    </joint>

    <!-- ROS-Industrial 'base' frame: base_link to Fanuc World Coordinates transform -->
    <link name="${prefix}base" />
    <joint name="${prefix}base_link-base" type="fixed">
      <origin xyz="0 0 0.330" rpy="0 0 0"/>
      <parent link="${prefix}base_link"/>
      <child link="${prefix}base"/>
    </joint>

    <!-- ROS-Industrial 'flange' frame: attachment point for EEF models -->
    <link name="${prefix}flange" />
    <joint name="${prefix}joint_5-flange" type="fixed">
      <origin xyz="0 0 0" rpy="0 0 0" />
      <parent link="${prefix}link_5" />
      <child link="${prefix}flange" />
    </joint>

    <!-- ROS-Industrial 'tool0' frame: all-zeros tool frame -->
    <link name="${prefix}tool0" />
    <joint name="${prefix}link_5-tool0" type="fixed">
      <origin xyz="0 0 0" rpy="${pi} ${-pi/2.0} 0" />
      <parent link="${prefix}link_5" />
      <child link="${prefix}tool0" />
    </joint>
  </xacro:macro>
</robot>
