<mujoco model="soft gripper">

    <compiler angle="radian"
              inertiafromgeom="auto" settotalmass="0.45" balanceinertia="true"/>

    <include file="soft_scene.xml"/>

    <size nconmax="500" njmax="5000" nstack="5000000"/>

    <default>
        <geom density="1" contype="1" conaffinity="1" rgba=".7 .7 .7 1" group="1"/>
<!--        <joint limited="true" damping="1"/>-->
        <site type="sphere" size="0.01"/>
        <tendon width="0.02"/>

        <!-- CHANGE HERE-->
        <!-- All changes rearding joint dynamics, box sizes, etc. can be adjusted from here! Digging
        In XML is not advised/-->
        <default class="gripper_sticks_main">
            <geom type="box" size="0.25 0.3 0.35" mass="0.1" contype="1" conaffinity="1"/>
        </default>
        <default class="gripper_sticks_middle">
            <geom type="box" size="0.5 0.15 0.35" mass="0.2" contype="1" conaffinity="1"/>
        </default>
        <default class="gripper_sticks_end">
            <geom type="box" size="0.4 0.15 0.35" mass="0.1" contype="1" conaffinity="1"/>
        </default>

        <!-- Looking from the behind -->
        <default class="finger_left_util">
            <joint type="hinge" range="-0.5 0.1" limited="true"/>
        </default>

        <default class="finger_right_util">
            <joint type="hinge" range="-0.1 0.5"  limited="true"/>
        </default>

        <default class="tinger_twist">
            <joint type="hinge" axis="1 0 0" limited="true" range="-0.01 0.01"/>
        </default>

        <default class="base">
            <geom type="box" quat="0.7 0.7 0.7 0.7" rgba="0.3 0.3 0.7 1"/>
        </default>

    </default>

    <worldbody>
        <body pos="0 0 0.8">

            <!--                         <freejoint />-->

            <!-- GRIPPER BASE-->
            <site name="sBase" pos="0.22 0 0"/>
            <geom class="base" size="0.5 0.4 0.1" pos="-0.1 0 0"/>
            <geom class="base" size="1.1 0.8 0.02"/>

            <!-- FINGERS LEFT -->
            <body pos="0 0.8 0">
                <body pos="0.3 0 0">
                    <geom class="gripper_sticks_main" name="g121"/>
                    <body pos="0.8 0.1 0">
                        <geom class="gripper_sticks_middle" name="g122"/>
                        <joint class="finger_left_util"/>
                        <joint class="tinger_twist"/>
                        <site name="s122" pos="0.2 -0.2 0"/>
                        <body pos="1.0 0 0">
                            <geom class="gripper_sticks_end" name="g123" quat="0.2 0 0 1"/>
                            <joint type="hinge" range="-0.02 0.4"  limited="true"/>
                            <joint class="tinger_twist"/>
                            <site name="sensor1" pos="-0.45 0.2 0"/>
                        </body>
                    </body>
                </body>
            </body>

            <!-- FINGER RIGHT -->
            <body pos="0 -0.8 0">
                <body pos="0.3 0 0">
                    <geom class="gripper_sticks_main" name="g21"/>
                    <body pos="0.8 -0.1 0">
                        <geom class="gripper_sticks_middle" name="g22"/>
                        <joint class="tinger_twist"/>
                        <joint class="finger_right_util"/>
                        <site name="s22" pos="0.2 0.2 0"/>
                        <body pos="1.0 0 0">
                            <geom class="gripper_sticks_end" name="g23" quat="-0.3 0 0 1"/>
                            <joint type="hinge" range="-0.4 0.02"  limited="true"/>
                            <joint class="tinger_twist"/>
                            <site name="sensor2" pos="-0.45 -0.2 0"/>
                        </body>
                    </body>
                </body>
            </body>
        </body>
    </worldbody>

        <!-- TENDONS-->
        <tendon>
            <spatial name="grip_l_12" width="0.002" rgba=".95 .3 .3 1">
                <site site="sBase"/>
                <site site="s122"/>
            </spatial>

            <spatial name="grip_r_21" width="0.002" rgba=".95 .3 .3 1">
                <site site="sBase"/>
                <site site="s22"/>
            </spatial>
        </tendon>

        <!-- ACTUATORS -->
        <actuator>
            <cylinder tendon="grip_l_12" area="1000"/>
            <cylinder tendon="grip_r_21" area="1000" />
        </actuator>

        <!-- SENSORS -->
        <sensor>
            <accelerometer name="a12_sensor" site="sensor1"/>
            <accelerometer name="a21_sensor" site="sensor2"/>
            <gyro name="g12_sensor" site="sensor1"/>
            <gyro name="g21_sensor" site="sensor2"/>
        </sensor>
</mujoco>
