<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

<!-- Front Laser -->
<xacro:macro name="laser_gpu" params="name parent xyz rpy meshes" >

  <joint name="${parent}_${name}_joint" type="fixed">
      <axis xyz="0 0 1" />
      <origin xyz="${xyz}" rpy="${rpy}"/>
      <parent link="${parent}"/>
      <child link="${name}"/>
    </joint>

    <link name="${name}">
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <box size="0.1 0.1 0.1"/>
        </geometry>
      </collision>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <mesh filename="${meshes}/hokuyo.dae"/>
        </geometry>
      </visual>
      <inertial>
        <mass value="1e-5" />
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
      </inertial>
    </link>

    <gazebo reference="${name}">
    <sensor type="gpu_ray" name="head_hokuyo_sensor">
      <pose>0 0 0 0 0 0</pose>
      <always_on>1</always_on>
      <update_rate>30</update_rate>
      <visualize>true</visualize>
      <ray>
        <scan>
          <horizontal>
            <!-- The URG-04LX-UG01  has  683 steps with 0.35139 Degree resolution -->
            <resolution>1</resolution>
            <max_angle>2.0944</max_angle> <!-- 120 Degree -->
            <min_angle>-2.0944</min_angle> <!-- -120 Degree -->
            <!--max_angle>3.14</max_angle--> <!-- 120 Degree -->
            <!--min_angle>-3.14</min_angle--> <!-- -120 Degree -->
            <samples>683</samples>
          </horizontal>
        </scan>
        <range>
          <min>0.10</min>
          <max>140.0</max>
          <resolution>0.01</resolution>
        </range>
        <noise>
          <type>gaussian</type>
          <!-- Noise parameters based on published spec for Hokuyo laser
               achieving "+-30mm" accuracy at range < 10m.  A mean of 0.0m and
               stddev of 0.01m will put 99.7% of samples within 0.03m of the true
               reading. -->
          <mean>0.0</mean>
          <stddev>0.01</stddev>
        </noise>
      </ray>
      <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_gpu_laser.so">
        <robotNamespace></robotNamespace>
        <topicName>${name}/scan</topicName>
        <frameName>${name}</frameName>
      </plugin>
    </sensor>
    </gazebo>
</xacro:macro>

</robot>
