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

Dynamically determine highlighting in RGBImgObsWrapper #388

Merged

Conversation

thesofakillers
Copy link
Contributor

Description

Changes the observation method of RGBImgObsWrapper such that the agent field-of-view (FOV) highlight is rendered only when the underlying environment has this enabled with the highlight bool. (default True). Previously the FOV highlighting was hardcoded to always be enabled, regardless of what highlight was.

Fixes #382, #326

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@@ -323,7 +323,7 @@ def __init__(self, env, tile_size=8):
)

def observation(self, obs):
rgb_img = self.get_frame(highlight=True, tile_size=self.tile_size)
rgb_img = self.get_frame(highlight=self.env.highlight, tile_size=self.tile_size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If wrappers can't modify this value, could you use self.unwrapped.highlight as if self.env is not the base environment, this will break in Gymnasium v1.0.0

Copy link
Contributor Author

@thesofakillers thesofakillers Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

I also changed self.env.height and self.env.width to use self.unwrapped, a few lines up.

@pseudo-rnd-thoughts pseudo-rnd-thoughts changed the title dont hardcode highlighting in RGBImgObsWrapper Dynamically determine highlighting in RGBImgObsWrapper Aug 1, 2023
@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit e6f34be into Farama-Foundation:master Aug 1, 2023
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

Successfully merging this pull request may close these issues.

[Bug Report] RGBImgObsWrapper hardcodes highlight parameter
2 participants