Skip to content

Instantly share code, notes, and snippets.

@atabakd
Last active July 15, 2018 11:37
Show Gist options
  • Save atabakd/795314a7d4faa0da1f88b03c77365c31 to your computer and use it in GitHub Desktop.
Save atabakd/795314a7d4faa0da1f88b03c77365c31 to your computer and use it in GitHub Desktop.
MJCF description of an inverted pendulum
<mujoco model="inverted pendulum">
<compiler angle="radian"/>
<option timestep="0.001" iterations="20">
<flag sensornoise="enable"/>
</option>
<default>
<geom rgba="0.45 0.6 0.6 1"/>
<site type="sphere" size="0.02"/>
</default>
<worldbody>
<light directional="true" cutoff="4" exponent="20" diffuse="1 1 1" specular="0 0 0" pos=".9 .3 2.5" dir="-.9 -.3 -2.5 "/>
<!-- ======= Ground ======= -->
<geom name="ground" type="plane" pos="0 0 0" size="0.5 1 2" rgba=" .25 .26 .25 1"/>
<site name="rFix" pos="0 -.2 .005"/>
<site name="lFix" pos="0 .2 .005"/>
<!-- ======= Beam ======= -->
<body name="beam" pos="0 0 .5">
<!--density of the rod is ten times smaller than other objects (e.g. the ball) for a better point mass approximation-->
<geom name="rod" type="cylinder" pos="0 0 0.0" size=".01 .1" density="100"/>
<geom pos="0 0 -.1" type="capsule" size=".01 .2" euler="1.57 0 0"/>
<joint name="pivot" pos="0 0 -0.1" axis="0 1 0" limited="false" damping=".05"/>
<site name="rBeam" pos="0 -.2 -.1"/>
<site name="lBeam" pos="0 .2 -.1"/>
<body name="ballbody" pos="0 0 0.1">
<geom name="ballgeom" type="sphere" size=".05"/>
</body>
</body>
</worldbody>
<tendon>
<spatial name="lThread" width="0.01">
<site site="lBeam"/>
<site site="lFix"/>
</spatial>
<spatial name="rThread" width="0.01">
<site site="rBeam"/>
<site site="rFix"/>
</spatial>
</tendon>
<actuator>
<motor joint='pivot' name='motor' gear="1" forcelimited="true" forcerange="-10 10"/>
</actuator>
<sensor>
<jointpos name="encoder" joint="pivot" noise="0.001"/>
</sensor>
</mujoco>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment