Change .gitignore; push docs/build to GitHub
This commit is contained in:
+284
@@ -0,0 +1,284 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Basic Usage — Fancy Gym 0.2 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
||||
<link rel="shortcut icon" href="../_static/icon.svg"/>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../_static/js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/sphinx_highlight.js"></script>
|
||||
<script src="../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Creating new MP Environments" href="upgrading_envs.html" />
|
||||
<link rel="prev" title="What is Episodic RL?" href="episodic_rl.html" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
<a href="../index.html" class="icon icon-home">
|
||||
Fancy Gym
|
||||
<img src="../_static/icon.svg" class="logo" alt="Logo"/>
|
||||
</a>
|
||||
<div class="version">
|
||||
0.2
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="episodic_rl.html">What is Episodic RL?</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Basic Usage</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#step-based-environments">Step-Based Environments</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#black-box-environments">Black-Box Environments</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="upgrading_envs.html">Creating new MP Environments</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Environments</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/fancy/index.html">Fancy</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/dmc.html">DeepMind Control (DMC)</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/meta.html">Metaworld</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/open_ai.html">Gymnasium</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Examples</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/general.html">General Usage Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/dmc.html">DeepMind Control Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/metaworld.html">Metaworld Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/open_ai.html">OpenAI Envs Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/movement_primitives.html">Movement Primitives Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/mp_params_tuning.html">MP Params Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/pd_control_gain_tuning.html">PD Control Gain Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/replanning_envs.html">Replanning Example</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">API</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../api.html">API</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Fancy Gym</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||||
<li class="breadcrumb-item active">Basic Usage</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
<a href="https://github.com/ALRhub/fancy_gym/blob/release/docs/source/guide/basic_usage.rst" class="fa fa-github"> Edit on GitHub</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<section id="basic-usage">
|
||||
<h1>Basic Usage<a class="headerlink" href="#basic-usage" title="Permalink to this heading"></a></h1>
|
||||
<p>We will only show the basics here and prepared <a class="reference internal" href="../examples/general.html#example-general"><span class="std std-ref">multiple examples</span></a> for a more detailed look.</p>
|
||||
<section id="step-based-environments">
|
||||
<h2>Step-Based Environments<a class="headerlink" href="#step-based-environments" title="Permalink to this heading"></a></h2>
|
||||
<p>Regular step based environments added by Fancy Gym are added into the
|
||||
<code class="docutils literal notranslate"><span class="pre">fancy/</span></code> namespace.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>Legacy versions of Fancy Gym used <code class="docutils literal notranslate"><span class="pre">fancy_gym.make(...)</span></code>. This is no longer supported and will raise an Exception on new versions.</p>
|
||||
</div>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">gymnasium</span> <span class="k">as</span> <span class="nn">gym</span>
|
||||
<span class="kn">import</span> <span class="nn">fancy_gym</span>
|
||||
|
||||
<span class="n">env</span> <span class="o">=</span> <span class="n">gym</span><span class="o">.</span><span class="n">make</span><span class="p">(</span><span class="s1">'fancy/Reacher5d-v0'</span><span class="p">)</span>
|
||||
<span class="c1"># or env = gym.make('metaworld/reach-v2') # fancy_gym allows access to all metaworld ML1 tasks via the metaworld/ NS</span>
|
||||
<span class="c1"># or env = gym.make('dm_control/ball_in_cup-catch-v0')</span>
|
||||
<span class="c1"># or env = gym.make('Reacher-v2')</span>
|
||||
<span class="n">observation</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="n">seed</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">):</span>
|
||||
<span class="n">action</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">action_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">reward</span><span class="p">,</span> <span class="n">terminated</span><span class="p">,</span> <span class="n">truncated</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="n">action</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">5</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">env</span><span class="o">.</span><span class="n">render</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">terminated</span> <span class="ow">or</span> <span class="n">truncated</span><span class="p">:</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="black-box-environments">
|
||||
<h2>Black-Box Environments<a class="headerlink" href="#black-box-environments" title="Permalink to this heading"></a></h2>
|
||||
<p>All environments provide by default the cumulative episode reward, this
|
||||
can however be changed if necessary. Optionally, each environment
|
||||
returns all collected information from each step as part of the infos.
|
||||
This information is, however, mainly meant for debugging as well as
|
||||
logging and not for training.</p>
|
||||
<table class="docutils align-default">
|
||||
<thead>
|
||||
<tr class="row-odd"><th class="head"><p>Key</p></th>
|
||||
<th class="head"><p>Description</p></th>
|
||||
<th class="head"><p>Type</p></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="row-even"><td><p><cite>positions</cite></p></td>
|
||||
<td><p>Generated trajectory from MP</p></td>
|
||||
<td><p>Optional</p></td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><p><cite>velocities</cite></p></td>
|
||||
<td><p>Generated trajectory from MP</p></td>
|
||||
<td><p>Optional</p></td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><p><cite>step_actions</cite></p></td>
|
||||
<td><p>Step-wise executed action based on controller output</p></td>
|
||||
<td><p>Optional</p></td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><p><cite>step_observations</cite></p></td>
|
||||
<td><p>Step-wise intermediate observations</p></td>
|
||||
<td><p>Optional</p></td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><p><cite>step_rewards</cite></p></td>
|
||||
<td><p>Step-wise rewards</p></td>
|
||||
<td><p>Optional</p></td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><p><cite>trajectory_length</cite></p></td>
|
||||
<td><p>Total number of environment interactions</p></td>
|
||||
<td><p>Always</p></td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><p><cite>other</cite></p></td>
|
||||
<td><p>All other information from the underlying environment are returned as a list with length <cite>trajectory_length</cite> maintaining the original key.
|
||||
In case some information are not provided every time step, the missing values are filled with <cite>None</cite>.</p></td>
|
||||
<td><p>Always</p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Existing MP tasks can be created the same way as above. The namespace of
|
||||
a MP-variant of an environment is given by
|
||||
<code class="docutils literal notranslate"><span class="pre"><original</span> <span class="pre">namespace>_<MP</span> <span class="pre">name>/</span></code>. Just keep in mind, calling
|
||||
<code class="docutils literal notranslate"><span class="pre">step()</span></code> executes a full trajectory.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>Currently, we are also in the process of enabling replanning as
|
||||
well as learning of sub-trajectories. This allows to split the
|
||||
episode into multiple trajectories and is a hybrid setting between
|
||||
step-based and black-box leaning. While this is already
|
||||
implemented, it is still in beta and requires further testing. Feel
|
||||
free to try it and open an issue with any problems that occur.</p>
|
||||
</div>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">gymnasium</span> <span class="k">as</span> <span class="nn">gym</span>
|
||||
<span class="kn">import</span> <span class="nn">fancy_gym</span>
|
||||
|
||||
<span class="n">env</span> <span class="o">=</span> <span class="n">gym</span><span class="o">.</span><span class="n">make</span><span class="p">(</span><span class="s1">'fancy_ProMP/Reacher5d-v0'</span><span class="p">)</span>
|
||||
<span class="c1"># or env = gym.make('metaworld_ProDMP/reach-v2')</span>
|
||||
<span class="c1"># or env = gym.make('dm_control_DMP/ball_in_cup-catch-v0')</span>
|
||||
<span class="c1"># or env = gym.make('gym_ProMP/Reacher-v2') # mp versions of envs added directly by gymnasium are in the gym_<MP-type> NS</span>
|
||||
|
||||
<span class="c1"># render() can be called once in the beginning with all necessary arguments.</span>
|
||||
<span class="c1"># To turn it of again just call render() without any arguments.</span>
|
||||
<span class="n">env</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">mode</span><span class="o">=</span><span class="s1">'human'</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># This returns the context information, not the full state observation</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="n">seed</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
|
||||
<span class="n">action</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">action_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">reward</span><span class="p">,</span> <span class="n">terminated</span><span class="p">,</span> <span class="n">truncated</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="n">action</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># terminated or truncated is always True as we are working on the episode level, hence we always reset()</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>To show all available environments, we provide some additional
|
||||
convenience variables. All of them return a dictionary with the keys
|
||||
<code class="docutils literal notranslate"><span class="pre">DMP</span></code>, <code class="docutils literal notranslate"><span class="pre">ProMP</span></code>, <code class="docutils literal notranslate"><span class="pre">ProDMP</span></code> and <code class="docutils literal notranslate"><span class="pre">all</span></code> that store a list of
|
||||
available environment ids.</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">fancy_gym</span>
|
||||
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"All Black-box tasks:"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">ALL_MOVEMENT_PRIMITIVE_ENVIRONMENTS</span><span class="p">)</span>
|
||||
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Fancy Black-box tasks:"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS</span><span class="p">)</span>
|
||||
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"OpenAI Gym Black-box tasks:"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">ALL_GYM_MOVEMENT_PRIMITIVE_ENVIRONMENTS</span><span class="p">)</span>
|
||||
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Deepmind Control Black-box tasks:"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS</span><span class="p">)</span>
|
||||
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"MetaWorld Black-box tasks:"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS</span><span class="p">)</span>
|
||||
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"If you add custom envs, their mp versions will be found in:"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS</span><span class="p">[</span><span class="s1">'<my_custom_namespace>'</span><span class="p">])</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||||
<a href="episodic_rl.html" class="btn btn-neutral float-left" title="What is Episodic RL?" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||||
<a href="upgrading_envs.html" class="btn btn-neutral float-right" title="Creating new MP Environments" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2020-2024, Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou.</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>What is Episodic RL? — Fancy Gym 0.2 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
||||
<link rel="shortcut icon" href="../_static/icon.svg"/>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../_static/js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/sphinx_highlight.js"></script>
|
||||
<script src="../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Basic Usage" href="basic_usage.html" />
|
||||
<link rel="prev" title="Installation" href="installation.html" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
<a href="../index.html" class="icon icon-home">
|
||||
Fancy Gym
|
||||
<img src="../_static/icon.svg" class="logo" alt="Logo"/>
|
||||
</a>
|
||||
<div class="version">
|
||||
0.2
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">What is Episodic RL?</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="upgrading_envs.html">Creating new MP Environments</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Environments</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/fancy/index.html">Fancy</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/dmc.html">DeepMind Control (DMC)</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/meta.html">Metaworld</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/open_ai.html">Gymnasium</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Examples</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/general.html">General Usage Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/dmc.html">DeepMind Control Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/metaworld.html">Metaworld Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/open_ai.html">OpenAI Envs Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/movement_primitives.html">Movement Primitives Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/mp_params_tuning.html">MP Params Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/pd_control_gain_tuning.html">PD Control Gain Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/replanning_envs.html">Replanning Example</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">API</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../api.html">API</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Fancy Gym</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||||
<li class="breadcrumb-item active">What is Episodic RL?</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
<a href="https://github.com/ALRhub/fancy_gym/blob/release/docs/source/guide/episodic_rl.rst" class="fa fa-github"> Edit on GitHub</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<section id="what-is-episodic-rl">
|
||||
<h1>What is Episodic RL?<a class="headerlink" href="#what-is-episodic-rl" title="Permalink to this heading"></a></h1>
|
||||
<div class="justify"><p>Movement primitive (MP) environments differ from traditional step-based
|
||||
environments. They align more with concepts from stochastic search,
|
||||
black-box optimization, and methods commonly found in classical robotics
|
||||
and control. Instead of individual steps, MP environments operate on an
|
||||
episode basis, executing complete trajectories. These trajectories are
|
||||
produced by trajectory generators like Dynamic Movement Primitives
|
||||
(DMP), Probabilistic Movement Primitives (ProMP) or Probabilistic
|
||||
Dynamic Movement Primitives (ProDMP).</p>
|
||||
<p>Once generated, these trajectories are converted into step-by-step
|
||||
actions using a trajectory tracking controller. The specific controller
|
||||
chosen depends on the environment’s requirements. Currently, we support
|
||||
position, velocity, and PD-Controllers tailored for position, velocity,
|
||||
and torque control. Additionally, we have a specialized controller
|
||||
designed for the MetaWorld control suite.</p>
|
||||
<p>While the overarching objective of MP environments remains the learning
|
||||
of an optimal policy, the actions here represent the parametrization of
|
||||
motion primitives to craft the right trajectory. Our framework further
|
||||
enhances this by accommodating a contextual setting. At the episode’s
|
||||
onset, we present the context space—a subset of the observation space.
|
||||
This demands the prediction of a new action or MP parametrization for
|
||||
every unique context.</p>
|
||||
</div></section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||||
<a href="installation.html" class="btn btn-neutral float-left" title="Installation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||||
<a href="basic_usage.html" class="btn btn-neutral float-right" title="Basic Usage" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2020-2024, Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou.</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Installation — Fancy Gym 0.2 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
||||
<link rel="shortcut icon" href="../_static/icon.svg"/>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../_static/js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/sphinx_highlight.js"></script>
|
||||
<script src="../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="What is Episodic RL?" href="episodic_rl.html" />
|
||||
<link rel="prev" title="Fancy Gym" href="../index.html" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
<a href="../index.html" class="icon icon-home">
|
||||
Fancy Gym
|
||||
<img src="../_static/icon.svg" class="logo" alt="Logo"/>
|
||||
</a>
|
||||
<div class="version">
|
||||
0.2
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Installation</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#installation-from-pypi-recommended">Installation from PyPI (recommended)</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#installation-from-master">Installation from master</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="episodic_rl.html">What is Episodic RL?</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="upgrading_envs.html">Creating new MP Environments</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Environments</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/fancy/index.html">Fancy</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/dmc.html">DeepMind Control (DMC)</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/meta.html">Metaworld</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/open_ai.html">Gymnasium</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Examples</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/general.html">General Usage Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/dmc.html">DeepMind Control Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/metaworld.html">Metaworld Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/open_ai.html">OpenAI Envs Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/movement_primitives.html">Movement Primitives Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/mp_params_tuning.html">MP Params Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/pd_control_gain_tuning.html">PD Control Gain Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/replanning_envs.html">Replanning Example</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">API</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../api.html">API</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Fancy Gym</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||||
<li class="breadcrumb-item active">Installation</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
<a href="https://github.com/ALRhub/fancy_gym/blob/release/docs/source/guide/installation.rst" class="fa fa-github"> Edit on GitHub</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<section id="installation">
|
||||
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h1>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>We recommend installing <code class="docutils literal notranslate"><span class="pre">fancy_gym</span></code> into a virtual environment as
|
||||
provided by <a class="reference external" href="https://docs.python.org/3/library/venv.html">venv</a>. 3rd
|
||||
party alternatives to venv like <a class="reference external" href="https://python-poetry.org/">Poetry</a>
|
||||
or <a class="reference external" href="https://docs.conda.io/en/latest/">Conda</a> can also be used.</p>
|
||||
</div>
|
||||
<section id="installation-from-pypi-recommended">
|
||||
<h2>Installation from PyPI (recommended)<a class="headerlink" href="#installation-from-pypi-recommended" title="Permalink to this heading"></a></h2>
|
||||
<p>Install <code class="docutils literal notranslate"><span class="pre">fancy_gym</span></code> via</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>fancy_gym
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We have a few optional dependencies. If you also want to install those
|
||||
use</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># to install all optional dependencies</span>
|
||||
pip<span class="w"> </span>install<span class="w"> </span><span class="s1">'fancy_gym[all]'</span>
|
||||
|
||||
<span class="c1"># or choose only those you want</span>
|
||||
pip<span class="w"> </span>install<span class="w"> </span><span class="s1">'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Pip can not automatically install up-to-date versions of metaworld,
|
||||
since they are not avaible on PyPI yet. Install metaworld via</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg<span class="o">=</span>metaworld
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="installation-from-master">
|
||||
<h2>Installation from master<a class="headerlink" href="#installation-from-master" title="Permalink to this heading"></a></h2>
|
||||
<ol class="arabic simple">
|
||||
<li><p>Clone the repository</p></li>
|
||||
</ol>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git<span class="w"> </span>clone<span class="w"> </span>git@github.com:ALRhub/fancy_gym.git
|
||||
</pre></div>
|
||||
</div>
|
||||
<ol class="arabic simple" start="2">
|
||||
<li><p>Go to the folder</p></li>
|
||||
</ol>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span><span class="w"> </span>fancy_gym
|
||||
</pre></div>
|
||||
</div>
|
||||
<ol class="arabic simple" start="3">
|
||||
<li><p>Install with</p></li>
|
||||
</ol>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>-e<span class="w"> </span>.
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We have a few optional dependencies. If you also want to install those
|
||||
use</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># to install all optional dependencies</span>
|
||||
pip<span class="w"> </span>install<span class="w"> </span>-e<span class="w"> </span><span class="s1">'.[all]'</span>
|
||||
|
||||
<span class="c1"># or choose only those you want</span>
|
||||
pip<span class="w"> </span>install<span class="w"> </span>-e<span class="w"> </span><span class="s1">'.[dmc,box2d,mujoco-legacy,jax,testing]'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Metaworld has to be installed manually with</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg<span class="o">=</span>metaworld
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||||
<a href="../index.html" class="btn btn-neutral float-left" title="Fancy Gym" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||||
<a href="episodic_rl.html" class="btn btn-neutral float-right" title="What is Episodic RL?" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2020-2024, Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou.</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Creating new MP Environments — Fancy Gym 0.2 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
|
||||
<link rel="shortcut icon" href="../_static/icon.svg"/>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../_static/js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/sphinx_highlight.js"></script>
|
||||
<script src="../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Fancy" href="../envs/fancy/index.html" />
|
||||
<link rel="prev" title="Basic Usage" href="basic_usage.html" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
<a href="../index.html" class="icon icon-home">
|
||||
Fancy Gym
|
||||
<img src="../_static/icon.svg" class="logo" alt="Logo"/>
|
||||
</a>
|
||||
<div class="version">
|
||||
0.2
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="episodic_rl.html">What is Episodic RL?</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Creating new MP Environments</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Environments</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/fancy/index.html">Fancy</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/dmc.html">DeepMind Control (DMC)</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/meta.html">Metaworld</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../envs/open_ai.html">Gymnasium</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">Examples</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/general.html">General Usage Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/dmc.html">DeepMind Control Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/metaworld.html">Metaworld Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/open_ai.html">OpenAI Envs Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/movement_primitives.html">Movement Primitives Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/mp_params_tuning.html">MP Params Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/pd_control_gain_tuning.html">PD Control Gain Tuning Example</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../examples/replanning_envs.html">Replanning Example</a></li>
|
||||
</ul>
|
||||
<p class="caption" role="heading"><span class="caption-text">API</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../api.html">API</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Fancy Gym</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||||
<li class="breadcrumb-item active">Creating new MP Environments</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
<a href="https://github.com/ALRhub/fancy_gym/blob/release/docs/source/guide/upgrading_envs.rst" class="fa fa-github"> Edit on GitHub</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<section id="creating-new-mp-environments">
|
||||
<h1>Creating new MP Environments<a class="headerlink" href="#creating-new-mp-environments" title="Permalink to this heading"></a></h1>
|
||||
<p>This guide will explain to you how to upgrade an existing step-based Gymnasium environment into one, that supports Movement Primitives (MPs). If you are looking for a guide to build such a Gymnasium environment instead, please have a look at <a class="reference external" href="https://gymnasium.farama.org/tutorials/gymnasium_basics/environment_creation/">this guide</a>.</p>
|
||||
<p>In case a required task is not supported yet in the MP framework, it can
|
||||
be created relatively easy. For the task at hand, the following
|
||||
<a class="reference external" href="https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/black_box/raw_interface_wrapper.py">interface</a>
|
||||
needs to be implemented.</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">abc</span> <span class="kn">import</span> <span class="n">abstractmethod</span>
|
||||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Tuple</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">gymnasium</span> <span class="k">as</span> <span class="nn">gym</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">RawInterfaceWrapper</span><span class="p">(</span><span class="n">gym</span><span class="o">.</span><span class="n">Wrapper</span><span class="p">):</span>
|
||||
<span class="n">mp_config</span> <span class="o">=</span> <span class="p">{</span>
|
||||
<span class="s1">'ProMP'</span><span class="p">:</span> <span class="p">{},</span>
|
||||
<span class="s1">'DMP'</span><span class="p">:</span> <span class="p">{},</span>
|
||||
<span class="s1">'ProDMP'</span><span class="p">:</span> <span class="p">{},</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">context_mask</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns boolean mask of the same shape as the observation space.</span>
|
||||
<span class="sd"> It determines whether the observation is returned for the contextual case or not.</span>
|
||||
<span class="sd"> This effectively allows to filter unwanted or unnecessary observations from the full step-based case.</span>
|
||||
<span class="sd"> E.g. Velocities starting at 0 are only changing after the first action. Given we only receive the</span>
|
||||
<span class="sd"> context/part of the first observation, the velocities are not necessary in the observation for the task.</span>
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> bool array representing the indices of the observations</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">observation_space</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">bool</span><span class="p">)</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">current_pos</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">]:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns the current position of the action/control dimension.</span>
|
||||
<span class="sd"> The dimensionality has to match the action/control dimension.</span>
|
||||
<span class="sd"> This is not required when exclusively using velocity control,</span>
|
||||
<span class="sd"> it should, however, be implemented regardless.</span>
|
||||
<span class="sd"> E.g. The joint positions that are directly or indirectly controlled by the action.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">current_vel</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">]:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns the current velocity of the action/control dimension.</span>
|
||||
<span class="sd"> The dimensionality has to match the action/control dimension.</span>
|
||||
<span class="sd"> This is not required when exclusively using position control,</span>
|
||||
<span class="sd"> it should, however, be implemented regardless.</span>
|
||||
<span class="sd"> E.g. The joint velocities that are directly or indirectly controlled by the action.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Default configurations for MPs can be overitten by defining attributes
|
||||
in mp_config. Available parameters are documented in the <a class="reference external" href="https://github.com/ALRhub/MP_PyTorch/blob/main/doc/README.md">MP_PyTorch
|
||||
Userguide</a>.</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">RawInterfaceWrapper</span><span class="p">(</span><span class="n">gym</span><span class="o">.</span><span class="n">Wrapper</span><span class="p">):</span>
|
||||
<span class="n">mp_config</span> <span class="o">=</span> <span class="p">{</span>
|
||||
<span class="s1">'ProMP'</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="s1">'phase_generator_kwargs'</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="s1">'phase_generator_type'</span><span class="p">:</span> <span class="s1">'linear'</span>
|
||||
<span class="c1"># When selecting another generator type, the default configuration will not be merged for the attribute.</span>
|
||||
<span class="p">},</span>
|
||||
<span class="s1">'controller_kwargs'</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="s1">'p_gains'</span><span class="p">:</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">]),</span>
|
||||
<span class="s1">'d_gains'</span><span class="p">:</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">]),</span>
|
||||
<span class="p">},</span>
|
||||
<span class="s1">'basis_generator_kwargs'</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="s1">'num_basis'</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||
<span class="s1">'num_basis_zero_start'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="s1">'num_basis_zero_goal'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">},</span>
|
||||
<span class="s1">'DMP'</span><span class="p">:</span> <span class="p">{},</span>
|
||||
<span class="s1">'ProDMP'</span><span class="p">:</span> <span class="p">{}</span><span class="o">.</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="p">[</span><span class="o">...</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>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
|
||||
<a class="reference internal" href="../examples/movement_primitives.html#example-mp"><span class="std std-ref">multiple examples</span></a>.</p>
|
||||
<p>If the step-based is already registered with gym, you can simply do the
|
||||
following:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">upgrade</span><span class="p">(</span>
|
||||
<span class="nb">id</span><span class="o">=</span><span class="s1">'custom/cool_new_env-v0'</span><span class="p">,</span>
|
||||
<span class="n">mp_wrapper</span><span class="o">=</span><span class="n">my_custom_MPWrapper</span>
|
||||
<span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If the step-based is not yet registered with gym we can add both the
|
||||
step-based and MP-versions via</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">fancy_gym</span><span class="o">.</span><span class="n">register</span><span class="p">(</span>
|
||||
<span class="nb">id</span><span class="o">=</span><span class="s1">'custom/cool_new_env-v0'</span><span class="p">,</span>
|
||||
<span class="n">entry_point</span><span class="o">=</span><span class="n">my_custom_env</span><span class="p">,</span>
|
||||
<span class="n">mp_wrapper</span><span class="o">=</span><span class="n">my_custom_MPWrapper</span>
|
||||
<span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>From this point on, you can access MP-version of your environments via</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">env</span> <span class="o">=</span> <span class="n">gym</span><span class="o">.</span><span class="n">make</span><span class="p">(</span><span class="s1">'custom_ProDMP/cool_new_env-v0'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rewards</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># number of samples/full trajectories (multiple environment steps)</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
|
||||
<span class="n">ac</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">action_space</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">reward</span><span class="p">,</span> <span class="n">terminated</span><span class="p">,</span> <span class="n">truncated</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="n">ac</span><span class="p">)</span>
|
||||
<span class="n">rewards</span> <span class="o">+=</span> <span class="n">reward</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">terminated</span> <span class="ow">or</span> <span class="n">truncated</span><span class="p">:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">rewards</span><span class="p">)</span>
|
||||
<span class="n">rewards</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">observation</span><span class="p">,</span> <span class="n">info</span> <span class="o">=</span> <span class="n">env</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||||
<a href="basic_usage.html" class="btn btn-neutral float-left" title="Basic Usage" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||||
<a href="../envs/fancy/index.html" class="btn btn-neutral float-right" title="Fancy" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2020-2024, Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou.</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user