kevinzakka / mujoco_cube

A 3x3x3 puzzle cube model for MuJoCo.
Apache License 2.0
29 stars 2 forks source link

Instability after many steps #4

Closed jjyyxx closed 1 month ago

jjyyxx commented 1 month ago

The model becomes instable after many steps, even with simplest control. Repro as follows. Could you investigate the cause? Or suggest workarounds to make the model more robust?

import os
os.environ["MUJOCO_GL"] = "egl"
import mujoco
assert mujoco.__version__ == '3.2.3'

model = mujoco.MjModel.from_xml_path("cube_3x3x3.xml")
data = mujoco.MjData(model)
data.ctrl[0] = 0.0195

renderer = mujoco.Renderer(model, height=240, width=320)

mujoco.mj_step(model, data, nstep=20845)
renderer.update_scene(data)
normal = renderer.render()

mujoco.mj_step(model, data, nstep=1)
renderer.update_scene(data)
abnormal = renderer.render()

from PIL import Image
Image.fromarray(normal).save("normal.png")
Image.fromarray(abnormal).save("abnormal.png")

normal Normal

abnormal Abnormal

kevinzakka commented 1 month ago

The timestep is really high right now. Just lower it until the instabilities go away, but not too much or it will be too slow.

kevinzakka commented 1 month ago

Hi @jjyyxx, did lowering the timestep help?