<?xml version="1.0"?>
<!--

  Copyright (c) 2021 PAL Robotics S.L. All rights reserved.
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<robot xmlns:xacro="http://ros.org/wiki/xacro">

  <xacro:macro name="ft_sensor" params="name parent">
    <!--************************-->
    <!--        ft sensor       -->
    <!--************************-->
    <link name="${name}_ft_link">
      <inertial>
        <mass value="0.1" />
        <inertia ixx="1.6E-05" ixy="-2.0E-06" ixz="0.0" iyy="1.6E-05" iyz="0.0" izz="2.7E-05" />
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <cylinder radius="${0.045*0.5}" length="0.0157"/>
        </geometry>
        <material name="LightGrey" />
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <cylinder radius="${0.045*0.5}" length="0.0157"/>
        </geometry>
      </collision>
    </link>

    <joint name="${name}_ft_joint" type="fixed">
      <parent link="${parent}" />
      <child link="${name}_ft_link" />
      <origin xyz="${0.0157*0.5} 0 0" rpy="${90.0 * deg_to_rad} 0 ${90.0 * deg_to_rad}" />
    </joint>

    <!--***********************-->
    <!--       FT TOOL         -->
    <!--***********************-->
    <link name="${name}_ft_tool_link">
      <inertial>
        <mass value="0.1" />
        <inertia ixx="1.64E-05" ixy="0.0" ixz="0.0" iyy="1.64E-05" iyz="0.0" izz="3.125E-05" />
      </inertial>
      <visual>
        <origin xyz="0.0 0 0" rpy="0 ${90.0 * deg_to_rad} 0" />
        <geometry>
          <cylinder radius="${0.05*0.5}" length="0.00975"/>
        </geometry>
        <material name="FlatBlack" />
      </visual>
      <collision>
        <origin xyz="0.0 0 0" rpy="0 ${90.0 * deg_to_rad} 0" />
        <geometry>
          <cylinder radius="${0.05*0.5}" length="0.00975"/>
        </geometry>
      </collision>
    </link>

    <joint name="${name}_tool_joint" type="fixed">
      <parent link="${name}_ft_link" />
      <child link="${name}_ft_tool_link" />
      <origin xyz="0 0 ${0.0157*0.5 + 0.00975*0.5}" rpy="${-90.0 * deg_to_rad} ${-90.0 * deg_to_rad} 0" />
    </joint>

</xacro:macro>

</robot>
