<?xml version="1.0"?>
<sdf version="1.8">
  <world name="default">

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

    <model name="M1">
      <pose>0 0 0.25 0 0.0 0</pose>
      <!-- link1 doesn't have a collision so it would fall indefinitely if the 
      contraint created by joint j1 is not enforced -->
      <link name="link1">
        <visual name="box_visual">
          <geometry>
            <box>
              <size>1 1 0.5</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>
      <joint name="j1" type="fixed">
        <parent>link1</parent>
        <child>nested_model::link2</child>
      </joint>

      <model name="nested_model">
        <pose>1 0 0.0 0 0.0 0</pose>
        <link name="link2">
          <collision name="box_collision">
            <geometry>
              <box>
                <size>1 1 0.5</size>
              </box>
            </geometry>
          </collision>

          <visual name="box_visual">
            <geometry>
              <box>
                <size>1 1 0.5</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>
    </model>

    <!-- This model is the same as M1 except the model pose and the parent and child elements of joint j1-->
    <model name="M2">
      <pose>0 5 0.25 0 0.0 0</pose>
      <!-- link1 doesn't have a collision so it would fall indefinitely if the 
      contraint created by joint j1 is not enforced -->
      <link name="link1">
        <visual name="box_visual">
          <geometry>
            <box>
              <size>1 1 0.5</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>
      <joint name="j1" type="fixed">
        <parent>nested_model::link2</parent>
        <child>link1</child>
      </joint>

      <model name="nested_model">
        <pose>1.0 0 0.0 0 0.0 0</pose>
        <link name="link2">
          <collision name="box_collision">
            <geometry>
              <box>
                <size>1 1 0.5</size>
              </box>
            </geometry>
          </collision>

          <visual name="box_visual">
            <geometry>
              <box>
                <size>1 1 0.5</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>
    </model>
  </world>
</sdf>
