Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset the environment to a specific state in Mujoco tasks. #1617

Closed
bluecontra opened this issue Jul 23, 2019 · 2 comments
Closed

Reset the environment to a specific state in Mujoco tasks. #1617

bluecontra opened this issue Jul 23, 2019 · 2 comments

Comments

@bluecontra
Copy link

Hello, I'm training my mujoco agent with gym == 0.9.5, mujoco-py == 0.5.7, mjpro131 and on Windows 7. Currently, I'm good with the original API.

My question is, how to reset the environment to a specific state ? I want this function to do some analysis work.

I see that the original API in (for example) 'half_cheetah.py', the original reset_model() function does not take any params and reset the env to a random initialized state.
图片

Is there any built-in function to do this, or I have to overwrite the original API with a new reset_model(some_state) function? If so, please tell me which upstream files of 'half_cheetah.py' to modify?

Thanks in advance !

@bluecontra bluecontra changed the title Reset the environment to a specific state. Reset the environment to a specific state in Mujoco tasks. Jul 23, 2019
@christopherhesse
Copy link
Contributor

As you've noticed this is not a feature of the current API, it looks like you'll have to make your own environment (possibly starting with a copy-and-pasted version of half_cheetah or wrapper) that allows passing in the desired state.

As far as I know there is no built-in way to do this, but there is an existing issue about saving and restoring environment state here: #402

For a retro example, I had a get_state() and reset(state=state) functions that I added in a wrapper: https://github.com/openai/retro/blob/master/retro/examples/determinism.py#L35

@hatfield-c
Copy link

Reset doesn't offer you this option, however the source code for mujoco_env.py shows there is a set_state( ) function you can use after you've performed the reset.

Keep in mind that set_state( ) expects the full input size, including the input related to the x position for the center of mass (which is normally hidden under default parameters).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants