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

Issue with rendering for VectorGymWrapper #535

Open
bridgesign opened this issue Oct 15, 2024 · 0 comments
Open

Issue with rendering for VectorGymWrapper #535

bridgesign opened this issue Oct 15, 2024 · 0 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@bridgesign
Copy link

bridgesign commented Oct 15, 2024

It seems that the code for the render function in brax.envs.wrappers.gym.VectorGymWrapper is wrong. The code is intended only to render the first environment and not all environments. In case of gym/gymansium, vector envs render all environments at the same time. The error comes on this line

The issue is that pipeline_state does not implement take.

The code can be fixed by replacing the line with the following:

  def render(self, mode='human'):
    if mode == 'rgb_array':
      sys, state = self._env.sys, self._state
      if state is None:
        raise RuntimeError('must call reset or step before rendering')
      # Change this line to return (env_num, height, width, 3)
      return np.stack([image.render_array(sys, state.take(i).pipeline_state, 256, 256) for i in range(self.num_envs)])
    else:
      return super().render(mode=mode)  # just raise an exception

This will return an ndarray with images stacked for each environment.

@btaba btaba added the good first issue Good for newcomers label Oct 24, 2024
bridgesign added a commit to bridgesign/brax that referenced this issue Nov 1, 2024
This is a solution in context of google#535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants