Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and Upgrade to Gymnasium #75

Merged
merged 201 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
0c7ac83
first updats to reacher and env creation
Oct 20, 2022
fbe3ef4
updated examples to new api,
Jan 12, 2023
ed72404
updated custom tasks to new api
Jan 12, 2023
9ebc021
updated dm_control envs to use shimmy
Jan 12, 2023
ec2063a
updated tests for dm_control
Jan 12, 2023
c53924d
updated to new API, so tests still failing
Jan 17, 2023
b695239
num_basis is not implemented; tests are expected to fail
May 15, 2023
9de1257
Updating gym(nasium) and metaworld; sticter versions
May 15, 2023
2cbfff7
Added box2d as a dependency
May 15, 2023
1c092d0
Optional Dependency: PyTest
May 15, 2023
826f22b
Update URL for Metaworld (rlworkgroup -> Farama)
May 15, 2023
228e343
Merge branch '47-update-to-new-gym-api' into gym_upgrade
May 15, 2023
a559f92
Adapted test to new gym interface
May 18, 2023
1e62da0
Use shimmy as a binding for dmc, also 'testing' seperate from 'all'
May 18, 2023
d4a8306
Buf Fix: PyTests still used binding to old gym
May 18, 2023
0dfd8e1
Fixed Bug: env_id was broken, when prefix is handled by other library
May 18, 2023
21d5ebb
Fixed Bug: ToyEnv did not follow new gym spec
May 18, 2023
07de655
Allow dmc envs to be accessed via dmc:... (for backwards compatibility)
May 18, 2023
bf3ed8a
Fix: TimeAwareObservation did not support float64 and tried to forbid…
May 19, 2023
e75ab89
Ported box_pushing to new mujoco bindings
May 19, 2023
e70a56a
Fixed: Typos
May 19, 2023
3bbf101
Fixed: test_black_box.py still used old gym specs in two places
May 19, 2023
bc9d4cf
More verbose errors for run_env_determinism
May 19, 2023
1c002a2
Warning no longer applicable
May 19, 2023
dabfc7c
Adapted Mujoco Envs to new gymnasium spec
May 19, 2023
d6df677
Auto convert output spaces.Dict to Box for BB-Envs
May 27, 2023
35680ab
Merge branch 'master' into gym_upgrade
May 27, 2023
a8a6760
Fix: NameError: name 'd' is not defined
May 27, 2023
29b458c
Fix: hopper_jump_on_box still used unpatched HopperEnv
May 27, 2023
dbd7c37
Also support old gym Box as observation_space (backwards compat)
May 27, 2023
110a8a9
Fix: MujocoEnv no longer supports manual assignment of mujoco_bindings
May 27, 2023
1fddeb8
Forgot to make it derive from Walker2dEnvCustomXML instead of origina…
May 27, 2023
38cb5e1
Converted mujoco env 'hopper_jump' to new coordinate convention
Jun 10, 2023
c06fbee
Converted mujoco env 'hopper_throw' to new coordinate convention
Jun 10, 2023
ff382a2
Converted mujoco env 'walker2d' to new coordinate convention
Jun 10, 2023
5e7f027
Fixed Bug: walker_2d_jump was missing obsvation_space attribute
Jun 10, 2023
ddf6fd7
Fixed: hopper_jump returned observations bigger then observation_space
Jun 10, 2023
42003a3
Allow custom XML-files for ant_env
Jun 10, 2023
40d2409
Fixed: ant_jump returned observations bigger then observation_space
Jun 10, 2023
f07b8a2
Made some assertions more verbose for easier debugging
Jun 10, 2023
ef64b0c
Adding/fixing obs space definitions and metadata for various envs
Jun 11, 2023
6f1a36d
Adding required render_fps metadata to custom envs
Jun 11, 2023
80de15f
Fix: Return for invalid trajectories did not follow new gym spec
Jun 11, 2023
4921cc4
Fix: Some envs had wrong obs space shapes and did not follow new gym …
Jun 11, 2023
e44b0ed
Fix: Version specification now requirted for dmc envs
Jun 11, 2023
2ad42f4
Fix: Minor bugs in time aware obs wrapper
Jun 11, 2023
abeb963
Little hack to make envs work, that don't expose the max_episode_step…
Jun 11, 2023
a23b447
Implement support for Dict spaces for time_aware_observation-wrapper
Jun 11, 2023
c9467c0
Upgrading metaworld (fixed bug that affected us)
Jun 11, 2023
9605f2e
Fix: Test for dmc still referenced lib directly (not via shimmy)
Jun 11, 2023
fbba129
Fix: Need to supply seed to reset in tests
Jun 18, 2023
f44f01b
Fix: Allow observation space dict in test_replanning
Jun 18, 2023
49ac9c3
Fix: Don't throw errors for envs, that do not expose a max_episode_st…
Jun 18, 2023
60a4cf1
Fix: Some envs used no longer existing binding to mujoco
Jun 18, 2023
b032dec
Better handling of envs without defined max_steps
Jun 18, 2023
9ade0dc
Fix: Make wrappers work with BB and Dict-Space
Jun 18, 2023
f8ad65b
Remove old file
Jun 18, 2023
b6089c4
ugly_hack_to_mitigate_metaworld_bug
Jun 18, 2023
7354257
Bug mitigation for metaworld refactored and extended
Jun 18, 2023
9af4211
Version bump (made very breaking changes)
Jun 24, 2023
0fe56c4
Stricter dependency versions
Jun 24, 2023
55c6cff
Fix: PyPi had troubles finding a compatible version for dm-control
Jun 24, 2023
bc0dcb7
Fixed: Tried importing old dependency
Jun 24, 2023
e811979
Updating some dependencies
Jun 24, 2023
ad7ddd3
Fix: A missing ',' caused very weird bugs...
Jun 24, 2023
55f84da
A fancy icon for fancy gym
Jun 27, 2023
1601a87
Added attribution for the icon.
Jun 27, 2023
de118a3
Down to 20 failing tests (more mitigations of metaworld bug)
Jun 28, 2023
eb1d145
Fix Test: Delay was not supplied to mp-generator
Jun 28, 2023
bf1eb49
Make Icon Attribution h2
Jun 28, 2023
cdabd3f
Downgrading mujoco 2.3.6 -> 2.3.3
Jul 7, 2023
14a95eb
Fixed Typo in README
Jul 7, 2023
27f8335
Remove dependence of wrapper on old gym
Jul 7, 2023
67a5d19
Weaker version requirement for dm-control
Jul 7, 2023
ffbada2
Started implementing new fancy registry
Jul 14, 2023
6c90f8a
Getting rid of some old code
Jul 14, 2023
f375a6e
Ported classic_control envs to fancy registry
Jul 14, 2023
30bafd7
Allow skipping merge with default bb config
Jul 14, 2023
9fa932d
minor refactoring
Jul 20, 2023
f6e1718
metadata.mp_config now expected in MP_wrapper (implementing Fabian's …
Jul 20, 2023
9d03542
Move mp_config out of metadata and onto MPWrappers
Jul 20, 2023
17d370e
Allow overriding mp_config during register and make (also better errors
Jul 20, 2023
8d26ccc
ported mp_config for mujoco/box_pushing
Jul 20, 2023
1b061b2
ported mp_config for mujoco/box_pushing
Jul 20, 2023
dbf2be1
refactoring env registration wip
Jul 20, 2023
83d5d39
removed deprecated envs
Jul 20, 2023
64e6ac5
ported mp_config for mujoco/beerpong
Jul 23, 2023
9ba3fa9
ported mp_config for mujoco/table_tennis
Jul 23, 2023
a069aaa
Removed old manual registration of mp-envs (port to fancy registry)
Jul 23, 2023
ce34df1
No longer export old custom make
Jul 23, 2023
21a9c0f
Fixed Bug leading to infinite recusrion when making mp envs
Jul 23, 2023
b0f7dc6
test/utils.py must use gym.make now (was fancy_gym.make)
Jul 23, 2023
eb9b6e1
test_black_box.py should use vanilla env.make
Jul 23, 2023
3e586a1
Added tests for new fancy registry
Jul 23, 2023
99a02b8
Started work on new adapter & mp_config port for metaworld
Jul 23, 2023
6787b02
Fixed missing import in metaworld_adapter
Jul 23, 2023
0fb0506
Fix: Many tests still tried to seed during make
Jul 23, 2023
e2ff915
Fix: Cannot use .get for object attributes
Jul 23, 2023
fc4b98e
Allow envs to already be wrapped with a RawInterfaceWrapper
Jul 23, 2023
95b2c25
Fixed typo
Jul 23, 2023
127d355
Move into our own namespace ('fancy')
Jul 23, 2023
58bb8c0
Fix: Env in new namespace
Jul 23, 2023
3a9143f
removed file deprecated
Jul 23, 2023
edd8c75
Consistent quotation marks
Jul 23, 2023
bb20bb5
entry_point does not have to be given, when skipping registration of …
Jul 24, 2023
2fc4466
fancy_gym.upgrade allows adding mp-versions for already registered envs
Jul 24, 2023
ae1033a
Remember mp-envs for each ns seperately (replicate legacy functionality)
Jul 29, 2023
6b07705
Fix: fancy_gym.upgrade ignored mp_config_override-arg
Jul 29, 2023
d488363
Print warning when trying to register already registered step-based env
Jul 29, 2023
e743663
Ported dmc envs to mp-config
Jul 30, 2023
e63a0a5
Ported metaworld to mp-config
Jul 30, 2023
bc3f540
weight_scale -> weights_scale
Jul 30, 2023
20d0be3
Replicate legacy behavior in exporting lists off all mp envs
Jul 30, 2023
b4793c8
Fix: ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS no longer exists in fancy
Jul 30, 2023
5519fd5
Fix: Wrong name for ns: dmc -> dm_controll
Jul 30, 2023
e30b6c0
Removed old code samples from meta mp docs
Jul 30, 2023
9c6d795
Extended Tests: Ensure no known namespace is empty
Jul 30, 2023
9020eb9
Fix: test/test_replanning_sequencing.py still referenced old fancy_gy…
Jul 30, 2023
fb8f81a
Don't use defaultdicts for MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS
Jul 30, 2023
caf483a
Fixed Typo dm_controll -> dm_control
Jul 30, 2023
221e3fe
Fix: Some tests omitted new ns 'fancy' when trying to access our envs
Jul 30, 2023
14223c5
Fix: Controllers not getting kwargs
Jul 30, 2023
fb1282f
Use new namespace convention for mp-versions of envs
Aug 14, 2023
eefcbcb
tiny fix to env references in test
Aug 14, 2023
14d545a
Fixed: Name generation wrong for mp envs
Aug 14, 2023
1fb5368
Fix: Multiple issues in test/test_fancy_registry.py
Aug 14, 2023
f3ffa71
Cleaning up test/test_dmc_envs.py
Aug 14, 2023
5b99227
Moving the ugly_mitigation_for_metaworld_bug into the metaworld env w…
Aug 14, 2023
78823d9
Various fixed to tests
Aug 14, 2023
94c4397
Fixed incorrect ns seperator for metaworld tests
Aug 21, 2023
6d80201
Simplified metaworld adapter
Aug 21, 2023
15e1bdc
Mitigation: Allow seeding Metaworld on reset
Aug 28, 2023
a4e2883
Fix: Incorrect Controller Type in mp_config for dmc reach_site
Aug 28, 2023
8b3d05a
Fix Typo: weights_scale should apply to traj_gen, not controller
Aug 28, 2023
20b1b0c
Quickfix for mp_config merging and allow defining different base_id for
Aug 28, 2023
2c0c4e5
Fix Typo: alpha_phase belongs to phase_gen not basis_gen
Aug 28, 2023
22a72fe
Fix: Seeding of act-space is not guaranteed, seed it manually since we
Aug 28, 2023
5921e00
Mitigation: Metaworld .reset ignores seeds; we must manually seed on …
Aug 28, 2023
07aeb77
Fix: Some fancy envs failed determinism test because they sampled dur…
Aug 28, 2023
820e781
Fix: Some simple_reacher did not seed correctly
Aug 28, 2023
1558072
Fix: SimpleReacher and ViaPointReacher did not seed correctly
Aug 28, 2023
315e135
Added message about discontinuation of fancy_gym.make
Sep 10, 2023
7f95923
Fixed typo in env registration
Sep 17, 2023
0629d12
Ensure mp_config defined for all envs, even if just using defaults.
Sep 17, 2023
da34db2
Fix: mp_config missing for BoxPushing ProDMP
Sep 17, 2023
8749fc5
Better README
Sep 17, 2023
7f58093
Fixed all examples
Sep 17, 2023
a76967a
Forgot to port gym_Reacher over
Sep 17, 2023
89bd678
mp_config for vanilla gym Reacher
Sep 17, 2023
38358c1
Upgrading metaworld
Sep 17, 2023
c933a75
More README improvements
Sep 18, 2023
4c8dda3
Fix: README code imported gym instead of gymnasium
Sep 18, 2023
513bf23
Fix: Deprecated beerpong env still referenced old mujoco binding
Sep 18, 2023
592f097
Future proofing: Accesing attributes of other wrappers needs to be
Sep 18, 2023
20510d8
Ported MetaWorld wrapper to new mujoco binding
Sep 18, 2023
9ce040d
Porting Metaworld Bug Mitigations
Sep 18, 2023
ddd11c1
Skip Tests: Metaworld does currently not correclty implement seeding
Sep 18, 2023
54e8ec4
Print warning on seeded metaworld reset
Sep 18, 2023
60a8204
Merge remote-tracking branch 'original/master' into great_refactor
Sep 18, 2023
5488ca6
Fixed merge error
Sep 18, 2023
725e6c8
Fixed wrong env name (still contained mp info)
Sep 18, 2023
659a717
Removed old files
Sep 18, 2023
cf886b2
New optional dependency: jax
Sep 18, 2023
c5b051d
Fixed typo in README
Sep 18, 2023
57c4a94
Another typo gone from the README
Sep 18, 2023
59ee559
README: reset will return (obs, info)
Sep 18, 2023
842ab3f
Added mujoco-legacy (mujoco-py) as an optional dependency
Sep 19, 2023
e077a8f
Updated README
Sep 19, 2023
d8315c8
Fixed typo in NS
Sep 19, 2023
4965851
Extended README
Sep 19, 2023
79c2eda
Fixed minor issues
Sep 19, 2023
310719e
Fix: Typo in README
Sep 19, 2023
740d1d7
README: Added link to changelog of refactor
Sep 19, 2023
6d0e96c
typo
Sep 19, 2023
d6ecc0d
minor changes to README
Sep 20, 2023
56c1c65
Better doumentation of fancy registry fucntions (register & upgrade)
Sep 29, 2023
8bba78b
Updated dmc README
Sep 29, 2023
e55905a
Improved and Updated README for custom mujoco envs
Sep 29, 2023
e305556
Improved README for classical controll envs
Sep 29, 2023
a803d92
Slighly better docs for OpenAI envs
Sep 30, 2023
e633b1e
Fixed open_ai README
Sep 30, 2023
b3de71e
Expanded README for Metaworld
Sep 30, 2023
27f3a82
Tiny update to Metaworld README
Sep 30, 2023
1eeccff
README: Justify text about MP envs (looks way better)
Sep 30, 2023
0ae8708
README: Better Justifycation of text
Sep 30, 2023
9fee527
Fix: Typo in setup.py
Oct 11, 2023
3180154
Added docstring to deprecated 'fancy_gym.make'
Oct 11, 2023
fcc79cd
Added Hongyi & Hongyi as authors to setup.py
Oct 11, 2023
5f3c28e
Added bibtex for citations to README
Oct 11, 2023
bc150f5
Fix: Bibtex in README mixed between tabs & spaces
Oct 11, 2023
757072c
Documnenting merging behavior for mp_configs (and remove TODOs)
Oct 11, 2023
3317ffb
README: @ is not a legal symbol in BibTex attribs
Oct 11, 2023
db5e032
Development status alpha -> beta; version to 1.0 (for pub release)
Oct 11, 2023
980bb0d
Add docstring to DefaultMPWrapper
Oct 11, 2023
877a7ea
Fix: Wrong horizon for Metaworld tasks
Oct 11, 2023
600575c
Dont run determinism tests on arbitrary external envs added by other
Oct 11, 2023
fc73824
README: Minor cosmetic changes
Oct 11, 2023
4f53477
READE: Minor cosmetic changes pt.2
Oct 11, 2023
614d2a4
READE: Minor cosmetic changes pt.3
Oct 11, 2023
f8dcf5b
Fix: Did not define MP_Wrapper for new RandomInit version of BoxPushing
Oct 11, 2023
a04a4b6
Link legacy branch in README
Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 166 additions & 85 deletions README.md

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions fancy_gym/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from fancy_gym import dmc, meta, open_ai
from fancy_gym.utils.make_env_helpers import make, make_bb, make_rank
from .dmc import ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS
# Convenience function for all MP environments
from .envs import ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS
from .meta import ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS
from .open_ai import ALL_GYM_MOVEMENT_PRIMITIVE_ENVIRONMENTS
from fancy_gym import envs as fancy
from fancy_gym.utils.make_env_helpers import make_bb
from .envs.registry import register, upgrade
from .envs.registry import ALL_MOVEMENT_PRIMITIVE_ENVIRONMENTS, MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS

ALL_MOVEMENT_PRIMITIVE_ENVIRONMENTS = {
key: value + ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS[key] +
ALL_GYM_MOVEMENT_PRIMITIVE_ENVIRONMENTS[key] +
ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS[key]
for key, value in ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS.items()}
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']
ALL_GYM_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['gym']


def make(*args, **kwargs):
"""
As part of the refactor of Fancy Gym and upgrade to gymnasium the use of fancy_gym.make has been discontinued. Regular gym.make should be used instead. For more details check out the github README. If your codebase was build for older versions of Fancy Gym and relies on the old behavior and dependency versions, please check out the legacy branch.
"""
raise Exception('As part of the refactor of Fancy Gym and upgrade to gymnasium the use of fancy_gym.make has been discontinued. Regular gym.make should be used instead. For more details check out the github README. If your codebase was build for older versions of Fancy Gym and relies on the old behavior and dependency versions, please check out the legacy branch.')
53 changes: 30 additions & 23 deletions fancy_gym/black_box/black_box_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Tuple, Optional, Callable
from typing import Tuple, Optional, Callable, Dict, Any

import gym
import gymnasium as gym
import numpy as np
from gym import spaces
from gymnasium import spaces
from gymnasium.core import ObsType
from mp_pytorch.mp.mp_interfaces import MPInterface

from fancy_gym.black_box.controller.base_controller import BaseController
Expand Down Expand Up @@ -67,7 +68,8 @@ def __init__(self,
self.reward_aggregation = reward_aggregation

# spaces
self.return_context_observation = not (learn_sub_trajectories or self.do_replanning)
self.return_context_observation = not (
learn_sub_trajectories or self.do_replanning)
self.traj_gen_action_space = self._get_traj_gen_action_space()
self.action_space = self._get_action_space()
self.observation_space = self._get_observation_space()
Expand Down Expand Up @@ -99,14 +101,17 @@ def get_trajectory(self, action: np.ndarray) -> Tuple:
# If we do not do this, the traj_gen assumes we are continuing the trajectory.
self.traj_gen.reset()

clipped_params = np.clip(action, self.traj_gen_action_space.low, self.traj_gen_action_space.high)
clipped_params = np.clip(
action, self.traj_gen_action_space.low, self.traj_gen_action_space.high)
self.traj_gen.set_params(clipped_params)
init_time = np.array(0 if not self.do_replanning else self.current_traj_steps * self.dt)
init_time = np.array(
0 if not self.do_replanning else self.current_traj_steps * self.dt)

condition_pos = self.condition_pos if self.condition_pos is not None else self.current_pos
condition_vel = self.condition_vel if self.condition_vel is not None else self.current_vel
condition_pos = self.condition_pos if self.condition_pos is not None else self.env.get_wrapper_attr('current_pos')
condition_vel = self.condition_vel if self.condition_vel is not None else self.env.get_wrapper_attr('current_vel')

self.traj_gen.set_initial_conditions(init_time, condition_pos, condition_vel)
self.traj_gen.set_initial_conditions(
init_time, condition_pos, condition_vel)
self.traj_gen.set_duration(duration, self.dt)

position = get_numpy(self.traj_gen.get_traj_pos())
Expand Down Expand Up @@ -153,24 +158,27 @@ def step(self, action: np.ndarray):
trajectory_length = len(position)
rewards = np.zeros(shape=(trajectory_length,))
if self.verbose >= 2:
actions = np.zeros(shape=(trajectory_length,) + self.env.action_space.shape)
actions = np.zeros(shape=(trajectory_length,) +
self.env.action_space.shape)
observations = np.zeros(shape=(trajectory_length,) + self.env.observation_space.shape,
dtype=self.env.observation_space.dtype)

infos = dict()
done = False

if not traj_is_valid:
obs, trajectory_return, done, infos = self.env.invalid_traj_callback(action, position, velocity,
self.return_context_observation,
self.tau_bound, self.delay_bound)
return self.observation(obs), trajectory_return, done, infos
obs, trajectory_return, terminated, truncated, infos = self.env.invalid_traj_callback(action, position, velocity,
self.return_context_observation, self.tau_bound, self.delay_bound)
return self.observation(obs), trajectory_return, terminated, truncated, infos

self.plan_steps += 1
for t, (pos, vel) in enumerate(zip(position, velocity)):
step_action = self.tracking_controller.get_action(pos, vel, self.current_pos, self.current_vel)
c_action = np.clip(step_action, self.env.action_space.low, self.env.action_space.high)
obs, c_reward, done, info = self.env.step(c_action)
step_action = self.tracking_controller.get_action(
pos, vel, self.env.get_wrapper_attr('current_pos'), self.env.get_wrapper_attr('current_vel'))
c_action = np.clip(
step_action, self.env.action_space.low, self.env.action_space.high)
obs, c_reward, terminated, truncated, info = self.env.step(
c_action)
rewards[t] = c_reward

if self.verbose >= 2:
Expand All @@ -185,9 +193,7 @@ def step(self, action: np.ndarray):
if self.render_kwargs:
self.env.render(**self.render_kwargs)

if done or (self.replanning_schedule(self.current_pos, self.current_vel, obs, c_action,
t + 1 + self.current_traj_steps)
and self.plan_steps < self.max_planning_times):
if terminated or truncated or (self.replanning_schedule(self.env.get_wrapper_attr('current_pos'), self.env.get_wrapper_attr('current_vel'), obs, c_action, t + 1 + self.current_traj_steps) and self.plan_steps < self.max_planning_times):

if self.condition_on_desired:
self.condition_pos = pos
Expand All @@ -207,17 +213,18 @@ def step(self, action: np.ndarray):

infos['trajectory_length'] = t + 1
trajectory_return = self.reward_aggregation(rewards[:t + 1])
return self.observation(obs), trajectory_return, done, infos
return self.observation(obs), trajectory_return, terminated, truncated, infos

def render(self, **kwargs):
"""Only set render options here, such that they can be used during the rollout.
This only needs to be called once"""
self.render_kwargs = kwargs

def reset(self, *, seed: Optional[int] = None, return_info: bool = False, options: Optional[dict] = None):
def reset(self, *, seed: Optional[int] = None, options: Optional[Dict[str, Any]] = None) \
-> Tuple[ObsType, Dict[str, Any]]:
self.current_traj_steps = 0
self.plan_steps = 0
self.traj_gen.reset()
self.condition_pos = None
self.condition_vel = None
return super(BlackBoxWrapper, self).reset()
return super(BlackBoxWrapper, self).reset(seed=seed, options=options)
6 changes: 3 additions & 3 deletions fancy_gym/black_box/factory/controller_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def get_controller(controller_type: str, **kwargs):
if controller_type == "motor":
return PDController(**kwargs)
elif controller_type == "velocity":
return VelController()
return VelController(**kwargs)
elif controller_type == "position":
return PosController()
return PosController(**kwargs)
elif controller_type == "metaworld":
return MetaWorldController()
return MetaWorldController(**kwargs)
else:
raise ValueError(f"Specified controller type {controller_type} not supported, "
f"please choose one of {ALL_TYPES}.")
7 changes: 4 additions & 3 deletions fancy_gym/black_box/raw_interface_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Union, Tuple

import gym
import gymnasium as gym
import numpy as np
from mp_pytorch.mp.mp_interfaces import MPInterface

Expand Down Expand Up @@ -114,7 +114,8 @@ def invalid_traj_callback(self, action: np.ndarray, pos_traj: np.ndarray, vel_tr
Returns:
obs: artificial observation if the trajectory is invalid, by default a zero vector
reward: artificial reward if the trajectory is invalid, by default 0
done: artificial done if the trajectory is invalid, by default True
terminated: artificial terminated if the trajectory is invalid, by default True
truncated: artificial truncated if the trajectory is invalid, by default False
info: artificial info if the trajectory is invalid, by default empty dict
"""
return np.zeros(1), 0, True, {}
return np.zeros(1), 0, True, False, {}
20 changes: 10 additions & 10 deletions fancy_gym/dmc/README.MD
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# DeepMind Control (DMC) Wrappers

These are the Environment Wrappers for selected
[DeepMind Control](https://deepmind.com/research/publications/2020/dm-control-Software-and-Tasks-for-Continuous-Control)
These are the Environment Wrappers for selected
[DeepMind Control](https://deepmind.com/research/publications/2020/dm-control-Software-and-Tasks-for-Continuous-Control)
environments in order to use our Motion Primitive gym interface with them.

## MP Environments

[//]: <> (These environments are wrapped-versions of their Deep Mind Control Suite &#40;DMC&#41; counterparts. Given most task can be)
[//]: <> (solved in shorter horizon lengths than the original 1000 steps, we often shorten the episodes for those task.)

|Name| Description|Trajectory Horizon|Action Dimension|Context Dimension
|---|---|---|---|---|
|`dmc_ball_in_cup-catch_promp-v0`| A ProMP wrapped version of the "catch" task for the "ball_in_cup" environment. | 1000 | 10 | 2
|`dmc_ball_in_cup-catch_dmp-v0`| A DMP wrapped version of the "catch" task for the "ball_in_cup" environment. | 1000| 10 | 2
|`dmc_reacher-easy_promp-v0`| A ProMP wrapped version of the "easy" task for the "reacher" environment. | 1000 | 10 | 4
|`dmc_reacher-easy_dmp-v0`| A DMP wrapped version of the "easy" task for the "reacher" environment. | 1000| 10 | 4
|`dmc_reacher-hard_promp-v0`| A ProMP wrapped version of the "hard" task for the "reacher" environment.| 1000 | 10 | 4
|`dmc_reacher-hard_dmp-v0`| A DMP wrapped version of the "hard" task for the "reacher" environment. | 1000 | 10 | 4
| Name | Description | Trajectory Horizon | Action Dimension | Context Dimension |
| ---------------------------------------- | ------------------------------------------------------------------------------ | ------------------ | ---------------- | ----------------- |
| `dm_control_ProDMP/ball_in_cup-catch-v0` | A ProMP wrapped version of the "catch" task for the "ball_in_cup" environment. | 1000 | 10 | 2 |
| `dm_control_DMP/ball_in_cup-catch-v0` | A DMP wrapped version of the "catch" task for the "ball_in_cup" environment. | 1000 | 10 | 2 |
| `dm_control_ProDMP/reacher-easy-v0` | A ProMP wrapped version of the "easy" task for the "reacher" environment. | 1000 | 10 | 4 |
| `dm_control_DMP/reacher-easy-v0` | A DMP wrapped version of the "easy" task for the "reacher" environment. | 1000 | 10 | 4 |
| `dm_control_ProDMP/reacher-hard-v0` | A ProMP wrapped version of the "hard" task for the "reacher" environment. | 1000 | 10 | 4 |
| `dm_control_DMP/reacher-hard-v0` | A DMP wrapped version of the "hard" task for the "reacher" environment. | 1000 | 10 | 4 |
Loading