Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41c5ca1120 | ||
|
|
4d0ef519d0 | ||
|
|
31b9182b53 | ||
|
|
3c7fdc8d5b | ||
|
|
259b13baa1 | ||
|
|
5aec4f835f |
@@ -1,26 +0,0 @@
|
|||||||
name: Ensure Tagged Commits on Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- release
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_tag:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Check if base commit of PR is tagged
|
|
||||||
run: |
|
|
||||||
BASE_COMMIT=$(jq -r .pull_request.base.sha < "$GITHUB_EVENT_PATH")
|
|
||||||
TAG=$(git tag --contains $BASE_COMMIT)
|
|
||||||
if [ -z "$TAG" ]; then
|
|
||||||
echo "Base commit of PR is not tagged. PRs onto release must be tagged with the version number."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Base commit of PR is tagged. Check passed."
|
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
name: Ensure Version Consistency on PR to Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_version_and_tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: true # Terminate the job immediately if any step fails
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Necessary to fetch all tags for comparison
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install toml
|
||||||
|
|
||||||
|
- name: Extract version from pyproject.toml
|
||||||
|
run: |
|
||||||
|
echo "Extracting version from pyproject.toml"
|
||||||
|
VERSION=$(python -c 'import toml; print(toml.load("pyproject.toml")["project"]["version"])')
|
||||||
|
echo "Version in pyproject.toml is $VERSION"
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Get tag for the PR's head commit
|
||||||
|
run: |
|
||||||
|
PR_HEAD_SHA=$(jq -r .pull_request.head.sha < "$GITHUB_EVENT_PATH")
|
||||||
|
TAG=$(git tag --contains $PR_HEAD_SHA)
|
||||||
|
echo "Tag on PR's head commit is $TAG"
|
||||||
|
echo "TAG=$TAG" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Compare version and tag
|
||||||
|
run: |
|
||||||
|
if [ -z "$TAG" ]; then
|
||||||
|
echo "Head commit of PR is not tagged. Ensure the head commit of PRs onto release is tagged with the version number."
|
||||||
|
exit 1
|
||||||
|
elif [ "$VERSION" != "$TAG" ]; then
|
||||||
|
echo "Version in pyproject.toml ($VERSION) does not match the git tag ($TAG)."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Version and git tag match. Check passed."
|
||||||
|
fi
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
name: Deploy static docs to Pages
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ["release"]
|
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
||||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
||||||
concurrency:
|
|
||||||
group: "pages"
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# Single deploy job since we're just deploying
|
|
||||||
deploy:
|
|
||||||
environment:
|
|
||||||
name: github-pages
|
|
||||||
url: ${{ steps.deployment.outputs.page_url }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Setup Pages
|
|
||||||
uses: actions/configure-pages@v4
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-pages-artifact@v3
|
|
||||||
with:
|
|
||||||
path: 'docs/build/html'
|
|
||||||
- name: Deploy to GitHub Pages
|
|
||||||
id: deployment
|
|
||||||
uses: actions/deploy-pages@v4
|
|
||||||
@@ -8,6 +8,8 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
name: Publish to PyPI
|
name: Publish to PyPI
|
||||||
|
strategy:
|
||||||
|
fail-fast: true # Terminate the job immediately if any step fails
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
@@ -15,19 +17,24 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0 # This fetches all history for all branches and tags
|
fetch-depth: 0 # This fetches all history for all branches and tags
|
||||||
|
|
||||||
- name: Check if commit is tagged
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.x"
|
||||||
|
|
||||||
|
- name: Validate version against tag
|
||||||
run: |
|
run: |
|
||||||
|
VERSION=$(python -c 'import toml; print(toml.load("pyproject.toml")["project"]["version"])')
|
||||||
TAG=$(git tag --contains HEAD)
|
TAG=$(git tag --contains HEAD)
|
||||||
if [ -z "$TAG" ]; then
|
if [ -z "$TAG" ]; then
|
||||||
echo "Commit is not tagged. Failing the workflow."
|
echo "Commit is not tagged. Failing the workflow."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Commit is tagged. Proceeding with the workflow."
|
if [ "$VERSION" != "$TAG" ]; then
|
||||||
|
echo "Version in pyproject.toml ($VERSION) does not match the git tag ($TAG). Failing the workflow."
|
||||||
- name: Set up Python
|
exit 1
|
||||||
uses: actions/setup-python@v4
|
fi
|
||||||
with:
|
echo "Version and commit tag match. Proceeding with the workflow."
|
||||||
python-version: "3.x"
|
|
||||||
|
|
||||||
- name: Install pypa/build/setuptools/twine
|
- name: Install pypa/build/setuptools/twine
|
||||||
run: >-
|
run: >-
|
||||||
@@ -36,9 +43,6 @@ jobs:
|
|||||||
build setuptools twine
|
build setuptools twine
|
||||||
--user
|
--user
|
||||||
|
|
||||||
- name: Prevent fallback onto setup.py
|
|
||||||
run: rm setup.py
|
|
||||||
|
|
||||||
- name: Build a binary wheel and a source tarball
|
- name: Build a binary wheel and a source tarball
|
||||||
run: python3 -m build
|
run: python3 -m build
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -1,13 +1,17 @@
|
|||||||
# This conf.py is in large parts inspired by the oen used by stable-baselines 3
|
# This conf.py is in large parts inspired by the oen used by stable-baselines 3
|
||||||
|
|
||||||
|
import toml
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
project = 'Fancy Gym'
|
project = 'Fancy Gym'
|
||||||
author = 'Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou'
|
author = 'Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou'
|
||||||
copyright = f'2020-{datetime.date.today().year}, {author}'
|
copyright = f'2020-{datetime.date.today().year}, {author}'
|
||||||
|
|
||||||
release = '0.2' # The full version, including alpha/beta/rc tags
|
pyproject_content = toml.load("../../pyproject.toml")
|
||||||
version = '0.2' # The short X.Y version
|
proj_version = pyproject_content["project"]["version"]
|
||||||
|
|
||||||
|
release = proj_version # The full version, including alpha/beta/rc tags
|
||||||
|
version = proj_version # The short X.Y version
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
'myst_parser',
|
'myst_parser',
|
||||||
@@ -50,4 +54,4 @@ html_context = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_css_file("style.css")
|
app.add_css_file("style.css")
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ class AntJumpEnv(AntEnvCustomXML):
|
|||||||
contact_force_range=contact_force_range,
|
contact_force_range=contact_force_range,
|
||||||
reset_noise_scale=reset_noise_scale,
|
reset_noise_scale=reset_noise_scale,
|
||||||
exclude_current_positions_from_observation=exclude_current_positions_from_observation, **kwargs)
|
exclude_current_positions_from_observation=exclude_current_positions_from_observation, **kwargs)
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def step(self, action):
|
def step(self, action):
|
||||||
self.current_step += 1
|
self.current_step += 1
|
||||||
@@ -154,15 +153,8 @@ class AntJumpEnv(AntEnvCustomXML):
|
|||||||
}
|
}
|
||||||
truncated = False
|
truncated = False
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return obs, reward, terminated, truncated, info
|
return obs, reward, terminated, truncated, info
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
return np.append(super()._get_obs(), self.goal)
|
return np.append(super()._get_obs(), self.goal)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ class BeerPongEnv(MujocoEnv, utils.EzPickle):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
utils.EzPickle.__init__(self)
|
|
||||||
self._steps = 0
|
self._steps = 0
|
||||||
# Small Context -> Easier. Todo: Should we do different versions?
|
# Small Context -> Easier. Todo: Should we do different versions?
|
||||||
# self.xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "beerpong_wo_cup.xml")
|
# self.xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "beerpong_wo_cup.xml")
|
||||||
@@ -90,7 +89,7 @@ class BeerPongEnv(MujocoEnv, utils.EzPickle):
|
|||||||
observation_space=self.observation_space,
|
observation_space=self.observation_space,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
self.render_active = False
|
utils.EzPickle.__init__(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def start_pos(self):
|
def start_pos(self):
|
||||||
@@ -170,15 +169,8 @@ class BeerPongEnv(MujocoEnv, utils.EzPickle):
|
|||||||
|
|
||||||
truncated = False
|
truncated = False
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return ob, reward, terminated, truncated, infos
|
return ob, reward, terminated, truncated, infos
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
theta = self.data.qpos.flat[:7].copy()
|
theta = self.data.qpos.flat[:7].copy()
|
||||||
theta_dot = self.data.qvel.flat[:7].copy()
|
theta_dot = self.data.qvel.flat[:7].copy()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import numpy as np
|
|||||||
from gymnasium import utils, spaces
|
from gymnasium import utils, spaces
|
||||||
from gymnasium.envs.mujoco import MujocoEnv
|
from gymnasium.envs.mujoco import MujocoEnv
|
||||||
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import rot_to_quat, get_quaternion_error, rotation_distance
|
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import rot_to_quat, get_quaternion_error, rotation_distance
|
||||||
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import rot_to_quat, get_quaternion_error, rotation_distance
|
|
||||||
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import q_max, q_min, q_dot_max, q_torque_max
|
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import q_max, q_min, q_dot_max, q_torque_max
|
||||||
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import desired_rod_quat
|
from fancy_gym.envs.mujoco.box_pushing.box_pushing_utils import desired_rod_quat
|
||||||
|
|
||||||
@@ -61,7 +60,6 @@ class BoxPushingEnvBase(MujocoEnv, utils.EzPickle):
|
|||||||
frame_skip=self.frame_skip,
|
frame_skip=self.frame_skip,
|
||||||
observation_space=self.observation_space, **kwargs)
|
observation_space=self.observation_space, **kwargs)
|
||||||
self.action_space = spaces.Box(low=-1, high=1, shape=(7,))
|
self.action_space = spaces.Box(low=-1, high=1, shape=(7,))
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def step(self, action):
|
def step(self, action):
|
||||||
action = 10 * np.clip(action, self.action_space.low, self.action_space.high)
|
action = 10 * np.clip(action, self.action_space.low, self.action_space.high)
|
||||||
@@ -110,15 +108,8 @@ class BoxPushingEnvBase(MujocoEnv, utils.EzPickle):
|
|||||||
terminated = episode_end and infos['is_success']
|
terminated = episode_end and infos['is_success']
|
||||||
truncated = episode_end and not infos['is_success']
|
truncated = episode_end and not infos['is_success']
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return obs, reward, terminated, truncated, infos
|
return obs, reward, terminated, truncated, infos
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def reset_model(self):
|
def reset_model(self):
|
||||||
# rest box to initial position
|
# rest box to initial position
|
||||||
self.set_state(self.init_qpos_box_pushing, self.init_qvel_box_pushing)
|
self.set_state(self.init_qpos_box_pushing, self.init_qvel_box_pushing)
|
||||||
|
|||||||
@@ -60,11 +60,7 @@ class HalfCheetahEnvCustomXML(HalfCheetahEnv):
|
|||||||
default_camera_config=DEFAULT_CAMERA_CONFIG,
|
default_camera_config=DEFAULT_CAMERA_CONFIG,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
class HalfCheetahJumpEnv(HalfCheetahEnvCustomXML):
|
class HalfCheetahJumpEnv(HalfCheetahEnvCustomXML):
|
||||||
"""
|
"""
|
||||||
@@ -124,9 +120,6 @@ class HalfCheetahJumpEnv(HalfCheetahEnvCustomXML):
|
|||||||
'max_height': self.max_height
|
'max_height': self.max_height
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return observation, reward, terminated, truncated, info
|
return observation, reward, terminated, truncated, info
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
|
|||||||
@@ -88,12 +88,6 @@ class HopperEnvCustomXML(HopperEnv):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
|
|
||||||
class HopperJumpEnv(HopperEnvCustomXML):
|
class HopperJumpEnv(HopperEnvCustomXML):
|
||||||
"""
|
"""
|
||||||
@@ -207,10 +201,6 @@ class HopperJumpEnv(HopperEnvCustomXML):
|
|||||||
healthy=self.is_healthy,
|
healthy=self.is_healthy,
|
||||||
contact_dist=self.contact_dist or 0
|
contact_dist=self.contact_dist or 0
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return observation, reward, terminated, truncated, info
|
return observation, reward, terminated, truncated, info
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
|
|||||||
@@ -140,9 +140,6 @@ class HopperJumpOnBoxEnv(HopperEnvCustomXML):
|
|||||||
|
|
||||||
truncated = self.current_step >= self.max_episode_steps and not terminated
|
truncated = self.current_step >= self.max_episode_steps and not terminated
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return observation, reward, terminated, truncated, info
|
return observation, reward, terminated, truncated, info
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ class HopperThrowEnv(HopperEnvCustomXML):
|
|||||||
exclude_current_positions_from_observation=exclude_current_positions_from_observation,
|
exclude_current_positions_from_observation=exclude_current_positions_from_observation,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def step(self, action):
|
def step(self, action):
|
||||||
self.current_step += 1
|
self.current_step += 1
|
||||||
self.do_simulation(action, self.frame_skip)
|
self.do_simulation(action, self.frame_skip)
|
||||||
@@ -96,15 +94,8 @@ class HopperThrowEnv(HopperEnvCustomXML):
|
|||||||
}
|
}
|
||||||
truncated = False
|
truncated = False
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return observation, reward, terminated, truncated, info
|
return observation, reward, terminated, truncated, info
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
return np.append(super()._get_obs(), self.goal)
|
return np.append(super()._get_obs(), self.goal)
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ class HopperThrowInBasketEnv(HopperEnvCustomXML):
|
|||||||
reset_noise_scale=reset_noise_scale,
|
reset_noise_scale=reset_noise_scale,
|
||||||
exclude_current_positions_from_observation=exclude_current_positions_from_observation,
|
exclude_current_positions_from_observation=exclude_current_positions_from_observation,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def step(self, action):
|
def step(self, action):
|
||||||
|
|
||||||
@@ -119,15 +118,8 @@ class HopperThrowInBasketEnv(HopperEnvCustomXML):
|
|||||||
}
|
}
|
||||||
truncated = False
|
truncated = False
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return observation, reward, terminated, truncated, info
|
return observation, reward, terminated, truncated, info
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
return np.append(super()._get_obs(), self.basket_x)
|
return np.append(super()._get_obs(), self.basket_x)
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ class ReacherEnv(MujocoEnv, utils.EzPickle):
|
|||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
def step(self, action):
|
def step(self, action):
|
||||||
self._steps += 1
|
self._steps += 1
|
||||||
|
|
||||||
@@ -79,15 +77,8 @@ class ReacherEnv(MujocoEnv, utils.EzPickle):
|
|||||||
goal=self.goal if hasattr(self, "goal") else None
|
goal=self.goal if hasattr(self, "goal") else None
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return ob, reward, terminated, truncated, info
|
return ob, reward, terminated, truncated, info
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def distance_reward(self):
|
def distance_reward(self):
|
||||||
vec = self.get_body_com("fingertip") - self.get_body_com("target")
|
vec = self.get_body_com("fingertip") - self.get_body_com("target")
|
||||||
return -self._reward_weight * np.linalg.norm(vec)
|
return -self._reward_weight * np.linalg.norm(vec)
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ class TableTennisEnv(MujocoEnv, utils.EzPickle):
|
|||||||
observation_space=self.observation_space,
|
observation_space=self.observation_space,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
if ctxt_dim == 2:
|
if ctxt_dim == 2:
|
||||||
self.context_bounds = CONTEXT_BOUNDS_2DIMS
|
self.context_bounds = CONTEXT_BOUNDS_2DIMS
|
||||||
elif ctxt_dim == 4:
|
elif ctxt_dim == 4:
|
||||||
@@ -160,15 +158,8 @@ class TableTennisEnv(MujocoEnv, utils.EzPickle):
|
|||||||
|
|
||||||
terminated, truncated = self._terminated, False
|
terminated, truncated = self._terminated, False
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return self._get_obs(), reward, terminated, truncated, info
|
return self._get_obs(), reward, terminated, truncated, info
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def _contact_checker(self, id_1, id_2):
|
def _contact_checker(self, id_1, id_2):
|
||||||
for coni in range(0, self.data.ncon):
|
for coni in range(0, self.data.ncon):
|
||||||
con = self.data.contact[coni]
|
con = self.data.contact[coni]
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ class Walker2dEnvCustomXML(Walker2dEnv):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.render_active = False
|
|
||||||
|
|
||||||
|
|
||||||
class Walker2dJumpEnv(Walker2dEnvCustomXML):
|
class Walker2dJumpEnv(Walker2dEnvCustomXML):
|
||||||
"""
|
"""
|
||||||
@@ -147,15 +145,8 @@ class Walker2dJumpEnv(Walker2dEnvCustomXML):
|
|||||||
}
|
}
|
||||||
truncated = False
|
truncated = False
|
||||||
|
|
||||||
if self.render_active and self.render_mode=='human':
|
|
||||||
self.render()
|
|
||||||
|
|
||||||
return observation, reward, terminated, truncated, info
|
return observation, reward, terminated, truncated, info
|
||||||
|
|
||||||
def render(self):
|
|
||||||
self.render_active = True
|
|
||||||
return super().render()
|
|
||||||
|
|
||||||
def _get_obs(self):
|
def _get_obs(self):
|
||||||
return np.append(super()._get_obs(), self.goal)
|
return np.append(super()._get_obs(), self.goal)
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import fancy_gym
|
|||||||
|
|
||||||
|
|
||||||
def example_run_replanning_env(env_name="fancy_ProDMP/BoxPushingDenseReplan-v0", seed=1, iterations=1, render=False):
|
def example_run_replanning_env(env_name="fancy_ProDMP/BoxPushingDenseReplan-v0", seed=1, iterations=1, render=False):
|
||||||
env = gym.make(env_name, render_mode='human' if render else None)
|
env = gym.make(env_name)
|
||||||
env.reset(seed=seed)
|
env.reset(seed=seed)
|
||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
while True:
|
while True:
|
||||||
ac = env.action_space.sample()
|
ac = env.action_space.sample()
|
||||||
obs, reward, terminated, truncated, info = env.step(ac)
|
obs, reward, terminated, truncated, info = env.step(ac)
|
||||||
if render:
|
if render:
|
||||||
env.render()
|
env.render(mode="human")
|
||||||
if terminated or truncated:
|
if terminated or truncated:
|
||||||
env.reset()
|
env.reset()
|
||||||
break
|
break
|
||||||
@@ -38,13 +38,13 @@ def example_custom_replanning_envs(seed=0, iteration=100, render=True):
|
|||||||
'replanning_schedule': lambda pos, vel, obs, action, t: t % 25 == 0,
|
'replanning_schedule': lambda pos, vel, obs, action, t: t % 25 == 0,
|
||||||
'condition_on_desired': True}
|
'condition_on_desired': True}
|
||||||
|
|
||||||
base_env = gym.make(base_env_id, render_mode='human' if render else None)
|
base_env = gym.make(base_env_id)
|
||||||
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs=black_box_kwargs,
|
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,
|
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
||||||
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
||||||
seed=seed)
|
seed=seed)
|
||||||
if render:
|
if render:
|
||||||
env.render()
|
env.render(mode="human")
|
||||||
|
|
||||||
obs = env.reset()
|
obs = env.reset()
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def example_dmc(env_id="dm_control/fish-swim", seed=1, iterations=1000, render=T
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
env = gym.make(env_id, render_mode='human' if render else None)
|
env = gym.make(env_id)
|
||||||
rewards = 0
|
rewards = 0
|
||||||
obs = env.reset(seed=seed)
|
obs = env.reset(seed=seed)
|
||||||
print("observation shape:", env.observation_space.shape)
|
print("observation shape:", env.observation_space.shape)
|
||||||
@@ -26,7 +26,7 @@ def example_dmc(env_id="dm_control/fish-swim", seed=1, iterations=1000, render=T
|
|||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
ac = env.action_space.sample()
|
ac = env.action_space.sample()
|
||||||
if render:
|
if render:
|
||||||
env.render()
|
env.render(mode="human")
|
||||||
obs, reward, terminated, truncated, info = env.step(ac)
|
obs, reward, terminated, truncated, info = env.step(ac)
|
||||||
rewards += reward
|
rewards += reward
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ def example_custom_dmc_and_mp(seed=1, iterations=1, render=True):
|
|||||||
# basis_generator_kwargs = {'basis_generator_type': 'rbf',
|
# basis_generator_kwargs = {'basis_generator_type': 'rbf',
|
||||||
# 'num_basis': 5
|
# 'num_basis': 5
|
||||||
# }
|
# }
|
||||||
base_env = gym.make(base_env_id, render_mode='human' if render else None)
|
base_env = gym.make(base_env_id)
|
||||||
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs={},
|
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs={},
|
||||||
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
||||||
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
||||||
@@ -96,7 +96,7 @@ def example_custom_dmc_and_mp(seed=1, iterations=1, render=True):
|
|||||||
# It is also possible to change them mode multiple times when
|
# It is also possible to change them mode multiple times when
|
||||||
# e.g. only every nth trajectory should be displayed.
|
# e.g. only every nth trajectory should be displayed.
|
||||||
if render:
|
if render:
|
||||||
env.render()
|
env.render(mode="human")
|
||||||
|
|
||||||
rewards = 0
|
rewards = 0
|
||||||
obs = env.reset()
|
obs = env.reset()
|
||||||
@@ -115,7 +115,7 @@ def example_custom_dmc_and_mp(seed=1, iterations=1, render=True):
|
|||||||
env.close()
|
env.close()
|
||||||
del env
|
del env
|
||||||
|
|
||||||
def main(render = False):
|
def main(render = True):
|
||||||
# # Standard DMC Suite tasks
|
# # Standard DMC Suite tasks
|
||||||
example_dmc("dm_control/fish-swim", seed=10, iterations=1000, render=render)
|
example_dmc("dm_control/fish-swim", seed=10, iterations=1000, render=render)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ def example_general(env_id="Pendulum-v1", seed=1, iterations=1000, render=True):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
env = gym.make(env_id, render_mode='human' if render else None)
|
env = gym.make(env_id)
|
||||||
rewards = 0
|
rewards = 0
|
||||||
obs = env.reset(seed=seed)
|
obs = env.reset(seed=seed)
|
||||||
print("Observation shape: ", env.observation_space.shape)
|
print("Observation shape: ", env.observation_space.shape)
|
||||||
@@ -85,7 +85,7 @@ def example_async(env_id="fancy/HoleReacher-v0", n_cpu=4, seed=int('533D', 16),
|
|||||||
# do not return values above threshold
|
# do not return values above threshold
|
||||||
return *map(lambda v: np.stack(v)[:n_samples], buffer.values()),
|
return *map(lambda v: np.stack(v)[:n_samples], buffer.values()),
|
||||||
|
|
||||||
def main(render = False):
|
def main(render = True):
|
||||||
# Basic gym task
|
# Basic gym task
|
||||||
example_general("Pendulum-v1", seed=10, iterations=200, render=render)
|
example_general("Pendulum-v1", seed=10, iterations=200, render=render)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import gymnasium as gym
|
|||||||
import fancy_gym
|
import fancy_gym
|
||||||
|
|
||||||
|
|
||||||
def example_meta(env_id="metaworld/button-press-v2", seed=1, iterations=1000, render=True):
|
def example_meta(env_id="fish-swim", seed=1, iterations=1000, render=True):
|
||||||
"""
|
"""
|
||||||
Example for running a MetaWorld based env in the step based setting.
|
Example for running a MetaWorld based env in the step based setting.
|
||||||
The env_id has to be specified as `task_name-v2`. V1 versions are not supported and we always
|
The env_id has to be specified as `task_name-v2`. V1 versions are not supported and we always
|
||||||
@@ -18,7 +18,7 @@ def example_meta(env_id="metaworld/button-press-v2", seed=1, iterations=1000, re
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
env = gym.make(env_id, render_mode='human' if render else None)
|
env = gym.make(env_id)
|
||||||
rewards = 0
|
rewards = 0
|
||||||
obs = env.reset(seed=seed)
|
obs = env.reset(seed=seed)
|
||||||
print("observation shape:", env.observation_space.shape)
|
print("observation shape:", env.observation_space.shape)
|
||||||
@@ -27,7 +27,9 @@ def example_meta(env_id="metaworld/button-press-v2", seed=1, iterations=1000, re
|
|||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
ac = env.action_space.sample()
|
ac = env.action_space.sample()
|
||||||
if render:
|
if render:
|
||||||
env.render()
|
# THIS NEEDS TO BE SET TO FALSE FOR NOW, BECAUSE THE INTERFACE FOR RENDERING IS DIFFERENT TO BASIC GYM
|
||||||
|
# TODO: Remove this, when Metaworld fixes its interface.
|
||||||
|
env.render(False)
|
||||||
obs, reward, terminated, truncated, info = env.step(ac)
|
obs, reward, terminated, truncated, info = env.step(ac)
|
||||||
rewards += reward
|
rewards += reward
|
||||||
if terminated or truncated:
|
if terminated or truncated:
|
||||||
@@ -79,7 +81,7 @@ def example_custom_meta_and_mp(seed=1, iterations=1, render=True):
|
|||||||
basis_generator_kwargs = {'basis_generator_type': 'rbf',
|
basis_generator_kwargs = {'basis_generator_type': 'rbf',
|
||||||
'num_basis': 5
|
'num_basis': 5
|
||||||
}
|
}
|
||||||
base_env = gym.make(base_env_id, render_mode='human' if render else None)
|
base_env = gym.make(base_env_id)
|
||||||
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs={},
|
env = fancy_gym.make_bb(env=base_env, wrappers=wrappers, black_box_kwargs={},
|
||||||
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
traj_gen_kwargs=trajectory_generator_kwargs, controller_kwargs=controller_kwargs,
|
||||||
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
phase_kwargs=phase_generator_kwargs, basis_kwargs=basis_generator_kwargs,
|
||||||
@@ -91,7 +93,7 @@ def example_custom_meta_and_mp(seed=1, iterations=1, render=True):
|
|||||||
# It is also possible to change them mode multiple times when
|
# It is also possible to change them mode multiple times when
|
||||||
# e.g. only every nth trajectory should be displayed.
|
# e.g. only every nth trajectory should be displayed.
|
||||||
if render:
|
if render:
|
||||||
env.render()
|
env.render(mode="human")
|
||||||
|
|
||||||
rewards = 0
|
rewards = 0
|
||||||
obs = env.reset(seed=seed)
|
obs = env.reset(seed=seed)
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ def example_mp(env_name, seed=1, render=True):
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
env = gym.make(env_name, render_mode='human' if render else None)
|
env = gym.make(env_name)
|
||||||
|
|
||||||
returns = 0
|
returns = 0
|
||||||
obs = env.reset(seed=seed)
|
obs = env.reset(seed=seed)
|
||||||
# number of samples/full trajectories (multiple environment steps)
|
# number of samples/full trajectories (multiple environment steps)
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
if render and i % 2 == 0:
|
if render and i % 2 == 0:
|
||||||
|
env.render(mode="human")
|
||||||
|
else:
|
||||||
env.render()
|
env.render()
|
||||||
ac = env.action_space.sample()
|
ac = env.action_space.sample()
|
||||||
obs, reward, terminated, truncated, info = env.step(ac)
|
obs, reward, terminated, truncated, info = env.step(ac)
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "fancy_gym"
|
name = "fancy_gym"
|
||||||
version = "0.1.4"
|
version = "0.3.0"
|
||||||
description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches."
|
description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [
|
authors = [
|
||||||
@@ -26,6 +26,7 @@ classifiers = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"toml",
|
||||||
"mp_pytorch<=0.1.3",
|
"mp_pytorch<=0.1.3",
|
||||||
"mujoco==2.3.3",
|
"mujoco==2.3.3",
|
||||||
"gymnasium[mujoco]>=0.26.0"
|
"gymnasium[mujoco]>=0.26.0"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# We still provide a setup.py for backwards compatability.
|
# We still provide a setup.py for backwards compatability.
|
||||||
# But the pyproject.toml should be prefered.
|
# But the pyproject.toml should be prefered.
|
||||||
|
import toml
|
||||||
import itertools
|
import itertools
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
@@ -8,6 +9,9 @@ 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.')
|
print('[!] You are currently installing/building fancy_gym via setup.py. This is only provided for backwards-compatability. Please use the pyproject.toml instead.')
|
||||||
|
|
||||||
|
pyproject_content = toml.load("pyproject.toml")
|
||||||
|
project_version = pyproject_content["project"]["version"]
|
||||||
|
|
||||||
# Environment-specific dependencies for dmc and metaworld
|
# Environment-specific dependencies for dmc and metaworld
|
||||||
extras = {
|
extras = {
|
||||||
'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'],
|
'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'],
|
||||||
@@ -38,7 +42,7 @@ def find_package_data(extensions_to_include: List[str]) -> List[str]:
|
|||||||
setup(
|
setup(
|
||||||
author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou',
|
author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou',
|
||||||
name='fancy_gym',
|
name='fancy_gym',
|
||||||
version='0.1.0',
|
version=project_version,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'Intended Audience :: Science/Research',
|
'Intended Audience :: Science/Research',
|
||||||
@@ -55,6 +59,7 @@ setup(
|
|||||||
],
|
],
|
||||||
extras_require=extras,
|
extras_require=extras,
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
'toml',
|
||||||
'mp_pytorch<=0.1.3',
|
'mp_pytorch<=0.1.3',
|
||||||
'mujoco==2.3.3',
|
'mujoco==2.3.3',
|
||||||
'gymnasium[mujoco]>=0.26.0'
|
'gymnasium[mujoco]>=0.26.0'
|
||||||
|
|||||||
Reference in New Issue
Block a user