rohanpsingh / mujoco-python-viewer

Simple renderer for use with MuJoCo (>=2.1.2) Python Bindings.
BSD 2-Clause "Simplified" License
163 stars 24 forks source link

Converted class to a context manager #14

Closed rpapallas closed 1 year ago

rpapallas commented 1 year ago

This allows a client to use the class in the following way:

with MujocoViewer(model, data) as viewer:
    viewer.render()

and it will call viewer.close() when it goes out of scope, so the client doesn't have to.

rohanpsingh commented 1 year ago
with MujocoViewer(model, data) as viewer:
    viewer.render()

While this functionality is useful, I will probably introduce this in a future release. For now, https://github.com/rohanpsingh/mujoco-python-viewer/pull/15 solves the original problem this intended to solve.

Thanks a lot for making the PR!