Compare commits
56
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
374d72ddde | ||
|
|
d6f42cf755 | ||
|
|
db842db2b7 | ||
|
|
d367ac0c4b | ||
|
|
e5bb6f1a88 | ||
|
|
14b7d1d6c3 | ||
|
|
dbd3caebb3 | ||
|
|
f6b56d5b0f | ||
|
|
c0e55b3f48 | ||
|
|
beaf5df2fc | ||
|
|
13e6a3b53a | ||
|
|
99ab2344ad | ||
|
|
74bede4ba3 | ||
|
|
fae7c887ce | ||
|
|
0d3336b8d9 | ||
|
|
06e6c64e49 | ||
|
|
9d1d925179 | ||
|
|
da5592124e | ||
|
|
e32f836a3c | ||
|
|
bbd964ed80 | ||
|
|
f024613800 | ||
|
|
4a9ea368b8 | ||
|
|
3c7df90810 | ||
|
|
707ec08808 | ||
|
|
11a46889d9 | ||
|
|
be250bee5e | ||
|
|
049e45cb09 | ||
|
|
af636164a8 | ||
|
|
d138c3c1f1 | ||
|
|
b277ed6477 | ||
|
|
b183c002ef | ||
|
|
5e63a72882 | ||
|
|
0b240b9eb4 | ||
|
|
a7031ce3b9 | ||
|
|
4051a13324 | ||
|
|
ebb0e00675 | ||
|
|
6fea48f6c1 | ||
|
|
4107704d9a | ||
|
|
a50d1788b1 | ||
|
|
9538c999a0 | ||
|
|
b0b58675b2 | ||
|
|
9565f7972f | ||
|
|
3f0c7b7302 | ||
|
|
0c93280796 | ||
|
|
a5b10e11a3 | ||
|
|
894982f77f | ||
|
|
95a6b9cf2c | ||
|
|
6528c5d5b9 | ||
|
|
ce779bc6fb | ||
|
|
b6c67b1adc | ||
|
|
ee573788fc | ||
|
|
a5a29176cb | ||
|
|
d10ea23b4c | ||
|
|
180b86771d | ||
|
|
10038f5d73 | ||
|
|
7a0f446406 |
@@ -0,0 +1,52 @@
|
||||
name: Publish Python package to PyPI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
if: false && startsWith(github.ref, 'refs/tags/') # Only run on tagged commits
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # This fetches all history for all branches and tags
|
||||
|
||||
- name: Verify tag is on master branch
|
||||
run: |
|
||||
TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master')
|
||||
if [ -z "$TAG_IS_ON_MASTER" ]; then
|
||||
echo "Tag is not on the master branch. Cancelling the workflow."
|
||||
exit 1
|
||||
fi
|
||||
echo "Tag is on the master branch. Proceeding with the workflow."
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install pypa/build/setuptools/twine
|
||||
run: >-
|
||||
python3 -m
|
||||
pip install
|
||||
build setuptools twine
|
||||
--user
|
||||
|
||||
- name: Prevent fallback onto setup.py
|
||||
run: rm setup.py
|
||||
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: python3 -m build
|
||||
|
||||
- name: Publish to PyPI
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||
run: twine upload dist/*
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
name: Publish Python package to TestPyPI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish to TestPyPI
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/') # Only run on tagged commits
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # This fetches all history for all branches and tags
|
||||
|
||||
- name: Verify tag is on master branch
|
||||
run: |
|
||||
TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master')
|
||||
if [ -z "$TAG_IS_ON_MASTER" ]; then
|
||||
echo "Tag is not on the master branch. Cancelling the workflow."
|
||||
exit 1
|
||||
fi
|
||||
echo "Tag is on the master branch. Proceeding with the workflow."
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install pypa/build/setuptools/twine
|
||||
run: >-
|
||||
python3 -m
|
||||
pip install
|
||||
build setuptools twine
|
||||
--user
|
||||
|
||||
- name: Prevent fallback onto setup.py
|
||||
run: rm setup.py
|
||||
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: python3 -m build
|
||||
|
||||
- name: Publish to TestPyPI
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
|
||||
run: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# Include the README
|
||||
include README.md
|
||||
|
||||
# Include the license, Code of Conduct and Contributing guidelines
|
||||
include LICENSE
|
||||
include CODE_OF_CONDUCT.md
|
||||
include CONTRIBUTING.md
|
||||
|
||||
# Include stl and xml files from the fancy_gym/envs/mujoco directory
|
||||
recursive-include fancy_gym/envs/mujoco *.stl
|
||||
recursive-include fancy_gym/envs/mujoco *.xml
|
||||
|
||||
# Also shipping the most important part of fancy gym
|
||||
include icon.svg
|
||||
@@ -1,12 +1,12 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<img src='./icon.svg' width="250px">
|
||||
<img src='https://raw.githubusercontent.com/ALRhub/fancy_gym/master/icon.svg' width="250px">
|
||||
<br><br>
|
||||
<b>Fancy Gym</b>
|
||||
<br><br>
|
||||
</h1>
|
||||
|
||||
| :exclamation: Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). |
|
||||
| ❗ Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
|
||||
Built upon the foundation of [Gymnasium](https://gymnasium.farama.org/) (a maintained fork of OpenAI’s renowned Gym library) `fancy_gym` offers a comprehensive collection of reinforcement learning environments.
|
||||
@@ -33,40 +33,72 @@ While the overarching objective of MP environments remains the learning of an op
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone the repository
|
||||
We recommend installing `fancy_gym` into a virtual environment as provided by [venv](https://docs.python.org/3/library/venv.html). 3rd party alternatives to venv like [Poetry](https://python-poetry.org/) or [Conda](https://docs.conda.io/en/latest/) can also be used.
|
||||
|
||||
### Installation from PyPI (recommended)
|
||||
|
||||
Install `fancy_gym` via
|
||||
```bash
|
||||
git clone git@github.com:ALRhub/fancy_gym.git
|
||||
```
|
||||
|
||||
2. Go to the folder
|
||||
|
||||
```bash
|
||||
cd fancy_gym
|
||||
```
|
||||
|
||||
3. Install with
|
||||
|
||||
```bash
|
||||
pip install -e .
|
||||
pip install fancy_gym
|
||||
```
|
||||
|
||||
We have a few optional dependencies. If you also want to install those use
|
||||
|
||||
```bash
|
||||
pip install -e '.[all]' # to install all optional dependencies
|
||||
pip install -e '.[dmc,metaworld,box2d,mujoco,mujoco-legacy,jax,testing]' # or choose only those you want
|
||||
# to install all optional dependencies
|
||||
pip install 'fancy_gym[all]'
|
||||
|
||||
# or choose only those you want
|
||||
pip install 'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]'
|
||||
```
|
||||
|
||||
Pip can not automatically install up-to-date versions of metaworld, since they are not avaible on PyPI yet.
|
||||
Install metaworld via
|
||||
|
||||
```bash
|
||||
pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld
|
||||
```
|
||||
|
||||
### Installation from master
|
||||
|
||||
1. Clone the repository
|
||||
```bash
|
||||
git clone git@github.com:ALRhub/fancy_gym.git
|
||||
```
|
||||
|
||||
2. Go to the folder
|
||||
```bash
|
||||
cd fancy_gym
|
||||
```
|
||||
|
||||
3. Install with
|
||||
```bash
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
We have a few optional dependencies. If you also want to install those use
|
||||
```bash
|
||||
# to install all optional dependencies
|
||||
pip install -e '.[all]'
|
||||
|
||||
# or choose only those you want
|
||||
pip install -e '.[dmc,box2d,mujoco-legacy,jax,testing]'
|
||||
```
|
||||
|
||||
Metaworld has to be installed manually with
|
||||
```bash
|
||||
pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld
|
||||
```
|
||||
|
||||
## How to use Fancy Gym
|
||||
|
||||
We will only show the basics here and prepared [multiple examples](fancy_gym/examples/) for a more detailed look.
|
||||
We will only show the basics here and prepared [multiple examples](https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/examples/) for a more detailed look.
|
||||
|
||||
### Step-Based Environments
|
||||
|
||||
Regular step based environments added by Fancy Gym are added into the `fancy/` namespace.
|
||||
|
||||
| :exclamation: Legacy versions of Fancy Gym used `fancy_gym.make(...)`. This is no longer supported and will raise an Exception on new versions. |
|
||||
| ❗ Legacy versions of Fancy Gym used `fancy_gym.make(...)`. This is no longer supported and will raise an Exception on new versions. |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
|
||||
```python
|
||||
@@ -165,7 +197,7 @@ print(fancy_gym.MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['<my_custom_namespace>'])
|
||||
### How to create a new MP task
|
||||
|
||||
In case a required task is not supported yet in the MP framework, it can be created relatively easy. For the task at
|
||||
hand, the following [interface](fancy_gym/black_box/raw_interface_wrapper.py) needs to be implemented.
|
||||
hand, the following [interface](https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/black_box/raw_interface_wrapper.py) needs to be implemented.
|
||||
|
||||
```python
|
||||
from abc import abstractmethod
|
||||
@@ -251,7 +283,7 @@ class RawInterfaceWrapper(gym.Wrapper):
|
||||
|
||||
If you created a new task wrapper, feel free to open a PR, so we can integrate it for others to use as well. Without the
|
||||
integration the task can still be used. A rough outline can be shown here, for more details we recommend having a look
|
||||
at the [examples](fancy_gym/examples/).
|
||||
at the [examples](https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/examples/).
|
||||
|
||||
If the step-based is already registered with gym, you can simply do the following:
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@ from .envs.registry import ALL_MOVEMENT_PRIMITIVE_ENVIRONMENTS, MOVEMENT_PRIMITI
|
||||
|
||||
ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['dm_control']
|
||||
ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['fancy']
|
||||
ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['metaworld']
|
||||
if 'metaworld' in MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS:
|
||||
ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['metaworld']
|
||||
else:
|
||||
ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = 'Metaworld is not installed.'
|
||||
ALL_GYM_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['gym']
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# TODO
|
||||
@@ -6,21 +6,21 @@ def example_run_replanning_env(env_name="fancy_ProDMP/BoxPushingDenseReplan-v0",
|
||||
env = gym.make(env_name)
|
||||
env.reset(seed=seed)
|
||||
for i in range(iterations):
|
||||
done = False
|
||||
while done is False:
|
||||
while True:
|
||||
ac = env.action_space.sample()
|
||||
obs, reward, terminated, truncated, info = env.step(ac)
|
||||
if render:
|
||||
env.render(mode="human")
|
||||
if terminated or truncated:
|
||||
env.reset()
|
||||
break
|
||||
env.close()
|
||||
del env
|
||||
|
||||
|
||||
def example_custom_replanning_envs(seed=0, iteration=100, render=True):
|
||||
# id for a step-based environment
|
||||
base_env_id = "BoxPushingDense-v0"
|
||||
base_env_id = "fancy/BoxPushingDense-v0"
|
||||
|
||||
wrappers = [fancy_gym.envs.mujoco.box_pushing.mp_wrapper.MPWrapper]
|
||||
|
||||
@@ -38,7 +38,8 @@ def example_custom_replanning_envs(seed=0, iteration=100, render=True):
|
||||
'replanning_schedule': lambda pos, vel, obs, action, t: t % 25 == 0,
|
||||
'condition_on_desired': True}
|
||||
|
||||
env = fancy_gym.make_bb(env_id=base_env_id, wrappers=wrappers, black_box_kwargs=black_box_kwargs,
|
||||
base_env = gym.make(base_env_id)
|
||||
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs=black_box_kwargs,
|
||||
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
||||
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
||||
seed=seed)
|
||||
@@ -56,10 +57,12 @@ def example_custom_replanning_envs(seed=0, iteration=100, render=True):
|
||||
env.close()
|
||||
del env
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main(render=False):
|
||||
# run a registered replanning environment
|
||||
example_run_replanning_env(env_name="fancy_ProDMP/BoxPushingDenseReplan-v0", seed=1, iterations=1, render=False)
|
||||
example_run_replanning_env(env_name="fancy_ProDMP/BoxPushingDenseReplan-v0", seed=1, iterations=1, render=render)
|
||||
|
||||
# run a custom replanning environment
|
||||
example_custom_replanning_envs(seed=0, iteration=8, render=True)
|
||||
example_custom_replanning_envs(seed=0, iteration=8, render=render)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -84,7 +84,8 @@ def example_custom_dmc_and_mp(seed=1, iterations=1, render=True):
|
||||
# basis_generator_kwargs = {'basis_generator_type': 'rbf',
|
||||
# 'num_basis': 5
|
||||
# }
|
||||
env = fancy_gym.make_bb(env_id=base_env_id, wrappers=wrappers, black_box_kwargs={},
|
||||
base_env = gym.make(base_env_id)
|
||||
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs={},
|
||||
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
||||
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
||||
seed=seed)
|
||||
@@ -114,21 +115,13 @@ def example_custom_dmc_and_mp(seed=1, iterations=1, render=True):
|
||||
env.close()
|
||||
del env
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Disclaimer: DMC environments require the seed to be specified in the beginning.
|
||||
# Adjusting it afterwards with env.seed() is not recommended as it does not affect the underlying physics.
|
||||
|
||||
# For rendering DMC
|
||||
# export MUJOCO_GL="osmesa"
|
||||
render = True
|
||||
|
||||
def main(render = True):
|
||||
# # Standard DMC Suite tasks
|
||||
example_dmc("dm_control/fish-swim", seed=10, iterations=1000, render=render)
|
||||
#
|
||||
# # Manipulation tasks
|
||||
# # Disclaimer: The vision versions are currently not integrated and yield an error
|
||||
example_dmc("dm_control/manipulation-reach_site_features", seed=10, iterations=250, render=render)
|
||||
example_dmc("dm_control/reach_site_features", seed=10, iterations=250, render=render)
|
||||
#
|
||||
# # Gym + DMC hybrid task provided in the MP framework
|
||||
example_dmc("dm_control_ProMP/ball_in_cup-catch-v0", seed=10, iterations=1, render=render)
|
||||
@@ -136,3 +129,20 @@ if __name__ == '__main__':
|
||||
# Custom DMC task # Different seed, because the episode is longer for this example and the name+seed combo is
|
||||
# already registered above
|
||||
example_custom_dmc_and_mp(seed=11, iterations=1, render=render)
|
||||
|
||||
# # Standard DMC Suite tasks
|
||||
example_dmc("dm_control/fish-swim", seed=10, iterations=1000, render=render)
|
||||
#
|
||||
# # Manipulation tasks
|
||||
# # Disclaimer: The vision versions are currently not integrated and yield an error
|
||||
example_dmc("dm_control/reach_site_features", seed=10, iterations=250, render=render)
|
||||
#
|
||||
# # Gym + DMC hybrid task provided in the MP framework
|
||||
example_dmc("dm_control_ProMP/ball_in_cup-catch-v0", seed=10, iterations=1, render=render)
|
||||
|
||||
# Custom DMC task # Different seed, because the episode is longer for this example and the name+seed combo is
|
||||
# already registered above
|
||||
example_custom_dmc_and_mp(seed=11, iterations=1, render=render)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -85,10 +85,7 @@ def example_async(env_id="fancy/HoleReacher-v0", n_cpu=4, seed=int('533D', 16),
|
||||
# do not return values above threshold
|
||||
return *map(lambda v: np.stack(v)[:n_samples], buffer.values()),
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
render = True
|
||||
|
||||
def main(render = True):
|
||||
# Basic gym task
|
||||
example_general("Pendulum-v1", seed=10, iterations=200, render=render)
|
||||
|
||||
@@ -100,3 +97,6 @@ if __name__ == '__main__':
|
||||
|
||||
# Vectorized multiprocessing environments
|
||||
# example_async(env_id="HoleReacher-v0", n_cpu=2, seed=int('533D', 16), n_samples=2 * 200)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -35,7 +35,7 @@ def example_meta(env_id="fish-swim", seed=1, iterations=1000, render=True):
|
||||
if terminated or truncated:
|
||||
print(env_id, rewards)
|
||||
rewards = 0
|
||||
obs = env.reset()
|
||||
obs = env.reset(seed=seed+i+1)
|
||||
|
||||
env.close()
|
||||
del env
|
||||
@@ -81,7 +81,8 @@ def example_custom_meta_and_mp(seed=1, iterations=1, render=True):
|
||||
basis_generator_kwargs = {'basis_generator_type': 'rbf',
|
||||
'num_basis': 5
|
||||
}
|
||||
env = fancy_gym.make_bb(env_id=base_env_id, wrappers=wrappers, black_box_kwargs={},
|
||||
base_env = gym.make(base_env_id)
|
||||
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs={},
|
||||
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
||||
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
||||
seed=seed)
|
||||
@@ -92,14 +93,10 @@ def example_custom_meta_and_mp(seed=1, iterations=1, render=True):
|
||||
# It is also possible to change them mode multiple times when
|
||||
# e.g. only every nth trajectory should be displayed.
|
||||
if render:
|
||||
raise ValueError("Metaworld render interface bug does not allow to render() fixes its interface. "
|
||||
"A temporary workaround is to alter their code in MujocoEnv render() from "
|
||||
"`if not offscreen` to `if not offscreen or offscreen == 'human'`.")
|
||||
# TODO: Remove this, when Metaworld fixes its interface.
|
||||
# env.render(mode="human")
|
||||
env.render(mode="human")
|
||||
|
||||
rewards = 0
|
||||
obs = env.reset()
|
||||
obs = env.reset(seed=seed)
|
||||
|
||||
# number of samples/full trajectories (multiple environment steps)
|
||||
for i in range(iterations):
|
||||
@@ -110,25 +107,23 @@ def example_custom_meta_and_mp(seed=1, iterations=1, render=True):
|
||||
if terminated or truncated:
|
||||
print(base_env_id, rewards)
|
||||
rewards = 0
|
||||
obs = env.reset()
|
||||
obs = env.reset(seed=seed+i+1)
|
||||
|
||||
env.close()
|
||||
del env
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Disclaimer: MetaWorld environments require the seed to be specified in the beginning.
|
||||
# Adjusting it afterwards with env.seed() is not recommended as it may not affect the underlying behavior.
|
||||
|
||||
def main(render = False):
|
||||
# For rendering it might be necessary to specify your OpenGL installation
|
||||
# export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
|
||||
render = False
|
||||
|
||||
# # Standard Meta world tasks
|
||||
example_meta("metaworld/button-press-v2", seed=10, iterations=500, render=render)
|
||||
|
||||
# # MP + MetaWorld hybrid task provided in the our framework
|
||||
example_meta("metaworld_ProMP/ButtonPress-v2", seed=10, iterations=1, render=render)
|
||||
example_meta("metaworld_ProMP/button-press-v2", seed=10, iterations=1, render=render)
|
||||
#
|
||||
# # Custom MetaWorld task
|
||||
example_custom_meta_and_mp(seed=10, iterations=1, render=render)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -26,6 +26,8 @@ def example_mp(env_name="fancy_ProMP/HoleReacher-v0", seed=1, iterations=1, rend
|
||||
for i in range(iterations):
|
||||
|
||||
if render and i % 1 == 0:
|
||||
# This renders the full MP trajectory
|
||||
# It is only required to call render() once in the beginning, which renders every consecutive trajectory.
|
||||
env.render()
|
||||
|
||||
# Now the action space is not the raw action but the parametrization of the trajectory generator,
|
||||
@@ -248,8 +250,7 @@ def example_fully_custom_mp_alternative(seed=1, iterations=1, render=True):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
render = False
|
||||
def main(render=False):
|
||||
# DMP
|
||||
example_mp("fancy_DMP/HoleReacher-v0", seed=10, iterations=5, render=render)
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ def example_mp(env_name, seed=1, render=True):
|
||||
print(returns)
|
||||
obs = env.reset()
|
||||
|
||||
def main(render=True):
|
||||
example_mp("gym_ProMP/Reacher-v2", render=render)
|
||||
|
||||
if __name__ == '__main__':
|
||||
example_mp("gym_ProMP/Reacher-v2")
|
||||
main()
|
||||
+54
-47
@@ -7,56 +7,63 @@ from ..envs.registry import register
|
||||
from . import goal_object_change_mp_wrapper, goal_change_mp_wrapper, goal_endeffector_change_mp_wrapper, \
|
||||
object_change_mp_wrapper
|
||||
|
||||
from . import metaworld_adapter
|
||||
try:
|
||||
import metaworld
|
||||
except ModuleNotFoundError:
|
||||
print('[FANCY GYM] Metaworld not avaible.')
|
||||
else:
|
||||
# Will only get executed, if import succeeds
|
||||
|
||||
metaworld_adapter.register_all_ML1()
|
||||
from . import metaworld_adapter
|
||||
|
||||
ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "ProMP": [], "ProDMP": []}
|
||||
metaworld_adapter.register_all_ML1()
|
||||
|
||||
# MetaWorld
|
||||
_goal_change_envs = ["assembly-v2", "pick-out-of-hole-v2", "plate-slide-v2", "plate-slide-back-v2",
|
||||
"plate-slide-side-v2", "plate-slide-back-side-v2"]
|
||||
for _task in _goal_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=goal_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "ProMP": [], "ProDMP": []}
|
||||
|
||||
_object_change_envs = ["bin-picking-v2", "hammer-v2", "sweep-into-v2"]
|
||||
for _task in _object_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=object_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
# MetaWorld
|
||||
_goal_change_envs = ["assembly-v2", "pick-out-of-hole-v2", "plate-slide-v2", "plate-slide-back-v2",
|
||||
"plate-slide-side-v2", "plate-slide-back-side-v2"]
|
||||
for _task in _goal_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=goal_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
|
||||
_goal_and_object_change_envs = ["box-close-v2", "button-press-v2", "button-press-wall-v2", "button-press-topdown-v2",
|
||||
"button-press-topdown-wall-v2", "coffee-button-v2", "coffee-pull-v2",
|
||||
"coffee-push-v2", "dial-turn-v2", "disassemble-v2", "door-close-v2",
|
||||
"door-lock-v2", "door-open-v2", "door-unlock-v2", "hand-insert-v2",
|
||||
"drawer-close-v2", "drawer-open-v2", "faucet-open-v2", "faucet-close-v2",
|
||||
"handle-press-side-v2", "handle-press-v2", "handle-pull-side-v2",
|
||||
"handle-pull-v2", "lever-pull-v2", "peg-insert-side-v2", "pick-place-wall-v2",
|
||||
"reach-v2", "push-back-v2", "push-v2", "pick-place-v2", "peg-unplug-side-v2",
|
||||
"soccer-v2", "stick-push-v2", "stick-pull-v2", "push-wall-v2", "reach-wall-v2",
|
||||
"shelf-place-v2", "sweep-v2", "window-open-v2", "window-close-v2"
|
||||
]
|
||||
for _task in _goal_and_object_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=goal_object_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
_object_change_envs = ["bin-picking-v2", "hammer-v2", "sweep-into-v2"]
|
||||
for _task in _object_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=object_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
|
||||
_goal_and_endeffector_change_envs = ["basketball-v2"]
|
||||
for _task in _goal_and_endeffector_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=goal_endeffector_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
_goal_and_object_change_envs = ["box-close-v2", "button-press-v2", "button-press-wall-v2", "button-press-topdown-v2",
|
||||
"button-press-topdown-wall-v2", "coffee-button-v2", "coffee-pull-v2",
|
||||
"coffee-push-v2", "dial-turn-v2", "disassemble-v2", "door-close-v2",
|
||||
"door-lock-v2", "door-open-v2", "door-unlock-v2", "hand-insert-v2",
|
||||
"drawer-close-v2", "drawer-open-v2", "faucet-open-v2", "faucet-close-v2",
|
||||
"handle-press-side-v2", "handle-press-v2", "handle-pull-side-v2",
|
||||
"handle-pull-v2", "lever-pull-v2", "peg-insert-side-v2", "pick-place-wall-v2",
|
||||
"reach-v2", "push-back-v2", "push-v2", "pick-place-v2", "peg-unplug-side-v2",
|
||||
"soccer-v2", "stick-push-v2", "stick-pull-v2", "push-wall-v2", "reach-wall-v2",
|
||||
"shelf-place-v2", "sweep-v2", "window-open-v2", "window-close-v2"
|
||||
]
|
||||
for _task in _goal_and_object_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=goal_object_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
|
||||
_goal_and_endeffector_change_envs = ["basketball-v2"]
|
||||
for _task in _goal_and_endeffector_change_envs:
|
||||
register(
|
||||
id=f'metaworld/{_task}',
|
||||
register_step_based=False,
|
||||
mp_wrapper=goal_endeffector_change_mp_wrapper.MPWrapper,
|
||||
add_mp_types=['ProMP', 'ProDMP'],
|
||||
)
|
||||
@@ -11,11 +11,7 @@ import numpy as np
|
||||
|
||||
from fancy_gym.utils.env_compatibility import EnvCompatibility
|
||||
|
||||
try:
|
||||
import metaworld
|
||||
except Exception:
|
||||
print('[FANCY GYM] Metaworld not avaible')
|
||||
|
||||
import metaworld
|
||||
|
||||
class FixMetaworldHasIncorrectObsSpaceWrapper(gym.Wrapper, gym.utils.RecordConstructorArgs):
|
||||
def __init__(self, env: gym.Env):
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
[project]
|
||||
name = "fancy_gym"
|
||||
version = "0.1.4"
|
||||
description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches."
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{name = "Fabian Otto", email = "fabian.otto@uni-tuebingen.de"},
|
||||
{name = "Onur Celik", email = "celik@kit.edu"},
|
||||
{name = "Dominik Roth", email = "fancy_gym@dominik-roth.eu"},
|
||||
{name = "Hongyi Zhou", email = "hongyi.zhou@kit.edu"}
|
||||
]
|
||||
license = { text = "MIT License" }
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Science/Research",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Natural Language :: English",
|
||||
"Operating System :: OS Independent",
|
||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11"
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"mp_pytorch<=0.1.3",
|
||||
"mujoco==2.3.3",
|
||||
"gymnasium[mujoco]>=0.26.0"
|
||||
]
|
||||
|
||||
requires-python = ">=3.7"
|
||||
|
||||
[project.urls]
|
||||
"Homepage" = "https://github.com/ALRhub/fancy_gym/"
|
||||
#"Documentation" = "https://github.com/ALRhub/fancy_gym/"
|
||||
"Bug Tracker" = "https://github.com/ALRhub/fancy_gym/issues"
|
||||
#"Repository" = "https://github.com/ALRhub/fancy_gym/"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0.0", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project.optional-dependencies]
|
||||
dmc = ["shimmy[dm-control]", "Shimmy==1.0.0"]
|
||||
# PyPi does not allow external dependencies. Metaworld will have to be installed manually until Farama publishes up-to-date version of metaworld on PyPi.
|
||||
#metaworld = ["metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld"]
|
||||
box2d = ["gymnasium[box2d]>=0.26.0"]
|
||||
mujoco-legacy = ["mujoco-py>=2.1,<2.2", "cython<3"]
|
||||
jax = ["jax>=0.4.0", "jaxlib>=0.4.0"]
|
||||
|
||||
all = [
|
||||
# include all the optional dependencies
|
||||
"shimmy[dm-control]",
|
||||
"Shimmy==1.0.0",
|
||||
#"metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld",
|
||||
"mujoco==2.3.3",
|
||||
"gymnasium[box2d,mujoco]>=0.26.0",
|
||||
"mujoco-py>=2.1,<2.2",
|
||||
"cython<3",
|
||||
"jax>=0.4.0",
|
||||
"jaxlib>=0.4.0"
|
||||
]
|
||||
|
||||
testing = [
|
||||
"pytest",
|
||||
# include all the optional dependencies as well
|
||||
"shimmy[dm-control]",
|
||||
"Shimmy==1.0.0",
|
||||
#"metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld",
|
||||
"mujoco==2.3.3",
|
||||
"gymnasium[box2d,mujoco]>=0.26.0",
|
||||
"mujoco-py>=2.1,<2.2",
|
||||
"cython<3",
|
||||
"jax>=0.4.0",
|
||||
"jaxlib>=0.4.0"
|
||||
]
|
||||
@@ -1,15 +1,17 @@
|
||||
# We still provide a setup.py for backwards compatability.
|
||||
# But the pyproject.toml should be prefered.
|
||||
import itertools
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
print('[!] You are currently installing/building fancy_gym via setup.py. This is only provided for backwards-compatability. Please use the pyproject.toml instead.')
|
||||
|
||||
# Environment-specific dependencies for dmc and metaworld
|
||||
extras = {
|
||||
'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'],
|
||||
'metaworld': ['mujoco==2.3.3', 'metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld'],
|
||||
'box2d': ['gymnasium[box2d]>=0.26.0'],
|
||||
'mujoco': ['mujoco==2.3.3', 'gymnasium[mujoco]>0.26.0'],
|
||||
'mujoco-legacy': ['mujoco-py >=2.1,<2.2', 'cython<3'],
|
||||
'jax': ["jax >=0.4.0", "jaxlib >=0.4.0"],
|
||||
'mushroom-rl': ['mushroom-rl'],
|
||||
@@ -36,7 +38,7 @@ def find_package_data(extensions_to_include: List[str]) -> List[str]:
|
||||
setup(
|
||||
author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou',
|
||||
name='fancy_gym',
|
||||
version='1.0',
|
||||
version='0.1.0',
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Intended Audience :: Science/Research',
|
||||
@@ -49,11 +51,13 @@ setup(
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Programming Language :: Python :: 3.10',
|
||||
'Programming Language :: Python :: 3.11',
|
||||
],
|
||||
extras_require=extras,
|
||||
install_requires=[
|
||||
'gymnasium>=0.26.0',
|
||||
'mp_pytorch<=0.1.3'
|
||||
'mp_pytorch<=0.1.3',
|
||||
'mujoco==2.3.3',
|
||||
'gymnasium[mujoco]>=0.26.0'
|
||||
],
|
||||
packages=[package for package in find_packages(
|
||||
) if package.startswith("fancy_gym")],
|
||||
|
||||
@@ -12,7 +12,9 @@ GYM_IDS = [spec.id for spec in gym.envs.registry.values() if
|
||||
not isinstance(spec.entry_point, Callable) and
|
||||
"fancy_gym" not in spec.entry_point and 'make_bb_env_helper' not in spec.entry_point
|
||||
and 'jax' not in spec.id.lower()
|
||||
and 'jax' not in spec.id.lower()
|
||||
and 'shimmy' not in spec.id.lower()
|
||||
and 'ale_py' not in spec.id.lower()
|
||||
and 'tabular' not in spec.id.lower()
|
||||
and not re.match(r'GymV2.Environment', spec.id)
|
||||
]
|
||||
GYM_MP_IDS = fancy_gym.ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS['all']
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_verbosity(mp_type: str, env_wrap: Tuple[str, Type[RawInterfaceWrapper]]
|
||||
|
||||
env_step = make(env_id)
|
||||
env_step.reset()
|
||||
_obs, _reward, _terminated, _truncated, info = env.step(env.action_space.sample())
|
||||
_obs, _reward, _terminated, _truncated, info = env_step.step(env_step.action_space.sample())
|
||||
info_keys_step = info.keys()
|
||||
|
||||
assert all(e in info_keys for e in info_keys_step)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import pytest
|
||||
|
||||
from fancy_gym.examples.example_replanning_envs import main as replanning_envs_main
|
||||
from fancy_gym.examples.examples_dmc import main as dmc_main
|
||||
from fancy_gym.examples.examples_general import main as general_main
|
||||
from fancy_gym.examples.examples_metaworld import main as metaworld_main
|
||||
from fancy_gym.examples.examples_movement_primitives import main as mp_main
|
||||
from fancy_gym.examples.examples_open_ai import main as open_ai_main
|
||||
|
||||
@pytest.mark.parametrize('entry', [replanning_envs_main, dmc_main, general_main, metaworld_main, mp_main, open_ai_main])
|
||||
@pytest.mark.parametrize('render', [False])
|
||||
def test_run_example(entry, render):
|
||||
entry(render=render)
|
||||
Reference in New Issue
Block a user