Skip to content

Commit

Permalink
Add docs from pypose/pypose
Browse files Browse the repository at this point in the history
  • Loading branch information
pyposebot committed Sep 19, 2024
1 parent 8bd503a commit abd76ee
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 11 deletions.
39 changes: 38 additions & 1 deletion docs/main/_modules/pypose/lietensor/convert/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@

<h1>Source code for pypose.lietensor.convert</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">torch</span><span class="o">,</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">torch.nn.functional</span> <span class="kn">import</span> <span class="n">normalize</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">SO3</span><span class="p">,</span> <span class="n">so3</span><span class="p">,</span> <span class="n">SE3</span><span class="p">,</span> <span class="n">RxSO3</span><span class="p">,</span> <span class="n">Sim3</span>
<span class="kn">from</span> <span class="nn">.lietensor</span> <span class="kn">import</span> <span class="n">LieTensor</span><span class="p">,</span> <span class="n">SE3_type</span><span class="p">,</span> <span class="n">SO3_type</span><span class="p">,</span> <span class="n">Sim3_type</span><span class="p">,</span> <span class="n">RxSO3_type</span>
<span class="kn">from</span> <span class="nn">.lietensor</span> <span class="kn">import</span> <span class="n">LieTensor</span><span class="p">,</span> <span class="n">liegroup</span><span class="p">,</span> <span class="n">liealgebra</span>
<span class="kn">from</span> <span class="nn">.lietensor</span> <span class="kn">import</span> <span class="n">SE3_type</span><span class="p">,</span> <span class="n">SO3_type</span><span class="p">,</span> <span class="n">Sim3_type</span><span class="p">,</span> <span class="n">RxSO3_type</span>


<div class="viewcode-block" id="mat2SO3"><a class="viewcode-back" href="../../../../generated/pypose.mat2SO3/#pypose.mat2SO3">[docs]</a><span class="k">def</span> <span class="nf">mat2SO3</span><span class="p">(</span><span class="n">mat</span><span class="p">,</span> <span class="n">check</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">rtol</span><span class="o">=</span><span class="mf">1e-5</span><span class="p">,</span> <span class="n">atol</span><span class="o">=</span><span class="mf">1e-5</span><span class="p">):</span>
Expand Down Expand Up @@ -1066,6 +1068,41 @@ <h1>Source code for pypose.lietensor.convert</h1><div class="highlight"><pre>
<span class="sd"> See :obj:`euler2SO3` for more information.</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">return</span> <span class="n">inputs</span><span class="o">.</span><span class="n">euler</span><span class="p">(</span><span class="n">eps</span><span class="o">=</span><span class="n">eps</span><span class="p">)</span></div>


<div class="viewcode-block" id="quat2unit"><a class="viewcode-back" href="../../../../generated/pypose.quat2unit/#pypose.quat2unit">[docs]</a><span class="k">def</span> <span class="nf">quat2unit</span><span class="p">(</span><span class="nb">input</span><span class="p">:</span> <span class="n">LieTensor</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="mf">1e-12</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">LieTensor</span><span class="p">:</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> Normalize the quaternion part of a ``LieTensor``, which has to be a Lie group.</span>
<span class="sd"> If input is a not a Lie group, then do nothing and return the input.</span>
<span class="sd"> If the quaternion parts contain pure zeros, then raise an error.</span>

<span class="sd"> The quaternion parts :math:`v` are normalized as</span>

<span class="sd"> .. math::</span>
<span class="sd"> v = \frac{v}{\max(\lVert v \rVert_2, \epsilon)},</span>

<span class="sd"> where :math:`\epsilon` is a small value to avoid division by zero</span>

<span class="sd"> Args:</span>
<span class="sd"> input (``LieTensor``): input LieTensor of any type and shape.</span>
<span class="sd"> eps (``float``): small value to avoid division by zero. Default: 1e-12.</span>

<span class="sd"> Return:</span>
<span class="sd"> :obj:`LieTensor`: the output LieTensor.</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="nb">input</span><span class="p">,</span> <span class="n">LieTensor</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">input</span><span class="o">.</span><span class="n">ltype</span> <span class="ow">in</span> <span class="n">liegroup</span><span class="p">):</span>
<span class="n">data</span> <span class="o">=</span> <span class="nb">input</span><span class="o">.</span><span class="n">tensor</span><span class="p">()</span>
<span class="k">if</span> <span class="nb">input</span><span class="o">.</span><span class="n">ltype</span> <span class="ow">in</span> <span class="p">[</span><span class="n">SO3_type</span><span class="p">,</span> <span class="n">RxSO3_type</span><span class="p">]:</span>
<span class="n">data</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="p">:</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="p">:</span><span class="mi">4</span><span class="p">],</span> <span class="n">p</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">dim</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="n">eps</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">input</span><span class="o">.</span><span class="n">ltype</span> <span class="ow">in</span> <span class="p">[</span><span class="n">SE3_type</span><span class="p">,</span> <span class="n">Sim3_type</span><span class="p">]:</span>
<span class="n">data</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="mi">3</span><span class="p">:</span><span class="mi">7</span><span class="p">]</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="mi">3</span><span class="p">:</span><span class="mi">7</span><span class="p">],</span> <span class="n">p</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">dim</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="n">eps</span><span class="p">)</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">LieTensor</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">ltype</span><span class="o">=</span><span class="nb">input</span><span class="o">.</span><span class="n">ltype</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">output</span><span class="o">.</span><span class="n">rotation</span><span class="p">()</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">p</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">dim</span><span class="o">=-</span><span class="mi">1</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">eps</span><span class="p">)</span><span class="o">.</span><span class="n">any</span><span class="p">():</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Detected zero quaternions, which cannot be normalized.&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">output</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;Input is not Lie group, doing thing and returning input..&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="nb">input</span></div>
</pre></div>

