<mujoco model="quadruped">

  <include file="../../common/skybox.xml" />
  <include file="../../common/visual.xml" />
  <include file="./quadruped_materials.xml" />

  <visual>
    <rgba rangefinder="1 1 0.1 0.1" />
    <map znear=".005" zfar="20" />
  </visual>

  <asset>
    </asset>

  <option timestep=".005" />

  <default>
    <geom solimp=".9 .99 .003" solref=".01 1" />
    <default class="body">
      <geom type="capsule" size=".08" condim="1" material="self" density="500" />
      <joint type="hinge" damping="30" armature=".01" limited="true" solimplimit="0 .99 .01" />
      <default class="hip">
        <default class="yaw">
          <joint axis="0 0 1" range="-50 50" />
        </default>
        <default class="pitch">
          <joint axis="0 1 0" range="-20 60" />
        </default>
        <geom fromto="0 0 0 .3 0 .11" />
      </default>
      <default class="knee">
        <joint axis="0 1 0" range="-60 25" />
        <geom size=".065" fromto="0 0 0 .25 0 -.25" />
      </default>
      <default class="ankle">
        <joint axis="0 1 0" range="-45 45" />
        <geom size=".055" fromto="0 0 0 0 0 -.25" />
      </default>
      <default class="toe">
        <geom type="sphere" size=".08" material="effector" friction="1.5" />
        <site type="sphere" size=".084" material="site" group="4" />
      </default>
    </default>
    <default class="rangefinder">
      <site type="capsule" size=".005 .1" material="site" group="4" />
    </default>
    <default class="wall">
      <geom type="plane" material="decoration" />
    </default>

    <default class="coupling">
      <equality solimp="0.95 0.99 0.01" solref=".005 .5" />
    </default>

    <general ctrllimited="true" gainprm="1000" biasprm="0 -1000" biastype="affine" dyntype="filter" dynprm=".1" />
    <default class="yaw_act">
      <general ctrlrange="-1 1" />
    </default>
    <default class="lift_act">
      <general ctrlrange="-1 1.1" />
    </default>
    <default class="extend_act">
      <general ctrlrange="-.8 .8" />
    </default>
  </default>

  <asset>
    <texture name="ball" builtin="checker" mark="cross" width="151" height="151" rgb1="0.1 0.1 0.1" rgb2="0.9 0.9 0.9" markrgb="1 1 1" />
    <material name="ball" texture="ball" />
  </asset>


  <worldbody>
    <geom name="floor" type="plane" size="0 0 0.01" material="motphys-ground" />
    <light pos="0 0 1.5" dir="0 0 -1" directional="true" />
    <camera name="global" pos="-10 10 10" xyaxes="-1 -1 0 1 0 1" mode="trackcom" />
    <body name="torso" childclass="body" pos="0 0 .57">
      <freejoint name="root" />

      <camera name="x" pos="-1.7 0 1" xyaxes="0 -1 0 .75 0 1" mode="trackcom" />
      <camera name="y" pos="0 4 2" xyaxes="-1 0 0 0 -.5 1" mode="trackcom" />
      <camera name="egocentric" pos=".3 0 .11" xyaxes="0 -1 0 .4 0 1" fovy="60" />

      <geom name="eye_r" type="cylinder" size=".05" fromto=".1 -.07 .12 .31 -.07 .08" mass="0" />
      <site name="pupil_r" type="sphere" size=".033" pos=".3 -.07 .08" zaxis="1 0 0" material="eye" />
      <geom name="eye_l" type="cylinder" size=".05" fromto=".1 .07 .12 .31 .07 .08" mass="0" />
      <site name="pupil_l" type="sphere" size=".033" pos=".3 .07 .08" zaxis="1 0 0" material="eye" />
      <site name="workspace" type="sphere" size=".3 .3 .3" material="site" pos=".8 0 -.2" group="3" />

      <geom name="torso" type="box" size=".3 .27 .2" density="1000" />
      <site name="torso_touch" type="box" size=".26 .26 .26" rgba="0 0 1 0" />
      <site name="torso" size=".05" rgba="1 0 0 1" />

      <body name="hip_front_left" pos=".2 .2 0" euler="0 0 45" childclass="hip">
        <joint name="yaw_front_left" class="yaw" />
        <joint name="pitch_front_left" class="pitch" />
        <geom name="thigh_front_left" />
        <body name="knee_front_left" pos=".3 0 .11" childclass="knee">
          <joint name="knee_front_left" />
          <geom name="shin_front_left" />
          <body name="ankle_front_left" pos=".25 0 -.25" childclass="ankle">
            <joint name="ankle_front_left" />
            <geom name="foot_front_left" />
            <body name="toe_front_left" pos="0 0 -.3" childclass="toe">
              <geom name="toe_front_left" />
              <site name="toe_front_left" />
            </body>
          </body>
        </body>
      </body>

      <body name="hip_front_right" pos=".2 -.2 0" euler="0 0 -45" childclass="hip">
        <joint name="yaw_front_right" class="yaw" />
        <joint name="pitch_front_right" class="pitch" />
        <geom name="thigh_front_right" />
        <body name="knee_front_right" pos=".3 0 .11" childclass="knee">
          <joint name="knee_front_right" />
          <geom name="shin_front_right" />
          <body name="ankle_front_right" pos=".25 0 -.25" childclass="ankle">
            <joint name="ankle_front_right" />
            <geom name="foot_front_right" />
            <body name="toe_front_right" pos="0 0 -.3" childclass="toe">
              <geom name="toe_front_right" />
              <site name="toe_front_right" />
            </body>
          </body>
        </body>
      </body>

      <body name="hip_back_right" pos="-.2 -.2 0" euler="0 0 -135" childclass="hip">
        <joint name="yaw_back_right" class="yaw" />
        <joint name="pitch_back_right" class="pitch" />
        <geom name="thigh_back_right" />
        <body name="knee_back_right" pos=".3 0 .11" childclass="knee">
          <joint name="knee_back_right" />
          <geom name="shin_back_right" />
          <body name="ankle_back_right" pos=".25 0 -.25" childclass="ankle">
            <joint name="ankle_back_right" />
            <geom name="foot_back_right" />
            <body name="toe_back_right" pos="0 0 -.3" childclass="toe">
              <geom name="toe_back_right" />
              <site name="toe_back_right" />
            </body>
          </body>
        </body>
      </body>

      <body name="hip_back_left" pos="-.2 .2 0" euler="0 0 135" childclass="hip">
        <joint name="yaw_back_left" class="yaw" />
        <joint name="pitch_back_left" class="pitch" />
        <geom name="thigh_back_left" />
        <body name="knee_back_left" pos=".3 0 .11" childclass="knee">
          <joint name="knee_back_left" />
          <geom name="shin_back_left" />
          <body name="ankle_back_left" pos=".25 0 -.25" childclass="ankle">
            <joint name="ankle_back_left" />
            <geom name="foot_back_left" />
            <body name="toe_back_left" pos="0 0 -.3" childclass="toe">
              <geom name="toe_back_left" />
              <site name="toe_back_left" />
            </body>
          </body>
        </body>
      </body>
    </body>

    </worldbody>

  <tendon>
    <fixed name="coupling_front_left">
      <joint joint="pitch_front_left" coef=".333" />
      <joint joint="knee_front_left" coef=".333" />
      <joint joint="ankle_front_left" coef=".333" />
    </fixed>
    <fixed name="coupling_front_right">
      <joint joint="pitch_front_right" coef=".333" />
      <joint joint="knee_front_right" coef=".333" />
      <joint joint="ankle_front_right" coef=".333" />
    </fixed>
    <fixed name="coupling_back_right">
      <joint joint="pitch_back_right" coef=".333" />
      <joint joint="knee_back_right" coef=".333" />
      <joint joint="ankle_back_right" coef=".333" />
    </fixed>
    <fixed name="coupling_back_left">
      <joint joint="pitch_back_left" coef=".333" />
      <joint joint="knee_back_left" coef=".333" />
      <joint joint="ankle_back_left" coef=".333" />
    </fixed>

    <fixed name="extend_front_left">
      <joint joint="pitch_front_left" coef=".25" />
      <joint joint="knee_front_left" coef="-.5" />
      <joint joint="ankle_front_left" coef=".25" />
    </fixed>
    <fixed name="lift_front_left">
      <joint joint="pitch_front_left" coef=".5" />
      <joint joint="ankle_front_left" coef="-.5" />
    </fixed>

    <fixed name="extend_front_right">
      <joint joint="pitch_front_right" coef=".25" />
      <joint joint="knee_front_right" coef="-.5" />
      <joint joint="ankle_front_right" coef=".25" />
    </fixed>
    <fixed name="lift_front_right">
      <joint joint="pitch_front_right" coef=".5" />
      <joint joint="ankle_front_right" coef="-.5" />
    </fixed>

    <fixed name="extend_back_right">
      <joint joint="pitch_back_right" coef=".25" />
      <joint joint="knee_back_right" coef="-.5" />
      <joint joint="ankle_back_right" coef=".25" />
    </fixed>
    <fixed name="lift_back_right">
      <joint joint="pitch_back_right" coef=".5" />
      <joint joint="ankle_back_right" coef="-.5" />
    </fixed>

    <fixed name="extend_back_left">
      <joint joint="pitch_back_left" coef=".25" />
      <joint joint="knee_back_left" coef="-.5" />
      <joint joint="ankle_back_left" coef=".25" />
    </fixed>
    <fixed name="lift_back_left">
      <joint joint="pitch_back_left" coef=".5" />
      <joint joint="ankle_back_left" coef="-.5" />
    </fixed>
  </tendon>

  <equality>
    <tendon name="coupling_front_left" tendon1="coupling_front_left" class="coupling" />
    <tendon name="coupling_front_right" tendon1="coupling_front_right" class="coupling" />
    <tendon name="coupling_back_right" tendon1="coupling_back_right" class="coupling" />
    <tendon name="coupling_back_left" tendon1="coupling_back_left" class="coupling" />
  </equality>

  <actuator>
    <general name="yaw_front_left" class="yaw_act" joint="yaw_front_left" />
    <general name="lift_front_left" class="lift_act" tendon="lift_front_left" />
    <general name="extend_front_left" class="extend_act" tendon="extend_front_left" />
    <general name="yaw_front_right" class="yaw_act" joint="yaw_front_right" />
    <general name="lift_front_right" class="lift_act" tendon="lift_front_right" />
    <general name="extend_front_right" class="extend_act" tendon="extend_front_right" />
    <general name="yaw_back_right" class="yaw_act" joint="yaw_back_right" />
    <general name="lift_back_right" class="lift_act" tendon="lift_back_right" />
    <general name="extend_back_right" class="extend_act" tendon="extend_back_right" />
    <general name="yaw_back_left" class="yaw_act" joint="yaw_back_left" />
    <general name="lift_back_left" class="lift_act" tendon="lift_back_left" />
    <general name="extend_back_left" class="extend_act" tendon="extend_back_left" />
  </actuator>

  <sensor>
    <accelerometer name="imu_accel" site="torso" />
    <gyro name="imu_gyro" site="torso" />
    <velocimeter name="velocimeter" site="torso" />
    <force name="force_toe_front_left" site="toe_front_left" />
    <force name="force_toe_front_right" site="toe_front_right" />
    <force name="force_toe_back_right" site="toe_back_right" />
    <force name="force_toe_back_left" site="toe_back_left" />
    <torque name="torque_toe_front_left" site="toe_front_left" />
    <torque name="torque_toe_front_right" site="toe_front_right" />
    <torque name="torque_toe_back_right" site="toe_back_right" />
    <torque name="torque_toe_back_left" site="toe_back_left" />
    <subtreecom name="center_of_mass" body="torso" />
    </sensor>

</mujoco>
