benelot / pybullet-gym

Open-source implementations of OpenAI Gym MuJoCo environments for use with the OpenAI Gym Reinforcement Learning Research Platform.
https://pybullet.org/
Other
823 stars 123 forks source link

AttributeError: 'HopperBulletEnv' object has no attribute '_p' #74

Closed dtch1997 closed 2 years ago

dtch1997 commented 2 years ago

Hello, I am working on incorporating PybulletGym into Facebook's AI repository for model-based RL, see pull request here: https://github.com/facebookresearch/mbrl-lib/pull/135

As part of the PR I need to implement some method of saving / loading the pybullet state. However this API is not provided by default in PyBullet gym, so I have implemented it by accessing the underlying PyBullet client using env._p. I currently experience an error as described here: https://github.com/facebookresearch/mbrl-lib/pull/135#issuecomment-938409444

I made sure that env.reset() is called for PyBullet envs before accessing the attribute. And in fact the error does not appear in units tests. So my current thoughts are that there is some interaction between PyBullet and multiprocessing.Pool that results in the error. Would love to get pointers on what could the potential causes be / how to fix it. Alternatively, if there is a better way to save / load the internal env state I would love to know that also.

The script to reproduce the error is: https://github.com/dtch1997/mbrl-lib/blob/feature-pybullet/mbrl/diagnostics/control_env.py The unit test that passes is: https://github.com/dtch1997/mbrl-lib/blob/ab6d9b688793f918115fc76d2c171d4593598aa0/tests/pybullet/test_util.py#L57