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

Allow multiple visual observations #2003

Merged
merged 2 commits into from May 6, 2019
Merged

Allow multiple visual observations #2003

merged 2 commits into from May 6, 2019

Conversation

GProulx
Copy link
Contributor

@GProulx GProulx commented May 1, 2019

Our objective is to be able to receive multiple visual observations when needed without breaking existing solutions.

When you initialize the UnityEnv class with the allow_multiple_visual_obs param set to True, the observation output will be a list instead of a single observation.

Examples:

With multiples visual observations:

import matplotlib.pyplot as plt
from gym_unity.envs import UnityEnv
env_name = "path_to_your_unity_project_output"
env = UnityEnv(env_name, worker_id=0, use_visual=True, allow_multiple_visual_obs=True)
observation, reward, done, info = env.step(env.action_space.sample())
plt.imshow(observation[0][:,:,:])
env.close()

Single observation:

import matplotlib.pyplot as plt
from gym_unity.envs import UnityEnv
env_name = "path_to_your_unity_project_output"
env = UnityEnv(env_name, worker_id=0, use_visual=True, allow_multiple_visual_obs=False) # You will have the same result by not providing the last parameter
observation, reward, done, info = env.step(env.action_space.sample())
plt.imshow(observation[:,:,:])
env.close()

Note:

If your Unity project returns more than one visual observation and you don't use the new allow parameter, you will receive this updated message:

WARNING:gym_unity: The environment contains more than one visual observation. You must define allow_multiple_visual_obs=True to received them all. Otherwise, please note that only the first will be provided in the observation.

@awjuliani
Copy link
Contributor

Hi @GProulx,

Thanks for making this PR. Could you also modify the accompanying markdown file to reflect this change?

@GProulx
Copy link
Contributor Author

GProulx commented May 1, 2019

Hi @awjuliani ,

Yep, I'll fix the conflicts and update these files in a few hours. Let me know if you think of others pages that need to be updated.

  • docs/Python-API.md
  • gym-unity/README.md (Sections Using the Gym Wrapper and Limitations)

@Unity-Technologies Unity-Technologies deleted a comment May 2, 2019
@GProulx
Copy link
Contributor Author

GProulx commented May 2, 2019

Hello @awjuliani ,

After reviewing the documentation, only the gym-unity/README.md file needed to be updated imho so it's the only other file I changed.

@Unity-Technologies Unity-Technologies deleted a comment May 2, 2019
@GProulx
Copy link
Contributor Author

GProulx commented May 6, 2019

Hi @awjuliani ,

Is anything more than I should do for that pull request to be merged?

@awjuliani
Copy link
Contributor

@GProulx Nope, it looks good to merge.

@awjuliani awjuliani merged commit 01651f1 into Unity-Technologies:develop May 6, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants