Skip to content

Commit

Permalink
Deployed 49c7707 with MkDocs version: 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Akira Sasaki committed Sep 5, 2024
1 parent 41d652d commit e613c6e
Show file tree
Hide file tree
Showing 19 changed files with 1,504 additions and 24 deletions.
56 changes: 32 additions & 24 deletions agv/idealworks.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<link rel="prev" href="../human/worker.html">


<link rel="next" href="idealworks_run.html">

<link rel="icon" href="../favicon.png">
<meta name="generator" content="mkdocs-1.3.0, mkdocs-material-9.1.3">

Expand Down Expand Up @@ -651,6 +653,20 @@








<li class="md-nav__item">
<a href="idealworks_run.html" class="md-nav__link">
IdealWorks移動
</a>
</li>




</ul>
</nav>
</li>
Expand Down Expand Up @@ -870,11 +886,7 @@ <h2 id="_1">ソースコード</h2>
<span class="normal">152</span>
<span class="normal">153</span>
<span class="normal">154</span>
<span class="normal">155</span>
<span class="normal">156</span>
<span class="normal">157</span>
<span class="normal">158</span>
<span class="normal">159</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="normal">155</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">omni.timeline</span>
<span class="kn">import</span> <span class="nn">omni.ui</span> <span class="k">as</span> <span class="nn">ui</span>
<span class="kn">from</span> <span class="nn">omni.isaac.ui.element_wrappers</span> <span class="kn">import</span> <span class="n">CollapsableFrame</span><span class="p">,</span> <span class="n">DropDown</span><span class="p">,</span> <span class="n">FloatField</span><span class="p">,</span> <span class="n">TextBlock</span>
Expand Down Expand Up @@ -983,11 +995,11 @@ <h2 id="_1">ソースコード</h2>

