<?xml version="1.0" encoding="utf-8"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="ee_with_one_link">
  <!-- safety_distance: Minimum safety distance in [m] by which the collision volumes are expanded and which is enforced during robot motions -->
  <xacro:macro name="ee_with_one_link" params="connected_to:='' arm_id arm_prefix:='' ee_id ee_inertials rpy_ee:='0 0 0' xyz_ee:='0 0 0' tcp_xyz:='0 0 0' tcp_rpy:='0 0 0' safety_distance:=0 gazebo:=false description_pkg:=moonshot_franka_description with_sc:=false">
    <xacro:property name="ee_prefix" default="robot_"/>
    <xacro:unless value="${arm_id == ''}">
      <xacro:property name="ee_prefix" value="${arm_prefix}${arm_id}_" />
    </xacro:unless>
    <xacro:unless value="${connected_to == ''}">
      <joint name="${ee_prefix}${ee_id}_joint" type="fixed">
        <parent link="${connected_to}" />
        <child link="${ee_prefix}${ee_id}" />
        <origin xyz="${xyz_ee}" rpy="${rpy_ee}" />
      </joint>
    </xacro:unless>

    <xacro:ee_link_with_sc name="${ee_id}" gazebo="${gazebo}" with_sc="${with_sc}">
      <self_collision_geometries>
        <xacro:collision_capsule xyz="0 0 0.04" direction="y" radius="${0.04+safety_distance}" length="0.1" />
        <xacro:collision_capsule xyz="0 0 0.10" direction="y" radius="${0.02+safety_distance}" length="0.1" />
      </self_collision_geometries>
    </xacro:ee_link_with_sc>

    <!-- Define the ${ee_id}_tcp frame -->
    <link name="${ee_prefix}${ee_id}_tcp" />
    <joint name="${ee_prefix}${ee_id}_tcp_joint" type="fixed">
      <origin xyz="${tcp_xyz}" rpy="${tcp_rpy}" />
      <parent link="${ee_prefix}${ee_id}" />
      <child link="${ee_prefix}${ee_id}_tcp" />
    </joint>
  </xacro:macro>
</robot>
