<?xml version="1.0" ?>

<sdf version="1.7">
  <world name="empty">
    <physics name="1ms" type="ignored">
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1.0</real_time_factor>
    </physics>
    <plugin
      filename="gz-sim-physics-system"
      name="gz::sim::systems::Physics">
    </plugin>
    <plugin
      filename="gz-sim-user-commands-system"
      name="gz::sim::systems::UserCommands">
    </plugin>
    <plugin
      filename="gz-sim-scene-broadcaster-system"
      name="gz::sim::systems::SceneBroadcaster">
    </plugin>
    <plugin
      filename="gz-sim-contact-system"
      name="gz::sim::systems::Contact">
    </plugin>
    <plugin
      filename="gz-sim-sensors-system"
      name="gz::sim::systems::Sensors">
      <!-- Harmonic's Ogre2 backend does not register the Brown distortion
           pass, so this tutorial uses Ogre for the camera sensors. -->
      <render_engine>ogre</render_engine>
    </plugin>

    <gui fullscreen="0">
      <plugin filename="MinimalScene" name="3D View">
        <gz-gui>
          <title>3D View</title>
          <property type="bool" key="showTitleBar">false</property>
          <property type="string" key="state">docked</property>
        </gz-gui>
        <engine>ogre2</engine>
        <scene>scene</scene>
        <ambient_light>0.4 0.4 0.4</ambient_light>
        <background_color>0.8 0.8 0.8</background_color>
        <camera_pose>7 7 5 0 0.45 -2.35</camera_pose>
      </plugin>

      <plugin filename="GzSceneManager" name="Scene Manager">
        <gz-gui>
          <property key="state" type="string">floating</property>
          <property key="showTitleBar" type="bool">false</property>
          <property key="width" type="double">5</property>
          <property key="height" type="double">5</property>
        </gz-gui>
      </plugin>
      <plugin filename="InteractiveViewControl" name="Interactive view control">
        <gz-gui>
          <property key="state" type="string">floating</property>
          <property key="showTitleBar" type="bool">false</property>
          <property key="width" type="double">5</property>
          <property key="height" type="double">5</property>
        </gz-gui>
      </plugin>

      <!-- Play, pause, and single-step controls. Keep the widget on the
           bottom-right so it does not overlap the camera windows on the left. -->
      <plugin filename="WorldControl" name="World control">
        <gz-gui>
          <title>World control</title>
          <property key="showTitleBar" type="bool">false</property>
          <property key="resizable" type="bool">false</property>
          <property key="width" type="double">121</property>
          <property key="height" type="double">72</property>
          <property key="z" type="double">2</property>
          <property key="state" type="string">floating</property>
          <anchors target="3D View">
            <line own="right" target="right"/>
            <line own="bottom" target="bottom"/>
          </anchors>
        </gz-gui>
        <play_pause>true</play_pause>
        <step>true</step>
        <start_paused>true</start_paused>
        <use_event>true</use_event>
      </plugin>

      <plugin filename="ImageDisplay" name="Camera image">
        <gz-gui>
          <title>camera</title>
          <property key="state" type="string">floating</property>
          <property key="width" type="double">320</property>
          <property key="height" type="double">240</property>
          <property key="x" type="double">0</property>
          <property key="y" type="double">0</property>
          <property key="z" type="double">1</property>
        </gz-gui>
        <topic>camera</topic>
        <topic_picker>false</topic_picker>
      </plugin>
      <plugin filename="ImageDisplay" name="Noisy camera image">
        <gz-gui>
          <title>camera_noise</title>
          <property key="state" type="string">floating</property>
          <property key="width" type="double">320</property>
          <property key="height" type="double">240</property>
          <property key="x" type="double">0</property>
          <property key="y" type="double">240</property>
          <property key="z" type="double">1</property>
        </gz-gui>
        <topic>camera_noise</topic>
        <topic_picker>false</topic_picker>
      </plugin>
      <plugin filename="ImageDisplay" name="Distorted camera image">
        <gz-gui>
          <title>camera_distortion</title>
          <property key="state" type="string">floating</property>
          <property key="width" type="double">320</property>
          <property key="height" type="double">240</property>
          <property key="x" type="double">0</property>
          <property key="y" type="double">480</property>
          <property key="z" type="double">1</property>
        </gz-gui>
        <topic>camera_distortion</topic>
        <topic_picker>false</topic_picker>
      </plugin>
      <plugin filename="ImageDisplay" name="Grayscale camera image">
        <gz-gui>
          <title>camera_gray</title>
          <property key="state" type="string">floating</property>
          <property key="width" type="double">320</property>
          <property key="height" type="double">240</property>
          <property key="x" type="double">320</property>
          <property key="y" type="double">0</property>
          <property key="z" type="double">1</property>
        </gz-gui>
        <topic>camera_gray</topic>
        <topic_picker>false</topic_picker>
      </plugin>
    </gui>

    <light type="directional" name="sun">
      <cast_shadows>true</cast_shadows>
      <pose>0 0 10 0 0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
    </light>

    <model name="ground_plane">
      <static>true</static>
      <link name="link">
        <collision name="collision">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <ambient>0.8 0.8 0.8 1</ambient>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.8 0.8 0.8 1</specular>
          </material>
        </visual>
      </link>
    </model>

    <model name="box">
      <pose>0 -1 0.5 0 0 0</pose>
      <link name="box_link">
        <inertial>
          <inertia>
            <ixx>1</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>1</iyy>
            <iyz>0</iyz>
            <izz>1</izz>
          </inertia>
          <mass>1.0</mass>
        </inertial>
        <collision name="box_collision">
          <geometry>
            <box>
              <size>1 1 1</size>
            </box>
          </geometry>
        </collision>

        <visual name="box_visual">
          <geometry>
            <box>
              <size>1 1 1</size>
            </box>
          </geometry>
          <material>
            <ambient>1 0 0 1</ambient>
            <diffuse>1 0 0 1</diffuse>
            <specular>1 0 0 1</specular>
          </material>
        </visual>
      </link>
    </model>

    <!-- Straight reference line makes the camera distortion easy to see. -->
    <model name="horizontal_reference_line">
      <static>true</static>
      <!-- Keep the line near the top of the camera image, where radial
           distortion is stronger than at the optical center. -->
      <pose>0 0 2.3 0 0 0</pose>
      <link name="link">
        <visual name="visual">
          <geometry>
            <box>
              <size>0.05 5 0.05</size>
            </box>
          </geometry>
          <material>
            <ambient>0.05 0.05 0.05 1</ambient>
            <diffuse>0.05 0.05 0.05 1</diffuse>
            <specular>0 0 0 1</specular>
          </material>
        </visual>
      </link>
    </model>

    <!-- camera -->
    <model name="camera">
      <pose>4 0 1.0 0 0.0 3.14</pose>
      <link name="link">
        <pose>0.05 0.05 0.05 0 0 0</pose>
        <inertial>
          <mass>0.1</mass>
          <inertia>
            <ixx>0.000166667</ixx>
            <iyy>0.000166667</iyy>
            <izz>0.000166667</izz>
          </inertia>
        </inertial>
        <collision name="collision">
          <geometry>
            <box>
              <size>0.1 0.1 0.1</size>
            </box>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <box>
              <size>0.1 0.1 0.1</size>
            </box>
          </geometry>
        </visual>
        <sensor name="camera" type="camera">
          <camera>
            <camera_info_topic>camera/camera_info</camera_info_topic>
            <horizontal_fov>1.047</horizontal_fov>
            <image>
              <width>320</width>
              <height>240</height>
            </image>
            <clip>
              <near>0.1</near>
              <far>100</far>
            </clip>
          </camera>
          <always_on>1</always_on>
          <update_rate>30</update_rate>
          <visualize>true</visualize>
          <topic>camera</topic>
        </sensor>
        <sensor name="camera_gray" type="camera">
          <camera>
            <camera_info_topic>camera_gray/camera_info</camera_info_topic>
            <horizontal_fov>1.047</horizontal_fov>
            <image>
              <width>320</width>
              <height>240</height>
              <format>L8</format>
            </image>
            <clip>
              <near>0.1</near>
              <far>100</far>
            </clip>
          </camera>
          <always_on>1</always_on>
          <update_rate>30</update_rate>
          <visualize>true</visualize>
          <topic>camera_gray</topic>
        </sensor>
        <sensor name="camera_noise" type="camera">
          <camera>
            <camera_info_topic>camera_noise/camera_info</camera_info_topic>
            <horizontal_fov>1.047</horizontal_fov>
            <image>
              <width>320</width>
              <height>240</height>
            </image>
            <clip>
              <near>0.1</near>
              <far>100</far>
            </clip>
            <noise>
              <type>gaussian</type>
              <mean>0.0</mean>
              <stddev>0.20</stddev>
            </noise>
          </camera>
          <always_on>1</always_on>
          <update_rate>30</update_rate>
          <visualize>true</visualize>
          <topic>camera_noise</topic>
        </sensor>
        <sensor name="camera_distortion" type="camera">
          <camera>
            <camera_info_topic>camera_distortion/camera_info</camera_info_topic>
            <horizontal_fov>1.047</horizontal_fov>
            <image>
              <width>320</width>
              <height>240</height>
            </image>
            <clip>
              <near>0.1</near>
              <far>100</far>
            </clip>
            <distortion>
              <k1>-0.4</k1>
              <k2>0.2</k2>
              <k3>0.0</k3>
              <p1>0.02</p1>
              <p2>-0.02</p2>
              <center>0.5 0.5</center>
            </distortion>
          </camera>
          <always_on>1</always_on>
          <update_rate>30</update_rate>
          <visualize>true</visualize>
          <topic>camera_distortion</topic>
        </sensor>
      </link>
    </model>
  </world>
</sdf>
