Skip to content

How to define a keyframe for joints in bodies that are being replicated? #2360

Discussion options

You must be logged in to vote

Thanks, I am able to achieve what I want programmatically by using the following xml file (I removed the <keyframe> section and added <size nkey="1"/> to manually reserve one keyframe) and python code:

Model:

manual keyframe allocation xml
<mujoco model="Ball translating along xy-plane">
  <!-- Reserve space for a "home" keyframe -->
  <size nkey="1"/>

  <worldbody>
    <replicate count="2" offset="0 1 0">
      <body name="ball" pos="0 0 1">
        <joint name="ball_slide_x" type="slide" axis="1 0 0" range="-2 2"/>
        <geom type="sphere" size="0.1" rgba="0 1 0 1"/>
      </body>
    </replicate>
  </worldbody>
</mujoco>

Code:

import mujoco

model = mujoco.MjModel.from_xml_string(

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@yuvaltassa
Comment options

@adlarkin
Comment options

Answer selected by adlarkin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants