-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea5921d
commit df971d2
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,3 +185,83 @@ Load MyoReflex Baseline | |
|
||
To load and execute the MyoReflex controller with baseline parameters. | ||
Run the MyoReflex tutorial `here <https://github.com/facebookresearch/myosuite/tree/main/docs/source/tutorials/4b_reflex>`__ | ||
|
||
|
||
|
||
Customizing Tasks | ||
================= | ||
|
||
In order to create a new customized task, there are two places where you need to act: | ||
|
||
1. Set up a new environment class for the new task | ||
|
||
2. Register the new task | ||
|
||
Set up a new environment | ||
+++++++++++++++++++++++++ | ||
|
||
Environment classes are developed according to the OpenAI Gym definition | ||
and contain all the information specific for a task, | ||
to interact with the environment, to observe it and to | ||
act on it. In addition, each environment class contains | ||
a reward function which converts the observation into a | ||
number that establishes how good the observation is with | ||
respect to the task objectives. In order to create a new | ||
task, a new environment class needs to be generated eg. | ||
reach2_v0.py (see for example how `reach_v0.py <https://github.com/MyoHub/myosuite/blob/main/myosuite/envs/myo/myobase/reach_v0.py>`__ is structured). | ||
In this file, it is possible to specify the type of observation (eg. joint angles, velocities, forces), actions (e.g. muscle, motors), goal, and reward. | ||
|
||
|
||
.. code-block:: python | ||
from myosuite.envs.myo.base_v0 import BaseV0 | ||
import deprl | ||
This comment has been minimized.
Sorry, something went wrong. |
||
# Class extends Basev0 | ||
class NewReachEnvV0(BaseV0): | ||
.... | ||
# defines the observation | ||
def get_obs_dict(self, sim): | ||
.... | ||
# defines the rewards | ||
def get_reward_dict(self, obs_dict): | ||
... | ||
#reset condition that | ||
def reset(self): | ||
... | ||
# step the simulation forward by acting on the environment | ||
def step(self, a, **kwargs): | ||
This comment has been minimized.
Sorry, something went wrong.
vikashplus
Collaborator
|
||
... | ||
return observation, reward, task_terminated, environment_information | ||
.. _setup_base_class: | ||
|
||
|
||
Register the new environment | ||
++++++++++++++++++++++++++++++ | ||
|
||
Once defined the task `reach2_v0.py`, the new environment needs to be registered to be | ||
visible when importing `myosuite`. This is achieved by introducing the new environment in | ||
the `__init__.py` (called when the library is imported) where the registration routine happens. | ||
The registration of the new enviornment is obtained adding: | ||
|
||
.. code-block:: python | ||
register_env_with_variants(id='newReachTask-v0', | ||
This comment has been minimized.
Sorry, something went wrong. |
||
entry_point='myosuite.envs.myo.myobase.reach_v0:NewReachEnvV0', # where to find the new Environment Class | ||
max_episode_steps=200, # duration of the episode | ||
kwargs={ | ||
'model_path': curr_dir+'/../assets/hand/myohand_pose.xml', # where the xml file of the environment is located | ||
'target_reach_range': {'IFtip': ((0.1, 0.05, 0.20), (0.2, 0.05, 0.20)),}, # this is used in the setup to define the goal e.g. rando position of the team between 0.1 and 0.2 in the x coordinates | ||
'normalize_act': True, # if to use normalized actions using a sigmoid function. | ||
'frame_skip': 5, # collect a sample every 5 iteration step | ||
} | ||
) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
.. _register_new_environment: | ||
|
Not sure if this is needed.