Spaces:
Running
Running
|
Download README.md from VectorW/xlerobot-sim: direct link, hf CLI and curl.
- Browser
- Download file 37.2 kB
-
https://huggingface.co/spaces/VectorW/xlerobot-sim/resolve/main/README.md
- Command line
-
hf download hf://spaces/VectorW/xlerobot-sim/README.md
-
curl -L -o README.md https://huggingface.co/spaces/VectorW/xlerobot-sim/resolve/main/README.md
37.2 kB
| title: XLeRobot Sim | |
| emoji: 🤖 | |
| colorFrom: blue | |
| colorTo: gray | |
| sdk: static | |
| app_file: dist/index.html | |
| pinned: false | |
| license: apache-2.0 | |
| short_description: XLeRobot in your browser, with MuJoCo 4.0 physics | |
| tags: [robotics, simulation, mujoco, xlerobot, lerobot, webassembly, 3dgs, agents, gemini, mcp] | |
| hf_oauth: true | |
| hf_oauth_scopes: | |
| - inference-api | |
| # XLeRobot Sim | |
| [XLeRobot](https://github.com/Vector-Wangel/XLeRobot), the open-source household dual-arm mobile | |
| robot, in the browser. Physics runs on your device with MuJoCo 4.0's official WebAssembly build: | |
| nothing to install, no server, no limit on visitors. | |
| The robot model, its inverse kinematics and keyboard map, and the 3D Gaussian splat scenes come from | |
| [MuJoCo-GS-Web](https://github.com/Vector-Wangel/MuJoCo-GS-Web), unchanged. Its agents can find objects | |
| with Gemini 4 Hydrogen, after Google DeepMind's [Gemini Robotics plugin](https://github.com/google-deepmind/robotics-antigravity-plugin), | |
| and Claude Code can drive it from your computer. | |
| ## What you can do | |
| - **Pick a scene**: MuJoCo-GS-Web's tabletop kitchen and boxing ring (Gaussian splats with collision | |
| boxes, and a model of each built from its splat for the other renderers), its empty floor, or a kitchen | |
| with a dining room built for this Space in the manner of RoboCasa's (a fridge, a microwave, drawers and | |
| cabinet doors that open; a stocked top-freezer fridge with glass shelves, crisper drawers and door bins, | |
| whose door a magnetic gasket pulls shut; a microwave without a handle, whose door pops open when its button | |
| is pressed and is pushed shut onto its magnet; an oven | |
| and a cooktop with a pot and a pan, a range hood, a coffee machine, a kettle, spices and a crock of | |
| wooden spoons; an island with a prep sink and two drawers; a trash can; a sideboard with a radio whose | |
| power button switches it on and off; a dining table under two lamps, windows, a clock, pictures and | |
| plants; a tiled kitchen floor; and objects to pick up, two of them in the fridge). The tabletop kitchen has the same objects as that kitchen, set out | |
| on its counters where the splat shows free worktop: fruit around a bowl, a plate, a mug and a glass on | |
| the back counter, a can, a juice carton and a yogurt by the microwave, a bottle of oil and a block on | |
| the left counter. | |
| - **Do household tasks** in the kitchen, in the style of the | |
| [BEHAVIOR Challenge](https://behavior.stanford.edu/challenge/): 21 tasks written in BDDL. Eight put | |
| things where they go (picking up trash, clearing the table, making a fruit bowl, putting away | |
| groceries, setting the table, preparing a snack, turning on the radio, tidying up); nine are | |
| [RoboCasa](https://robocasa.ai)'s door and drawer tasks and what they are for (opening and closing the | |
| fridge, the microwave and the island's drawer; putting a cube away in the drawer, chilling a yogurt in | |
| the fridge, getting the juice out of it); and four are long ones that chain these: serving a cold | |
| drink (a cola from the fridge to the dining table, the fridge shut behind), making breakfast (the juice | |
| and the yogurt from the fridge to the table, the fridge shut, the radio on), stocking the fridge, and | |
| tidying up after dinner (six goals: the sink, the fridge, the drawer, both shut). Each has as many | |
| instances as you like, scored as the challenge scores them. Watch a scripted demonstrator do one, ask | |
| the agent, or do it yourself (Tasks tab; see below). | |
| - **Drive and teleoperate** with MuJoCo-GS-Web's keys: W/S and A/D for the dual-wheel base; for each arm | |
| rotation, end-effector height and reach, wrist pitch and roll, and the gripper; R/T and F/G for the head. | |
| - **Walk a Unitree G1**: choose it under Robot; W/S walk, A/D turn, Q/E step sideways. A locomotion | |
| policy trained with mjlab (from [mjswan](https://huggingface.co/ttktjmt/mjswan)) runs in your browser | |
| with ONNX Runtime Web at 50 Hz, and the G1 stands back up after a fall. | |
| - **Drag objects** with the mouse. | |
| - **Switch renderers**: Toon (cel shading with ink outlines; in the kitchen, its photographic room below in | |
| each material's mean colour); Lit (PBR materials; in the kitchen, a | |
| photographic room built in Blender on the kitchen's layout, so every surface the robot meets is where | |
| the physics has it: oak parquet, walnut and white marble, a garden behind its windows and glass door, | |
| an afternoon sun and the room's own lamps, its light baked with Cycles and denoised into a light map; | |
| the robot, the objects and the fixtures' moving parts lit by light probes captured in the page from | |
| the lit room, a key light from the lamps nearest to where you look (what moves shades the baked room | |
| under it) and the room's reflections; AgX tone mapping; elsewhere image-based lighting, shadows and | |
| procedural textures; the robot is matte charcoal plastic on a matte powder-coated cart, as the real one); | |
| 3DGS (the scene's splat; the robot is lit by light captured from | |
| the splat, and its shadows fall on the splat's floor, counters and walls; drawn at 66% of the | |
| screen's resolution, which about doubles the frame rate for little sharpness); Pixel (pixel art of the | |
| splat, or of the Toon scene where there is none: about 240 rows of whole pixels, 32 colours chosen | |
| from what the view shows, and ordered dithering; the modelled scenes keep Toon's ink lines). | |
| `?env=tabletop&style=pixel` in the URL opens a scene in a renderer; without them the page opens on the | |
| kitchen in Lit, whatever was chosen last time. Walls between the camera and the | |
| room are drawn as low stubs, without the pictures and windows on them, so they never hide it; in | |
| the kitchen's photographic room they are left out with what is on them, and the ceiling too when you | |
| look from above (the robot's cameras see them whole, and the garden outside). | |
| - **Embed it**: the page runs in an `<iframe>`. It follows the system's light or dark theme unless the | |
| URL says `?theme=dark` or the embedding page sends `{type: "xlerobot-sim:theme", theme: "dark"}` | |
| (the page posts `{type: "xlerobot-sim:hello"}` to its parent when it starts). | |
| - **Watch the robot's cameras**: head and both wrists, under Scene (off at first: each draws the | |
| scene again). | |
| - **Run skills**: go to an object, pick it (scripted grasp), place it in or on another object. Going to | |
| an object drives around the furniture without touching it, to a spot from which an arm grasps the | |
| object well (see below). The base and the arms move together: the arms fold up while the way is | |
| planned and finish folding as the base sets off; as the base comes in, the arm that will grasp swings | |
| out over the object, and the grasp is one motion from there (over, down, close, lift). Putting | |
| something down is one motion too (over the spot and down; then out along the gripper, up and back to | |
| rest), and the jaws open wide if the object is still between them. Picking an object out of reach | |
| drives there first. A grasp closes across the object's narrow side however it lies: a box turned any | |
| way, a banana or a bottle lying down, a mug clear of its handle. A held object stays put: while a | |
| gripper squeezes something, MuJoCo's noslip solver (ten iterations; with three, an object lifted high | |
| still creeps out as the base turns) keeps it from creeping out of the jaws (`src/robots/xlerobot.js`). | |
| - **Open and close drawers and doors** by their bar pulls (`src/robots/fixtures.js`). To open one, an | |
| arm grasps the bar from above, its jaws closing round it across the front (the fridge's upright bar, | |
| 0.28 to 0.92 m up on the middle of its door as on a real fridge, with the hand level, from the side); to | |
| close one, the closed gripper comes down just in front of the bar and pushes it. For a drawer the robot backs straight out | |
| with it, or drives in. For a door it drives a circle round the hinge, with its axle's line through the | |
| hinge: the robot and the door turn as one body and the arm holds still (a base on two wheels cannot | |
| follow a pull's arc sideways; turning with the door, it does not have to). Where to stand is worked | |
| out from the hinge or the slide, the arm's reach and the furniture along the way. The fridge's door is | |
| hinged on the wall's side, so it opens away from the counter, to about 60 degrees (further, the robot | |
| turning with it would meet the wall); the island's drawer 30 cm. The doors close on magnets, with | |
| MuJoCo's contact adhesion (`adhesion` and `gap` on a contact pair): a strip inside each door near its | |
| free edge and the cabinet pull together within a few millimetres (the fridge's within 2 cm), so a | |
| door pushed nearly shut swings shut and opens with a tug. The microwave's door also has a spring that | |
| pops it open about 20 degrees: its release button (a slide, held out by a spring) drives a pin in the | |
| cabinet 2.2 times as far (an equality), which pushes the door past its magnet's reach. The robot presses | |
| it with the closed gripper level, square to the panel (`pushIn` in `src/robots/skills.js`), and closes | |
| the door by pushing its face where a mark (a capsule named `*push` that neither collides nor shows) says, | |
| as it pushes the other doors' pulls. | |
| - **Run a learned policy**: an ACT policy trained with LeRobot picks objects, in your browser with ONNX | |
| Runtime Web. | |
| - **Give the robot instructions in words**: an LLM agent calls the skills as tools. Its model is one of | |
| Hugging Face's Inference Providers (sign in with Hugging Face; it needs Inference Providers credits), | |
| Gemini 4 Hydrogen (a Gemini API key), Claude (an Anthropic API key) or any OpenAI-compatible endpoint, | |
| such as a local Ollama server. Keys stay in your browser and go only to their own API. | |
| - **Find objects with Gemini 4 Hydrogen**: `locate` sends a robot camera's picture to Google DeepMind's | |
| model for robotics and turns the points it gives into positions the skills take, after the Gemini | |
| Robotics plugin's rgb-object-localization skill; with camera-only perception it is all an agent has to | |
| go by. See [Perception with Gemini 4 Hydrogen](#perception-with-gemini-4-hydrogen). | |
| - **Drive it from Claude Code**: an MCP server on your computer (`tools/mcp/server.mjs`) gives Claude | |
| Code, or another MCP client, the agent's tools and a few more (scenes, household tasks, every camera); | |
| the robot moves in the page as it calls them. See [Claude Code (MCP)](#claude-code-mcp). | |
| - **Bring your own robot**: upload a folder with one MuJoCo XML and its meshes, as in MuJoCo-GS-Web | |
| ([MuJoCo Menagerie](https://github.com/google-deepmind/mujoco_menagerie) robots work). It gets a | |
| slider for every actuator. | |
| - **Script it**: `window.xlerobotSim` exposes the simulation and the agent's tools, so browser agents | |
| and tests can drive it, for example `await xlerobotSim.call("pick", {object: "orange"})`, or | |
| `xlerobotSim.tasks.start("picking_up_trash", 3)`, `await xlerobotSim.tasks.demo()` and | |
| `xlerobotSim.tasks.report()`. | |
| ## How the robot goes to an object | |
| `src/robots/nav.js` plans and drives the base; `src/robots/skills.js` decides where to stand. | |
| 1. **What the base can hit.** The scene's collision geoms, except the robot, become 2D shapes | |
| (rectangles and circles) with a height range: counters, walls, chairs, open doors, and the objects | |
| standing about. The robot is its chassis outline plus, for each arm, the links that reach beyond it, | |
| each with its own height range. A shape only counts against the parts it overlaps in height, so an | |
| arm can pass over a worktop that the chassis cannot. The free arms fold up for driving, so nothing | |
| reaches beyond the chassis (the path is planned for the folded robot while they fold); an arm holding | |
| something stays as it is. | |
| 2. **Where to stand.** Around the object, at every 5 degrees of heading and with either arm, the poses | |
| from which the object is 0.23 to 0.43 m ahead and in line with the arm, clear of everything by 2 cm, | |
| and from which the grasp planner finds a grasp. They are ranked by the length of the way there, how | |
| comfortably the arm reaches, and how well the grasp goes: from above where it can, square to the | |
| object's narrow side, the wrist turned little, a tall object held by its middle. | |
| 3. **The path.** A hybrid A* search over the pose of the point between the wheels, which stays put when | |
| the base turns in place. It drives the base the way a person drives a two-wheeled robot: forward, | |
| steering as it goes (straight drives and arcs); turns in place to face a new way; and backs up only | |
| straight and a little, to make room to turn: at most 0.3 m in all, or 0.6 m and then 1 m if there is | |
| no other way (with an arm holding something out in front, the base can need more room). Backing up | |
| costs three times as much as driving forward, and in the search order a pose that faces away from | |
| the way to go counts as further away, so the search turns toward the way rather than reversing | |
| along it. Every move is checked along its way with 3.5 cm to spare; near the start, 2 cm (or what the | |
| base has there, less a few millimetres: steering away from a counter it stands along swings the back | |
| of the base toward it), growing back to 3.5 cm over the first 35 cm, since following the path the | |
| base's corners swing out a centimetre or two more than planned. The path ends, where | |
| there is room, with one smooth curve (a Dubins arc-straight-arc, no arc over 150 degrees) onto the | |
| goal's heading and a straight run in, so the base meets the counter square; or it turns in place to | |
| face the start of the run in first. Once it has a way, the search goes on a little for a cheaper one. | |
| 4. **Driving it.** Pure pursuit on the path at up to 0.4 m/s, speeding up and slowing down smoothly, | |
| slower near furniture and before bends, with turns in place at up to 1.6 rad/s that end on the | |
| planned heading. With something in a gripper, gently: up to 0.22 m/s and 0.45 rad/s, and turns that | |
| start and stop softly (1.2 rad/s²), or the turn swings it out of the fingers. Over the last stretch the arm reaches out over the object. A quarter of a second | |
| ahead, the base checks the pose it is heading for and stops before one that would touch; then it | |
| folds the arm back and plans again from where it is. Where it finds no way at all (nose-in beside | |
| an open fridge door, whose edge is in the way straight back), it first backs out 30 to 40 cm, | |
| straight or along a curve, and plans again. | |
| In the tabletop scene the robot goes to every object from its start and picks each one it can lift, | |
| without the base touching a counter (`npm run check`). Going to, picking and putting each of six | |
| objects in the bowl or on the plate, the base backs up 2.7 m in all over 13 drives, no more than 0.3 m | |
| at a time. | |
| ## Household tasks | |
| In the style of the [BEHAVIOR Challenge](https://behavior.stanford.edu/challenge/), in one MuJoCo scene: | |
| the kitchen (`src/tasks/`, `assets/environments/kitchen/tasks/`). | |
| - **Tasks are BDDL problems**, written as BEHAVIOR-1K writes them: typed objects named by WordNet | |
| synsets (`can__of__soda.n.01_1 - can__of__soda.n.01`), an initial state and a goal, with `and`, `or`, | |
| `not`, `forall` and `exists`. `tasks/index.json` says what each name is in the scene: a free body, box | |
| sites in the scene's XML that mark surfaces (the island, the dining table, the pantry shelf), | |
| containers (the sink, the trash can, the fridge, the island's drawer; the fridge's upper shelf is | |
| where things go in it) and the parts of surfaces the arms reach, or a switch (the radio's button | |
| joint). A container with a joint opens and closes. | |
| - **Predicates** are evaluated on the simulation: `ontop` (resting on a surface or on an object), | |
| `inside` (in a container, or a bowl), `nextto`, `toggled_on` (the radio switches each time its button | |
| goes down 8 mm) and `open` (a door or drawer joint); an object in a gripper is on and in nothing. | |
| - **Instances**: a seed puts the task's objects where `:init` says, at random spots the arms reach, apart | |
| from each other (in the fridge, facing out, as people put things away); drawers and doors are open or | |
| shut as it says; what the task does not use goes out of the way (the back of the counter, the coffee | |
| table); the robot starts on a free spot of the floor, facing any way. | |
| - **Score**, as the challenge's: the share of the goal's conditions that hold at the end (`forall` | |
| expanded, so throwing two cans and a bottle away is three), and whether all do, within a time limit | |
| (1.5 times the demonstrator's mean, and a quarter more than its slowest run); with the simulated | |
| time, the distance the base travelled and the | |
| distance the arms moved the hands, as efficiency measures. | |
| - **A scripted demonstrator** (`src/tasks/solver.js`) does each task with the skills: for every | |
| condition that does not hold, it picks the object up and puts it where the condition says (at a free | |
| spot of a surface an arm reaches, next to what a `nextto` names, on the fridge's shelf, or let go over | |
| a container or into a drawer's corner), presses the switch, or opens or closes the drawer or door. A | |
| drawer or door that something comes out of or goes into is opened first, with both hands free, and | |
| shut as soon as the goal wants it shut and nothing more comes out of it or goes in (taken out, the | |
| object goes on in one hand while the other shuts it). Into the fridge, it carries a thing with the arm | |
| on the door's hinge side: reaching in with the other, the base would stand where the open door is. | |
| It uses both hands: when another object goes to the same place or near it (within | |
| 1.2 m), the other hand picks that one up before the robot goes there, so one trip carries two. Only | |
| light objects (100 g at most, and not balls) share a trip: a heavier one (the juice box, the yogurt | |
| pot, the bottle) creeps along the fingers and tilts over the long carry, and a ball rolls out. The | |
| agent gets the same tools (`observe` lists the fixtures, which are open, and the task; `place` takes a | |
| fixture; `press`, `open`, `close`, `task`). | |
| - **Unlike the challenge**: there is one scene; things start where XLeRobot's arms reach (about 11 cm | |
| past the edge of a counter the base stands at, between 0.6 and 0.9 m up), so no task asks for the | |
| floor, the freezer or the back of the counter. Level pulls are at most about 0.8 m up (grasped from | |
| above; higher, the wrist cannot point the gripper down), so the counter's drawers and doors, under the | |
| worktop's overhang, stay shut in the tasks. The demonstrator and the agent see the simulation's state | |
| (where things are), not only the cameras. | |
| The demonstrator over five instances of each task (`node tools/eval_tasks.mjs 5`; means over the | |
| instances), carrying two objects at a time where it can, and one at a time (`ONE_HAND=1`). Runs in Node | |
| are repeatable: there the searches for a path and a place to stand split their work by estimates rather | |
| than by the machine's clock, so the simulated time they take does not depend on how busy it is. | |
| | Task | Goal conditions | Q | Success | Time | Base travelled | One at a time: Q, time, base | Time limit | | |
| |---|---|---|---|---|---|---|---| | |
| | Turning on the radio | 1 | 1.00 | 5/5 | 16 s | 3.0 m | 1.00, 16 s, 3.0 m | 30 s | | |
| | Picking up trash | 3 | 1.00 | 5/5 | 127 s | 16.8 m | 1.00, 131 s, 20.8 m | 200 s | | |
| | Clearing the table | 3 | 1.00 | 5/5 | 132 s | 17.7 m | 1.00, 149 s, 23.4 m | 200 s | | |
| | Making a fruit bowl | 3 | 1.00 | 5/5 | 119 s | 13.7 m | 1.00, 119 s, 13.7 m | 180 s | | |
| | Putting away groceries | 3 | 1.00 | 5/5 | 114 s | 16.3 m | 1.00, 114 s, 16.3 m | 180 s | | |
| | Setting the table | 4 | 1.00 | 5/5 | 68 s | 7.1 m | 0.90, 86 s, 10.8 m | 110 s | | |
| | Preparing a snack | 3 | 1.00 | 5/5 | 95 s | 9.5 m | 1.00, 108 s, 13.2 m | 170 s | | |
| | Tidying up the kitchen | 5 | 1.00 | 5/5 | 173 s | 22.7 m | 1.00, 173 s, 22.7 m | 260 s | | |
| | Opening the fridge | 1 | 1.00 | 5/5 | 16 s | 2.7 m | 1.00, 16 s, 2.7 m | 30 s | | |
| | Closing the fridge | 1 | 1.00 | 5/5 | 27 s | 3.9 m | 1.00, 27 s, 3.9 m | 50 s | | |
| | Opening the drawer | 1 | 1.00 | 5/5 | 18 s | 3.6 m | 1.00, 18 s, 3.6 m | 30 s | | |
| | Closing the drawer | 1 | 1.00 | 5/5 | 19 s | 3.2 m | 1.00, 19 s, 3.2 m | 30 s | | |
| | Putting away the cube | 2 | 1.00 | 5/5 | 79 s | 9.9 m | 1.00, 79 s, 9.9 m | 120 s | | |
| | Chilling the yogurt | 2 | 1.00 | 5/5 | 118 s | 14.2 m | 1.00, 118 s, 14.2 m | 180 s | | |
| | Getting the juice | 2 | 1.00 | 5/5 | 118 s | 12.1 m | 1.00, 118 s, 12.1 m | 180 s | | |
| | Opening the microwave | 1 | 1.00 | 5/5 | 12 s | 2.2 m | 1.00, 12 s, 2.2 m | 30 s | | |
| | Closing the microwave | 1 | 1.00 | 5/5 | 15 s | 2.5 m | 1.00, 15 s, 2.5 m | 30 s | | |
| | Serving a cold drink | 2 | 1.00 | 5/5 | 121 s | 13.0 m | 1.00, 121 s, 13.0 m | 190 s | | |
| | Making breakfast | 4 | 1.00 | 5/5 | 182 s | 20.7 m | 1.00, 182 s, 20.7 m | 280 s | | |
| | Stocking the fridge | 4 | 1.00 | 5/5 | 219 s | 27.1 m | 1.00, 219 s, 27.1 m | 330 s | | |
| | Tidying up after dinner | 6 | 1.00 | 5/5 | 301 s | 33.0 m | 1.00, 315 s, 37.9 m | 460 s | | |
| | **All** | 53 | 1.00 | 100% | | | | | | |
| The door and drawer tasks move one object at most, so both ways come to the same. | |
| ## The learned policy | |
| | | | | |
| |---|---| | |
| | Task | lift an object from a table in front of one arm | | |
| | Inputs | the arm's 6 joint angles; the object's position from the arm's shoulder, its size, and a box's yaw (no camera images) | | |
| | Output | 6 joint targets, in chunks of 50 at 50 Hz, 25 executed per inference | | |
| | Data | 900 scripted picks in the tabletop scene, on MuJoCo-GS-Web's blocks and balls with random sizes, made in Node with the page's own physics (`tools/gen_demos.mjs`) | | |
| | Model | LeRobot ACT, 4.2 M parameters at inference, exported to ONNX (17 MB) | | |
| | Check | the ONNX graph matches LeRobot's own inference within 3e-6 rad | | |
| | Success | 75 of 100 unseen tabletop layouts (the scripted demonstrator manages 83%); in the kitchen, after the go-to skill, 2 of 3 objects | | |
| One policy serves both arms: its inputs are relative to the arm that acts. | |
| ## Perception with Gemini 4 Hydrogen | |
| `locate` is built on Google DeepMind's [Gemini Robotics plugin](https://github.com/google-deepmind/robotics-antigravity-plugin), | |
| the skills its agents use to control robots, and on Gemini 4 Hydrogen (`gemini-4-hydrogen`), the model the | |
| plugin runs on. It does what the plugin's | |
| [rgb-object-localization](https://github.com/google-deepmind/robotics-antigravity-plugin/tree/main/plugins/robotics/skills/rgb-object-localization) | |
| skill does, in the page (`src/agent/perception.js`): | |
| 1. **2D detection by Gemini.** A robot camera's picture (head, or a wrist) goes to Gemini 4 Hydrogen with Google's | |
| pointing prompt for robotics, asking for each match's label, point `[y, x]` and box `[ymin, xmin, ymax, xmax]` | |
| on a 0–1000 grid, the skill's format, at thinking level `low` as the skill sets it (`high` for clutter). | |
| 2. **Metric 3D through the camera**, whose pose and lens the simulation knows exactly: | |
| - `depth`, the head camera's default: XLeRobot's head camera can be a RealSense RGB-D camera, and a ray into | |
| the physics scene stands in for its depth (the robot's own geoms skipped; the middle of five rays within | |
| the box), moved back by half the object's width to its middle. | |
| - `plane`, the wrist cameras' default (RGB only): the skill's ray–plane mapping. The ray through the bottom | |
| of the box meets the surface the object stands on (the room's furniture is the map), and the box's size | |
| there gives the object's width and height. | |
| 3. **Positions for the skills**: each match comes back with `at`, its position `[forward, left, up]`, which | |
| `pick`, `place`, `go_to` and `look_at` take in place of a name, and the picture with the matches drawn on it. | |
| With the true points and boxes in place of Gemini's answers (112 objects in view of the head camera in the | |
| kitchen's 21 tasks, two instances each), `depth` lands 1.6 cm from the object's middle at the median and | |
| within 3.0 cm for 9 in 10, `plane` 1.9 cm and 5.4 cm; the nearest object to the point was the right one 111 | |
| times of 112 with `depth` (the miss: an orange 4.5 m away behind the island) and 112 of 112 with `plane`. | |
| How close Gemini's own points come is not measured here. | |
| - **Camera only** (Agent tab, Perception): an agent's `observe` leaves the objects out, and names do not | |
| work for them; it finds them with `locate`, looking around with `look_at` and `turn`. The fixtures (the | |
| counters, the fridge, the drawer) keep their names, as a map of the home would give them, and the Skills | |
| tab still names everything. | |
| - **The key**: a Gemini API key from [Google AI Studio](https://aistudio.google.com/apikey), under | |
| Perception. It stays in this browser and goes only to `generativelanguage.googleapis.com`. For Claude | |
| Code, set `GEMINI_API_KEY` for the MCP server, as the plugin's skills take it. | |
| - **Without a key**, `locate` maps the points an agent gives it in a camera's last picture, the skill's | |
| fallback when there is no key: Claude Code looks at the picture itself. | |
| - **Gemini as the agent**: with Provider set to Gemini, Gemini 4 Hydrogen drives the robot too (function | |
| calling with `generateContent`; its turns, with their thought signatures, go back as they came). | |
| ## Claude Code (MCP) | |
| Claude Code, or another MCP client, can drive the robot in this page from your computer. | |
| `tools/mcp/server.mjs` (Node 18 or later, no dependencies) is an MCP server over stdio that also listens | |
| on `127.0.0.1:8770`, where it serves the page: `open_sim` opens `http://127.0.0.1:8770/index.html?bridge=8770` | |
| in your browser, a copy of this Space's page that the server fetches from the Space as the browser asks | |
| for it. The page connects to the server over a WebSocket when its URL has `?bridge` (or `?bridge=PORT`), or | |
| when you press Connect in the Agent tab, under Claude Code (MCP); each call then runs in the page with the | |
| agent's tools, one at a time, and the Agent tab lists them. In this folder, `.mcp.json` adds the server | |
| and `.claude/skills/xlerobot-sim/` tells Claude how to use it: | |
| ```bash | |
| claude # in this folder; approve the xlerobot-sim server once | |
| > Open the simulation, set up the task "Chilling the yogurt" and do it. | |
| ``` | |
| Anywhere else, add the server yourself (the file also runs on its own): | |
| ```bash | |
| curl -LO https://huggingface.co/spaces/VectorW/xlerobot-sim/resolve/main/tools/mcp/server.mjs | |
| claude mcp add xlerobot-sim -- node "$PWD/server.mjs" | |
| ``` | |
| | Tools | | | |
| |---|---| | |
| | `status`, `open_sim` | whether a page is connected, its scene and tasks; open the page in the default browser and wait for it | | |
| | `observe`, `task` | the robot, the objects, the fixtures and the task in progress, from the page's agent | | |
| | `go_to`, `drive`, `turn`, `pick`, `place`, `press`, `open`, `close`, `gripper`, `move_arm`, `home_arms`, `look_at`, `wait` | the agent's skills | | |
| | `camera` | a picture from the head or a wrist camera, or of the main view | | |
| | `locate` | objects in a camera's picture, by Gemini 4 Hydrogen (with `GEMINI_API_KEY`) or by the points Claude gives it, as positions the skills take | | |
| | `load_scene`, `reset_scene`, `start_task` | what the Scene and Tasks tabs do | | |
| With `GEMINI_API_KEY` in the server's environment, the server hands the key to the page it accepted, which | |
| asks Gemini with it (and keeps it in memory only while connected). The Gemini Robotics plugin's skills can | |
| go into Claude Code next to this one (`npx skills add google-deepmind/robotics-antigravity-plugin`); the | |
| xlerobot-sim skill says which of them apply here. | |
| Only pages from this Space and from localhost may connect (`XLEROBOT_SIM_ORIGINS` adds more origins), | |
| and the server listens on 127.0.0.1 only; a tab that connects replaces the one before. A tab of the Space | |
| itself can connect too, once you let it reach apps on this device: browsers keep a public page from | |
| reaching 127.0.0.1 unless you allow it (Chrome's local network access), which is why `open_sim` serves the | |
| page from the server instead. `XLEROBOT_SIM_URL` points `open_sim` at another copy of the page, such as | |
| `npm run dev`'s, and `XLEROBOT_SIM_PORT` moves the port (a free one is taken when it is in use). A tab | |
| behind others gets no animation frames: while connected, the page steps the physics on a timer and on the | |
| server's ticks instead. | |
| ## How it is built | |
| ``` | |
| assets/robots/ robots: MuJoCo-GS-Web's xlerobot.xml, objects.xml and meshes, plus robot.json | |
| (controller, cameras); index.json lists them | |
| assets/environments/ scenes: MuJoCo-GS-Web's tabletop, UFC and basic, with decor.xml models of the two | |
| splats (tools/make_decor.py) and the tabletop's objects.xml (tools/make_tabletop.py); | |
| kitchen/ (tools/make_kitchen.py); both kitchens' objects come from tools/objects.py | |
| assets/policies/ exported policies | |
| src/core/ loading, scene composition (as MuJoCo-GS-Web's SceneManager), the simulation loop | |
| src/robots/ xlerobot.js (MuJoCo-GS-Web's IK and keys), skills.js, nav.js (the base's map, | |
| planner and path follower), g1.js (the G1's walking policy and keys), generic.js | |
| (uploaded robots) | |
| src/render/ three.js views: toon (outlines in toon.js), lit, 3DGS (Spark) and pixel (pixel.js; | |
| its colours in palette.js); the scenery and its light map layout, shared with the | |
| light baker (statics.js); baked light, probes and shade from above (baked.js); the | |
| photographic room (home.js) | |
| assets/textures/ Lit's photo textures (tools/make_textures.py) | |
| assets/environments/kitchen/home/ the kitchen's photographic room for Lit: home.glb (z up, MuJoCo's | |
| frame), its light map, the sky and home.json (tools/home/) | |
| assets/environments/kitchen/dressing/ its appliance and object models and where they go | |
| (tools/make_appliances.py, make_objects.py; the room is built round the appliances) | |
| tools/home/ the photographic room: dump_layout.mjs (the MuJoCo layout), assets.py (CC0 textures, | |
| models and sky, cached outside the repository), build_home.py and hb.py (the room in | |
| Blender: every geom of the scenery and the fixtures rebuilt in place, then walls, | |
| windows, doors, lamps, sofa, rug, curtains and plants where nothing collides), | |
| bake_home.py (Cycles bake and glTF export), denoise.py, make_home.py (all of it) | |
| src/policy/ ONNX Runtime policy runner | |
| src/tasks/ the pick task's observation; household tasks: BDDL (bddl.js), predicates, instances | |
| and scores (household.js), the scripted demonstrator (solver.js) | |
| src/agent/ the agent's tools (specs.js, tools.js), perception with Gemini (perception.js), the chat | |
| loop (agent.js) with its models (llm.js: OpenAI-compatible; gemini.js; claude.js, with | |
| Anthropic's SDK, loaded when chosen), Hugging Face sign-in, and the page's end of the MCP | |
| bridge (bridge.js) | |
| tools/mcp/ the MCP server for Claude Code and other MCP clients (server.mjs) | |
| tools/, train/ Node checks, demonstrations, dataset, training, ONNX export, publishing | |
| ``` | |
| Scenes are composed as MuJoCo-GS-Web composes them: the environment's XML with `<include>` elements for | |
| the robot and its objects, so the robot behaves as it does there. The static host sends files | |
| uncompressed, so the build ships the WebAssembly runtimes and each robot's meshes gzipped and the page | |
| inflates them. | |
| ## Develop | |
| ```bash | |
| npm install | |
| npm run dev # builds public/ from assets/, then http://localhost:5173 | |
| npm run build # writes dist/, which this Space serves | |
| node tools/gen_demos.mjs 900 demos/pick.jsonl # scripted demonstrations | |
| python train/make_dataset.py demos/pick.jsonl data/pick # LeRobot dataset (lerobot 0.7) | |
| python train/train_policy.py data/pick outputs/act_pick # ACT, about 25 min on a laptop GPU | |
| python train/export_onnx.py outputs/act_pick/checkpoints/050000/pretrained_model assets/policies/xlerobot_pick --dataset data/pick | |
| node tools/eval_policy.mjs assets/policies/xlerobot_pick 100 # unseen tabletop layouts | |
| node tools/eval_kitchen.mjs # go to and pick kitchen objects with the policy | |
| npm run check # teleop, base speed loop, grasps, go-to and pick everywhere, kitchen place, tasks | |
| node tools/eval_tasks.mjs 5 # the household tasks' demonstrator, 5 instances each | |
| npm run check:g1 # the G1 stands, walks, turns, steps sideways and stops | |
| python tools/make_kitchen.py # regenerate the kitchen (then make its photographic room again) | |
| python tools/home/make_home.py # the kitchen's photographic room: Blender 5.1, Cycles on an NVIDIA | |
| # GPU (OptiX), ~10 min; then node tools/build_public.mjs | |
| python tools/make_textures.py # Lit's photo textures from Poly Haven | |
| python tools/make_appliances.py # the kitchen's fridge and microwave from USDCraft-10K (needs usd-core) | |
| python tools/make_objects.py # its objects' scanned models (YCB; needs trimesh) | |
| python tools/make_tabletop.py # regenerate the tabletop's objects | |
| python tools/make_decor.py # remodel the splat scenes (samples their colours) | |
| python tools/make_g1.py # the G1 and its policy from mjswan, set up as mjlab trained it | |
| python tools/publish.py space # upload (needs a Hugging Face write token) | |
| ``` | |
| To add a robot, put its folder under `assets/robots/` with a `robot.json` (see xlerobot's) and list it | |
| in `assets/robots/index.json`. Robots without a controller get actuator sliders. `"colorSpace": "linear"` | |
| says the model's rgba values are linear, as in MuJoCo-GS-Web, whose viewer turns colour management off | |
| (its XLeRobot's white plastic is rgba 0.3); otherwise they are read as MuJoCo shows them. | |
| ## Licenses and credits | |
| - **This Space:** Apache-2.0. | |
| - **Robot model, IK, keyboard map and 3DGS scenes:** [MuJoCo-GS-Web](https://github.com/Vector-Wangel/MuJoCo-GS-Web) | |
| (MIT). The XLeRobot meshes come from [XLeRobot](https://github.com/Vector-Wangel/XLeRobot); its arms | |
| derive from TheRobotStudio's SO-ARM100 (Apache-2.0). | |
| - **Kitchen, and the models of the splat scenes:** made for this Space from MuJoCo primitives, with | |
| procedural textures. The kitchen's photographic room is modelled for this Space in Blender (scripted, | |
| `tools/home/`), its light baked with Cycles and denoised with Intel Open Image Denoise (Apache-2.0). | |
| - **Its textures, models and sky:** [Poly Haven](https://polyhaven.com) (CC0): the herringbone_parquet, | |
| plastered_wall_04, natural_walnut_veneer, smoked_walnut_veneer, white_oak_veneer, long_white_tiles, | |
| rough_linen, curly_teddy_natural, brown_leather and hessian_230 textures; the potted_plant_02, | |
| potted_plant_04, ceramic_vase_01, ceramic_vase_02, wall_clock, modern_ceiling_lamp_01, pot_enamel_01 | |
| and vintage_electric_kettle models; the suburban_garden sky. [ambientCG](https://ambientcg.com) (CC0): | |
| the Marble012 marble (`tools/home/assets.py`). Blender and Cycles (GPL) build and light it; none of | |
| their code is in the page. | |
| - **Lit's photo textures elsewhere:** Poly Haven (CC0): the wood_floor, oak_veneer_01 and | |
| poly_wool_herringbone textures (`assets/textures/sources.json`). | |
| - **Lit's fridge and microwave:** NVIDIA's [USDCraft-10K](https://huggingface.co/datasets/nvidia/USDCraft-10K) | |
| (Apache-2.0; C. Zhang et al., "USDCraft: Geometrically Grounded Programmatic Modeling of Articulated 3D | |
| Assets for Simulation", arXiv:2610.11322): the top-freezer refrigerator (ds_R002_01) and the stainless | |
| inverter microwave (ds_R001_02), converted to glTF in parts, without their handles or the fridge's | |
| liner, shelves and door bins, their boxes' edges bevelled (`tools/make_appliances.py`). | |
| - **Lit's object models:** scans from the [YCB Object and Model Set](http://ycbbenchmarks.com) (B. Calli et | |
| al., CC BY 4.0): the apple, orange, lemon, banana, master chef can, tomato soup can, mug, bowl, plate | |
| and mustard bottle, reduced to 1024-pixel textures (`tools/make_objects.py`). | |
| - **Unitree G1:** the model is MuJoCo Menagerie's (BSD-3-Clause, Unitree Robotics; `assets/robots/g1/LICENSE`); | |
| the locomotion policy is mjswan's (Apache-2.0), trained with [mjlab](https://github.com/mujocolab/mjlab). | |
| - **Perception and the Gemini agent:** after Google DeepMind's [Gemini Robotics plugin](https://github.com/google-deepmind/robotics-antigravity-plugin) | |
| (Apache-2.0): `locate` follows its rgb-object-localization skill (the 0–1000 points and boxes from | |
| `gemini-4-hydrogen`, the ray–plane mapping), with Google's pointing prompt for Gemini Robotics. The | |
| models are Google's Gemini 4 Hydrogen, called with your own key. | |
| - **Libraries:** MuJoCo (Apache-2.0), three.js (MIT), Spark (MIT), ONNX Runtime Web (MIT), | |
| huggingface.js (MIT), Anthropic's TypeScript SDK (Apache-2.0); the policy was trained with LeRobot (Apache-2.0). | |