<span class="hll"> <span class="k">def</span> <span class="nf">_on_set_object</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
</span><span class="hll"><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
</span><span class="hll"><span class="sd"> USDシーンにWorkerオブジェクトを追加し、位置、スケール、回転、剛体物理と衝突設定を行う</span>
</span><span class="hll"><span class="sd"> USDシーンにRobotオブジェクトを追加し、位置、スケール、回転、剛体物理と衝突設定を行う</span>
</span><span class="hll"><span class="sd"> &quot;&quot;&quot;</span>
</span><span class="hll"> <span class="c1"># USDステージのコンテキストを取得</span>
</span><span class="hll"> <span class="n">context</span> <span class="o">=</span> <span class="n">omni</span><span class="o">.</span><span class="n">usd</span><span class="o">.</span><span class="n">get_context</span><span class="p">()</span>
</span><span class="hll"> <span class="n">stage</span> <span class="o">=</span> <span class="n">context</span><span class="o">.</span><span class="n">get_stage</span><span class="p">()</span>
</span><span class="hll"> <span class="n">stage</span> <span class="o">=</span> <span class="n">context</span><span class="o">.</span><span class="n">get_stage</span><span class="p">()</span> <span class="c1"># self.stageではなく、ここで直接取得する</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># オブジェクトのパスを指定</span>
</span><span class="hll"> <span class="n">prim_path</span> <span class="o">=</span> <span class="s1">&#39;/World/Robot&#39;</span>
Expand All @@ -999,35 +1011,31 @@ <h2 id="_1">ソースコード</h2>
</span><span class="hll"> <span class="c1"># 新しいプリム(オブジェクト)を作成</span>
</span><span class="hll"> <span class="n">prim_spec</span> <span class="o">=</span> <span class="n">Sdf</span><span class="o">.</span><span class="n">CreatePrimInLayer</span><span class="p">(</span><span class="n">current_layer</span><span class="p">,</span> <span class="n">prim_path</span><span class="p">)</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># WorkerオブジェクトのUSDファイルをペイロードとしてロード</span>
</span><span class="hll"> <span class="c1"># RobotオブジェクトのUSDファイルをペイロードとしてロード</span>
</span><span class="hll"> <span class="n">prim_spec</span><span class="o">.</span><span class="n">payloadList</span><span class="o">.</span><span class="n">Prepend</span><span class="p">(</span><span class="n">Sdf</span><span class="o">.</span><span class="n">Payload</span><span class="p">(</span>
</span><span class="hll"> <span class="s1">&#39;omniverse://localhost/NVIDIA/Assets/Isaac/4.2/Isaac/Robots/Idealworks/iw_hub_static.usd&#39;</span><span class="p">,</span>
</span><span class="hll"> <span class="s1">&#39;omniverse://localhost/NVIDIA/Assets/Isaac/4.2/Isaac/Robots/Idealworks/iw_hub_sensors.usd&#39;</span><span class="p">,</span>
</span><span class="hll"> <span class="n">Sdf</span><span class="o">.</span><span class="n">Path</span><span class="o">.</span><span class="n">emptyPath</span><span class="p">))</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># Workerオブジェクトを取得</span>
</span><span class="hll"> <span class="c1"># Robotオブジェクトを取得</span>
</span><span class="hll"> <span class="n">robot_prim</span> <span class="o">=</span> <span class="n">stage</span><span class="o">.</span><span class="n">GetPrimAtPath</span><span class="p">(</span><span class="n">prim_path</span><span class="p">)</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># オブジェクトが正しく取得できたか確認</span>
</span><span class="hll"> <span class="k">if</span> <span class="ow">not</span> <span class="n">robot_prim</span><span class="o">.</span><span class="n">IsValid</span><span class="p">():</span>
</span><span class="hll"> <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Error: Could not load prim at </span><span class="si">{</span><span class="n">prim_path</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</span><span class="hll"> <span class="k">return</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># Workerの位置、スケール、回転を設定</span>
</span><span class="hll"> <span class="c1"># Robotの位置、スケール、回転を設定</span>
</span><span class="hll"> <span class="n">xformable</span> <span class="o">=</span> <span class="n">UsdGeom</span><span class="o">.</span><span class="n">Xformable</span><span class="p">(</span><span class="n">robot_prim</span><span class="p">)</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># 位置を設定</span>
</span><span class="hll"> <span class="n">xform_ops</span> <span class="o">=</span> <span class="n">xformable</span><span class="o">.</span><span class="n">AddTranslateOp</span><span class="p">()</span>
</span><span class="hll"> <span class="n">xform_ops</span><span class="o">.</span><span class="n">Set</span><span class="p">(</span><span class="n">Gf</span><span class="o">.</span><span class="n">Vec3f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">))</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># 体物理やコリジョンを追加</span>
</span><span class="hll"> <span class="n">physicsAPI</span> <span class="o">=</span> <span class="n">UsdPhysics</span><span class="o">.</span><span class="n">RigidBodyAPI</span><span class="o">.</span><span class="n">Apply</span><span class="p">(</span><span class="n">robot_prim</span><span class="p">)</span>
</span><span class="hll"> <span class="n">PhysxSchema</span><span class="o">.</span><span class="n">PhysxRigidBodyAPI</span><span class="o">.</span><span class="n">Apply</span><span class="p">(</span><span class="n">robot_prim</span><span class="p">)</span>
</span><span class="hll"> <span class="n">physicsAPI</span><span class="o">.</span><span class="n">CreateRigidBodyEnabledAttr</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</span><span class="hll">
</span><span class="hll"> <span class="c1"># コリジョンの設定を追加</span>
</span><span class="hll"> <span class="n">collisionAPI</span> <span class="o">=</span> <span class="n">UsdPhysics</span><span class="o">.</span><span class="n">CollisionAPI</span><span class="o">.</span><span class="n">Apply</span><span class="p">(</span><span class="n">robot_prim</span><span class="p">)</span>
</span><span class="hll"> <span class="n">PhysxSchema</span><span class="o">.</span><span class="n">PhysxCollisionAPI</span><span class="o">.</span><span class="n">Apply</span><span class="p">(</span><span class="n">robot_prim</span><span class="p">)</span>
</span><span class="hll"> <span class="n">collisionAPI</span><span class="o">.</span><span class="n">CreateCollisionEnabledAttr</span><span class="p">()</span><span class="o">.</span><span class="n">Set</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</span><span class="hll"> <span class="c1"># 位置を設定(既存の translate op があるか確認)</span>
</span><span class="hll"> <span class="k">if</span> <span class="n">xformable</span><span class="o">.</span><span class="n">GetOrderedXformOps</span><span class="p">():</span>
</span><span class="hll"> <span class="n">translate_ops</span> <span class="o">=</span> <span class="p">[</span><span class="n">op</span> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="n">xformable</span><span class="o">.</span><span class="n">GetOrderedXformOps</span><span class="p">()</span> <span class="k">if</span> <span class="n">op</span><span class="o">.</span><span class="n">GetOpName</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;xformOp:translate&#39;</span><span class="p">]</span>
</span><span class="hll"> <span class="k">if</span> <span class="n">translate_ops</span><span class="p">:</span>
</span><span class="hll"> <span class="n">translate_ops</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">Set</span><span class="p">(</span><span class="n">Gf</span><span class="o">.</span><span class="n">Vec3f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">))</span>
</span><span class="hll"> <span class="k">else</span><span class="p">:</span>
</span><span class="hll"> <span class="n">xformable</span><span class="o">.</span><span class="n">AddTranslateOp</span><span class="p">()</span><span class="o">.</span><span class="n">Set</span><span class="p">(</span><span class="n">Gf</span><span class="o">.</span><span class="n">Vec3f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">))</span>
</span><span class="hll"> <span class="k">else</span><span class="p">:</span>
</span><span class="hll"> <span class="n">xformable</span><span class="o">.</span><span class="n">AddTranslateOp</span><span class="p">()</span><span class="o">.</span><span class="n">Set</span><span class="p">(</span><span class="n">Gf</span><span class="o">.</span><span class="n">Vec3f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">))</span>
</span><span class="hll">
</span><span class="hll"> <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Robot </span><span class="si">{</span><span class="n">prim_path</span><span class="si">}</span><span class="s2"> added, rotated by 180 degrees, and configured.&quot;</span><span class="p">)</span>
</span>
Expand Down
Loading

0 comments on commit e613c6e

Please sign in to comment.