<?xml version="1.0" ?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:macro name="motoman_ar2010" params="prefix">

    <xacro:include filename="$(find motoman_resources)/urdf/common_materials.xacro"/>

    <!-- link list -->
    <link name="${prefix}base_link">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/base_link.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/base_link.stl"/>
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_1_s">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/link_1_s.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/link_1_s.stl"/>
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_2_l">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/link_2_l.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/link_2_l.stl"/>
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_3_u">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/link_3_u.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/link_3_u.stl"/>
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_4_r">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/link_4_r.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/link_4_r.stl"/>
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_5_b">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/link_5_b.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/link_5_b.stl"/>
        </geometry>
      </collision>
    </link>
    <link name="${prefix}link_6_t">
      <visual>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/visual/link_6_t.stl"/>
        </geometry>
        <xacro:material_yaskawa_blue/>
      </visual>
      <collision>
        <geometry>
          <mesh filename="package://motoman_ar2010_support/meshes/collision/link_6_t.stl"/>
        </geometry>
      </collision>
    </link>
    <!-- end of link list -->

    <!-- joint list -->
    <!-- Joints are specified such that the driver rotates the joints about the positive Z axis. -->
    <joint name="${prefix}joint_1_s" type="revolute">
      <parent link="${prefix}base_link"/>
      <child link="${prefix}link_1_s"/>
      <origin xyz="0 0 0.505" rpy="0 0 0"/>
      <axis xyz="0 0 1"/>
      <limit lower="${radians(-180)}" upper="${radians(180)}" effort="3087" velocity="${radians(210)}"/>
    </joint>
    <joint name="${prefix}joint_2_l" type="revolute">
      <parent link="${prefix}link_1_s"/>
      <child link="${prefix}link_2_l"/>
      <origin xyz="0.150 0 0" rpy="${pi/2} ${-pi/2} ${-pi}"/>
      <axis xyz="0 0 1"/>
      <limit lower="${radians(-105)}" upper="${radians(155)}" effort="3087" velocity="${radians(210)}"/>
    </joint>
    <joint name="${prefix}joint_3_u" type="revolute">
      <parent link="${prefix}link_2_l"/>
      <child link="${prefix}link_3_u"/>
      <origin xyz="0.760 0 0" rpy="${pi} 0 0"/>
      <axis xyz="0 0 1"/>
      <limit lower="${radians(-86)}" upper="${radians(160)}" effort="926.1" velocity="${radians(220)}"/>
    </joint>
    <joint name="${prefix}joint_4_r" type="revolute">
      <parent link="${prefix}link_3_u"/>
      <child link="${prefix}link_4_r"/>
      <origin xyz="0.200 -1.082 0" rpy="${-pi/2} 0 0"/>
      <axis xyz="0 0 1"/>
      <limit lower="${radians(-150)}" upper="${radians(150)}" effort="78.4" velocity="${radians(435)}"/>
    </joint>
    <joint name="${prefix}joint_5_b" type="revolute">
      <parent link="${prefix}link_4_r"/>
      <child link="${prefix}link_5_b"/>
      <origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
      <axis xyz="0 0 1"/>
      <limit lower="${radians(-135)}" upper="${radians(90)}" effort="67.03" velocity="${radians(435)}"/>
    </joint>
    <joint name="${prefix}joint_6_t" type="revolute">
      <parent link="${prefix}link_5_b"/>
      <child link="${prefix}link_6_t"/>
      <origin xyz="0 -0.100 0" rpy="${-pi/2} 0 0"/>
      <axis xyz="0 0 1"/>
      <limit lower="${radians(-210)}" upper="${radians(210)}" effort="33.3" velocity="${radians(700)}"/>
    </joint>
    <!-- end of joint list -->

    <!-- ROS base_link to Robot Manufacturer World Coordinates transform -->
    <link name="${prefix}base"/>
    <joint name="${prefix}base_link-base" type="fixed">
      <origin xyz="0 0 0.505" 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_6_t-flange" type="fixed">
      <origin xyz="0 0 0" rpy="0 ${pi/2} 0"/>
      <parent link="${prefix}link_6_t"/>
      <child link="${prefix}flange"/>
    </joint>

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