Skip to content

Commit

Permalink
add MuJoCo.tests.test_model_sensors() (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kallinteris-Andreas authored Dec 6, 2023
1 parent b879469 commit a942a16
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/envs/mujoco/test_mujoco_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,27 @@ def test_model_object_count(version: str):
assert env.model.ntendon == 0


# note: fails with `mujoco-mjx==3.0.1`
@pytest.mark.parametrize("version", ["v5", "v4", "v3", "v2"])
def test_model_sensors(version: str):
"""Verify that all the sensors of the model are loaded."""
env = gym.make(f"Ant-{version}").unwrapped
assert env.data.cfrc_ext.shape == (14, 6)

env = gym.make(f"Humanoid-{version}").unwrapped
assert env.data.cinert.shape == (14, 10)
assert env.data.cvel.shape == (14, 6)
assert env.data.qfrc_actuator.shape == (23,)
assert env.data.cfrc_ext.shape == (14, 6)

if version != "v3": # HumanoidStandup v3 does not exist
env = gym.make(f"HumanoidStandup-{version}").unwrapped
assert env.data.cinert.shape == (14, 10)
assert env.data.cvel.shape == (14, 6)
assert env.data.qfrc_actuator.shape == (23,)
assert env.data.cfrc_ext.shape == (14, 6)


def test_dt():
"""Assert that env.dt gets assigned correctly."""
env_a = gym.make("Ant-v5", include_cfrc_ext_in_observation=False).unwrapped
Expand Down

0 comments on commit a942a16

Please sign in to comment.