Buckets:

hf-doc-build/doc / simulate /v0.0.2 /en /quicktour.html
rtrm's picture
download
raw
34.8 kB
<meta charset="utf-8" /><meta http-equiv="content-security-policy" content=""><meta name="hf:doc:metadata" content="{&quot;local&quot;:&quot;reinforcement-learning-rl-with-simulate&quot;,&quot;sections&quot;:[{&quot;local&quot;:&quot;tips&quot;,&quot;title&quot;:&quot;Tips&quot;}],&quot;title&quot;:&quot;Reinforcement Learning (RL) with Simulate&quot;}" data-svelte="svelte-1phssyn">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/assets/pages/__layout.svelte-hf-doc-builder.css">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/start-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/chunks/vendor-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/chunks/paths-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/pages/__layout.svelte-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/pages/quicktour.mdx-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/chunks/IconCopyLink-hf-doc-builder.js">
<link rel="modulepreload" href="/docs/simulate/v0.0.2/en/_app/chunks/CodeBlock-hf-doc-builder.js">
<h1 class="relative group"><a id="quicktour" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#quicktour"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Quicktour
</span></h1>
<p>Simulate’s API is inspired by the great <a href="https://github.com/google-research/kubric" rel="nofollow">Kubric’s API</a>.
The user create a scene and add assets in it (objects, cameras, lights if needed).
Once the scene is created you can save/share it and also render or do simulations using one of the backend rendering/simulation engines (at the moment Unity, Blender and Godot). The saving/sharing format is engine agnostic and using the industry standard glTF format for saving scenes.</p>
<p>Let’s do a quick exploration together.</p>
<p>We’ll use the default backend which is a simple</p>
<p>To install and contribute (from <a href="CONTRIBUTING.md">CONTRIBUTING.md</a>)</p>
<p>Create a virtual env and then install the code style/quality tools as well as the code base locally</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->pip install <span class="hljs-comment">--upgrade simulate</span><!-- HTML_TAG_END --></pre></div>
<p>Before you merge a PR, fix the style (we use <code>isort</code> + <code>black</code>)</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-attribute">make style</span><!-- HTML_TAG_END --></pre></div>
<h2 class="relative group"><a id="project-structure" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#project-structure"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Project Structure
</span></h2>
<p>The Python API is located in src/simulate. It allows creation and loading of scenes, and sending commands to the backend.</p>
<p>The backend, currently just Unity, is located in <a href="integrations/Unity">integrations/Unity</a>.
This is currently a Unity editor project, which must be opened in Unity 2021.3.2f1.
In the future, this will be built as an executable, and spawned by the Python API.</p>
<h2 class="relative group"><a id="loading-a-scene-from-the-hub-or-a-local-file" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#loading-a-scene-from-the-hub-or-a-local-file"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Loading a scene from the hub or a local file
</span></h2>
<p>Loading a scene from a local file or the hub is done with <code>Scene.create_from()</code>, saving or pushing to the hub with <code>scene.save()</code> or <code>scene.push_to_hub()</code>:</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->from simulate import Scene
scene = <span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Scene</span>.</span></span>create<span class="hljs-constructor">_from(&#x27;<span class="hljs-params">tests</span><span class="hljs-operator">/</span><span class="hljs-params">test_assets</span><span class="hljs-operator">/</span><span class="hljs-params">fixtures</span><span class="hljs-operator">/</span>Box.<span class="hljs-params">gltf</span>&#x27;)</span> # either local (priority) <span class="hljs-keyword">or</span> on the hub <span class="hljs-keyword">with</span> full path <span class="hljs-keyword">to</span> file
scene = <span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Scene</span>.</span></span>create<span class="hljs-constructor">_from(&#x27;<span class="hljs-params">simulate</span>-<span class="hljs-params">tests</span><span class="hljs-operator">/</span>Box<span class="hljs-operator">/</span><span class="hljs-params">glTF</span><span class="hljs-operator">/</span>Box.<span class="hljs-params">gltf</span>&#x27;, <span class="hljs-params">is_local</span>=False)</span> # Set priority <span class="hljs-keyword">to</span> the hub file
scene.save(&#x27;local_dir/file.gltf&#x27;) # Save <span class="hljs-keyword">to</span> a local file
scene.push<span class="hljs-constructor">_to_hub(&#x27;<span class="hljs-params">simulate</span>-<span class="hljs-params">tests</span><span class="hljs-operator">/</span>Debug<span class="hljs-operator">/</span><span class="hljs-params">glTF</span><span class="hljs-operator">/</span>Box.<span class="hljs-params">gltf</span>&#x27;)</span> # Save <span class="hljs-keyword">to</span> the hub<!-- HTML_TAG_END --></pre></div>
<p align="center"><br>
<img src="https://user-images.githubusercontent.com/10695622/191554717-acba4764-a4f4-4609-834a-39ddb50b844a.png" width="400">
<br></p>
<h2 class="relative group"><a id="creating-a-scene-and-addingmanaging-objects-in-the-scene" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#creating-a-scene-and-addingmanaging-objects-in-the-scene"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Creating a Scene and adding/managing Objects in the scene
</span></h2>
<p>Basic example of creating a scene with a plane and a sphere above it:</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->import simulate as sm
<span class="hljs-built_in">scene</span> = sm.Scene()
<span class="hljs-built_in">scene</span> += sm.Plane() + sm.Sphere(<span class="hljs-built_in">position</span>=[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>], <span class="hljs-built_in">radius</span>=<span class="hljs-number">0.2</span>)
&gt;&gt;&gt; <span class="hljs-built_in">scene</span>
&gt;&gt;&gt; Scene(dimensionality=<span class="hljs-number">3</span>, engine=&#x27;PyVistaEngine&#x27;)
&gt;&gt;&gt; └── plane_01 (Plane - Mesh: <span class="hljs-number">121</span> <span class="hljs-built_in">points</span>, <span class="hljs-number">100</span> cells)
&gt;&gt;&gt; └── sphere_02 (Sphere - Mesh: <span class="hljs-number">842</span> <span class="hljs-built_in">points</span>, <span class="hljs-number">870</span> cells)
<span class="hljs-built_in">scene</span>.<span class="hljs-built_in">show</span>()<!-- HTML_TAG_END --></pre></div>
<p>An object (as well as the Scene) is just a node in a tree provided with optional mesh (as <code>pyvista.PolyData</code> structure) and material and/or light, camera, agents special objects.</p>
<p>The following objects creation helpers are currently provided:</p>
<ul><li><code>Object3D</code> any object with a <code>pyvista.PolyData</code> mesh and/or material</li>
<li><code>Plane</code></li>
<li><code>Sphere</code></li>
<li><code>Capsule</code></li>
<li><code>Cylinder</code></li>
<li><code>Box</code></li>
<li><code>Cone</code></li>
<li><code>Line</code></li>
<li><code>MultipleLines</code></li>
<li><code>Tube</code></li>
<li><code>Polygon</code></li>
<li><code>Ring</code></li>
<li><code>Text3D</code></li>
<li><code>Triangle</code></li>
<li><code>Rectangle</code></li>
<li><code>Circle</code></li>
<li><code>StructuredGrid</code></li></ul>
<p>Most of these objects can be visualized by running the following <a href="https://github.com/huggingface/simulate/tree/main/examples/objects.py" rel="nofollow">example</a>:</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->python examples<span class="hljs-regexp">/basic/</span>objects.py<!-- HTML_TAG_END --></pre></div>
<p align="center"><br>
<img src="https://user-images.githubusercontent.com/10695622/191562825-49d4c692-a1ed-44e9-bdb9-da5f0bfb9828.png" width="400">
<br></p>
<h3 class="relative group"><a id="objects-are-organized-in-a-tree-structure" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#objects-are-organized-in-a-tree-structure"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Objects are organized in a tree structure
</span></h3>
<p>Adding/removing objects:</p>
<ul><li>Using the addition (<code>+</code>) operator (or alternatively the method <code>.add(object)</code>) will add an object as a child of a previous object.</li>
<li>Objects can be removed with the subtraction (<code>-</code>) operator or the <code>.remove(object)</code> command.</li>
<li>The whole scene can be cleared with <code>.clear()</code>.</li></ul>
<p>Accessing objects:</p>
<ul><li>Objects can be directly accessed as attributes of their parents using their names (given with <code>name</code> attribute at creation or automatically generated from the class name + creation counter).</li>
<li>Objects can also be accessed from their names with <code>.get(name)</code> or by navigating in the tree using the various <code>tree_*</code> attributes available on any node.</li></ul>
<p>Here are a couple of examples of manipulations:</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START --><span class="hljs-comment"># Add two copy of the sphere to the scene as children of the root node (using list will add all objects on the same level)</span>
<span class="hljs-comment"># Using `.copy()` will create a copy of an object (the copy doesn&#x27;t have any parent or children)</span>
scene += [scene.plane_01.sphere_02.copy(), scene.plane_01.sphere_02.copy()]
&gt;&gt;&gt; scene
&gt;&gt;&gt; Scene(dimensionality=3, engine=&#x27;pyvista&#x27;)
&gt;&gt;&gt; ├── plane_01 (Plane - Mesh:<span class="hljs-number"> 121 </span>points,<span class="hljs-number"> 100 </span>cells)
&gt;&gt;&gt; │ └── sphere_02 (Sphere - Mesh:<span class="hljs-number"> 842 </span>points,<span class="hljs-number"> 870 </span>cells)
&gt;&gt;&gt; ├── sphere_03 (Sphere - Mesh:<span class="hljs-number"> 842 </span>points,<span class="hljs-number"> 870 </span>cells)
&gt;&gt;&gt; └── sphere_04 (Sphere - Mesh:<span class="hljs-number"> 842 </span>points,<span class="hljs-number"> 870 </span>cells)
<span class="hljs-comment"># Remove the last added sphere</span>
&gt;&gt;&gt; scene.remove(scene.sphere_04)
&gt;&gt;&gt; Scene(dimensionality=3, engine=&#x27;pyvista&#x27;)
&gt;&gt;&gt; ├── plane_01 (Plane - Mesh:<span class="hljs-number"> 121 </span>points,<span class="hljs-number"> 100 </span>cells)
&gt;&gt;&gt; │ └── sphere_02 (Sphere - Mesh:<span class="hljs-number"> 842 </span>points,<span class="hljs-number"> 870 </span>cells)
&gt;&gt;&gt; └── sphere_03 (Sphere - Mesh:<span class="hljs-number"> 842 </span>points,<span class="hljs-number"> 870 </span>cells)<!-- HTML_TAG_END --></pre></div>
<h3 class="relative group"><a id="objects-can-be-translated-rotated-scaled" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#objects-can-be-translated-rotated-scaled"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Objects can be translated, rotated, scaled
</span></h3>
Here are a couple of examples:
```
# Let&#39;s translate our floor (with the first sphere, it&#39;s child)
scene.plane_01.translate_x(1)
<h1 class="relative group"><a id="let’s-scale-the-second-sphere-uniformly" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#let’s-scale-the-second-sphere-uniformly"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Let’s scale the second sphere uniformly
</span></h1>
<p>scene.sphere_03.scale(0.1)</p>
<h1 class="relative group"><a id="inspect-the-current-position-and-scaling-values" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#inspect-the-current-position-and-scaling-values"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>Inspect the current position and scaling values
</span></h1>
<p>print(scene.plane_01.position)</p>
<blockquote><blockquote><blockquote><p>array([1., 0., 0.])
print(scene.sphere_03.scaling)
array([0.1, 0.1, 0.1])</p></blockquote></blockquote></blockquote>
<h1 class="relative group"><a id="we-can-also-translate-from-a-vector-and-rotate-from-a-quaternion-or-along-the-various-axis" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#we-can-also-translate-from-a-vector-and-rotate-from-a-quaternion-or-along-the-various-axis"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
<span>We can also translate from a vector and rotate from a quaternion or along the various axis
</span></h1>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->
&lt;h3 id=<span class="hljs-string">&quot;visualization-engine&quot;</span>&gt;Visualization engine&lt;/h3&gt;
A <span class="hljs-keyword">default</span> vizualization engine <span class="hljs-keyword">is</span> provided <span class="hljs-keyword">with</span> the vtk backend of <span class="hljs-string">`pyvista`</span>.
Starting the vizualization engine can be done simply <span class="hljs-keyword">with</span> <span class="hljs-string">`.show()`</span>.<!-- HTML_TAG_END --></pre></div>
<p>scene.show()</p>
<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
Copied</div></button></div>
<pre><!-- HTML_TAG_START -->
You can find bridges <span class="hljs-keyword">to</span> other rendering/simulation engines <span class="hljs-keyword">in</span> <span class="hljs-keyword">the</span> `integrations` directory.
&lt;h1 <span class="hljs-built_in">id</span>=<span class="hljs-string">&quot;reinforcement-learning-rl-with-simulate&quot;</span>&gt;Reinforcement Learning (RL) <span class="hljs-keyword">with</span> Simulate&lt;/h1&gt;
Simulate <span class="hljs-keyword">is</span> designed <span class="hljs-keyword">to</span> provide easy <span class="hljs-keyword">and</span> scalable integration <span class="hljs-keyword">with</span> reinforcement learning algorithms.
The core abstraction <span class="hljs-keyword">is</span> <span class="hljs-keyword">through</span> <span class="hljs-keyword">the</span> [RLEnv](/docs/simulate/v0<span class="hljs-number">.0</span><span class="hljs-number">.2</span>/en/api/rl_env<span class="hljs-comment">#simulate.RLEnv) class that wraps a `Scene`.</span>
The [RLEnv](/docs/simulate/v0<span class="hljs-number">.0</span><span class="hljs-number">.2</span>/en/api/rl_env<span class="hljs-comment">#simulate.RLEnv) allows an [Actuator](/docs/simulate/v0.0.2/en/api/actuators#simulate.Actuator) to be manipulated by an external agent or policy.</span>
It <span class="hljs-keyword">is</span> core <span class="hljs-keyword">to</span> <span class="hljs-keyword">the</span> design <span class="hljs-keyword">of</span> Simulate <span class="hljs-keyword">that</span> we are *<span class="hljs-keyword">not</span> creating* Agents, <span class="hljs-keyword">but</span> rather providing an interface <span class="hljs-keyword">for</span> applications <span class="hljs-keyword">of</span> machine learning <span class="hljs-keyword">and</span> embodied AI.
The core API <span class="hljs-keyword">for</span> RL applications can be seen <span class="hljs-keyword">below</span>, <span class="hljs-keyword">where</span> Simulate constrains <span class="hljs-keyword">the</span> information <span class="hljs-keyword">that</span> flows <span class="hljs-keyword">from</span> <span class="hljs-keyword">the</span> Scene <span class="hljs-keyword">to</span> <span class="hljs-keyword">the</span> external agent <span class="hljs-keyword">through</span> an Actuator abstraction.
&lt;p align=<span class="hljs-string">&quot;center&quot;</span>&gt;
&lt;br&gt;
&lt;img src=<span class="hljs-string">&quot;https://user-images.githubusercontent.com/10695622/192663853-a7543091-8d45-4fba-b8dc-2b632d66a35f.png&quot;</span> width=<span class="hljs-string">&quot;500&quot;</span>/&gt;
&lt;br&gt;
&lt;/p&gt;
At release, we include a <span class="hljs-keyword">set</span> <span class="hljs-keyword">of</span> pre-designed `Actor`&#x27;s <span class="hljs-keyword">that</span> can act <span class="hljs-keyword">or</span> navigate a scene. An `Actor` inherits <span class="hljs-keyword">from</span> an `Object3D` <span class="hljs-keyword">and</span> has sensors, actuators, <span class="hljs-keyword">and</span> action mappings.
&lt;h3 <span class="hljs-built_in">id</span>=<span class="hljs-string">&quot;tips&quot;</span>&gt;Tips&lt;/h3&gt;
If you are <span class="hljs-built_in">running</span> <span class="hljs-keyword">on</span> GCP, remember <span class="hljs-keyword">to</span> <span class="hljs-keyword">not</span> install `pyvistaqt`, <span class="hljs-keyword">and</span> <span class="hljs-keyword">if</span> you did so, uninstall <span class="hljs-keyword">it</span> <span class="hljs-keyword">in</span> your environment, <span class="hljs-keyword">since</span> QT doesn&#x27;t work well <span class="hljs-keyword">on</span> GCP.
<!-- HTML_TAG_END --></pre></div>
<script type="module" data-hydrate="116qdeu">
import { start } from "/docs/simulate/v0.0.2/en/_app/start-hf-doc-builder.js";
start({
target: document.querySelector('[data-hydrate="116qdeu"]').parentNode,
paths: {"base":"/docs/simulate/v0.0.2/en","assets":"/docs/simulate/v0.0.2/en"},
session: {},
route: false,
spa: false,
trailing_slash: "never",
hydrate: {
status: 200,
error: null,
nodes: [
import("/docs/simulate/v0.0.2/en/_app/pages/__layout.svelte-hf-doc-builder.js"),
import("/docs/simulate/v0.0.2/en/_app/pages/quicktour.mdx-hf-doc-builder.js")
],
params: {}
}
});
</script>

Xet Storage Details

Size:
34.8 kB
·
Xet hash:
19267a041dd63efe15f4b77229d283d74e4ff1c0643af13a74f31bd0d07e5aeb

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.