<?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:include filename="$(find pmb2_description)/urdf/sensors/range.gazebo.xacro" />

  <xacro:macro name="range_sensor" params="name parent *origin ros_topic update_rate maxRange minRange fov radiation">
    <link name="${name}_link">
      <inertial>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <mass value="0.001"/>
        <inertia ixx="0.000001" ixy="0" ixz="0"
                 iyy="0.000001" iyz="0"
                 izz="0.000001"/>
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://pmb2_description/meshes/sensors/srf05.stl"/>
        </geometry>
        <material name="DarkGrey"/>
      </visual>
    </link>

    <joint name="${name}_joint" type="fixed">
      <xacro:insert_block name="origin"/>
      <axis xyz="0 0 1"/>
      <parent link="${parent}_link"/>
      <child link="${name}_link"/>
    </joint>

    <!-- gazebo extensions -->
    <xacro:range_gazebo name="${name}" ros_topic="${ros_topic}" update_rate="${update_rate}" maxRange="${maxRange}" minRange="${minRange}" fov="${fov}" radiation="${radiation}"/>
  </xacro:macro>
</robot>
