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

  Copyright (c) 2016, PAL Robotics, S.L.
  All rights reserved.

  This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to
  Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

  Laser configuration according with the SICK TiM 561 product specification:
  https://www.sick.com/media/pdf/6/46/446/dataSheet_TiM561-2050101_1071419_en.pdf
-->
<robot xmlns:xacro="http://ros.org/wiki/xacro">

  <xacro:macro name="sick_tim561_laser_gazebo" params="name ros_topic update_rate min_angle max_angle">
    <gazebo reference="${name}_link">
      <sensor type="ray" name="${name}">
        <pose>0 0 0 0 0 0</pose>
        <update_rate>${update_rate}</update_rate>
        <visualize>true</visualize>
        <ray>
          <scan>
            <horizontal>
              <!-- 818 (270/0.33) steps in 270deg fov -->
              <samples>${818*(max_angle - min_angle)/(270.0 * deg_to_rad)}</samples>
              <resolution>1</resolution> <!-- not the sensor resolution; just 1 -->
              <min_angle>${min_angle}</min_angle>
              <max_angle>${max_angle}</max_angle>
            </horizontal>
          </scan>
          <range>
            <min>0.05</min>
            <max>10.0</max>
            <resolution>0.001</resolution>
          </range>
        </ray>
        <plugin filename="libgazebo_ros_laser.so" name="gazebo_ros_sick_laser">
          <gaussianNoise>0.06</gaussianNoise>
          <alwaysOn>true</alwaysOn>
          <updateRate>${update_rate}</updateRate>
          <topicName>${ros_topic}</topicName>
          <frameName>${name}_link</frameName>
        </plugin>
      </sensor>
      <material>Gazebo/DarkGrey</material>
    </gazebo>
  </xacro:macro>

</robot>

