Package: deprl
DEP-RL: Embodied Exploration for Reinforcement Learning in Overactuated and Musculoskeletal SystemsPlease read thedocs.This repo contains the code for the paperDEP-RL: Embodied Exploration for Reinforcement Learning in Overactuated and Musculoskeletal Systemspaper, published at ICLR 2023 with perfect review scores (8, 8, 8, 10) and a notable-top-25% rating. Seeherefor videos.The work was performed by Pierre Schumacher, Daniel F.B. Haeufle, Dieter Büchler, Syn Schmitt and Georg Martius.If you just want to see the code for DEP, take a look atdeprl/dep_controller.py,deprl/custom_agents.pyanddeprl/env_wrapper/wrappers.pyBig update!We now provide code for our newest preprint,Natural and Robust Walking using Reinforcement Learning without Demonstrations in High-Dimensional Musculoskeletal Models. With this work, we take a step towardsnaturalmovement generation with RL. Take a look at thedocsfor more information.AbstractMuscle-actuated organisms are capable of learning an unparalleled diversity of
dexterous movements despite their vast amount of muscles. Reinforcement learning (RL) on large musculoskeletal models, however, has not been able to show
similar performance. We conjecture that ineffective exploration in large overactuated action spaces is a key problem. This is supported by our finding that common
exploration noise strategies are inadequate in synthetic examples of overactuated
systems. We identify differential extrinsic plasticity (DEP), a method from the
domain of self-organization, as being able to induce state-space covering exploration within seconds of interaction. By integrating DEP into RL, we achieve fast
learning of reaching and locomotion in musculoskeletal systems, outperforming
current approaches in all considered tasks in sample efficiency and robustness.InstallationWe provide a python package for easy installation:pip install deprlThere are more instructions on installation from source, and other things, in thedocumentationEnvironmentsThe ICLR publication includes experiments with human arms:pip install git+https://github.com/P-Schumacher/warmup.gitand a bipedal ostrich. The OstrichRL environment can be installed fromhere.We also collaborated with groups that provide musculoskeletal control environments and provide additional baselines as well as code from our latest preprints.HyfydyWe include several pre-trained baselines and configuration files to train the policies from our newestpreprint. These allow you to train walking agents inHyfydywith RL for natural walking and robust running tasks. We joined forces with Thomas Geijtenbeek@tgeijtento create a python environment interface for Hyfydy. Take a look atsconegym!MyoLegIf you are coming here for the MyoLeg, take a look at thistutorial. It will show you how to run the pre-trained baseline. We also explain how to train the walking agent in the MyoSuitedocumentation.This repository has been updated with training files that have been used for the MyoSuite baselines, as well as pretrained networks.
Simply try training something:python -m deprl.main experiments/myosuite_training_files/myoChaseTag.jsonor render the pretrained baselines with:python experiments/myosuite_training_files/render_baselines.pyYou have to find your own reward function, of course. These files also require the installation ofmyosuite==2.1.5.ExperimentsThe major experiments (humanreacher reaching and ostrich running) can be repeated with the config files.
Simply run from the root folder:python -m deprl.main experiments/ostrich_running_dep.json
python -m deprl.main experiments/humanreacher.jsonto train an agent. Model checkpoints will be saved in theoutputdirectory.
The progress can be monitored with:python -m tonic.plot --path output/folder/To execute a trained policy, use:python -m deprl.play --path output/folder/See theTonicRLdocumentation for details.Be aware that ostrich training can be seed-dependant, as seen in the plots of the original publication.Pure DEPIf you want to see pure DEP in action, just run the following bash files after installing the ostrichrl and warmup environments.bash play_files/play_dep_humanreacher.sh
bash play_files/play_dep_ostrich.sh
bash play_files/play_dep_dmcontrol_quadruped.shYou might see a more interesting ostrich behavior by disabling episode resets in the ostrich environment first.EnvironmentsThe ostrich environment can be foundhereand is installed automatically via poetry.The arm-environmentwarmupis also automatically installed by poetry and can be used like any other gym environment:import gym
import warmup

env = gym.make("humanreacher-v0")

for ep in range(5):
     ep_steps = 0
     state = env.reset()
     while True:
         next_state, reward, done, info = env.step(env.action_space.sample())
         env.render()
         if done or (ep_steps >= env.max_episode_steps):
             break
         ep_steps += 1The humanoid environments were simulated withSCONE. A ready-to-use RL package will be released in cooperation with GOATSTREAM at a later date.Source Code InstallationWe recommend an installation withpoetryto ensure reproducibility.
WhileTonicRLwith PyTorch is used for the RL algorithms, DEP itself is implemented injax. Westronglyrecommend GPU-usage to speed up the computation of DEP. On systems without GPUs, give the tensorflow version of TonicRL a try! We also provide a requirements file for pip. Please check the instructions for GPU and CPU versions oftorchandjaxabove.PipJust clone the repository and install locally:git clone https://github.com/martius-lab/depRL.git
cd depRL
pip install -r requirements.txt
pip install -e ./PoetryMake sure to install poetry and deactivate all virtual environments.Clone the environmentgit clone https://github.com/martius-lab/depRLGo to the root folder and runpoetry install
poetry shellThat's it!The build has been tested with:Ubuntu 20.04 and Ubuntu 22.04
CUDA 12.0
poetry 1.4.0TroubleshootingA common error with poetry is a faulty interaction with the python keyring, resulting in aFailed to unlock the collection!-error. It could also happen that the dependency solving takes very long (more than 60s), this is caused by the same error.
If it happens, try to appendexport PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyringto your bashrc. You can also try to prepend it to the poetry command:PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring poetry install.If you have an error related to yourptxasversion, this means that your cuda environment is not setup correctly and you should install the cuda-toolkit. The easiest way is to do this via conda if you don't have admin rights on your workstation.
I recommend runningconda install -c conda-forge cudatoolkit-devIn any other case, first try to delete thepoetry.lockfile and the virtual env.venv, then runpoetry installagain.Feel free to open an issue if you encounter any problems.CitationIf you find this repository useful, please consider giving a star ⭐ and cite ourpaperby using the following BibTeX entrys.@inproceedings{schumacher2023:deprl,
  title = {DEP-RL: Embodied Exploration for Reinforcement Learning in Overactuated and Musculoskeletal Systems},
  author = {Schumacher, Pierre and Haeufle, Daniel F.B. and B{\"u}chler, Dieter and Schmitt, Syn and Martius, Georg},
  booktitle = {Proceedings of the Eleventh International Conference on Learning Representations (ICLR)},
  month = may,
  year = {2023},
  doi = {},
  url = {https://openreview.net/forum?id=C-xa_D3oTj6},
  month_numeric = {5}
}@misc{schumacher2023natural,
      title={Natural and Robust Walking using Reinforcement Learning without Demonstrations in High-Dimensional Musculoskeletal Models},
      author={Pierre Schumacher and Thomas Geijtenbeek and Vittorio Caggiano and Vikash Kumar and Syn Schmitt and Georg Martius and Daniel F. B. Haeufle},
      year={2023},
      eprint={2309.02976},
      archivePrefix={arXiv},
      primaryClass={cs.RO}
}