Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Loading Environments from the Hub","local":"loading-environments-from-the-hub","sections":[{"title":"What is EnvHub?","local":"what-is-envhub","sections":[],"depth":2},{"title":"Quick Start","local":"quick-start","sections":[],"depth":2},{"title":"Repository Structure","local":"repository-structure","sections":[{"title":"Required Files","local":"required-files","sections":[],"depth":3},{"title":"Optional Files","local":"optional-files","sections":[],"depth":3},{"title":"Example Repository Structure","local":"example-repository-structure","sections":[],"depth":3}],"depth":2},{"title":"Creating Your Environment Repository","local":"creating-your-environment-repository","sections":[{"title":"Step 1: Define Your Environment","local":"step-1-define-your-environment","sections":[],"depth":3},{"title":"Step 2: Test Locally","local":"step-2-test-locally","sections":[],"depth":3},{"title":"Step 3: Upload to the Hub","local":"step-3-upload-to-the-hub","sections":[],"depth":3}],"depth":2},{"title":"Loading Environments from the Hub","local":"loading-environments-from-the-hub","sections":[{"title":"Basic Usage","local":"basic-usage","sections":[],"depth":3},{"title":"Advanced: Pinning to Specific Versions","local":"advanced-pinning-to-specific-versions","sections":[],"depth":3},{"title":"Custom File Paths","local":"custom-file-paths","sections":[],"depth":3},{"title":"Async Environments","local":"async-environments","sections":[],"depth":3}],"depth":2},{"title":"URL Format Reference","local":"url-format-reference","sections":[],"depth":2},{"title":"EnvHub and the simulator server","local":"envhub-and-the-simulator-server","sections":[],"depth":2},{"title":"Multi-Task Environments","local":"multi-task-environments","sections":[],"depth":2},{"title":"Security Considerations","local":"security-considerations","sections":[],"depth":2},{"title":"Example: CartPole from the Hub","local":"example-cartpole-from-the-hub","sections":[],"depth":2},{"title":"Benefits of EnvHub","local":"benefits-of-envhub","sections":[{"title":"For Environment Authors","local":"for-environment-authors","sections":[],"depth":3},{"title":"For Researchers","local":"for-researchers","sections":[],"depth":3},{"title":"For the Community","local":"for-the-community","sections":[],"depth":3}],"depth":2},{"title":"Troubleshooting","local":"troubleshooting","sections":[{"title":"“Refusing to execute remote code”","local":"refusing-to-execute-remote-code","sections":[],"depth":3},{"title":"“Module X not found”","local":"module-x-not-found","sections":[],"depth":3},{"title":"“make_env not found in module”","local":"makeenv-not-found-in-module","sections":[],"depth":3},{"title":"Environment returns wrong type","local":"environment-returns-wrong-type","sections":[],"depth":3}],"depth":2},{"title":"Best Practices","local":"best-practices","sections":[],"depth":2},{"title":"Future Directions","local":"future-directions","sections":[],"depth":2},{"title":"See Also","local":"see-also","sections":[],"depth":2}],"depth":1}"/> | |
| <link href="/docs/lerobot/main/en/_app/immutable/entry/start.CMgyct4B.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/BcbLrCAJ.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/HSgsrBod.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/entry/app.MB6jwTHx.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/BEZitcl7.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/BTc-1quM.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/dgjUeEXU.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/nodes/0.DBFtATH6.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/ydAQHvtg.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/nodes/9.CrejVKtJ.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/D1Xs6TFQ.js" rel="modulepreload"> | |
| <link href="/docs/lerobot/main/en/_app/immutable/chunks/Cep_Xb_S.js" rel="modulepreload"> | |
| <!--1qltytr--><meta name="hf:doc:metadata" content="{"title":"Loading Environments from the Hub","local":"loading-environments-from-the-hub","sections":[{"title":"What is EnvHub?","local":"what-is-envhub","sections":[],"depth":2},{"title":"Quick Start","local":"quick-start","sections":[],"depth":2},{"title":"Repository Structure","local":"repository-structure","sections":[{"title":"Required Files","local":"required-files","sections":[],"depth":3},{"title":"Optional Files","local":"optional-files","sections":[],"depth":3},{"title":"Example Repository Structure","local":"example-repository-structure","sections":[],"depth":3}],"depth":2},{"title":"Creating Your Environment Repository","local":"creating-your-environment-repository","sections":[{"title":"Step 1: Define Your Environment","local":"step-1-define-your-environment","sections":[],"depth":3},{"title":"Step 2: Test Locally","local":"step-2-test-locally","sections":[],"depth":3},{"title":"Step 3: Upload to the Hub","local":"step-3-upload-to-the-hub","sections":[],"depth":3}],"depth":2},{"title":"Loading Environments from the Hub","local":"loading-environments-from-the-hub","sections":[{"title":"Basic Usage","local":"basic-usage","sections":[],"depth":3},{"title":"Advanced: Pinning to Specific Versions","local":"advanced-pinning-to-specific-versions","sections":[],"depth":3},{"title":"Custom File Paths","local":"custom-file-paths","sections":[],"depth":3},{"title":"Async Environments","local":"async-environments","sections":[],"depth":3}],"depth":2},{"title":"URL Format Reference","local":"url-format-reference","sections":[],"depth":2},{"title":"EnvHub and the simulator server","local":"envhub-and-the-simulator-server","sections":[],"depth":2},{"title":"Multi-Task Environments","local":"multi-task-environments","sections":[],"depth":2},{"title":"Security Considerations","local":"security-considerations","sections":[],"depth":2},{"title":"Example: CartPole from the Hub","local":"example-cartpole-from-the-hub","sections":[],"depth":2},{"title":"Benefits of EnvHub","local":"benefits-of-envhub","sections":[{"title":"For Environment Authors","local":"for-environment-authors","sections":[],"depth":3},{"title":"For Researchers","local":"for-researchers","sections":[],"depth":3},{"title":"For the Community","local":"for-the-community","sections":[],"depth":3}],"depth":2},{"title":"Troubleshooting","local":"troubleshooting","sections":[{"title":"“Refusing to execute remote code”","local":"refusing-to-execute-remote-code","sections":[],"depth":3},{"title":"“Module X not found”","local":"module-x-not-found","sections":[],"depth":3},{"title":"“make_env not found in module”","local":"makeenv-not-found-in-module","sections":[],"depth":3},{"title":"Environment returns wrong type","local":"environment-returns-wrong-type","sections":[],"depth":3}],"depth":2},{"title":"Best Practices","local":"best-practices","sections":[],"depth":2},{"title":"Future Directions","local":"future-directions","sections":[],"depth":2},{"title":"See Also","local":"see-also","sections":[],"depth":2}],"depth":1}"/><!----> | |
| <link href="/docs/lerobot/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" 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><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="loading-environments-from-the-hub" 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-environments-from-the-hub"><span><svg 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 Environments from the Hub<!----></span></h1><!--]--><!----> <p>The <strong>EnvHub</strong> feature allows you to load simulation environments directly from the Hugging Face Hub with a single line of code. This unlocks a powerful new model for collaboration: instead of environments being locked away inside monolithic libraries, anyone can publish custom environments and share them with the community.</p> <!--[1--><h2 class="relative group"><a id="what-is-envhub" 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="#what-is-envhub"><span><svg 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><!---->What is EnvHub?<!----></span></h2><!--]--><!----> <p>EnvHub lets you create custom robotics simulation environments with your own robot models and scenarios, and make them easily usable by anyone through the LeRobot framework.</p> <p>EnvHub packages are stored on the Hugging Face Hub, and can be seamlessly pulled and used in your AI robotics projects through LeRobot with a single line of code.</p> <p>Thanks to EnvHub, you can:</p> <ol><li><strong>Create and publish environments</strong> to the Hugging Face Hub as Git repositories, and distribute complex physics simulations without packaging hassles</li> <li><strong>Load environments</strong> dynamically, without installing them as packages</li> <li><strong>Version and track</strong> environment changes using Git semantics</li> <li><strong>Discover</strong> new simulation tasks shared by the community</li></ol> <p>This design means you can go from discovering an interesting environment on the Hub to running experiments in seconds, or create your own custom robot and environment without worrying about dependency conflicts or complex installation procedures.</p> <p>When you create an EnvHub package, you can build anything you want inside it and use any simulation tool you like: this is your own space to play with. The only requirement is that the package contains an <code>env.py</code> file that defines the environment and allows LeRobot to load and use your EnvHub package.</p> <p>This <code>env.py</code> file needs to expose a small API so LeRobot can load and run it. In particular, you must provide a <code>make_env(n_envs: int = 1, use_async_envs: bool = False)</code> function, which is the main entry point for LeRobot. LeRobot calls it without a config, locally and when served. It should return one of:</p> <ul><li>A <code>gym.vector.VectorEnv</code> (most common)</li> <li>A single <code>gym.Env</code> (will be automatically wrapped)</li> <li>A dict mapping <code>{suite_name: {task_id: VectorEnv}}</code> (for multi-task benchmarks)</li></ul> <p>By default, a returned vector env must be an unwrapped <code>SyncVectorEnv</code> or <code>AsyncVectorEnv</code>: LeRobot takes its <code>env_fns</code> and builds each environment itself. Custom vector wrappers and subclasses are rejected rather than silently removed.</p> <p>For provider-owned vector wrappers or GPU-native batches, use <code>--env.use_native_batch=true</code>. This keeps the repository’s vector environment intact for local batched evaluation, including its preprocessing requirements. It cannot be combined with an endpoint or <code>SimRobot</code>. The string API (<code>make_env("user/repo")</code>) also keeps the provider’s environment intact.</p> <p><code>env.py</code> may also define an optional <code>LEROBOT_SIM</code> dictionary describing the environment (fps, control_mode, component names; see <a href="#envhub-and-the-simulator-server">EnvHub and the simulator server</a>). It applies locally and when served.</p> <!--[1--><h2 class="relative group"><a id="quick-start" 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="#quick-start"><span><svg 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><!---->Quick Start<!----></span></h2><!--]--><!----> <p>Loading an environment from the Hub is as simple as:</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 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 class="language-python "><!----><span class="hljs-keyword">from</span> lerobot.envs <span class="hljs-keyword">import</span> make_env | |
| <span class="hljs-comment"># Load a hub environment (requires explicit consent to run remote code)</span> | |
| env = make_env(<span class="hljs-string">"lerobot/cartpole-env"</span>, trust_remote_code=<span class="hljs-literal">True</span>)<!----></pre></div><!----> <blockquote class="warning"><!---->**Security Notice**: Loading environments from the Hub executes Python code | |
| from third-party repositories. Only use `trust_remote_code=True` with | |
| repositories you trust. We strongly recommend pinning to a specific commit | |
| hash for reproducibility and security.<!----></blockquote><!----> <!--[1--><h2 class="relative group"><a id="repository-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="#repository-structure"><span><svg 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><!---->Repository Structure<!----></span></h2><!--]--><!----> <p>To make your environment loadable from the Hub, your repository must contain at minimum:</p> <!--[2--><h3 class="relative group"><a id="required-files" 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="#required-files"><span><svg 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><!---->Required Files<!----></span></h3><!--]--><!----> <p><strong><code>env.py</code></strong> (or custom Python file)</p> <ul><li>Must expose a <code>make_env(n_envs: int, use_async_envs: bool)</code> function</li> <li>Extra keyword arguments of <code>make_env</code> are the environment’s own options: <code>--env.make_env_kwargs='{"episode_length": 900}'</code> passes them (<code>--robot.env.make_env_kwargs</code> for a sim robot), and a server takes them with <code>--sim.kwargs='{make_env_kwargs: {episode_length: 900}}'</code></li> <li>This function should return one of: <ul><li>A <code>gym.vector.VectorEnv</code> (most common)</li> <li>A single <code>gym.Env</code> (will be automatically wrapped)</li> <li>A dict mapping <code>{suite_name: {task_id: VectorEnv}}</code> (for multi-task benchmarks)</li></ul></li></ul> <!--[2--><h3 class="relative group"><a id="optional-files" 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="#optional-files"><span><svg 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><!---->Optional Files<!----></span></h3><!--]--><!----> <p><strong><code>requirements.txt</code></strong></p> <ul><li>List any additional dependencies your environment needs</li> <li>Users will need to install these manually before loading your environment</li></ul> <p><strong><code>LEROBOT_SIM</code> in <code>env.py</code></strong></p> <ul><li>A module-level dictionary that describes the environment when it is served by the <a href="#envhub-and-the-simulator-server">simulator server</a>, so it starts with a single command</li> <li>Every key is optional; repositories without <code>LEROBOT_SIM</code> keep working with the defaults</li> <li><code>robot_type</code> is the type the real robot records (<code>so_follower</code>, <code>omx_follower</code>) when lerobot has a class for the body, so simulated and real datasets match</li></ul> <table><thead><tr><th>Key</th><th>Meaning</th><th>Default</th></tr></thead><tbody><tr><td><code>fps</code></td><td>Control rate of one <code>step()</code></td><td><code>30</code></td></tr><tr><td><code>control_mode</code></td><td>Action convention: <code>position</code>, <code>delta</code> or <code>eef_pose</code></td><td><code>"position"</code></td></tr><tr><td><code>semantics</code></td><td>Name of the observation/action conventions</td><td><code>"envhub-v1"</code></td></tr><tr><td><code>state_names</code></td><td>Names of the <code>observation.state</code> components, in order</td><td>generic <code>state_0</code>, <code>state_1</code>, …</td></tr><tr><td><code>action_names</code></td><td>Names of the action components, in order</td><td>generic <code>command_0</code>, <code>command_1</code>, …</td></tr><tr><td><code>robot_type</code></td><td>Simulated body, recorded as a sim robot’s dataset <code>robot_type</code></td><td>none (datasets record <code>sim_robot</code>)</td></tr></tbody></table> <p><strong><code>README.md</code></strong></p> <ul><li>Document your environment: what task it implements, observation/action spaces, rewards, etc.</li> <li>Include usage examples and any special setup instructions</li></ul> <p><strong><code>.gitignore</code></strong></p> <ul><li>Exclude unnecessary files from your repository</li></ul> <!--[2--><h3 class="relative group"><a id="example-repository-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="#example-repository-structure"><span><svg 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><!---->Example Repository Structure<!----></span></h3><!--]--><!----> <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 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 class=" "><!---->my-environment-repo<span class="hljs-symbol">/</span> | |
| ├── env.py <span class="hljs-comment"># Main environment definition (required)</span> | |
| ├── requirements.txt <span class="hljs-comment"># Dependencies (optional)</span> | |
| ├── README.md <span class="hljs-comment"># Documentation (recommended)</span> | |
| ├── assets<span class="hljs-symbol">/</span> <span class="hljs-comment"># Images, videos, etc. (optional)</span> | |
| │ └── demo.gif | |
| └── configs<span class="hljs-symbol">/</span> <span class="hljs-comment"># Config files if needed (optional)</span> | |
| └── task_config.yaml<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="creating-your-environment-repository" 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-your-environment-repository"><span><svg 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 Your Environment Repository<!----></span></h2><!--]--><!----> <!--[2--><h3 class="relative group"><a id="step-1-define-your-environment" 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="#step-1-define-your-environment"><span><svg 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><!---->Step 1: Define Your Environment<!----></span></h3><!--]--><!----> <p>Create an <code>env.py</code> file with a <code>make_env</code> function:</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 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 class="language-python "><!----><span class="hljs-comment"># env.py</span> | |
| <span class="hljs-keyword">import</span> gymnasium <span class="hljs-keyword">as</span> gym | |
| <span class="hljs-comment"># Optional: describes the environment to the simulator server (see "Optional Files").</span> | |
| LEROBOT_SIM = {<span class="hljs-string">"fps"</span>: <span class="hljs-number">50</span>, <span class="hljs-string">"control_mode"</span>: <span class="hljs-string">"position"</span>} | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">make_env</span>(<span class="hljs-params">n_envs: <span class="hljs-built_in">int</span> = <span class="hljs-number">1</span>, use_async_envs: <span class="hljs-built_in">bool</span> = <span class="hljs-literal">False</span></span>): | |
| <span class="hljs-string">""" | |
| Create vectorized environments for your custom task. | |
| Args: | |
| n_envs: Number of parallel environments | |
| use_async_envs: Whether to use AsyncVectorEnv or SyncVectorEnv | |
| Returns: | |
| gym.vector.VectorEnv or dict mapping suite names to vectorized envs | |
| """</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">_make_single_env</span>(): | |
| <span class="hljs-comment"># Create your custom environment</span> | |
| <span class="hljs-keyword">return</span> gym.make(<span class="hljs-string">"CartPole-v1"</span>) | |
| <span class="hljs-comment"># Choose vector environment type</span> | |
| env_cls = gym.vector.AsyncVectorEnv <span class="hljs-keyword">if</span> use_async_envs <span class="hljs-keyword">else</span> gym.vector.SyncVectorEnv | |
| <span class="hljs-comment"># Create vectorized environment</span> | |
| vec_env = env_cls([_make_single_env <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(n_envs)]) | |
| <span class="hljs-keyword">return</span> vec_env<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="step-2-test-locally" 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="#step-2-test-locally"><span><svg 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><!---->Step 2: Test Locally<!----></span></h3><!--]--><!----> <p>Before uploading, test your environment 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 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 class="language-python "><!----><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| <span class="hljs-keyword">from</span> lerobot.envs.configs <span class="hljs-keyword">import</span> HubEnvConfig | |
| <span class="hljs-comment"># Build the envs from the local folder that holds env.py, as lerobot-eval and the env server do</span> | |
| envs = HubEnvConfig(hub_path=<span class="hljs-string">"./my-env"</span>, trust_remote_code=<span class="hljs-literal">True</span>).create_envs(n_envs=<span class="hljs-number">2</span>) | |
| <span class="hljs-comment"># Verify it works</span> | |
| suite_name = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(envs)) | |
| env = envs[suite_name][<span class="hljs-number">0</span>] | |
| obs, info = env.reset(seed=<span class="hljs-number">0</span>) | |
| <span class="hljs-built_in">print</span>({key: value.shape <span class="hljs-keyword">for</span> key, value <span class="hljs-keyword">in</span> obs.items()}) <span class="hljs-comment"># LeRobot keys, e.g. observation.state</span> | |
| env.step(np.zeros(env.action_space.shape, np.float32)) | |
| env.close()<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="step-3-upload-to-the-hub" 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="#step-3-upload-to-the-hub"><span><svg 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><!---->Step 3: Upload to the Hub<!----></span></h3><!--]--><!----> <p>Upload your repository to Hugging Face:</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 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 class="language-bash "><!----><span class="hljs-comment"># Install huggingface_hub if needed</span> | |
| pip install huggingface_hub | |
| <span class="hljs-comment"># Login to Hugging Face</span> | |
| hf auth login | |
| <span class="hljs-comment"># Create a new repository</span> | |
| hf repos create my-org/my-custom-env | |
| <span class="hljs-comment"># Initialize git and push</span> | |
| git init | |
| git add . | |
| git commit -m <span class="hljs-string">"Initial environment implementation"</span> | |
| git remote add origin https://huggingface.co/my-org/my-custom-env | |
| git push -u origin main<!----></pre></div><!----> <p>Alternatively, use the <code>huggingface_hub</code> Python API:</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 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 class="language-python "><!----><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfApi | |
| api = HfApi() | |
| <span class="hljs-comment"># Create repository</span> | |
| api.create_repo(<span class="hljs-string">"my-custom-env"</span>, repo_type=<span class="hljs-string">"space"</span>) | |
| <span class="hljs-comment"># Upload files</span> | |
| api.upload_folder( | |
| folder_path=<span class="hljs-string">"./my-env-folder"</span>, | |
| repo_id=<span class="hljs-string">"username/my-custom-env"</span>, | |
| repo_type=<span class="hljs-string">"space"</span>, | |
| )<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="loading-environments-from-the-hub" 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-environments-from-the-hub"><span><svg 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 Environments from the Hub<!----></span></h2><!--]--><!----> <!--[2--><h3 class="relative group"><a id="basic-usage" 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="#basic-usage"><span><svg 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><!---->Basic Usage<!----></span></h3><!--]--><!----> <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 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 class="language-python "><!----><span class="hljs-keyword">from</span> lerobot.envs <span class="hljs-keyword">import</span> make_env | |
| <span class="hljs-comment"># Load from the hub</span> | |
| envs_dict = make_env( | |
| <span class="hljs-string">"username/my-custom-env"</span>, | |
| n_envs=<span class="hljs-number">4</span>, | |
| trust_remote_code=<span class="hljs-literal">True</span> | |
| ) | |
| <span class="hljs-comment"># Access the environment</span> | |
| suite_name = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(envs_dict)) | |
| env = envs_dict[suite_name][<span class="hljs-number">0</span>] | |
| <span class="hljs-comment"># Use it like any gym environment</span> | |
| obs, info = env.reset() | |
| action = env.action_space.sample() | |
| obs, reward, terminated, truncated, info = env.step(action)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="advanced-pinning-to-specific-versions" 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="#advanced-pinning-to-specific-versions"><span><svg 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><!---->Advanced: Pinning to Specific Versions<!----></span></h3><!--]--><!----> <p>For reproducibility and security, pin to a specific Git revision:</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 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 class="language-python "><!----><span class="hljs-comment"># Pin to a specific branch</span> | |
| env = make_env(<span class="hljs-string">"username/my-env@main"</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-comment"># Pin to a specific commit (recommended for papers/experiments)</span> | |
| env = make_env(<span class="hljs-string">"username/my-env@abc123def456"</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-comment"># Pin to a tag</span> | |
| env = make_env(<span class="hljs-string">"username/my-env@v1.0.0"</span>, trust_remote_code=<span class="hljs-literal">True</span>)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="custom-file-paths" 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="#custom-file-paths"><span><svg 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><!---->Custom File Paths<!----></span></h3><!--]--><!----> <p>If your environment definition is not in <code>env.py</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 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 class="language-python "><!----><span class="hljs-comment"># Load from a custom file</span> | |
| env = make_env(<span class="hljs-string">"username/my-env:custom_env.py"</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-comment"># Combine with version pinning</span> | |
| env = make_env(<span class="hljs-string">"username/my-env@v1.0:envs/task_a.py"</span>, trust_remote_code=<span class="hljs-literal">True</span>)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="async-environments" 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="#async-environments"><span><svg 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><!---->Async Environments<!----></span></h3><!--]--><!----> <p>For better performance with multiple environments:</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 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 class="language-python "><!---->envs_dict = make_env( | |
| <span class="hljs-string">"username/my-env"</span>, | |
| n_envs=<span class="hljs-number">8</span>, | |
| use_async_envs=<span class="hljs-literal">True</span>, <span class="hljs-comment"># Use AsyncVectorEnv for parallel execution</span> | |
| trust_remote_code=<span class="hljs-literal">True</span> | |
| )<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="url-format-reference" 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="#url-format-reference"><span><svg 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><!---->URL Format Reference<!----></span></h2><!--]--><!----> <p>The hub URL format supports several patterns:</p> <table><thead><tr><th>Pattern</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>user/repo</code></td><td>Load <code>env.py</code> from main branch</td><td><code>make_env("lerobot/cartpole-env")</code></td></tr><tr><td><code>user/repo@revision</code></td><td>Load from specific revision</td><td><code>make_env("lerobot/cartpole-env@main")</code></td></tr><tr><td><code>user/repo:path</code></td><td>Load custom file</td><td><code>make_env("lerobot/envs:pusht.py")</code></td></tr><tr><td><code>user/repo@rev:path</code></td><td>Revision + custom file</td><td><code>make_env("lerobot/envs@v1:pusht.py")</code></td></tr></tbody></table> <!--[1--><h2 class="relative group"><a id="envhub-and-the-simulator-server" 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="#envhub-and-the-simulator-server"><span><svg 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><!---->EnvHub and the simulator server<!----></span></h2><!--]--><!----> <p>By default, EnvHub environments run inside the evaluation process: <code>make_env</code> downloads the repository’s <code>env.py</code>, and its dependencies are installed next to LeRobot. To keep an environment’s dependencies away from your policy’s, serve it with the <a href="./simulation">simulator server</a> instead. One command builds an image with the repository and its <code>requirements.txt</code>, and starts the server:</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 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 class="language-bash "><!---->lerobot-env-server --envhub=username/my-env@<commit> --docker=<span class="hljs-literal">true</span><!----></pre></div><!----> <p>Besides <code>requirements.txt</code> (installed with pip’s rules, so <code>--extra-index-url</code> lines work), the image installs the apt packages listed in an optional <code>packages.txt</code>, one per line, as in Hugging Face Spaces. The image is plain Ubuntu: the GPU driver comes from the host, and CUDA libraries come from the Python wheels that need them (torch, Isaac Sim).</p> <p>Passing <code>--envhub</code> is the explicit consent to run the repository’s code, like <code>trust_remote_code=True</code>. Pin a commit. Then evaluate against it like any other environment, adding its endpoint:</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 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 class="language-bash "><!---->lerobot-eval --policy.path=<checkpoint> \ | |
| --env.type=envhub --env.hub_path=username/my-env@<commit> --env.server.endpoint=tcp/127.0.0.1:7448 \ | |
| --rename_map=<span class="hljs-string">'{"observation.images.front": "observation.images.camera1"}'</span> \ | |
| --eval.n_episodes=10<!----></pre></div><!----> <p>Without <code>--env.server.endpoint</code>, the same command runs the environment locally (with <code>--trust_remote_code=true</code>); a sim robot takes the same options under <code>--robot.env.*</code>.</p> <p>The server reads the control rate, action convention and component names from the repository’s <a href="#optional-files"><code>LEROBOT_SIM</code></a>, and uses the defaults for anything it does not declare. Override a value on the command line, which wins over the repository, e.g. <code>--sim.fps=15</code>.</p> <p>To be served, an environment must follow these conventions:</p> <ul><li><code>make_env</code> returns vector environments built from per-environment factories (<code>SyncVectorEnv</code>/<code>AsyncVectorEnv</code>, as in the examples above) or a single <code>gym.Env</code>. The server builds its own environments from those factories and closes them when a session ends.</li> <li><code>env.py</code> is executed once per server process, so it can keep process-wide state, such as a simulator application that can only start once (Isaac Sim’s <code>SimulationApp</code>).</li> <li>Observations are the dictionaries LeRobot reads locally: <code>pixels</code> (one HWC uint8 image or a dictionary of cameras), <code>agent_pos</code> and <code>environment_state</code>, as NumPy arrays.</li> <li>Actions are a one-dimensional continuous <code>Box</code>.</li> <li>Episodes end through <code>terminated</code>/<code>truncated</code> or <code>_max_episode_steps</code> (default 500), and <code>info["is_success"]</code> reports success. The task text comes from the environment’s <code>task_description</code> (or <code>task</code>) attribute.</li> <li><code>LEROBOT_SIM</code> is optional, but declare it whenever the defaults (30 fps, position control) do not match your environment.</li></ul> <p>For examples, see the <a href="https://huggingface.co/collections/lerobot/envhub-environments-6ad0f5bf3fac8dbe626c17dc" rel="nofollow">EnvHub environments collection</a>: <a href="https://huggingface.co/lerobot/so101-tabletop-mujoco" rel="nofollow"><code>lerobot/so101-tabletop-mujoco</code></a> (MuJoCo) and <a href="https://huggingface.co/lerobot/so101-tabletop-isaac" rel="nofollow"><code>lerobot/so101-tabletop-isaac</code></a> (Isaac Sim, installed through <code>requirements.txt</code> and <code>packages.txt</code>) serve the same SO-101 scene with the same observations, actions and <code>LEROBOT_SIM</code>.</p> <p>The repository is downloaded on your machine with your Hugging Face login (<code>HF_TOKEN</code> or <code>hf auth login</code>), so private repositories work too, and the image build never sees a token. <code>--envhub</code> also takes a local directory holding <code>env.py</code>, to serve an environment before pushing it: <code>lerobot-env-server --envhub=./my-env --docker=true</code>. <code>--build=true</code> rebuilds only what changed: the apt packages when <code>packages.txt</code> changes, the requirements when <code>requirements.txt</code> changes, and otherwise just the repository’s files. Test a new environment locally first (see <a href="#step-2-test-locally">Step 2: Test Locally</a>).</p> <!--[1--><h2 class="relative group"><a id="multi-task-environments" 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="#multi-task-environments"><span><svg 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><!---->Multi-Task Environments<!----></span></h2><!--]--><!----> <p>For benchmarks with multiple tasks (like LIBERO), return a nested dictionary:</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 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 class="language-python "><!----><span class="hljs-keyword">def</span> <span class="hljs-title function_">make_env</span>(<span class="hljs-params">n_envs: <span class="hljs-built_in">int</span> = <span class="hljs-number">1</span>, use_async_envs: <span class="hljs-built_in">bool</span> = <span class="hljs-literal">False</span></span>): | |
| env_cls = gym.vector.AsyncVectorEnv <span class="hljs-keyword">if</span> use_async_envs <span class="hljs-keyword">else</span> gym.vector.SyncVectorEnv | |
| <span class="hljs-comment"># Return dict: {suite_name: {task_id: VectorEnv}}</span> | |
| <span class="hljs-keyword">return</span> { | |
| <span class="hljs-string">"suite_1"</span>: { | |
| <span class="hljs-number">0</span>: env_cls([<span class="hljs-keyword">lambda</span>: gym.make(<span class="hljs-string">"Task1-v0"</span>) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(n_envs)]), | |
| <span class="hljs-number">1</span>: env_cls([<span class="hljs-keyword">lambda</span>: gym.make(<span class="hljs-string">"Task2-v0"</span>) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(n_envs)]), | |
| }, | |
| <span class="hljs-string">"suite_2"</span>: { | |
| <span class="hljs-number">0</span>: env_cls([<span class="hljs-keyword">lambda</span>: gym.make(<span class="hljs-string">"Task3-v0"</span>) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(n_envs)]), | |
| } | |
| }<!----></pre></div><!----> <p><code>make_env</code> builds every task when it is called. For a GPU simulator that steps a whole batch in one world (e.g. Isaac Lab), or a benchmark with many tasks, define <code>vector_env_fns</code> in <code>env.py</code> instead, as LeRobot’s own integrations do. It returns factories, and only the factories of the tasks that run are called:</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 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 class="language-python "><!----><span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> partial | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">vector_env_fns</span>(<span class="hljs-params">task: <span class="hljs-built_in">str</span>, n_envs: <span class="hljs-built_in">int</span>, **make_env_kwargs</span>): | |
| <span class="hljs-comment"># {suite_name: {task_id: factory}}, each factory building one vector env of n_envs envs</span> | |
| <span class="hljs-keyword">return</span> {<span class="hljs-string">"suite_1"</span>: {<span class="hljs-number">0</span>: partial(MyBatchedEnv, n_envs, <span class="hljs-string">"Task1"</span>), <span class="hljs-number">1</span>: partial(MyBatchedEnv, n_envs, <span class="hljs-string">"Task2"</span>)}}<!----></pre></div><!----> <p>Each vector env must have <code>num_envs == n_envs</code>, must not autoreset (<code>metadata["autoreset_mode"] = gym.vector.AutoresetMode.DISABLED</code>), returns batched observations in the format above, takes one seed per env in <code>reset(seed=[...])</code>, and reports <code>info["is_success"]</code> per env. <code>--env.make_env_kwargs</code> are passed to it, and both <code>lerobot-eval</code> and the simulator server use it in place of <code>make_env</code>. Since one vector env already steps the whole batch, evaluate with <code>--eval.use_async_envs=false</code>: a worker process would only copy every observation batch between processes, and a server would build the simulator a second time, in the worker.</p> <!--[1--><h2 class="relative group"><a id="security-considerations" 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="#security-considerations"><span><svg 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><!---->Security Considerations<!----></span></h2><!--]--><!----> <blockquote class="warning"><!---->**Important**: The `trust_remote_code=True` flag is required to execute | |
| environment code from the Hub. This is by design for security.<!----></blockquote><!----> <p>When loading environments from the Hub:</p> <ol><li><strong>Review the code first</strong>: Visit the repository and inspect <code>env.py</code> before loading</li> <li><strong>Pin to commits</strong>: Use specific commit hashes for reproducibility</li> <li><strong>Check dependencies</strong>: Review <code>requirements.txt</code> for suspicious packages</li> <li><strong>Use trusted sources</strong>: Prefer official organizations or well-known researchers</li> <li><strong>Sandbox if needed</strong>: Run untrusted code in isolated environments (containers, VMs)</li></ol> <p>Example of safe usage:</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 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 class="language-python "><!----><span class="hljs-comment"># ❌ BAD: Loading without inspection</span> | |
| env = make_env(<span class="hljs-string">"random-user/untrusted-env"</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-comment"># ✅ GOOD: Review code, then pin to specific commit</span> | |
| <span class="hljs-comment"># 1. Visit https://huggingface.co/trusted-org/verified-env</span> | |
| <span class="hljs-comment"># 2. Review the env.py file</span> | |
| <span class="hljs-comment"># 3. Copy the commit hash</span> | |
| env = make_env(<span class="hljs-string">"trusted-org/verified-env@a1b2c3d4"</span>, trust_remote_code=<span class="hljs-literal">True</span>)<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="example-cartpole-from-the-hub" 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="#example-cartpole-from-the-hub"><span><svg 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><!---->Example: CartPole from the Hub<!----></span></h2><!--]--><!----> <p>Here’s a complete example using the reference CartPole environment:</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 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 class="language-python "><!----><span class="hljs-keyword">from</span> lerobot.envs <span class="hljs-keyword">import</span> make_env | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| <span class="hljs-comment"># Load the environment</span> | |
| envs_dict = make_env(<span class="hljs-string">"lerobot/cartpole-env"</span>, n_envs=<span class="hljs-number">4</span>, trust_remote_code=<span class="hljs-literal">True</span>) | |
| <span class="hljs-comment"># Get the vectorized environment</span> | |
| suite_name = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(envs_dict)) | |
| env = envs_dict[suite_name][<span class="hljs-number">0</span>] | |
| <span class="hljs-comment"># Run a simple episode</span> | |
| obs, info = env.reset() | |
| done = np.zeros(env.num_envs, dtype=<span class="hljs-built_in">bool</span>) | |
| total_reward = np.zeros(env.num_envs) | |
| <span class="hljs-keyword">while</span> <span class="hljs-keyword">not</span> done.<span class="hljs-built_in">all</span>(): | |
| <span class="hljs-comment"># Random policy</span> | |
| action = env.action_space.sample() | |
| obs, reward, terminated, truncated, info = env.step(action) | |
| total_reward += reward | |
| done = terminated | truncated | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">f"Average reward: <span class="hljs-subst">{total_reward.mean():<span class="hljs-number">.2</span>f}</span>"</span>) | |
| env.close()<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="benefits-of-envhub" 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="#benefits-of-envhub"><span><svg 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><!---->Benefits of EnvHub<!----></span></h2><!--]--><!----> <!--[2--><h3 class="relative group"><a id="for-environment-authors" 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="#for-environment-authors"><span><svg 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><!---->For Environment Authors<!----></span></h3><!--]--><!----> <ul><li><strong>Easy distribution</strong>: No PyPI packaging required</li> <li><strong>Version control</strong>: Use Git for environment versioning</li> <li><strong>Rapid iteration</strong>: Push updates instantly</li> <li><strong>Documentation</strong>: Hub README renders beautifully</li> <li><strong>Community</strong>: Reach LeRobot users directly</li></ul> <!--[2--><h3 class="relative group"><a id="for-researchers" 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="#for-researchers"><span><svg 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><!---->For Researchers<!----></span></h3><!--]--><!----> <ul><li><strong>Quick experiments</strong>: Load any environment in one line</li> <li><strong>Reproducibility</strong>: Pin to specific commits</li> <li><strong>Discovery</strong>: Browse environments on the Hub</li> <li><strong>No conflicts</strong>: No need to install conflicting packages</li></ul> <!--[2--><h3 class="relative group"><a id="for-the-community" 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="#for-the-community"><span><svg 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><!---->For the Community<!----></span></h3><!--]--><!----> <ul><li><strong>Growing ecosystem</strong>: More diverse simulation tasks</li> <li><strong>Standardization</strong>: Common <code>make_env</code> API</li> <li><strong>Collaboration</strong>: Fork and improve existing environments</li> <li><strong>Accessibility</strong>: Lower barrier to sharing research</li></ul> <!--[1--><h2 class="relative group"><a id="troubleshooting" 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="#troubleshooting"><span><svg 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><!---->Troubleshooting<!----></span></h2><!--]--><!----> <!--[2--><h3 class="relative group"><a id="refusing-to-execute-remote-code" 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="#refusing-to-execute-remote-code"><span><svg 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><!---->“Refusing to execute remote code”<!----></span></h3><!--]--><!----> <p>You must explicitly pass <code>trust_remote_code=True</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 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 class="language-python "><!---->env = make_env(<span class="hljs-string">"user/repo"</span>, trust_remote_code=<span class="hljs-literal">True</span>)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="module-x-not-found" 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="#module-x-not-found"><span><svg 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><!---->“Module X not found”<!----></span></h3><!--]--><!----> <p>The hub environment has dependencies you need to install:</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 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 class="language-bash "><!----><span class="hljs-comment"># Check the repo's requirements.txt and install dependencies</span> | |
| pip install gymnasium numpy<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="makeenv-not-found-in-module" 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="#makeenv-not-found-in-module"><span><svg 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><!---->“make_env not found in module”<!----></span></h3><!--]--><!----> <p>Your <code>env.py</code> must expose a <code>make_env</code> function:</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 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 class="language-python "><!----><span class="hljs-keyword">def</span> <span class="hljs-title function_">make_env</span>(<span class="hljs-params">n_envs: <span class="hljs-built_in">int</span>, use_async_envs: <span class="hljs-built_in">bool</span></span>): | |
| <span class="hljs-comment"># Your implementation</span> | |
| <span class="hljs-keyword">pass</span><!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="environment-returns-wrong-type" 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="#environment-returns-wrong-type"><span><svg 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><!---->Environment returns wrong type<!----></span></h3><!--]--><!----> <p>The <code>make_env</code> function must return:</p> <ul><li>A <code>gym.vector.VectorEnv</code>, or</li> <li>A single <code>gym.Env</code>, or</li> <li>A dict <code>{suite_name: {task_id: VectorEnv}}</code></li></ul> <!--[1--><h2 class="relative group"><a id="best-practices" 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="#best-practices"><span><svg 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><!---->Best Practices<!----></span></h2><!--]--><!----> <ol><li><strong>Document your environment</strong>: Include observation/action space descriptions, reward structure, and termination conditions in your README</li> <li><strong>Add requirements.txt</strong>: List all dependencies with versions</li> <li><strong>Declare <code>LEROBOT_SIM</code></strong>: Let the environment be served by the simulator server with one command</li> <li><strong>Test thoroughly</strong>: Verify your environment works locally before pushing</li> <li><strong>Use semantic versioning</strong>: Tag releases with version numbers</li> <li><strong>Add examples</strong>: Include usage examples in your README</li> <li><strong>Keep it simple</strong>: Minimize dependencies when possible</li> <li><strong>License your work</strong>: Add a LICENSE file to clarify usage terms</li></ol> <!--[1--><h2 class="relative group"><a id="future-directions" 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="#future-directions"><span><svg 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><!---->Future Directions<!----></span></h2><!--]--><!----> <p>The EnvHub ecosystem enables exciting possibilities:</p> <ul><li><strong>GPU-accelerated physics</strong>: Share Isaac Gym or Brax environments</li> <li><strong>Photorealistic rendering</strong>: Distribute environments with advanced graphics</li> <li><strong>Multi-agent scenarios</strong>: Complex interaction tasks</li> <li><strong>Real-world simulators</strong>: Digital twins of physical setups</li> <li><strong>Procedural generation</strong>: Infinite task variations</li> <li><strong>Domain randomization</strong>: Pre-configured DR pipelines</li></ul> <p>As more researchers and developers contribute, the diversity and quality of available environments will grow, benefiting the entire robotics learning community.</p> <!--[1--><h2 class="relative group"><a id="see-also" 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="#see-also"><span><svg 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><!---->See Also<!----></span></h2><!--]--><!----> <ul><li><a href="https://huggingface.co/docs/hub/en/index" rel="nofollow">Hugging Face Hub Documentation</a></li> <li><a href="https://gymnasium.farama.org/index.html" rel="nofollow">Gymnasium Documentation</a></li> <li><a href="https://huggingface.co/lerobot/cartpole-env" rel="nofollow">Example Hub Environment</a></li></ul> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/lerobot/blob/main/docs/source/envhub.mdx" target="_blank"><svg class="mr-1" 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="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]--> | |
| <script> | |
| { | |
| __sveltekit_1xprr1v = { | |
| base: "/docs/lerobot/main/en", | |
| assets: "/docs/lerobot/main/en" | |
| }; | |
| const element = document.currentScript.parentElement; | |
| Promise.all([ | |
| import("/docs/lerobot/main/en/_app/immutable/entry/start.CMgyct4B.js"), | |
| import("/docs/lerobot/main/en/_app/immutable/entry/app.MB6jwTHx.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 9], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 105 kB
- Xet hash:
- 0c82672d319d6f21b10caeacf8631903d0add00f3f427045fe581ff4a4220613
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.