</article>
Expand Down
3 changes: 2 additions & 1 deletion docs/main/_modules/pypose/lietensor/lietensor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,8 @@ <h1>Source code for pypose.lietensor.lietensor</h1><div class="highlight"><pre>
<span class="n">SE3_type</span><span class="p">,</span> <span class="n">se3_type</span> <span class="o">=</span> <span class="n">SE3Type</span><span class="p">(),</span> <span class="n">se3Type</span><span class="p">()</span>
<span class="n">Sim3_type</span><span class="p">,</span> <span class="n">sim3_type</span> <span class="o">=</span> <span class="n">Sim3Type</span><span class="p">(),</span> <span class="n">sim3Type</span><span class="p">()</span>
<span class="n">RxSO3_type</span><span class="p">,</span> <span class="n">rxso3_type</span> <span class="o">=</span> <span class="n">RxSO3Type</span><span class="p">(),</span> <span class="n">rxso3Type</span><span class="p">()</span>

<span class="n">liegroup</span> <span class="o">=</span> <span class="p">[</span><span class="n">SO3_type</span><span class="p">,</span> <span class="n">SE3_type</span><span class="p">,</span> <span class="n">Sim3_type</span><span class="p">,</span> <span class="n">RxSO3_type</span><span class="p">]</span>
<span class="n">liealgebra</span> <span class="o">=</span> <span class="p">[</span><span class="n">so3_type</span><span class="p">,</span> <span class="n">se3_type</span><span class="p">,</span> <span class="n">sim3_type</span><span class="p">,</span> <span class="n">rxso3_type</span><span class="p">]</span>

<div class="viewcode-block" id="LieTensor"><a class="viewcode-back" href="../../../../generated/pypose.LieTensor/#pypose.LieTensor">[docs]</a><span class="k">class</span> <span class="nc">LieTensor</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">):</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot; A sub-class of :obj:`torch.Tensor` to represent Lie Algebra and Lie Group.</span>
Expand Down
1 change: 1 addition & 0 deletions docs/main/_sources/convert.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Convert
euler
scale
matrix
quat2unit
cart2homo
homo2cart
point2pixel
Expand Down
6 changes: 6 additions & 0 deletions docs/main/_sources/generated/pypose.quat2unit.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pypose.quat2unit
================

.. currentmodule:: pypose

