openai / spinningup

An educational resource to help anyone learn deep reinforcement learning.
https://spinningup.openai.com/
MIT License
9.97k stars 2.2k forks source link

How to switch to use pybullet instead of mujoco where models exist? #271

Open rojas70 opened 4 years ago

rojas70 commented 4 years ago

Upon calling gym.make() I would like to be able to use pybullet instead of mujoco to run the environment. What is the mechanism to do so?

riveSunder commented 3 years ago

Hello @rojas70, you may have figured it out already, but I think others may benefit from some instructions on how to use PyBullet with spinningup.

It's actually pretty straightforward. With your conda/virtualenv environment activated, install pybullet with pip:

pip install pybullet

Then you can register the pybullet version of robotics environments with gym by adding the line

import pybullet_envs

I think the best place to add this line is in ./spinup/__init__.py. It will also get loaded by __init__.py if you add that line to any of the algos (which are in turn loaded by __init__.py).

I tested these instructions with a fresh virtual environment and copy of spinningup at commit 038665d6 for several of the algos using both tf1 and pytorch implementations. It seems to work just fine.

I think there are plenty of people interested in using PyBullet for these environments, and PyBullet instructions would be a worthwhile addition to the documentation.

rojas70 commented 3 years ago

Thank you

On Mon, Nov 23, 2020 at 9:02 AM riveSunder notifications@github.com wrote:

Hello @rojas70 https://github.com/rojas70, you may have figured it out already, but I think others may benefit from some instructions on how to use PyBullet with spinningup.

It's actually pretty straightforward. With your conda/virtualenv environment activated, install pybullet with pip:

pip install pybullet

Then you can register the pybullet version of robotics environments with gym by adding the line

import pybullet_envs

I think the best place to add this line is in ./spinup/init.py. It will also get loaded by init.py if you add that line to any of the algos (which are in turn loaded by init.py).

I tested these instructions with a fresh virtual environment and copy of spinningup at commit 038665d https://github.com/openai/spinningup/commit/038665d62d569055401d91856abb287263096178 for several of the algos using both tf1 and pytorch implementations. It seems to work just fine.

I think there are plenty of people interested in using PyBullet for these environments, and PyBullet instructions would be a worthwhile addition to the documentation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openai/spinningup/issues/271#issuecomment-731881139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5ZPUADKWGTWYBN2FF6T33SRGYCNANCNFSM4ORMSIRQ .

riveSunder commented 3 years ago

No problem, happy to help.

I've made a pull request to add these instructions to the spinningup documentation: https://github.com/openai/spinningup/pull/305

Hopefully this gets incorporated into the spinningup project so that more people can more easily benefit from spinningup without necessarily needing a MuJoCO license. :)