"""2D Hopper with simple jumping controller — modern MuJoCo example.""" import numpy as np import mujoco import mujoco.viewer XML = """ """ def main(): model = mujoco.MjModel.from_xml_string(XML) data = mujoco.MjData(model) # Simple open-loop hopping pattern phase = 0.0 with mujoco.viewer.launch_passive(model, data) as viewer: while viewer.is_running() and data.time < 10.0: phase = data.time * 4.0 # 4 Hz hopping # Sinusoidal joint commands for hopping data.ctrl[0] = -0.8 * np.sin(phase) # thigh data.ctrl[1] = -0.5 * np.sin(phase + 0.5) # leg data.ctrl[2] = 0.3 * np.cos(phase) # foot mujoco.mj_step(model, data) viewer.sync() if __name__ == "__main__": main()