-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
How to use Class FullyObsWrapper in 'wrappers.py' #39
Comments
Hey something like: import gym
import gym_minigrid
from gym_minigrid.wrappers import FullyObsWrapper
env = gym.make(env_id)
env = FullyObsWrapper(env)
state = env.reset() It would be great if you could post the method and result of the experiment! :) |
Thanks for you help! Now I am trying to do the experiment with the FullyObsWrapper, but it converge slower than the method with Partial-Obs, may be I should adjust the hyperparameters:) |
What kind of frame rate are you getting with the FullyObsWrapper? Is it converging slower in terms of number of frames or in terms of wall clock time? |
|
Hm, I wouldn't use the grid size because this could have the same id as a valid object. We should instead add an object type for "agent" and use that id. |
The frame I set is 128 per process, and it convege slower in the real time, with particallyObs, it convege in 5 mins, but with the FullyObs, it converge in 8 mins. the code I used for traning is : python3 -m scripts.train --algo ppo --env MiniGrid-Empty-8x8-v0 --model PPO --save-interval 100 --frames-per-proc 128 Did I have some misunderstanding for the FullyObsWrapper? After we import the FullyObsWrapper, should we change the codes of ‘step()’ or ‘gen_obs(self)’ in minigrid.py? Because I think that the obs we get in ‘step()’ is still the particallyObs (the image we get in gen_obs is based on the sub-grid observed by the agent --- image = grid.encode(vis_mask)) Can I get the same result of observations with the method FullyObsWrapper if I change these codes?
|
You don't have to change any code. I think a change from 5 minutes to 8 minutes is pretty normal. It probably takes longer to generate and process the larger images produced by the fully observable wrapper. |
D'accord~I still have a question: after we import FullyObsWrapper, the shape of obs that we get from 'step()' is FullyObs or partiallyObs related to the agent view size? |
If you use |
When I run the following code,
The image I see is still that of the agent's (partial) view |
I'm guessing that the render function will use the base environment agent's view rather than the modified wrapper's agent view |
Maybe we can turn off the highlight? |
The problem is that the rendering happens in the base environment and ignores wrappers (mainly because the environment cannot "see" them). Otherwise, the wrapper modifying the base environment would work but this will affect other wrappers that use the render observation |
In this case, having a render wrapper that corrects this would be nice. Do you think that it is possible to custom-create one? |
Being able to change all rendering configurations would require many changes to the codebase, but for this specific case, turning off the highlight is very easy to do, we just need to set @PriyeshV can you explain a bit more on what your expected behavior would be? |
HI @BolunDai0216, Thanks for your response.
|
From my end, if you change def __init__(self, env):
super().__init__(env)
self.unwrapped.highlight = False
new_image_space = spaces.Box(
low=0,
high=255,
shape=(self.env.width, self.env.height, 3), # number of cells
dtype="uint8",
)
self.observation_space = spaces.Dict(
{**self.observation_space.spaces, "image": new_image_space}
) it gets rid of the highlight. Let me know if this works for you. Another alternative is to simply set env = gym.make("MiniGrid-Empty-5x5-v0", render_mode="human", highlight=False)
env = FullyObsWrapper(env) Let me know if any of these work for you. |
I tried the latter, and that helped. Thanks a lot :) |
Hi:
It's really a great projet! After reading the realted issues about the FullyObs, i want to try it, but i don't know how to use the Class FullyObsWrapper in the files--'wrappers.py' . Should I import it or change the code of funciton 'gen_obs(self)' in the files--'minigrid.py' ?
Thank you!
The text was updated successfully, but these errors were encountered: