<?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/bumper.gazebo.xacro" />

  <xacro:macro name="bumper" params="name parent ros_topic update_rate *origin">

    <link name="${name}_link">
      <inertial>
        <origin xyz="-0.05002000000 0.00000000000 0.00000000000" rpy="0 0 0"/>
        <mass value="0.15368000000"/>
        <inertia ixx="0.00281031560" ixy="0.00000000000" ixz="0.00000000000"
                 iyy="0.00021829037" iyz="0.00000000000"
                 izz="0.00302258512"/>
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://pmb2_description/meshes/sensors/bumper.stl"/>
        </geometry>
        <material name="DarkGrey"/>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://pmb2_description/meshes/sensors/bumper_collision.stl"/>
        </geometry>
        <material name="DarkGrey"/>
      </collision>
    </link>

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

    <!-- gazebo extensions -->
    <xacro:bumper_gazebo name="${name}" ros_topic="${ros_topic}" update_rate="${update_rate}" />

  </xacro:macro>

</robot>
