Skip to content

Commit

Permalink
deploy: a29bea0
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyguo11 committed Jan 3, 2025
1 parent 3572815 commit 8767e04
Show file tree
Hide file tree
Showing 11 changed files with 2,838 additions and 2,725 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ <h1>Source code for omni.isaac.lab.assets.rigid_object.rigid_object_data</h1><di
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">body_link_state_w</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;State of all bodies `[pos, quat, lin_vel, ang_vel]` in simulation world frame.</span>
<span class="sd"> Shape is (num_instances,1, 13).</span>
<span class="sd"> Shape is (num_instances, 1, 13).</span>

<span class="sd"> The position, quaternion, and linear/angular velocity are of the body&#39;s link frame relative to the world.</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
9 changes: 8 additions & 1 deletion main/_modules/omni/isaac/lab/envs/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,15 @@ <h1>Source code for omni.isaac.lab.envs.common</h1><div class="highlight"><pre>
<span class="sd"> Default is (1280, 720).</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">origin_type</span><span class="p">:</span> <span class="n">Literal</span><span class="p">[</span><span class="s2">&quot;world&quot;</span><span class="p">,</span> <span class="s2">&quot;env&quot;</span><span class="p">,</span> <span class="s2">&quot;asset_root&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;world&quot;</span>
<span class="n">origin_type</span><span class="p">:</span> <span class="n">Literal</span><span class="p">[</span><span class="s2">&quot;world&quot;</span><span class="p">,</span> <span class="s2">&quot;env&quot;</span><span class="p">,</span> <span class="s2">&quot;asset_root&quot;</span><span class="p">,</span> <span class="s2">&quot;asset_body&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;world&quot;</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The frame in which the camera position (eye) and target (lookat) are defined in. Default is &quot;world&quot;.</span>

<span class="sd"> Available options are:</span>

<span class="sd"> * ``&quot;world&quot;``: The origin of the world.</span>
<span class="sd"> * ``&quot;env&quot;``: The origin of the environment defined by :attr:`env_index`.</span>
<span class="sd"> * ``&quot;asset_root&quot;``: The center of the asset defined by :attr:`asset_name` in environment :attr:`env_index`.</span>
<span class="sd"> * ``&quot;asset_body&quot;``: The center of the body defined by :attr:`body_name` in asset defined by :attr:`asset_name` in environment :attr:`env_index`.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">env_index</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
Expand All @@ -573,6 +574,12 @@ <h1>Source code for omni.isaac.lab.envs.common</h1><div class="highlight"><pre>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The asset name in the interactive scene for the frame origin. Default is None.</span>

<span class="sd"> This quantity is only effective if :attr:`origin` is set to &quot;asset_root&quot;.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">body_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The name of the body in :attr:`asset_name` in the interactive scene for the frame origin. Default is None.</span>

<span class="sd"> This quantity is only effective if :attr:`origin` is set to &quot;asset_body&quot;.</span>
<span class="sd"> &quot;&quot;&quot;</span></div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ <h1>Source code for omni.isaac.lab.envs.ui.viewport_camera_controller</h1><div c
<span class="kn">import</span> <span class="nn">omni.kit.app</span>
<span class="kn">import</span> <span class="nn">omni.timeline</span>

<span class="kn">from</span> <span class="nn">omni.isaac.lab.assets.articulation.articulation</span> <span class="kn">import</span> <span class="n">Articulation</span>

<span class="k">if</span> <span class="n">TYPE_CHECKING</span><span class="p">:</span>
<span class="kn">from</span> <span class="nn">omni.isaac.lab.envs</span> <span class="kn">import</span> <span class="n">DirectRLEnv</span><span class="p">,</span> <span class="n">ManagerBasedEnv</span><span class="p">,</span> <span class="n">ViewerCfg</span>

Expand Down Expand Up @@ -576,12 +578,15 @@ <h1>Source code for omni.isaac.lab.envs.ui.viewport_camera_controller</h1><div c
<span class="bp">self</span><span class="o">.</span><span class="n">set_view_env_index</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">env_index</span><span class="p">)</span>
<span class="c1"># set the camera origin to the center of the environment</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_to_env</span><span class="p">()</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">==</span> <span class="s2">&quot;asset_root&quot;</span><span class="p">:</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">==</span> <span class="s2">&quot;asset_root&quot;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">==</span> <span class="s2">&quot;asset_body&quot;</span><span class="p">:</span>
<span class="c1"># note: we do not yet update camera for tracking an asset origin, as the asset may not yet be</span>
<span class="c1"># in the scene when this is called. Instead, we subscribe to the post update event to update the camera</span>
<span class="c1"># at each rendering step.</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;No asset name provided for viewer with origin type: &#39;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span><span class="si">}</span><span class="s2">&#39;.&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">==</span> <span class="s2">&quot;asset_body&quot;</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">body_name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;No body name provided for viewer with origin type: &#39;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span><span class="si">}</span><span class="s2">&#39;.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># set the camera origin to the center of the world</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_to_world</span><span class="p">()</span>
Expand Down Expand Up @@ -677,6 +682,41 @@ <h1>Source code for omni.isaac.lab.envs.ui.viewport_camera_controller</h1><div c
<span class="c1"># update the camera view</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_location</span><span class="p">()</span></div>

<div class="viewcode-block" id="ViewportCameraController.update_view_to_asset_body"><a class="viewcode-back" href="../../../../../../source/api/lab/omni.isaac.lab.envs.ui.html#omni.isaac.lab.envs.ui.ViewportCameraController.update_view_to_asset_body">[docs]</a> <span class="k">def</span> <span class="nf">update_view_to_asset_body</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">asset_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">body_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Updates the viewer&#39;s origin based upon the body of an asset in the scene.</span>

<span class="sd"> Args:</span>
<span class="sd"> asset_name: The name of the asset in the scene. The name should match the name of the</span>
<span class="sd"> asset in the scene.</span>
<span class="sd"> body_name: The name of the body in the asset.</span>

<span class="sd"> Raises:</span>
<span class="sd"> ValueError: If the asset is not in the scene or the body is not valid.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># check if the asset is in the scene</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span> <span class="o">!=</span> <span class="n">asset_name</span><span class="p">:</span>
<span class="n">asset_entities</span> <span class="o">=</span> <span class="p">[</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_env</span><span class="o">.</span><span class="n">scene</span><span class="o">.</span><span class="n">rigid_objects</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_env</span><span class="o">.</span><span class="n">scene</span><span class="o">.</span><span class="n">articulations</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span>
<span class="k">if</span> <span class="n">asset_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">asset_entities</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Asset &#39;</span><span class="si">{</span><span class="n">asset_name</span><span class="si">}</span><span class="s2">&#39; is not in the scene. Available entities: </span><span class="si">{</span><span class="n">asset_entities</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">)</span>
<span class="c1"># check if the body is in the asset</span>
<span class="n">asset</span><span class="p">:</span> <span class="n">Articulation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_env</span><span class="o">.</span><span class="n">scene</span><span class="p">[</span><span class="n">asset_name</span><span class="p">]</span>
<span class="k">if</span> <span class="n">body_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">asset</span><span class="o">.</span><span class="n">body_names</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;&#39;</span><span class="si">{</span><span class="n">body_name</span><span class="si">}</span><span class="s2">&#39; is not a body of Asset &#39;</span><span class="si">{</span><span class="n">asset_name</span><span class="si">}</span><span class="s2">&#39;. Available bodies: </span><span class="si">{</span><span class="n">asset</span><span class="o">.</span><span class="n">body_names</span><span class="si">}</span><span class="s2">.&quot;</span>
<span class="p">)</span>
<span class="c1"># get the body index</span>
<span class="n">body_id</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">asset</span><span class="o">.</span><span class="n">find_bodies</span><span class="p">(</span><span class="n">body_name</span><span class="p">)</span>
<span class="c1"># update the asset name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span> <span class="o">=</span> <span class="n">asset_name</span>
<span class="c1"># set origin type to asset_body</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">=</span> <span class="s2">&quot;asset_body&quot;</span>
<span class="c1"># update the camera origins</span>
<span class="bp">self</span><span class="o">.</span><span class="n">viewer_origin</span> <span class="o">=</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">scene</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span><span class="p">]</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">body_link_pos_w</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">env_index</span><span class="p">,</span> <span class="n">body_id</span><span class="p">]</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="p">)</span>
<span class="c1"># update the camera view</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_location</span><span class="p">()</span></div>

<div class="viewcode-block" id="ViewportCameraController.update_view_location"><a class="viewcode-back" href="../../../../../../source/api/lab/omni.isaac.lab.envs.ui.html#omni.isaac.lab.envs.ui.ViewportCameraController.update_view_location">[docs]</a> <span class="k">def</span> <span class="nf">update_view_location</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">eye</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="nb">float</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">lookat</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="nb">float</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Updates the camera view pose based on the current viewer origin and the eye and lookat positions.</span>

Expand Down Expand Up @@ -706,7 +746,9 @@ <h1>Source code for omni.isaac.lab.envs.ui.viewport_camera_controller</h1><div c
<span class="c1"># update the camera view if the origin is set to asset_root</span>
<span class="c1"># in other cases, the camera view is static and does not need to be updated continuously</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">==</span> <span class="s2">&quot;asset_root&quot;</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_to_asset_root</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_to_asset_root</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">origin_type</span> <span class="o">==</span> <span class="s2">&quot;asset_body&quot;</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">body_name</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_view_to_asset_body</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">asset_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">body_name</span><span class="p">)</span></div>
</pre></div>

</article>
Expand Down
Loading

0 comments on commit 8767e04

Please sign in to comment.