<?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.

  ROS Gazebo plugin for RGBD sensor (OpenNI/Kinect/ASUS) imitating the real ASUS Xtion Pro Life
   * sensor_msgs/Image format RGB8 in rgb/image_raw
   * Depth distance sensor_msgs/Image format 32FC1 in depth_registered/image_raw
   * sensor_msgs/PointCloud2 in depth_registered/points with RGB
  Note that the depth 16UC1 image is NOT published in simulation.
  Note that the IR image is NOT published in simulation.
-->
<robot xmlns:xacro="http://ros.org/wiki/xacro">

  <xacro:macro name="openni_camera_gazebo_v0" params="name">
    <gazebo reference="${name}_rgb_frame">
      <sensor type="depth" name="${name}_frame_sensor">
        <always_on>true</always_on>
        <update_rate>30.0</update_rate>
        <camera>
          <horizontal_fov>${63.0*M_PI/180.0}</horizontal_fov>
          <image>
            <format>B8G8R8</format>
            <width>640</width>
            <height>480</height>
          </image>
          <clip>
            <near>0.3</near>
            <far>8.0</far>
          </clip>
        </camera>
        <plugin name="${name}_frame_controller" filename="libgazebo_ros_openni_kinect.so">
          <alwaysOn>true</alwaysOn>
          <updateRate>30.0</updateRate>
          <cameraName>${name}</cameraName>
          <imageTopicName>rgb/image_raw</imageTopicName>
          <cameraInfoTopicName>rgb/camera_info</cameraInfoTopicName>
          <depthImageTopicName>depth_registered/image_raw</depthImageTopicName>
          <depthImageCameraInfoTopicName>depth_registered/camera_info</depthImageCameraInfoTopicName>
          <pointCloudTopicName>depth_registered/points</pointCloudTopicName>
          <frameName>${name}_rgb_optical_frame</frameName>
          <pointCloudCutoff>0.5</pointCloudCutoff>
          <pointCloudCutoffMax>8.0</pointCloudCutoffMax>
          <distortionK1>0.00000001</distortionK1>
          <distortionK2>0.00000001</distortionK2>
          <distortionK3>0.00000001</distortionK3>
          <distortionT1>0.00000001</distortionT1>
          <distortionT2>0.00000001</distortionT2>
        </plugin>
      </sensor>
    </gazebo>
  </xacro:macro>
</robot>
