xlerobot-sim / index.html
VectorW's picture
Update the web simulation
8ff66cf verified
Raw History Blame Contribute Delete
15.4 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>XLeRobot Sim</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%230071e3'/%3E%3Ctext x='32' y='42' font-size='28' font-weight='700' text-anchor='middle' fill='white' font-family='Arial'%3EXL%3C/text%3E%3C/svg%3E" />
<script>
// The theme follows the system. A page that embeds this one can choose it: ?theme=dark in the URL, or
// a message {type: "xlerobot-sim:theme", theme: "dark"}, which this page asks for when it starts.
(function () {
function set(theme) {
if (theme === "light" || theme === "dark") document.documentElement.dataset.theme = theme;
}
set(new URLSearchParams(location.search).get("theme"));
addEventListener("message", function (event) {
if (event.data && event.data.type === "xlerobot-sim:theme") set(event.data.theme);
});
if (window.parent !== window) window.parent.postMessage({ type: "xlerobot-sim:hello" }, "*");
})();
</script>
<meta name="description" content="XLeRobot in your browser: MuJoCo 4.0 physics, MuJoCo-GS-Web's robot and 3D Gaussian splat scenes, a kitchen, a learned policy and an LLM agent." />
</head>
<body>
<main class="app">
<section class="stage" aria-label="Simulation">
<canvas id="view" tabindex="0"></canvas>
<div id="view-labels" class="view-labels" aria-hidden="true"></div>
<header class="brand">
<h1>XLeRobot Sim</h1>
<p>MuJoCo 4.0 in your browser · <span id="fps">– fps</span></p>
</header>
<div id="activity" class="activity" hidden></div>
<p class="hint">Drag to orbit · drag objects to push them · keys drive the robot</p>
<div id="loading" class="loading" role="status">
<div class="loading-card">
<p id="loading-text">Loading MuJoCo and the robot…</p>
<div class="progress"><div id="loading-bar"></div></div>
</div>
</div>
</section>
<aside class="panel">
<nav class="tabs" role="tablist">
<button type="button" role="tab" data-tab="scene" aria-selected="true">Scene</button>
<button type="button" role="tab" data-tab="skills" aria-selected="false">Skills &amp; policy</button>
<button type="button" role="tab" data-tab="tasks" aria-selected="false">Tasks</button>
<button type="button" role="tab" data-tab="agent" aria-selected="false">Agent</button>
</nav>
<div class="tab" data-panel="scene">
<section>
<h2>Environment</h2>
<select id="env" aria-label="Environment"></select>
<p id="env-note" class="note"></p>
</section>
<section>
<h2>Robot</h2>
<div class="row">
<select id="robot" aria-label="Robot"></select>
<button type="button" id="upload-robot" title="A folder with one robot XML and its meshes under assets/ or meshes/, as in MuJoCo-GS-Web">Upload…</button>
<input id="robot-folder" type="file" webkitdirectory multiple hidden />
</div>
</section>
<section>
<h2>Renderer</h2>
<div class="segmented" role="group" aria-label="Renderer">
<button type="button" data-style="toon" aria-pressed="false">Toon</button>
<button type="button" data-style="lit" aria-pressed="true">Lit</button>
<button type="button" data-style="splat" aria-pressed="false">3DGS</button>
<button type="button" data-style="pixel" aria-pressed="false" title="Pixel art of the 3DGS scene, or of the modelled one where there is none">Pixel</button>
</div>
<p id="style-note" class="note error" role="status" hidden></p>
</section>
<section id="cameras-section">
<h2>Robot cameras</h2>
<div id="cameras" class="chips"></div>
</section>
<section>
<div class="buttons">
<button type="button" id="reset">Reset scene</button>
</div>
</section>
<section id="keys-section">
<h2>Keyboard</h2>
<dl id="keys" class="keys"></dl>
</section>
<section id="sliders-section" hidden>
<h2>Actuators</h2>
<div id="sliders" class="sliders"></div>
</section>
</div>
<div class="tab" data-panel="skills" hidden>
<section>
<h2>Object</h2>
<select id="object" aria-label="Object"></select>
<p id="object-note" class="note"></p>
<div class="buttons wrap">
<button type="button" data-skill="go_to">Go to</button>
<button type="button" data-skill="pick" class="primary">Pick</button>
<button type="button" data-skill="pick_policy">Pick (policy)</button>
</div>
</section>
<section>
<h2>Put it down</h2>
<div class="row">
<select id="place-target" aria-label="Put on"></select>
<button type="button" data-skill="place">Place</button>
</div>
<div class="buttons wrap">
<button type="button" data-skill="home">Rest arms</button>
<button type="button" data-skill="stop">Stop</button>
</div>
<p id="skill-status" class="status" aria-live="polite"></p>
</section>
<section>
<h2>Learned policy</h2>
<p class="note" id="policy-note">ACT trained with LeRobot on scripted picks in the tabletop scene, run here with ONNX Runtime Web. It sees the arm's joints and the object's position (no camera images).</p>
<p id="policy-status" class="status"></p>
</section>
<details>
<summary>Robot state</summary>
<table id="state" class="state"></table>
</details>
</div>
<div class="tab" data-panel="tasks" hidden>
<section id="tasks-none" hidden>
<p class="note">Household tasks come with the Kitchen (and XLeRobot).</p>
<div class="buttons"><button type="button" id="tasks-open-kitchen">Open the kitchen</button></div>
</section>
<div id="tasks-body">
<section>
<h2>Household task</h2>
<select id="task" aria-label="Task"></select>
<p id="task-instruction" class="task-instruction"></p>
<div class="row">
<label class="instance">Instance <input id="task-seed" type="number" min="0" max="99" step="1" value="0" /></label>
<button type="button" id="task-start">Set up</button>
</div>
<div class="buttons wrap">
<button type="button" id="task-demo" class="primary">Watch the demonstrator</button>
<button type="button" id="task-agent">Ask the agent</button>
<button type="button" id="task-stop">Stop</button>
</div>
<p class="note">In the style of the BEHAVIOR Challenge: the task is a BDDL problem; each instance puts its objects and the robot somewhere else; the score is the share of the goal's conditions that hold at the end. You can also do it yourself with the keys and the Skills tab.</p>
</section>
<section>
<h2>Goal <span id="task-score" class="score"></span></h2>
<ul id="task-goals" class="goals"></ul>
<p id="task-status" class="status" aria-live="polite"></p>
<table id="task-metrics" class="state"></table>
</section>
<details>
<summary>BDDL definition</summary>
<pre id="task-bddl" class="bddl"></pre>
</details>
</div>
</div>
<div class="tab" data-panel="agent" hidden>
<section class="connect">
<div data-provider="hf">
<div id="signed-out">
<button type="button" id="hf-signin" class="hf">Sign in with Hugging Face</button>
<p class="note">The agent runs here and calls a model on Hugging Face Inference Providers with your account. Or choose Gemini, Claude or your own endpoint below.</p>
</div>
<div id="signed-in" hidden>
<p>Signed in as <strong id="hf-user"></strong> · <button type="button" id="hf-signout" class="link">Sign out</button></p>
</div>
</div>
<details id="agent-settings">
<summary>Model and endpoint</summary>
<label
>Provider
<select id="provider">
<option value="hf">Hugging Face, or another OpenAI-compatible endpoint</option>
<option value="gemini">Gemini (Google AI Studio API key)</option>
<option value="claude">Claude (Anthropic API key)</option>
</select>
</label>
<div data-provider="hf">
<label>Model <input id="model" list="models" spellcheck="false" /></label>
<datalist id="models"></datalist>
<label>Endpoint <input id="endpoint" spellcheck="false" placeholder="https://router.huggingface.co/v1" /></label>
<label>Token / API key <input id="api-key" type="password" spellcheck="false" placeholder="hf_… (kept in this browser only)" /></label>
<label class="check"><input id="vision" type="checkbox" /> Model accepts images (adds the head camera tool)</label>
</div>
<div data-provider="gemini" hidden>
<label>Model <input id="gemini-model" spellcheck="false" /></label>
<p class="note">Gemini 4 Hydrogen, the model the Gemini Robotics plugin runs on, drives the robot here and finds objects with locate. It uses the Gemini API key under Perception.</p>
</div>
<div data-provider="claude" hidden>
<label>Model <select id="claude-model"></select></label>
<label>Anthropic API key <input id="claude-key" type="password" spellcheck="false" placeholder="sk-ant-… (kept in this browser only)" /></label>
<p class="note">An API key from <a href="https://console.anthropic.com/" target="_blank" rel="noopener">console.anthropic.com</a>, paid per use (Claude Max and Team plans include monthly API credit there); a Claude plan by itself covers Claude Code, which can drive the robot through the MCP server below.</p>
</div>
<label data-provider="gemini claude" hidden
>Effort
<select id="effort">
<option value="low">low: fastest</option>
<option value="medium" selected>medium</option>
<option value="high">high: thinks longest</option>
</select>
</label>
</details>
<details id="perception-section">
<summary>Perception: Gemini 4 Hydrogen</summary>
<p class="note">
<code>locate</code> sends a robot camera's picture to Gemini 4 Hydrogen, Google DeepMind's model for robotics, and gets back labelled points and boxes, which it maps to positions through the camera, as the
<a href="https://github.com/google-deepmind/robotics-antigravity-plugin/tree/main/plugins/robotics/skills/rgb-object-localization" target="_blank" rel="noopener">rgb-object-localization</a> skill of Google DeepMind's Gemini Robotics plugin does.
</p>
<label>Gemini API key <input id="gemini-key" type="password" spellcheck="false" placeholder="from aistudio.google.com (kept in this browser only)" /></label>
<label
>Thinking
<select id="locate-thinking">
<option value="low" selected>low (as the plugin's skill)</option>
<option value="medium">medium</option>
<option value="high">high: for clutter</option>
</select>
</label>
<label class="check"><input id="camera-only" type="checkbox" /> Camera only: an agent finds the objects with locate (observe leaves them out)</label>
<p id="perception-status" class="note" role="status"></p>
</details>
<details id="bridge-section">
<summary>Claude Code (MCP)</summary>
<p class="note">Claude Code, or another MCP client on this computer, can drive the robot here: run its MCP server (<code>tools/mcp/server.mjs</code>; <a href="https://huggingface.co/spaces/VectorW/xlerobot-sim/blob/main/README.md#claude-code-mcp" target="_blank" rel="noopener">setup</a>), then connect. The page talks only to 127.0.0.1.</p>
<div class="row bridge-row">
<span id="bridge-status" class="status" role="status">Not connected.</span>
<button type="button" id="bridge-connect">Connect</button>
</div>
</details>
</section>
<section class="chat">
<div id="chat" class="chat-log" aria-live="polite"></div>
<div class="examples" id="examples">
<button type="button">Pick up the orange and put it in the bowl</button>
<button type="button">What objects can you reach?</button>
<button type="button">Use the learned policy to pick up the cube</button>
<button type="button">Find the fruit with the head camera (locate) and say where each piece is</button>
</div>
<form id="chat-form" class="chat-form">
<textarea id="chat-input" rows="2" placeholder="Tell the robot what to do…"></textarea>
<div class="buttons">
<button type="submit" id="send" class="primary">Send</button>
<button type="button" id="stop-agent" hidden>Stop</button>
</div>
</form>
</section>
</div>
<footer>
<p>
Robot, IK and 3DGS scenes from <a href="https://github.com/Vector-Wangel/MuJoCo-GS-Web" target="_blank" rel="noopener">MuJoCo-GS-Web</a>;
physics by <a href="https://github.com/google-deepmind/mujoco" target="_blank" rel="noopener">MuJoCo</a> 4.0 (WebAssembly);
pick policy trained with <a href="https://github.com/huggingface/lerobot" target="_blank" rel="noopener">LeRobot</a>;
Unitree G1 and its walking policy (trained with mjlab) from <a href="https://huggingface.co/ttktjmt/mjswan" target="_blank" rel="noopener">mjswan</a>;
perception (<code>locate</code>) and the Gemini agent after Google DeepMind's <a href="https://github.com/google-deepmind/robotics-antigravity-plugin" target="_blank" rel="noopener">Gemini Robotics plugin</a>, with Gemini 4 Hydrogen.
Scripting: <code>window.xlerobotSim</code>.
</p>
</footer>
</aside>
</main>
<script type="module" src="/src/main.js"></script>
</body>
</html>