Gymnasium: [Bug Report] MujocoEnv only accepts frame_skip=5
Describe the bug
The AntEnv
class in ant-v4.py calls the MujocoEnv class with frame_skip=5
by default. Changing this value to any other value (e.g., frame_skip=1
) results in an error.
More generally, it would be useful to be able to directly control the time step (self.dt
). Currently it seems like the only way to control self.dt
is by modifying self.frame_skip
, such that self.dt=self.model.opt.timestep * self.frame_skip
.
Code example
MujocoEnv.__init__(
self,
xml_file,
frame_skip=1,
observation_space=observation_space,
default_camera_config=DEFAULT_CAMERA_CONFIG,
**kwargs,
)
MujocoEnv.__init__(
File "D:\programs\Python\Python310\lib\site-packages\gymnasium\envs\mujoco\mujoco_env.py", line 333, in __init__
super().__init__(
File "D:\programs\Python\Python310\lib\site-packages\gymnasium\envs\mujoco\mujoco_env.py", line 65, in __init__
int(np.round(1.0 / self.dt)) == self.metadata["render_fps"]
AssertionError: Expected value: 100, Actual value: 20
System info
No response
Additional context
No response
Checklist
- I have checked that there is no similar issue in the repo
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (5 by maintainers)
Having a bigger
dt
means there will be more information contained in astep()
(s, a, r, s')
and therefore get your learning algorithm to learn with higher sample efficiencyThe downside is the inability to give learn finer control
metadata["render_fps"]
@pseudo-rnd-thoughts Great, I will add the
frame_skip
arg to themujoco-v5
environments, and computemetadata.render_fps
on__init__
time@Omer1Yuval1 The
render_fps
is independent from the number of actions taken per simulation second and can in theory be any value. Butround(1000/dt)
seems reasonable, you need a positive integer. For the frame_skip, this is more complex as I believe that this refers to the length of internal time the same action is taken and should definitely be separate fromrender_fps
.@Kallinteris-Andreas No, as the original error of modifying
frame_skip
has no been solved. @rodrigodelazcano I think you missed the last @, could you look at the original error and know if there is an easy solutionSure; for backward compatibility, the default value should be
None
and in that case, we use the value in metadata, correct?