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

Possible to implement env.render()? #6

Open
signalprime opened this issue Jun 19, 2018 · 0 comments
Open

Possible to implement env.render()? #6

signalprime opened this issue Jun 19, 2018 · 0 comments

Comments

@signalprime
Copy link

signalprime commented Jun 19, 2018

I have been playing around with implementing an updating chart with the gym.envs.classic_control.rendering object, as seen in https://github.com/openai/gym/blob/master/gym/envs/classic_control/pendulum.py

I added a variable 'self.data' to save the data, and

   def render(self, mode='human'):
        if self.viewer is None:
            print("Creating the rendering view:")
            self.viewer = rendering.Viewer(640, 480)
        fig = self.data.plot().get_figure()
        filename = './plot.png'
        fig.savefig(filename)
        plt.close('all')
        self.img = rendering.Image(filename, 640., 480.)
        self.imgtrans = rendering.Transform()
        self.img.add_attr(self.imgtrans)
        self.viewer.add_onetime(self.img)
        return self.viewer.render(return_rgb_array = mode =='rgb_array')

However only a white image window appears. The png file is fine, but it doesn't show in self.viewer. I've not been able to find much information on this. Any thoughts?

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

No branches or pull requests

1 participant