Gymnasium icon indicating copy to clipboard operation
Gymnasium copied to clipboard

[Proposal] Default metadata in BaseMujocoEnv

Open spiglerg opened this issue 9 months ago • 2 comments

Proposal

The current code for BaseMujocoEnv requires the env metadata dictionary to have fixed, pre-specified values. While this may be useful for future API changes, it doesn't seem very useful at the moment.


    assert self.metadata["render_modes"] == [
        "human",
        "rgb_array",
        "depth_array",
    ], self.metadata["render_modes"]
    if "render_fps" in self.metadata:
        assert (
            int(np.round(1.0 / self.dt)) == self.metadata["render_fps"]
        ), f'Expected value: {int(np.round(1.0 / self.dt))}, Actual value: {self.metadata["render_fps"]}'

I propose to set the metadata attribute in BaseMujocoEnv to the current fixed values


self.metadata["render_modes"] = [
            "human",
            "rgb_array",
            "depth_array",
        ]
self.metadata["render_fps"] = int(np.round(1.0 / self.dt))

This will enable classes derived from MujocoEnv to overwrite the dictionary (if required, in the future), but it will not force them to write an explicit metadata dictionary if the default values suffice, reducing redundancy and making derived classes more compact and readable.

Motivation

No response

Pitch

No response

Alternatives

No response

Additional context

No response

Checklist

  • [X] I have checked that there is no similar issue in the repo

spiglerg avatar May 20 '24 13:05 spiglerg