def test_mj_pid():
    xml = MODEL_XML.format(actuator=PID_ACTUATOR)
    model = load_model_from_xml(xml)
    sim = MjSim(model)
    cymj.set_pid_control(sim.model, sim.data)
    init_pos = (0.1 * (random.random() - 0.5))
    print('init pos', init_pos)
    sim.data.qpos[0] = init_pos
    pos = 0.0
    sim.data.ctrl[0] = pos
    print('desire position:', pos)
    for _ in range(100):
        sim.step()
    print('final pos', sim.data.qpos[0])
    assert (abs((sim.data.qpos[0] - pos)) < 0.01)
def test_mj_pid():
    xml = MODEL_XML.format(actuator=PID_ACTUATOR)
    model = load_model_from_xml(xml)
    sim = MjSim(model)
    cymj.set_pid_control(sim.model, sim.data)
    init_pos = (0.1 * (random.random() - 0.5))
    print('init pos', init_pos)
    sim.data.qpos[0] = init_pos
    pos = 0.0
    sim.data.ctrl[0] = pos
    print('desire position:', pos)
    for _ in range(100):
        sim.step()
    print('final pos', sim.data.qpos[0])
    assert (abs((sim.data.qpos[0] - pos)) < 0.01)