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


<xacro:property name="headLength"   value="0.023" />
<xacro:property name="headRadius"   value="0.045" />

<xacro:property name="radarSupportLength"   value="0.36" />
<xacro:property name="radarSupportRadius"   value="0.019" />

    <xacro:macro name="radar">
        <link name="velodyne">
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${headLength}" radius="${headRadius}" />
                </geometry>
            </visual>
            <visual>
                <origin xyz="0 0 ${-headLength/2-radarSupportLength/2}" rpy="0 0 0" />
                <geometry>
                    <cylinder length="${radarSupportLength}" radius="${radarSupportRadius}" />
                </geometry>
            </visual>
        </link>


        <gazebo reference="velodyne">
			<material>Gazebo/PaintedWall</material>
		</gazebo>

		<gazebo reference="velodyne">
			  <sensor type="ray" name="sensor">
    		  	<pose>0 0 0 0 0 0</pose>
    		  	<visualize>true</visualize>
    			<update_rate>5</update_rate>
   				 <ray>
     				 <scan>
        				<horizontal>
          					<samples>400</samples>
         					 <resolution>0.2</resolution>
          					<min_angle>-3.1415</min_angle>
          					<max_angle>3.1415</max_angle>
        				</horizontal>
     				 </scan>
     				 <range>
        					<min>1.2</min>
       						 <max>20</max>
       						 <resolution>0.03</resolution>
      				</range>
      				<noise>
       					 <type>gaussian</type>
        				<mean>0.0</mean>
        				<stddev>0.01</stddev>
      				</noise>
    			</ray>
    			<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
     					 <topicName>scan</topicName>
     					 <frameName>velodyne</frameName>
    			</plugin>
  			</sensor>
		</gazebo>

		<gazebo reference="velodyne">
			<sensor type="ray" name="clouds">
          		<pose>0 0 0 0 0 0</pose>
          		<visualize>false</visualize>
          		<update_rate>5</update_rate>
          		<ray>
            		<scan>
              			<horizontal>
               				 <samples>400</samples>
                			<resolution>0.2</resolution>
                			<min_angle>-3.1415</min_angle>
               				<max_angle>3.1415</max_angle>
             			 </horizontal>
              			<vertical>
                			<samples>16</samples>
                			<resolution>1</resolution>
                			<min_angle>-15.0*3.14159/180.0</min_angle>
                			<max_angle> 15.0*3.14159/180.0</max_angle>
              			</vertical>
            		</scan>
            		<range>
              			<min>1.2</min>
              			<max>20</max>
              			<resolution>0.03</resolution>
            		</range>
            		<noise>
              			<type>gaussian</type>
             			 <mean>0.0</mean>
              			<stddev>0.01</stddev>
            		</noise>
          		</ray>
			  <plugin name="gazebo_ros_laser_controller" filename="libgazebo_ros_velodyne_laser.so">
			    <topicName>velodyne_points</topicName>
			    <frameName>velodyne</frameName>
			    <min_range>1.2</min_range>
			    <max_range>20</max_range>
			    <gaussianNoise>0.008</gaussianNoise>
			  </plugin>
			</sensor>
		</gazebo>
    </xacro:macro>

</robot>
