Skip to content

Instantly share code, notes, and snippets.

@matthiasplappert
Last active October 14, 2020 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiasplappert/1e4860600275efd00b9b80bcc4a4e2bc to your computer and use it in GitHub Desktop.
Save matthiasplappert/1e4860600275efd00b9b80bcc4a4e2bc to your computer and use it in GitHub Desktop.
import numpy as np
import gym
env = gym.make('FetchReach-v0')
# Simply wrap the goal-based environment using FlattenDictWrapper
# and specify the keys that you would like to use.
env = gym.wrappers.FlattenDictWrapper(
env, dict_keys=['observation', 'desired_goal'])
# From now on, you can use the wrapper env as per usual:
ob = env.reset()
print(ob.shape) # is now just an np.array
@OhkuboSGMS
Copy link

OhkuboSGMS commented Oct 14, 2020

You need to change FlattenDictWrapper(env, dict_keys=['observation', 'desired_goal']) to FlattenObservation(FilterObservation(env, ["observation", "desired_goal"]))

https://github.com/openai/baselines/pull/1034/files#diff-06f2d87316632bf8909f91507556c46a278bd62b6d60a5536cfb50eef2b0902bR130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment