From 757072c7625fdd7e992b51adefc47780cadbf01a Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Wed, 11 Oct 2023 12:35:23 +0200 Subject: [PATCH] Documnenting merging behavior for mp_configs (and remove TODOs) --- README.md | 30 +++++++++++++++++++++++++++++- fancy_gym/envs/registry.py | 3 --- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8b82975..3f2ea95 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ import numpy as np class RawInterfaceWrapper(gym.Wrapper): - mp_config = { # Default configurations for MPs can be overitten by defining attributes here. + mp_config = { 'ProMP': {}, 'DMP': {}, 'ProDMP': {}, @@ -222,6 +222,34 @@ class RawInterfaceWrapper(gym.Wrapper): ``` +Default configurations for MPs can be overitten by defining attributes in mp_config. +Available parameters are documented in the [MP_PyTorch Userguide](https://github.com/ALRhub/MP_PyTorch/blob/main/doc/README.md). + +```python +class RawInterfaceWrapper(gym.Wrapper): + mp_config = { + 'ProMP': { + 'phase_generator_kwargs': { + 'phase_generator_type': 'linear' + # When selecting another generator type, the default configuration will not be merged for the attribute. + }, + 'controller_kwargs': { + 'p_gains': 0.5 * np.array([1.0, 4.0, 2.0, 4.0, 1.0, 4.0, 1.0]), + 'd_gains': 0.5 * np.array([0.1, 0.4, 0.2, 0.4, 0.1, 0.4, 0.1]), + }, + 'basis_generator_kwargs': { + 'num_basis': 3, + 'num_basis_zero_start': 1, + 'num_basis_zero_goal': 1, + }, + }, + 'DMP': {}, + 'ProDMP': {}. + } + + [...] +``` + 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/). diff --git a/fancy_gym/envs/registry.py b/fancy_gym/envs/registry.py index c3eb896..4736cf4 100644 --- a/fancy_gym/envs/registry.py +++ b/fancy_gym/envs/registry.py @@ -8,7 +8,6 @@ from collections import defaultdict from collections.abc import Mapping, MutableMapping from fancy_gym.utils.make_env_helpers import make_bb -# from fancy_gym.utils.utils import nested_update from fancy_gym.black_box.raw_interface_wrapper import RawInterfaceWrapper from gymnasium import register as gym_register @@ -238,8 +237,6 @@ def register_mp(id: str, base_id: str, mp_wrapper: RawInterfaceWrapper, mp_type: MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS[ns][mp_type].append(fancy_id) MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS[ns]['all'].append(fancy_id) -# TODO: Apply inherit_defaults: False to appropiate places and remove this... - def nested_update(base: MutableMapping, update): """