.. autofunction:: quat2unit
11 changes: 7 additions & 4 deletions docs/main/convert/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,19 @@ <h1>Convert<a class="headerlink" href="#convert" title="Permalink to this headin
<tr class="row-odd"><td><p><a class="reference internal" href="../generated/pypose.matrix/#pypose.matrix" title="pypose.matrix"><code class="xref py py-obj docutils literal notranslate"><span class="pre">matrix</span></code></a></p></td>
<td><p>Convert a <a class="reference internal" href="../generated/pypose.LieTensor/#pypose.LieTensor" title="pypose.LieTensor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LieTensor</span></code></a> into matrix form.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="../generated/pypose.cart2homo/#pypose.cart2homo" title="pypose.cart2homo"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cart2homo</span></code></a></p></td>
<tr class="row-even"><td><p><a class="reference internal" href="../generated/pypose.quat2unit/#pypose.quat2unit" title="pypose.quat2unit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">quat2unit</span></code></a></p></td>
<td><p>Normalize the quaternion part of a <code class="docutils literal notranslate"><span class="pre">LieTensor</span></code>, which has to be a Lie group.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="../generated/pypose.cart2homo/#pypose.cart2homo" title="pypose.cart2homo"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cart2homo</span></code></a></p></td>
<td><p>Converts batched Cartesian coordinates to Homogeneous coordinates by adding ones to last dimension.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="../generated/pypose.homo2cart/#pypose.homo2cart" title="pypose.homo2cart"><code class="xref py py-obj docutils literal notranslate"><span class="pre">homo2cart</span></code></a></p></td>
<tr class="row-even"><td><p><a class="reference internal" href="../generated/pypose.homo2cart/#pypose.homo2cart" title="pypose.homo2cart"><code class="xref py py-obj docutils literal notranslate"><span class="pre">homo2cart</span></code></a></p></td>
<td><p>Converts batched Homogeneous coordinates to Cartesian coordinates by dividing the last row.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="../generated/pypose.point2pixel/#pypose.point2pixel" title="pypose.point2pixel"><code class="xref py py-obj docutils literal notranslate"><span class="pre">point2pixel</span></code></a></p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="../generated/pypose.point2pixel/#pypose.point2pixel" title="pypose.point2pixel"><code class="xref py py-obj docutils literal notranslate"><span class="pre">point2pixel</span></code></a></p></td>
<td><p>Project batched sets of points (either in camera or world frame) to pixels.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="../generated/pypose.pixel2point/#pypose.pixel2point" title="pypose.pixel2point"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pixel2point</span></code></a></p></td>
<tr class="row-even"><td><p><a class="reference internal" href="../generated/pypose.pixel2point/#pypose.pixel2point" title="pypose.pixel2point"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pixel2point</span></code></a></p></td>
<td><p>Convert batch of pixels with depth into points (in camera coordinate)</p></td>
</tr>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions docs/main/generated/pypose.cart2homo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<link rel="index" title="Index" href="../../genindex/" />
<link rel="search" title="Search" href="../../search/" />
<link rel="next" title="pypose.homo2cart" href="../pypose.homo2cart/" />
<link rel="prev" title="pypose.matrix" href="../pypose.matrix/" />
<link rel="prev" title="pypose.quat2unit" href="../pypose.quat2unit/" />

<!--
Search engines should not index the master version of documentation.
Expand Down Expand Up @@ -294,7 +294,7 @@ <h1>pypose.cart2homo<a class="headerlink" href="#pypose-cart2homo" title="Permal
<a href="../pypose.homo2cart/" class="btn btn-neutral float-right" title="pypose.homo2cart" accesskey="n" rel="next">Next <img src="../../_static/images/chevron-right-orange.svg" class="next-page"></a>


<a href="../pypose.matrix/" class="btn btn-neutral" title="pypose.matrix" accesskey="p" rel="prev"><img src="../../_static/images/chevron-right-orange.svg" class="previous-page"> Previous</a>
<a href="../pypose.quat2unit/" class="btn btn-neutral" title="pypose.quat2unit" accesskey="p" rel="prev"><img src="../../_static/images/chevron-right-orange.svg" class="previous-page"> Previous</a>

</div>

Expand Down
4 changes: 2 additions & 2 deletions docs/main/generated/pypose.matrix/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<link rel="stylesheet" href="../../_static/katex-math.css" type="text/css" />
<link rel="index" title="Index" href="../../genindex/" />
<link rel="search" title="Search" href="../../search/" />
<link rel="next" title="pypose.cart2homo" href="../pypose.cart2homo/" />
<link rel="next" title="pypose.quat2unit" href="../pypose.quat2unit/" />
<link rel="prev" title="pypose.scale" href="../pypose.scale/" />

<!--
Expand Down Expand Up @@ -286,7 +286,7 @@ <h1>pypose.matrix<a class="headerlink" href="#pypose-matrix" title="Permalink to

<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">

<a href="../pypose.cart2homo/" class="btn btn-neutral float-right" title="pypose.cart2homo" accesskey="n" rel="next">Next <img src="../../_static/images/chevron-right-orange.svg" class="next-page"></a>
<a href="../pypose.quat2unit/" class="btn btn-neutral float-right" title="pypose.quat2unit" accesskey="n" rel="next">Next <img src="../../_static/images/chevron-right-orange.svg" class="next-page"></a>


<a href="../pypose.scale/" class="btn btn-neutral" title="pypose.scale" accesskey="p" rel="prev"><img src="../../_static/images/chevron-right-orange.svg" class="previous-page"> Previous</a>
Expand Down
Loading

0 comments on commit abd76ee

Please sign in to comment.