Gym: can't capture full screen for MuJoCo based env

Created on 15 Mar 2018  路  4Comments  路  Source: openai/gym

Hi, I am trying to record video for HandReach env. An example code is:

goal_env_id = 'HandReach-v0'
env = gym.make(goal_env_id)
env = gym.wrappers.Monitor(env, 'video/' + goal_env_id, force=True)
obs = env.reset()
done = False

def policy(observation, desired_goal):
    # Here you would implement your smarter policy. In this case,
    # we just sample random actions.
    return env.action_space.sample()

while not done:
    env.render()
    action = policy(obs['observation'], obs['desired_goal'])
    obs, reward, done, info = env.step(action)

    # If we want, we can substitute a goal here and re-compute
    # the reward. For instance, we can just pretend that the desired
    # goal was what we achieved all along.
    substitute_goal = obs['achieved_goal'].copy()
    substitute_reward = env.compute_reward(
        obs['achieved_goal'], substitute_goal, info)
    print('reward is {}, substitute_reward is {}'.format(

However, I can't record the full screen as expected. I quickly browsed the source code of Monitor wrapper class. I did't find any functions or attributes that I can set the screen size. BTW, can I set the video resolution when I record the video? Hope someone can give me some help.

mujoco

Most helpful comment

https://github.com/openai/gym/blob/28df2b1a213896766f2b6cf49353096bb24dd252/gym/envs/robotics/robot_env.py#L94

The problem is here.

New mujoco_py use XlibScreen(display= which is a 1280 * 1024 screen.

But the code specify the screen to be 500 * 500 when rendering.

All 4 comments

+1

https://github.com/openai/gym/blob/28df2b1a213896766f2b6cf49353096bb24dd252/gym/envs/robotics/robot_env.py#L94

The problem is here.

New mujoco_py use XlibScreen(display= which is a 1280 * 1024 screen.

But the code specify the screen to be 500 * 500 when rendering.

Thanks for posting that, I think you might be right. I tried to validate your comments by modifying the code. However, my mujoco failed to work for some reasons. The package is really messy and it's painful to make it work normally. So I am gonna leave it for some time. If someone else find the comments work, let me know.

@pzhokhov I think should be fixed by https://github.com/openai/gym/pull/1182?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RuofanKong picture RuofanKong  路  4Comments

Gawne picture Gawne  路  4Comments

lbbc1117 picture lbbc1117  路  3Comments

mdavis-xyz picture mdavis-xyz  路  3Comments

zhan0903 picture zhan0903  路  4Comments