def test_mj_proptional_only():
    model = load_model_from_xml(MODEL_XML.format(actuator=P_ONLY_ACTUATOR))
    sim = MjSim(model)
    cymj.set_pid_control(sim.model, sim.data)
    model2 = load_model_from_xml(MODEL_XML.format(actuator=POSITION_ACTUATOR))
    sim2 = MjSim(model2)
    init_pos = (0.1 * (random.random() - 0.5))
    sim.data.qpos[0] = sim2.data.qpos[0] = init_pos
    sim.data.ctrl[0] = sim2.data.ctrl[0] = 0
    for i in range(2000):
        print(i, sim.data.qpos[0], sim2.data.qpos[0])
        sim.step()
        sim2.step()
        assert (abs((sim.data.qpos[0] - sim2.data.qpos[0])) <= 1e-07), ('%d step violates' % i)
def test_mj_proptional_only():
    model = load_model_from_xml(MODEL_XML.format(actuator=P_ONLY_ACTUATOR))
    sim = MjSim(model)
    cymj.set_pid_control(sim.model, sim.data)
    model2 = load_model_from_xml(MODEL_XML.format(actuator=POSITION_ACTUATOR))
    sim2 = MjSim(model2)
    init_pos = (0.1 * (random.random() - 0.5))
    sim.data.qpos[0] = sim2.data.qpos[0] = init_pos
    sim.data.ctrl[0] = sim2.data.ctrl[0] = 0
    for i in range(2000):
        print(i, sim.data.qpos[0], sim2.data.qpos[0])
        sim.step()
        sim2.step()
        assert (abs((sim.data.qpos[0] - sim2.data.qpos[0])) <= 1e-07), ('%d step violates' % i)