<?xml version="1.0"?>

<sdf version="1.6"
  xmlns:xacro="http://www.ros.org/wiki/xacro">
  <world name="demo">

    <physics name="1ms" type="ignored">
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1.0</real_time_factor>
    </physics>

    <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>-4 0 6 0 0.5 0</camera_pose>
      </plugin>

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

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


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

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

    <xacro:include filename="macros.xacro" />

    <xacro:property name="m" value="20" />
    <xacro:property name="l" value="1" />
    <xacro:property name="z" value="${l + 0.5}" />
    <xacro:property name="r" value="0.05" />


    <xacro:pendulum name="pendulum" mass="${m}" length="${l}" radius="${r}" color="0 1 0 1">
      <pose>0 0 ${z} ${pi/4} 0 0</pose>
      <dynamics>
      </dynamics>
    </xacro:pendulum>

    <xacro:pendulum name="pendulum_1" mass="${m}" length="${l}" radius="${r}" color="0 1 1 1">
      <pose>0.5 0 ${z} ${pi/4} 0 0</pose>
      <dynamics>
        <damping>0</damping>
        <friction>1.0</friction>
      </dynamics>
    </xacro:pendulum>

    <xacro:pendulum name="pendulum_10" mass="${m}" length="${l}" radius="${r}" color="0 0 1 1">
      <pose>1 0 ${z} ${pi/4} 0 0</pose>
      <dynamics>
        <damping>0</damping>
        <friction>10.0</friction>
      </dynamics>
    </xacro:pendulum>

    <xacro:pendulum name="pendulum_100" mass="${m}" length="${l}" radius="${r}" color="1 0 1 1">
      <pose>1.5 0 ${z} ${pi/4} 0 0</pose>
      <dynamics>
        <damping>0</damping>
        <friction>100.0</friction>
      </dynamics>
    </xacro:pendulum>

    <xacro:pendulum name="pendulum_1000" mass="${m}" length="${l}" radius="${r}" color="1 0 0 1">
      <pose>2 0 ${z} ${pi/4} 0 0</pose>
      <dynamics>
        <damping>0</damping>
        <friction>1000.0</friction>
      </dynamics>
    </xacro:pendulum>

  </world>
</sdf>