Spaces:
Running
Running
Carry two light objects per trip; grip lock with 10 noslip iterations; gentle turns on curves while carrying
Browse files- README.md +22 -17
- assets/environments/kitchen/scene.xml +0 -0
- assets/environments/kitchen/tasks/index.json +4 -4
- dist/assets/{__vite-browser-external-BMBOnQvz.js → __vite-browser-external-D-Nkj3lU.js} +1 -1
- dist/assets/{index-DozhdMr-.js → index-DJo7AKiw.js} +0 -0
- dist/assets/{ort.wasm.bundle.min-je0PFEmG.js → ort.wasm.bundle.min-D8L_Sl8J.js} +0 -0
- dist/assets/{spark.module-CYH_ONPA.js → spark.module-C-deHUr4.js} +1 -1
- dist/environments/kitchen/scene.xml +0 -0
- dist/environments/kitchen/tasks/index.json +4 -4
- dist/index.html +1 -1
- src/agent/agent.js +1 -0
- src/agent/tools.js +6 -1
- src/robots/nav.js +14 -13
- src/robots/skills.js +25 -6
- src/robots/xlerobot.js +11 -3
- src/tasks/household.js +7 -0
- src/tasks/solver.js +132 -32
- tools/eval_tasks.mjs +3 -2
- tools/make_kitchen.py +1 -1
README.md
CHANGED
|
@@ -66,10 +66,10 @@ The robot model, its inverse kinematics and keyboard map, and the 3D Gaussian sp
|
|
| 66 |
out over the object, and the grasp is one motion from there (over, down, close, lift). Putting
|
| 67 |
something down is one motion too (over the spot and down; then out along the gripper, up and back to
|
| 68 |
rest), and the jaws open wide if the object is still between them. Picking an object out of reach
|
| 69 |
-
drives there first. A grasp closes across the object's narrow side
|
| 70 |
-
|
| 71 |
-
gripper squeezes something, MuJoCo's noslip solver
|
| 72 |
-
(`src/robots/xlerobot.js`).
|
| 73 |
- **Run a learned policy**: an ACT policy trained with LeRobot picks objects, in your browser with ONNX
|
| 74 |
Runtime Web.
|
| 75 |
- **Give the robot instructions in words**: an LLM agent calls the skills as tools. Sign in with Hugging
|
|
@@ -113,7 +113,8 @@ The robot model, its inverse kinematics and keyboard map, and the 3D Gaussian sp
|
|
| 113 |
face the start of the run in first. Once it has a way, the search goes on a little for a cheaper one.
|
| 114 |
4. **Driving it.** Pure pursuit on the path at up to 0.4 m/s, speeding up and slowing down smoothly,
|
| 115 |
slower near furniture and before bends, with turns in place at up to 1.6 rad/s that end on the
|
| 116 |
-
planned heading.
|
|
|
|
| 117 |
ahead, the base checks the pose it is heading for and stops before one that would touch; then it
|
| 118 |
folds the arm back and plans again from where it is.
|
| 119 |
|
|
@@ -146,26 +147,30 @@ the kitchen (`src/tasks/`, `assets/environments/kitchen/tasks/`).
|
|
| 146 |
- **A scripted demonstrator** (`src/tasks/solver.js`) does each task with the skills: for every
|
| 147 |
condition that does not hold, it picks the object up and puts it where the condition says (at a free
|
| 148 |
spot of a surface an arm reaches, next to what a `nextto` names, or let go over a container), or
|
| 149 |
-
presses the switch.
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
- **Unlike the challenge**: there is one scene; things start where XLeRobot's arms reach (about 11 cm
|
| 152 |
past the edge of a counter the base stands at, between 0.6 and 0.9 m up), so no task asks for the
|
| 153 |
floor, the fridge or the back of the counter; and the demonstrator and the agent see the simulation's
|
| 154 |
state (where things are), not only the cameras.
|
| 155 |
|
| 156 |
The demonstrator over five instances of each task (`node tools/eval_tasks.mjs 5`; means over the
|
| 157 |
-
instances):
|
| 158 |
|
| 159 |
-
| Task | Goal conditions | Q | Success | Time | Base travelled |
|
| 160 |
|---|---|---|---|---|---|---|---|
|
| 161 |
-
| Turning on the radio | 1 | 1.00 | 5/5 | 14 s | 3.1 m |
|
| 162 |
-
| Picking up trash | 3 | 1.00 | 5/5 |
|
| 163 |
-
| Clearing the table | 3 | 1.00 | 5/5 |
|
| 164 |
-
| Making a fruit bowl | 3 | 1.00 | 5/5 |
|
| 165 |
-
| Putting away groceries | 3 | 1.00 | 5/5 |
|
| 166 |
-
| Setting the table | 4 |
|
| 167 |
-
| Preparing a snack | 3 | 1.00 | 5/5 |
|
| 168 |
-
| Tidying up the kitchen | 5 |
|
| 169 |
| **All** | 25 | 0.99 | 98% | | | | |
|
| 170 |
|
| 171 |
## The learned policy
|
|
|
|
| 66 |
out over the object, and the grasp is one motion from there (over, down, close, lift). Putting
|
| 67 |
something down is one motion too (over the spot and down; then out along the gripper, up and back to
|
| 68 |
rest), and the jaws open wide if the object is still between them. Picking an object out of reach
|
| 69 |
+
drives there first. A grasp closes across the object's narrow side however it lies: a box turned any
|
| 70 |
+
way, a banana or a bottle lying down, a mug clear of its handle. A held object stays put: while a
|
| 71 |
+
gripper squeezes something, MuJoCo's noslip solver (ten iterations; with three, an object lifted high
|
| 72 |
+
still creeps out as the base turns) keeps it from creeping out of the jaws (`src/robots/xlerobot.js`).
|
| 73 |
- **Run a learned policy**: an ACT policy trained with LeRobot picks objects, in your browser with ONNX
|
| 74 |
Runtime Web.
|
| 75 |
- **Give the robot instructions in words**: an LLM agent calls the skills as tools. Sign in with Hugging
|
|
|
|
| 113 |
face the start of the run in first. Once it has a way, the search goes on a little for a cheaper one.
|
| 114 |
4. **Driving it.** Pure pursuit on the path at up to 0.4 m/s, speeding up and slowing down smoothly,
|
| 115 |
slower near furniture and before bends, with turns in place at up to 1.6 rad/s that end on the
|
| 116 |
+
planned heading. With something in a gripper, gently: up to 0.22 m/s and 0.45 rad/s, and turns that
|
| 117 |
+
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
|
| 118 |
ahead, the base checks the pose it is heading for and stops before one that would touch; then it
|
| 119 |
folds the arm back and plans again from where it is.
|
| 120 |
|
|
|
|
| 147 |
- **A scripted demonstrator** (`src/tasks/solver.js`) does each task with the skills: for every
|
| 148 |
condition that does not hold, it picks the object up and puts it where the condition says (at a free
|
| 149 |
spot of a surface an arm reaches, next to what a `nextto` names, or let go over a container), or
|
| 150 |
+
presses the switch. It uses both hands: when another object goes to the same place or near it (within
|
| 151 |
+
1.2 m), the other hand picks that one up before the robot goes there, so one trip carries two. Only
|
| 152 |
+
light objects (100 g at most, and not balls) share a trip: a heavier one (the juice box, the yogurt
|
| 153 |
+
pot, the bottle) creeps along the fingers and tilts over the long carry, and a ball rolls out. The
|
| 154 |
+
agent gets the same tools (`observe` lists the fixtures and the task, `place` takes a fixture,
|
| 155 |
+
`press`, `task`).
|
| 156 |
- **Unlike the challenge**: there is one scene; things start where XLeRobot's arms reach (about 11 cm
|
| 157 |
past the edge of a counter the base stands at, between 0.6 and 0.9 m up), so no task asks for the
|
| 158 |
floor, the fridge or the back of the counter; and the demonstrator and the agent see the simulation's
|
| 159 |
state (where things are), not only the cameras.
|
| 160 |
|
| 161 |
The demonstrator over five instances of each task (`node tools/eval_tasks.mjs 5`; means over the
|
| 162 |
+
instances), carrying two objects at a time where it can, and one at a time (`ONE_HAND=1`):
|
| 163 |
|
| 164 |
+
| Task | Goal conditions | Q | Success | Time | Base travelled | One at a time: Q, time, base | Time limit |
|
| 165 |
|---|---|---|---|---|---|---|---|
|
| 166 |
+
| Turning on the radio | 1 | 1.00 | 5/5 | 14 s | 3.1 m | 1.00, 14 s, 3.1 m | 30 s |
|
| 167 |
+
| Picking up trash | 3 | 1.00 | 5/5 | 125 s | 16.6 m | 0.87, 114 s, 17.8 m | 190 s |
|
| 168 |
+
| Clearing the table | 3 | 1.00 | 5/5 | 131 s | 17.6 m | 1.00, 148 s, 23.2 m | 200 s |
|
| 169 |
+
| Making a fruit bowl | 3 | 1.00 | 5/5 | 108 s | 13.0 m | 1.00, 110 s, 12.9 m | 170 s |
|
| 170 |
+
| Putting away groceries | 3 | 1.00 | 5/5 | 111 s | 16.0 m | 1.00, 111 s, 16.1 m | 170 s |
|
| 171 |
+
| Setting the table | 4 | 1.00 | 5/5 | 67 s | 7.1 m | 0.90, 86 s, 10.7 m | 110 s |
|
| 172 |
+
| Preparing a snack | 3 | 1.00 | 5/5 | 83 s | 9.4 m | 1.00, 96 s, 13.3 m | 130 s |
|
| 173 |
+
| Tidying up the kitchen | 5 | 0.96 | 4/5 | 171 s | 22.1 m | 0.96, 173 s, 22.0 m | 260 s |
|
| 174 |
| **All** | 25 | 0.99 | 98% | | | | |
|
| 175 |
|
| 176 |
## The learned policy
|
assets/environments/kitchen/scene.xml
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
assets/environments/kitchen/tasks/index.json
CHANGED
|
@@ -236,14 +236,14 @@
|
|
| 236 |
"title": "Clearing the table",
|
| 237 |
"file": "clearing_the_table.bddl",
|
| 238 |
"instruction": "Clear the dining table: put the cup and the mug in the sink, and throw the empty blue can in the trash.",
|
| 239 |
-
"timeLimit":
|
| 240 |
},
|
| 241 |
{
|
| 242 |
"id": "making_a_fruit_bowl",
|
| 243 |
"title": "Making a fruit bowl",
|
| 244 |
"file": "making_a_fruit_bowl.bddl",
|
| 245 |
"instruction": "Put the apple, the orange and the lemon in the bowl.",
|
| 246 |
-
"timeLimit":
|
| 247 |
},
|
| 248 |
{
|
| 249 |
"id": "putting_away_groceries",
|
|
@@ -257,14 +257,14 @@
|
|
| 257 |
"title": "Setting the table",
|
| 258 |
"file": "setting_the_table.bddl",
|
| 259 |
"instruction": "Set the table: put the mug and the cup on the dining table, next to the plate.",
|
| 260 |
-
"timeLimit":
|
| 261 |
},
|
| 262 |
{
|
| 263 |
"id": "preparing_a_snack",
|
| 264 |
"title": "Preparing a snack",
|
| 265 |
"file": "preparing_a_snack.bddl",
|
| 266 |
"instruction": "Put the banana on the plate on the dining table and the cup next to the plate, and turn on the radio.",
|
| 267 |
-
"timeLimit":
|
| 268 |
},
|
| 269 |
{
|
| 270 |
"id": "tidying_up_the_kitchen",
|
|
|
|
| 236 |
"title": "Clearing the table",
|
| 237 |
"file": "clearing_the_table.bddl",
|
| 238 |
"instruction": "Clear the dining table: put the cup and the mug in the sink, and throw the empty blue can in the trash.",
|
| 239 |
+
"timeLimit": 200
|
| 240 |
},
|
| 241 |
{
|
| 242 |
"id": "making_a_fruit_bowl",
|
| 243 |
"title": "Making a fruit bowl",
|
| 244 |
"file": "making_a_fruit_bowl.bddl",
|
| 245 |
"instruction": "Put the apple, the orange and the lemon in the bowl.",
|
| 246 |
+
"timeLimit": 170
|
| 247 |
},
|
| 248 |
{
|
| 249 |
"id": "putting_away_groceries",
|
|
|
|
| 257 |
"title": "Setting the table",
|
| 258 |
"file": "setting_the_table.bddl",
|
| 259 |
"instruction": "Set the table: put the mug and the cup on the dining table, next to the plate.",
|
| 260 |
+
"timeLimit": 110
|
| 261 |
},
|
| 262 |
{
|
| 263 |
"id": "preparing_a_snack",
|
| 264 |
"title": "Preparing a snack",
|
| 265 |
"file": "preparing_a_snack.bddl",
|
| 266 |
"instruction": "Put the banana on the plate on the dining table and the cup next to the plate, and turn on the radio.",
|
| 267 |
+
"timeLimit": 130
|
| 268 |
},
|
| 269 |
{
|
| 270 |
"id": "tidying_up_the_kitchen",
|
dist/assets/{__vite-browser-external-BMBOnQvz.js → __vite-browser-external-D-Nkj3lU.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{Y as e}from"./index-
|
|
|
|
| 1 |
+
import{Y as e}from"./index-DJo7AKiw.js";var t=e(((e,t)=>{t.exports={}}));export default t();
|
dist/assets/{index-DozhdMr-.js → index-DJo7AKiw.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{ort.wasm.bundle.min-je0PFEmG.js → ort.wasm.bundle.min-D8L_Sl8J.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{spark.module-CYH_ONPA.js → spark.module-C-deHUr4.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,_ as ee,a as te,b as ne,c as S,d as C,f as w,g as re,h as ie,i as ae,j as oe,k as se,l as ce,m as le,n as T,o as ue,p as de,q as fe,r as pe,s as me,t as he,u as ge,v as _e,w as ve,x as ye,y as be,z as xe}from"./index-DozhdMr-.js";var Se=new e(-1,1,1,-1,0,1),Ce=new class extends ue{constructor(){super(),this.setAttribute(`position`,new ie([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new ie([0,2,0,0,2,0],2))}},we=class{constructor(e){this._mesh=new i(Ce,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Se)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},E=Uint8Array,Te=Uint16Array,Ee=Int32Array,De=new E([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Oe=new E([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ke=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ae=function(e,t){for(var n=new Te(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new Ee(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},je=Ae(De,2),Me=je.b,Ne=je.r;Me[28]=258,Ne[258]=28;var Pe=Ae(Oe,0),Fe=Pe.b;Pe.r;for(var Ie=new Te(32768),D=0;D<32768;++D){var Le=(D&43690)>>1|(D&21845)<<1;Le=(Le&52428)>>2|(Le&13107)<<2,Le=(Le&61680)>>4|(Le&3855)<<4,Ie[D]=((Le&65280)>>8|(Le&255)<<8)>>1}for(var Re=(function(e,t,n){for(var r=e.length,i=0,a=new Te(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new Te(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new Te(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Ie[d]>>c]=l}else for(s=new Te(r),i=0;i<r;++i)e[i]&&(s[i]=Ie[o[e[i]-1]++]>>15-e[i]);return s}),ze=new E(288),D=0;D<144;++D)ze[D]=8;for(var D=144;D<256;++D)ze[D]=9;for(var D=256;D<280;++D)ze[D]=7;for(var D=280;D<288;++D)ze[D]=8;for(var Be=new E(32),D=0;D<32;++D)Be[D]=5;var Ve=Re(ze,9,1),He=Re(Be,5,1),Ue=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},O=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},We=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ge=function(e){return(e+7)/8|0},Ke=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new E(e.subarray(t,n))},qe=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],k=function(e,t,n){var r=Error(t||qe[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,k),!n)throw r;return r},Je=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new E(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new E(i*3));var l=function(e){var t=n.length;if(e>t){var r=new E(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=O(e,d,1);var v=O(e,d+1,3);if(d+=3,!v){var y=Ge(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&k(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=Ve,m=He,h=9,g=5;else if(v==2){var ee=O(e,d,31)+257,te=O(e,d+10,15)+4,ne=ee+O(e,d+5,31)+1;d+=14;for(var S=new E(ne),C=new E(19),w=0;w<te;++w)C[ke[w]]=O(e,d+w*3,7);d+=te*3;for(var re=Ue(C),ie=(1<<re)-1,ae=Re(C,re,1),w=0;w<ne;){var oe=ae[O(e,d,ie)];d+=oe&15;var y=oe>>4;if(y<16)S[w++]=y;else{var se=0,ce=0;for(y==16?(ce=3+O(e,d,3),d+=2,se=S[w-1]):y==17?(ce=3+O(e,d,7),d+=3):y==18&&(ce=11+O(e,d,127),d+=7);ce--;)S[w++]=se}}var le=S.subarray(0,ee),T=S.subarray(ee);h=Ue(le),g=Ue(T),p=Re(le,h,1),m=Re(T,g,1)}else k(1);if(d>_){c&&k(0);break}}s&&l(f+131072);for(var ue=(1<<h)-1,de=(1<<g)-1,fe=d;;fe=d){var se=p[We(e,d)&ue],pe=se>>4;if(d+=se&15,d>_){c&&k(0);break}if(se||k(2),pe<256)n[f++]=pe;else if(pe==256){fe=d,p=null;break}else{var me=pe-254;if(pe>264){var w=pe-257,he=De[w];me=O(e,d,(1<<he)-1)+Me[w],d+=he}var ge=m[We(e,d)&de],_e=ge>>4;ge||k(3),d+=ge&15;var T=Fe[_e];if(_e>3){var he=Oe[_e];T+=We(e,d)&(1<<he)-1,d+=he}if(d>_){c&&k(0);break}s&&l(f+131072);var ve=f+me;if(f<T){var ye=a-T,be=Math.min(T,ve);for(ye+f<0&&k(3);f<be;++f)n[f]=r[ye+f]}for(;f<ve;++f)n[f]=n[f-T]}}t.l=p,t.p=fe,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Ke(n,0,f):n.subarray(0,f)},Ye=new E(0),A=function(e,t){return e[t]|e[t+1]<<8},j=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Xe=function(e,t){return j(e,t)+j(e,t+4)*4294967296},Ze=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&k(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Qe=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new E(32768),this.p=new E(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||k(5),this.d&&k(4),!this.p.length)this.p=e;else if(e.length){var t=new E(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=Je(this.p,this.s,this.o);this.ondata(Ke(n,t,this.s.b),this.d),this.o=Ke(n,this.s.b-32768),this.s.b=this.o.length,this.p=Ke(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();function $e(e,t){return Je(e,{i:2},t&&t.out,t&&t.dictionary)}var et=function(){function e(e,t){this.v=1,this.r=0,Qe.call(this,e,t)}return e.prototype.push=function(e,t){if(Qe.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),r=n.length>3?Ze(n):4;if(r>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(r),this.v=0}Qe.prototype.c.call(this,t),this.s.f&&!this.s.l&&!t&&(this.v=Ge(this.s.p)+9,this.s={i:0},this.o=new E(0),this.push(new E(0),t))},e}(),tt=typeof TextDecoder<`u`&&new TextDecoder;try{tt.decode(Ye,{stream:!0})}catch{}var nt=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Ke(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function rt(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(tt)return tt.decode(e);var i=nt(e),a=i.s,n=i.r;return n.length&&k(8),a}var it=function(e,t){return t+30+A(e,t+26)+A(e,t+28)},at=function(e,t,n){var r=A(e,t+28),i=rt(e.subarray(t+46,t+46+r),!(A(e,t+8)&2048)),a=t+46+r,o=j(e,t+20),s=n&&o==4294967295?ot(e,a):[o,j(e,t+24),j(e,t+42)],c=s[0],l=s[1],u=s[2];return[A(e,t+10),c,l,i,a+A(e,t+30)+A(e,t+32),u]},ot=function(e,t){for(;A(e,t)!=1;t+=4+A(e,t+2));return[Xe(e,t+12),Xe(e,t+4),Xe(e,t+20)]};function st(e,t){for(var n={},r=e.length-22;j(e,r)!=101010256;--r)(!r||e.length-r>65558)&&k(13);var i=A(e,r+8);if(!i)return{};var a=j(e,r+16),o=a==4294967295||i==65535;if(o){var s=j(e,r-12);o=j(e,s)==101075792,o&&(i=j(e,s+32),a=j(e,s+48))}for(var c=t&&t.filter,l=0;l<i;++l){var u=at(e,a,o),d=u[0],f=u[1],p=u[2],m=u[3],h=u[4],g=u[5],_=it(e,g);a=h,(!c||c({name:m,size:f,originalSize:p,compression:d}))&&(d?d==8?n[m]=$e(e.subarray(_,_+f),{out:new E(p)}):k(14,`unknown compression type `+d):n[m]=Ke(e,_,_+f))}return n}var ct=Math.exp(-30),M=2048,N=2048,P=function(e){return e.PLY=`ply`,e.SPZ=`spz`,e.SPLAT=`splat`,e.KSPLAT=`ksplat`,e.PCSOGS=`pcsogs`,e.PCSOGSZIP=`pcsogszip`,e.RAD=`rad`,e}({}),lt={rgbMin:0,rgbMax:1,lnScaleMin:-12,lnScaleMax:9,sh1Max:1,sh2Max:1,sh3Max:1,lodOpacity:!1};function ut(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`}function dt(e){return e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`}function ft(e){return e===`float`||e===`vec2`||e===`vec3`||e===`vec4`}function pt(e){return e===`mat2`||e===`mat2x2`||e===`mat2x3`||e===`mat2x4`||e===`mat3`||e===`mat3x2`||e===`mat3x3`||e===`mat3x4`||e===`mat4`||e===`mat4x2`||e===`mat4x3`||e===`mat4x4`}function mt(e){return ft(e)||pt(e)}function ht(e){return e===`mat2`||e===`mat2x2`}function gt(e){return e===`mat3`||e===`mat3x3`}function _t(e){return e===`mat4`||e===`mat4x4`}function F(e){return Math.trunc(e).toString()}function I(e){return`${Math.max(0,Math.trunc(e)).toString()}u`}function L(e){return e===1/0?`INFINITY`:e===-1/0?`-INFINITY`:Number.isInteger(e)?e.toFixed(1):e.toString()}function vt(e){return e instanceof yt?e.type:e.dynoOut().type}var yt=class{constructor(e){this.__isDynoValue=!0,this.type=e}},R=class extends yt{constructor(e,t){super(e.outTypes[t]),this.dyno=e,this.key=t}},bt=class extends yt{constructor(e,t){super(e),this.literal=t}getLiteral(){return this.literal}},xt=class extends bt{constructor(e,t){super(e,``),this.value=t}getLiteral(){let{type:e,value:t}=this;switch(e){case`bool`:return t?`true`:`false`;case`uint`:return I(t);case`int`:return F(t);case`float`:return L(t);case`bvec2`:{let e=t;return`bvec2(${e[0]}, ${e[1]})`}case`uvec2`:{if(t instanceof x)return`uvec2(${I(t.x)}, ${I(t.y)})`;let e=t;return`uvec2(${I(e[0])}, ${I(e[1])})`}case`ivec2`:{if(t instanceof x)return`ivec2(${F(t.x)}, ${F(t.y)})`;let e=t;return`ivec2(${F(e[0])}, ${F(e[1])})`}case`vec2`:{if(t instanceof x)return`vec2(${L(t.x)}, ${L(t.y)})`;let e=t;return`vec2(${L(e[0])}, ${L(e[1])})`}case`bvec3`:{let e=t;return`bvec3(${e[0]}, ${e[1]}, ${e[2]})`}case`uvec3`:{if(t instanceof o)return`uvec3(${I(t.x)}, ${I(t.y)}, ${I(t.z)})`;let e=t;return`uvec3(${I(e[0])}, ${I(e[1])}, ${I(e[2])})`}case`ivec3`:{if(t instanceof o)return`ivec3(${F(t.x)}, ${F(t.y)}, ${F(t.z)})`;let e=t;return`ivec3(${F(e[0])}, ${F(e[1])}, ${F(e[2])})`}case`vec3`:{if(t instanceof o)return`vec3(${L(t.x)}, ${L(t.y)}, ${L(t.z)})`;let e=t;return`vec3(${L(e[0])}, ${L(e[1])}, ${L(e[2])})`}case`bvec4`:{let e=t;return`bvec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}case`uvec4`:{if(t instanceof u)return`uvec4(${I(t.x)}, ${I(t.y)}, ${I(t.z)}, ${I(t.w)})`;let e=t;return`uvec4(${I(e[0])}, ${I(e[1])}, ${I(e[2])}, ${I(e[3])})`}case`ivec4`:{if(t instanceof u)return`ivec4(${F(t.x)}, ${F(t.y)}, ${F(t.z)}, ${F(t.w)})`;let e=t;return`ivec4(${F(e[0])}, ${F(e[1])}, ${F(e[2])}, ${F(e[3])})`}case`vec4`:{if(t instanceof u||t instanceof f)return`vec4(${L(t.x)}, ${L(t.y)}, ${L(t.z)}, ${L(t.w)})`;let e=t;return`vec4(${L(e[0])}, ${L(e[1])}, ${L(e[2])}, ${L(e[3])})`}case`mat2`:case`mat2x2`:{let r=t,i=r instanceof n?r.elements:t;return`${e}(${[,,,,].fill(0).map((e,t)=>L(i[t])).join(`, `)})`}case`mat2x3`:{let n=t;return`${e}(${[,,,,,,].fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat2x4`:{let n=t;return`${e}(${Array(8).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat3`:case`mat3x3`:{let n=t,r=n instanceof ve?n.elements:t;return`${e}(${Array(9).fill(0).map((e,t)=>L(r[t])).join(`, `)})`}case`mat3x2`:{let n=t;return`${e}(${[,,,,,,].fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat3x4`:{let n=t;return`${e}(${Array(12).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat4`:case`mat4x4`:{let n=t,r=n instanceof v?n.elements:t;return`${e}(${Array(16).fill(0).map((e,t)=>L(r[t])).join(`, `)})`}case`mat4x2`:{let n=t;return`${e}(${Array(8).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat4x3`:{let n=t;return`${e}(${Array(12).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}default:throw Error(`Type not implemented: ${String(e)}`)}}};function St(e,t){return new xt(e,t)}var Ct=` `,wt=class{constructor({indent:e}={}){this.globals=new Set,this.statements=[],this.uniforms={},this.declares=new Set,this.updaters=[],this.sequence=0,this.indent=Ct,this.indent=e??Ct}nextSequence(){return this.sequence++}},z=class{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){this.inTypes=e??{},this.outTypes=t??{},this.inputs=n??{},this.update=r,this.globals=i,this.statements=a,this.generate=o??(({inputs:e,outputs:t,compile:n})=>({globals:this.globals?.({inputs:e,outputs:t,compile:n}),statements:this.statements?.({inputs:e,outputs:t,compile:n})}))}get outputs(){let e={};for(let t in this.outTypes)e[t]=new R(this,t);return e}apply(e){return Object.assign(this.inputs,e),this.outputs}compile({inputs:e,outputs:t,compile:n}){let r=[`// ${this.constructor.name}(${Object.values(e).join(`, `)}) => (${Object.values(t).join(`, `)})`],i=[];for(let e in t){let r=t[e];r&&!n.declares.has(r)&&(n.declares.add(r),i.push(e))}let{globals:a,statements:o,uniforms:s}=this.generate({inputs:e,outputs:t,compile:n});for(let e of a??[])n.globals.add(e);for(let e in s)n.uniforms[e]=s[e];this.update&&n.updaters.push(this.update);for(let e of i){let i=t[e];i&&(n.uniforms[i]||r.push(`${Dt(i,this.outTypes[e])};`))}return o?.length&&(r.push(`{`),r.push(...o.map(e=>n.indent+e)),r.push(`}`)),r}},Tt=class extends z{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,construct:a}){super({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,generate:e=>this.generateBlock(e)}),this.construct=a}generateBlock({inputs:e,outputs:t,compile:n}){let r={},i={};for(let t in e)e[t]!=null&&(r[t]=new bt(this.inTypes[t],e[t]));for(let e in t)t[e]!=null&&(i[e]=new yt(this.outTypes[e]));let a={roots:[]},o=this.construct(r,i,a);for(let r of this.globals?.({inputs:e,outputs:t,compile:n})??[])n.globals.add(r);let s=[],c=new Map;function l(e,t,r){let i=c.get(e);if(!i){i={sequence:n.nextSequence(),outNames:new Map,newOuts:new Set},c.set(e,i);for(let t in e.inputs){let n=e.inputs[t];for(;n;){if(n instanceof yt){n instanceof R&&l(n.dyno,n.key);break}if(typeof n.dynoOut!=`function`)throw Error(`dynoOut is not a function for ${n.constructor.name}`);n=n.dynoOut()}}s.push(e)}t&&(r||i.newOuts.add(t),i.outNames.set(t,r??`${t}_${i.sequence}`))}for(let e of a.roots)l(e);for(let e in i){let n=o?.[e]??i[e];for(;n;){if(n instanceof yt){n instanceof R&&l(n.dyno,n.key,t[e]);break}n=n.dynoOut()}i[e]=n}let u=[];for(let e of s){let t={},r={};for(let n in e.inputs){let r=e.inputs[n];for(;r;){if(r instanceof yt){if(r instanceof bt)t[n]=r.getLiteral();else if(r instanceof R){let e=c.get(r.dyno)?.outNames.get(r.key);if(!e)throw Error(`Source not found for ${r.dyno.constructor.name}.${r.key}`);t[n]=e}break}r=r.dynoOut()}}let i=c.get(e)??{outNames:new Map};for(let[e,t]of i.outNames.entries())r[e]=t;let a=e.compile({inputs:t,outputs:r,compile:n});u.push(a)}let d=[];for(let e in t)i[e]instanceof bt&&d.push(`${t[e]} = ${i[e].getLiteral()};`);return d.length>0&&u.push(d),{statements:u.flatMap((e,t)=>t===0?e:[``,...e])}}};function B(e,t,n,{update:r,globals:i}={}){return new Tt({inTypes:e,outTypes:t,construct:n,update:r,globals:i})}function Et({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){return new z({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o})}function Dt(e,t,n){let r=typeof t==`string`?t:t.type;if(!r)throw Error(`Invalid DynoType: ${String(t)}`);return`${r} ${e}${n==null?``:`[${n}]`}`}function V(e){let t=!1,n=e.split(`
|
| 2 |
`).map(e=>{let n=e.trimEnd();return t?n:n.length>0?(t=!0,n):null}).filter(e=>e!=null);for(;n.length>0&&n[n.length-1].length===0;)n.pop();if(n.length===0)return[];let r=n[0].match(/^\s*/)?.[0];if(!r)return n;let i=RegExp(`^${r}`);return n.map(e=>e.replace(i,``))}function H(e){return V(e).join(`
|
| 3 |
`)}var Ot=class extends z{constructor({a:e,outKey:t,outTypeFunc:n}){let r={a:vt(e)},i=n(vt(e));super({inTypes:r,outTypes:{[t]:i},inputs:{a:e}}),this.outKey=t}dynoOut(){return new R(this,this.outKey)}},kt=class extends z{constructor({a:e,b:t,outKey:n,outTypeFunc:r}){let i={a:vt(e),b:vt(t)},a=r(vt(e),vt(t));super({inTypes:i,outTypes:{[n]:a},inputs:{a:e,b:t}}),this.outKey=n}dynoOut(){return new R(this,this.outKey)}},At=Number.parseInt(`187`)>=179,jt=new Float32Array(1),Mt=new Uint32Array(jt.buffer),Nt=`Float16Array`in globalThis,Pt=Nt?new globalThis.Float16Array(1):null,Ft=new Uint16Array(Pt?.buffer);function It(e){return jt[0]=e,Mt[0]}function Lt(e){return Mt[0]=e,jt[0]}var U=Nt?Rt:zt,W=Nt?Bt:Vt;function Rt(e){return Pt[0]=e,Ft[0]}function zt(e){jt[0]=e;let t=Mt[0],n=t>>31&1,r=t>>23&255,i=t&8388607,a=n<<15;if(r===255)return i===0?a|31744:a|32767;let o=r-127+15;if(o>=31)return a|31744;if(o<=0)return o<-10?a:a|(i|8388608)>>1-o+13;let s=i>>13;return a|o<<10|s}function Bt(e){return Ft[0]=e,Pt[0]}function Vt(e){let t=e>>15&1,n=e>>10&31,r=e&1023,i;if(n===0){if(r===0)i=t<<31;else{let e=r,n=-14;for(;!(e&1024);)e<<=1,n--;e&=1023;let a=n+127,o=e<<13;i=t<<31|a<<23|o}}else if(n===31)i=r===0?t<<31|2139095040:t<<31|2143289344;else{let e=n-15+127,a=r<<13;i=t<<31|e<<23|a}return Mt[0]=i,jt[0]}function Ht(e){return Math.max(0,Math.min(255,Math.round(e*255)))}function Ut(e){let t=[],n=new Set;function r(e){e&&typeof e==`object`&&!n.has(e)&&(n.add(e),e instanceof ArrayBuffer?t.push(e):ArrayBuffer.isView(e)?t.push(e.buffer):Array.isArray(e)?e.forEach(r):Object.values(e).forEach(r))}return r(e),t}function Wt(e,t){return Array(e).fill(null).map((e,n)=>t(n))}function Gt(e,t){let n=0;for(let r of e)t(r)||(e[n++]=r);e.length=n}function Kt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=t*4,[_,v]=e;_[g]=It(n),_[g+1]=It(r),_[g+2]=It(i),_[g+3]=U(f),v[g]=U(p)|U(m)<<16,v[g+1]=U(h)|U(Math.log(a))<<16,v[g+2]=U(Math.log(o))|U(Math.log(s))<<16,v[g+3]=ln(c,l,u,d)}function qt(e,t){let n=Xt,r=t*4,[i,a]=e;return n.center.x=Lt(i[r]),n.center.y=Lt(i[r+1]),n.center.z=Lt(i[r+2]),n.opacity=W(i[r+3]&65535),n.color.r=W(a[r]&65535),n.color.g=W(a[r]>>>16),n.color.b=W(a[r+1]&65535),n.scales.x=Math.exp(W(a[r+1]>>>16)),n.scales.y=Math.exp(W(a[r+2]&65535)),n.scales.z=Math.exp(W(a[r+2]>>>16)),un(a[r+3],n.quaternion),n}function Jt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=g?.rgbMin??0,v=(g?.rgbMax??1)-_,y=Ht((p-_)/v),b=Ht((m-_)/v),x=Ht((h-_)/v),ee=Ht(g?.lodOpacity?.5*f:f),te=sn(Yt.set(c,l,u,d)),ne=te&255,S=te>>>8&255,C=te>>>16&255,w=g?.lnScaleMin??-12,re=254/((g?.lnScaleMax??9)-w),ie=a<ct?0:Math.min(255,Math.max(1,Math.round((Math.log(a)-w)*re)+1)),ae=o<ct?0:Math.min(255,Math.max(1,Math.round((Math.log(o)-w)*re)+1)),oe=s<ct?0:Math.min(255,Math.max(1,Math.round((Math.log(s)-w)*re)+1)),se=U(n),ce=U(r),le=U(i),T=t*4;e[T]=y|b<<8|x<<16|ee<<24,e[T+1]=se|ce<<16,e[T+2]=le|ne<<16|S<<24,e[T+3]=ie|ae<<8|oe<<16|C<<24}var Yt=new f,Xt={center:new o,scales:new o,quaternion:new f,color:new S,opacity:0};function Zt(e,t,n){let r=Xt,i=t*4,a=e[i],o=e[i+1],s=e[i+2],c=e[i+3],l=n?.rgbMin??0,u=(n?.rgbMax??1)-l;r.color.set(l+(a&255)/255*u,l+(a>>>8&255)/255*u,l+(a>>>16&255)/255*u),r.opacity=(a>>>24&255)/255,n?.lodOpacity&&(r.opacity=2*r.opacity),r.center.set(W(o&65535),W(o>>>16&65535),W(s&65535));let d=n?.lnScaleMin??-12,f=((n?.lnScaleMax??9)-d)/254,p=c&255;r.scales.x=p===0?0:Math.exp(d+(p-1)*f);let m=c>>>8&255;r.scales.y=m===0?0:Math.exp(d+(m-1)*f);let h=c>>>16&255;return r.scales.z=h===0?0:Math.exp(d+(h-1)*f),cn(s>>>16&65535|c>>>8&16711680,r.quaternion),r}function G(e){let t=M,n=Math.max(1,Math.min(N,Math.ceil(e/t))),r=Math.ceil(e/(t*n));return{width:t,height:n,depth:r,maxSplats:t*n*r}}function Qt(){return navigator.platform.toLowerCase().startsWith(`win`)?!1:navigator.maxTouchPoints>0||/Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/.test(navigator.userAgent)}function $t(){return/Android/.test(navigator.userAgent)||/Tizen/.test(navigator.userAgent)}function en(){return!!navigator.xr&&/Oculus/.test(navigator.userAgent)}function tn(){return/iPhone|iPad/.test(navigator.userAgent)}function nn(){return!!navigator.xr&&tn()&&/Safari/.test(navigator.userAgent)&&Qt()}var rn=H(`
|
| 4 |
precision highp float;
|
|
|
|
| 1 |
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,_ as ee,a as te,b as ne,c as S,d as C,f as w,g as re,h as ie,i as ae,j as oe,k as se,l as ce,m as le,n as T,o as ue,p as de,q as fe,r as pe,s as me,t as he,u as ge,v as _e,w as ve,x as ye,y as be,z as xe}from"./index-DJo7AKiw.js";var Se=new e(-1,1,1,-1,0,1),Ce=new class extends ue{constructor(){super(),this.setAttribute(`position`,new ie([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new ie([0,2,0,0,2,0],2))}},we=class{constructor(e){this._mesh=new i(Ce,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Se)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},E=Uint8Array,Te=Uint16Array,Ee=Int32Array,De=new E([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Oe=new E([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ke=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ae=function(e,t){for(var n=new Te(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new Ee(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},je=Ae(De,2),Me=je.b,Ne=je.r;Me[28]=258,Ne[258]=28;var Pe=Ae(Oe,0),Fe=Pe.b;Pe.r;for(var Ie=new Te(32768),D=0;D<32768;++D){var Le=(D&43690)>>1|(D&21845)<<1;Le=(Le&52428)>>2|(Le&13107)<<2,Le=(Le&61680)>>4|(Le&3855)<<4,Ie[D]=((Le&65280)>>8|(Le&255)<<8)>>1}for(var Re=(function(e,t,n){for(var r=e.length,i=0,a=new Te(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new Te(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new Te(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Ie[d]>>c]=l}else for(s=new Te(r),i=0;i<r;++i)e[i]&&(s[i]=Ie[o[e[i]-1]++]>>15-e[i]);return s}),ze=new E(288),D=0;D<144;++D)ze[D]=8;for(var D=144;D<256;++D)ze[D]=9;for(var D=256;D<280;++D)ze[D]=7;for(var D=280;D<288;++D)ze[D]=8;for(var Be=new E(32),D=0;D<32;++D)Be[D]=5;var Ve=Re(ze,9,1),He=Re(Be,5,1),Ue=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},O=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},We=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ge=function(e){return(e+7)/8|0},Ke=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new E(e.subarray(t,n))},qe=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],k=function(e,t,n){var r=Error(t||qe[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,k),!n)throw r;return r},Je=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new E(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new E(i*3));var l=function(e){var t=n.length;if(e>t){var r=new E(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=O(e,d,1);var v=O(e,d+1,3);if(d+=3,!v){var y=Ge(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&k(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=Ve,m=He,h=9,g=5;else if(v==2){var ee=O(e,d,31)+257,te=O(e,d+10,15)+4,ne=ee+O(e,d+5,31)+1;d+=14;for(var S=new E(ne),C=new E(19),w=0;w<te;++w)C[ke[w]]=O(e,d+w*3,7);d+=te*3;for(var re=Ue(C),ie=(1<<re)-1,ae=Re(C,re,1),w=0;w<ne;){var oe=ae[O(e,d,ie)];d+=oe&15;var y=oe>>4;if(y<16)S[w++]=y;else{var se=0,ce=0;for(y==16?(ce=3+O(e,d,3),d+=2,se=S[w-1]):y==17?(ce=3+O(e,d,7),d+=3):y==18&&(ce=11+O(e,d,127),d+=7);ce--;)S[w++]=se}}var le=S.subarray(0,ee),T=S.subarray(ee);h=Ue(le),g=Ue(T),p=Re(le,h,1),m=Re(T,g,1)}else k(1);if(d>_){c&&k(0);break}}s&&l(f+131072);for(var ue=(1<<h)-1,de=(1<<g)-1,fe=d;;fe=d){var se=p[We(e,d)&ue],pe=se>>4;if(d+=se&15,d>_){c&&k(0);break}if(se||k(2),pe<256)n[f++]=pe;else if(pe==256){fe=d,p=null;break}else{var me=pe-254;if(pe>264){var w=pe-257,he=De[w];me=O(e,d,(1<<he)-1)+Me[w],d+=he}var ge=m[We(e,d)&de],_e=ge>>4;ge||k(3),d+=ge&15;var T=Fe[_e];if(_e>3){var he=Oe[_e];T+=We(e,d)&(1<<he)-1,d+=he}if(d>_){c&&k(0);break}s&&l(f+131072);var ve=f+me;if(f<T){var ye=a-T,be=Math.min(T,ve);for(ye+f<0&&k(3);f<be;++f)n[f]=r[ye+f]}for(;f<ve;++f)n[f]=n[f-T]}}t.l=p,t.p=fe,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Ke(n,0,f):n.subarray(0,f)},Ye=new E(0),A=function(e,t){return e[t]|e[t+1]<<8},j=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Xe=function(e,t){return j(e,t)+j(e,t+4)*4294967296},Ze=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&k(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Qe=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new E(32768),this.p=new E(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||k(5),this.d&&k(4),!this.p.length)this.p=e;else if(e.length){var t=new E(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=Je(this.p,this.s,this.o);this.ondata(Ke(n,t,this.s.b),this.d),this.o=Ke(n,this.s.b-32768),this.s.b=this.o.length,this.p=Ke(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();function $e(e,t){return Je(e,{i:2},t&&t.out,t&&t.dictionary)}var et=function(){function e(e,t){this.v=1,this.r=0,Qe.call(this,e,t)}return e.prototype.push=function(e,t){if(Qe.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),r=n.length>3?Ze(n):4;if(r>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(r),this.v=0}Qe.prototype.c.call(this,t),this.s.f&&!this.s.l&&!t&&(this.v=Ge(this.s.p)+9,this.s={i:0},this.o=new E(0),this.push(new E(0),t))},e}(),tt=typeof TextDecoder<`u`&&new TextDecoder;try{tt.decode(Ye,{stream:!0})}catch{}var nt=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Ke(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function rt(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(tt)return tt.decode(e);var i=nt(e),a=i.s,n=i.r;return n.length&&k(8),a}var it=function(e,t){return t+30+A(e,t+26)+A(e,t+28)},at=function(e,t,n){var r=A(e,t+28),i=rt(e.subarray(t+46,t+46+r),!(A(e,t+8)&2048)),a=t+46+r,o=j(e,t+20),s=n&&o==4294967295?ot(e,a):[o,j(e,t+24),j(e,t+42)],c=s[0],l=s[1],u=s[2];return[A(e,t+10),c,l,i,a+A(e,t+30)+A(e,t+32),u]},ot=function(e,t){for(;A(e,t)!=1;t+=4+A(e,t+2));return[Xe(e,t+12),Xe(e,t+4),Xe(e,t+20)]};function st(e,t){for(var n={},r=e.length-22;j(e,r)!=101010256;--r)(!r||e.length-r>65558)&&k(13);var i=A(e,r+8);if(!i)return{};var a=j(e,r+16),o=a==4294967295||i==65535;if(o){var s=j(e,r-12);o=j(e,s)==101075792,o&&(i=j(e,s+32),a=j(e,s+48))}for(var c=t&&t.filter,l=0;l<i;++l){var u=at(e,a,o),d=u[0],f=u[1],p=u[2],m=u[3],h=u[4],g=u[5],_=it(e,g);a=h,(!c||c({name:m,size:f,originalSize:p,compression:d}))&&(d?d==8?n[m]=$e(e.subarray(_,_+f),{out:new E(p)}):k(14,`unknown compression type `+d):n[m]=Ke(e,_,_+f))}return n}var ct=Math.exp(-30),M=2048,N=2048,P=function(e){return e.PLY=`ply`,e.SPZ=`spz`,e.SPLAT=`splat`,e.KSPLAT=`ksplat`,e.PCSOGS=`pcsogs`,e.PCSOGSZIP=`pcsogszip`,e.RAD=`rad`,e}({}),lt={rgbMin:0,rgbMax:1,lnScaleMin:-12,lnScaleMax:9,sh1Max:1,sh2Max:1,sh3Max:1,lodOpacity:!1};function ut(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`}function dt(e){return e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`}function ft(e){return e===`float`||e===`vec2`||e===`vec3`||e===`vec4`}function pt(e){return e===`mat2`||e===`mat2x2`||e===`mat2x3`||e===`mat2x4`||e===`mat3`||e===`mat3x2`||e===`mat3x3`||e===`mat3x4`||e===`mat4`||e===`mat4x2`||e===`mat4x3`||e===`mat4x4`}function mt(e){return ft(e)||pt(e)}function ht(e){return e===`mat2`||e===`mat2x2`}function gt(e){return e===`mat3`||e===`mat3x3`}function _t(e){return e===`mat4`||e===`mat4x4`}function F(e){return Math.trunc(e).toString()}function I(e){return`${Math.max(0,Math.trunc(e)).toString()}u`}function L(e){return e===1/0?`INFINITY`:e===-1/0?`-INFINITY`:Number.isInteger(e)?e.toFixed(1):e.toString()}function vt(e){return e instanceof yt?e.type:e.dynoOut().type}var yt=class{constructor(e){this.__isDynoValue=!0,this.type=e}},R=class extends yt{constructor(e,t){super(e.outTypes[t]),this.dyno=e,this.key=t}},bt=class extends yt{constructor(e,t){super(e),this.literal=t}getLiteral(){return this.literal}},xt=class extends bt{constructor(e,t){super(e,``),this.value=t}getLiteral(){let{type:e,value:t}=this;switch(e){case`bool`:return t?`true`:`false`;case`uint`:return I(t);case`int`:return F(t);case`float`:return L(t);case`bvec2`:{let e=t;return`bvec2(${e[0]}, ${e[1]})`}case`uvec2`:{if(t instanceof x)return`uvec2(${I(t.x)}, ${I(t.y)})`;let e=t;return`uvec2(${I(e[0])}, ${I(e[1])})`}case`ivec2`:{if(t instanceof x)return`ivec2(${F(t.x)}, ${F(t.y)})`;let e=t;return`ivec2(${F(e[0])}, ${F(e[1])})`}case`vec2`:{if(t instanceof x)return`vec2(${L(t.x)}, ${L(t.y)})`;let e=t;return`vec2(${L(e[0])}, ${L(e[1])})`}case`bvec3`:{let e=t;return`bvec3(${e[0]}, ${e[1]}, ${e[2]})`}case`uvec3`:{if(t instanceof o)return`uvec3(${I(t.x)}, ${I(t.y)}, ${I(t.z)})`;let e=t;return`uvec3(${I(e[0])}, ${I(e[1])}, ${I(e[2])})`}case`ivec3`:{if(t instanceof o)return`ivec3(${F(t.x)}, ${F(t.y)}, ${F(t.z)})`;let e=t;return`ivec3(${F(e[0])}, ${F(e[1])}, ${F(e[2])})`}case`vec3`:{if(t instanceof o)return`vec3(${L(t.x)}, ${L(t.y)}, ${L(t.z)})`;let e=t;return`vec3(${L(e[0])}, ${L(e[1])}, ${L(e[2])})`}case`bvec4`:{let e=t;return`bvec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}case`uvec4`:{if(t instanceof u)return`uvec4(${I(t.x)}, ${I(t.y)}, ${I(t.z)}, ${I(t.w)})`;let e=t;return`uvec4(${I(e[0])}, ${I(e[1])}, ${I(e[2])}, ${I(e[3])})`}case`ivec4`:{if(t instanceof u)return`ivec4(${F(t.x)}, ${F(t.y)}, ${F(t.z)}, ${F(t.w)})`;let e=t;return`ivec4(${F(e[0])}, ${F(e[1])}, ${F(e[2])}, ${F(e[3])})`}case`vec4`:{if(t instanceof u||t instanceof f)return`vec4(${L(t.x)}, ${L(t.y)}, ${L(t.z)}, ${L(t.w)})`;let e=t;return`vec4(${L(e[0])}, ${L(e[1])}, ${L(e[2])}, ${L(e[3])})`}case`mat2`:case`mat2x2`:{let r=t,i=r instanceof n?r.elements:t;return`${e}(${[,,,,].fill(0).map((e,t)=>L(i[t])).join(`, `)})`}case`mat2x3`:{let n=t;return`${e}(${[,,,,,,].fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat2x4`:{let n=t;return`${e}(${Array(8).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat3`:case`mat3x3`:{let n=t,r=n instanceof ve?n.elements:t;return`${e}(${Array(9).fill(0).map((e,t)=>L(r[t])).join(`, `)})`}case`mat3x2`:{let n=t;return`${e}(${[,,,,,,].fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat3x4`:{let n=t;return`${e}(${Array(12).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat4`:case`mat4x4`:{let n=t,r=n instanceof v?n.elements:t;return`${e}(${Array(16).fill(0).map((e,t)=>L(r[t])).join(`, `)})`}case`mat4x2`:{let n=t;return`${e}(${Array(8).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}case`mat4x3`:{let n=t;return`${e}(${Array(12).fill(0).map((e,t)=>L(n[t])).join(`, `)})`}default:throw Error(`Type not implemented: ${String(e)}`)}}};function St(e,t){return new xt(e,t)}var Ct=` `,wt=class{constructor({indent:e}={}){this.globals=new Set,this.statements=[],this.uniforms={},this.declares=new Set,this.updaters=[],this.sequence=0,this.indent=Ct,this.indent=e??Ct}nextSequence(){return this.sequence++}},z=class{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){this.inTypes=e??{},this.outTypes=t??{},this.inputs=n??{},this.update=r,this.globals=i,this.statements=a,this.generate=o??(({inputs:e,outputs:t,compile:n})=>({globals:this.globals?.({inputs:e,outputs:t,compile:n}),statements:this.statements?.({inputs:e,outputs:t,compile:n})}))}get outputs(){let e={};for(let t in this.outTypes)e[t]=new R(this,t);return e}apply(e){return Object.assign(this.inputs,e),this.outputs}compile({inputs:e,outputs:t,compile:n}){let r=[`// ${this.constructor.name}(${Object.values(e).join(`, `)}) => (${Object.values(t).join(`, `)})`],i=[];for(let e in t){let r=t[e];r&&!n.declares.has(r)&&(n.declares.add(r),i.push(e))}let{globals:a,statements:o,uniforms:s}=this.generate({inputs:e,outputs:t,compile:n});for(let e of a??[])n.globals.add(e);for(let e in s)n.uniforms[e]=s[e];this.update&&n.updaters.push(this.update);for(let e of i){let i=t[e];i&&(n.uniforms[i]||r.push(`${Dt(i,this.outTypes[e])};`))}return o?.length&&(r.push(`{`),r.push(...o.map(e=>n.indent+e)),r.push(`}`)),r}},Tt=class extends z{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,construct:a}){super({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,generate:e=>this.generateBlock(e)}),this.construct=a}generateBlock({inputs:e,outputs:t,compile:n}){let r={},i={};for(let t in e)e[t]!=null&&(r[t]=new bt(this.inTypes[t],e[t]));for(let e in t)t[e]!=null&&(i[e]=new yt(this.outTypes[e]));let a={roots:[]},o=this.construct(r,i,a);for(let r of this.globals?.({inputs:e,outputs:t,compile:n})??[])n.globals.add(r);let s=[],c=new Map;function l(e,t,r){let i=c.get(e);if(!i){i={sequence:n.nextSequence(),outNames:new Map,newOuts:new Set},c.set(e,i);for(let t in e.inputs){let n=e.inputs[t];for(;n;){if(n instanceof yt){n instanceof R&&l(n.dyno,n.key);break}if(typeof n.dynoOut!=`function`)throw Error(`dynoOut is not a function for ${n.constructor.name}`);n=n.dynoOut()}}s.push(e)}t&&(r||i.newOuts.add(t),i.outNames.set(t,r??`${t}_${i.sequence}`))}for(let e of a.roots)l(e);for(let e in i){let n=o?.[e]??i[e];for(;n;){if(n instanceof yt){n instanceof R&&l(n.dyno,n.key,t[e]);break}n=n.dynoOut()}i[e]=n}let u=[];for(let e of s){let t={},r={};for(let n in e.inputs){let r=e.inputs[n];for(;r;){if(r instanceof yt){if(r instanceof bt)t[n]=r.getLiteral();else if(r instanceof R){let e=c.get(r.dyno)?.outNames.get(r.key);if(!e)throw Error(`Source not found for ${r.dyno.constructor.name}.${r.key}`);t[n]=e}break}r=r.dynoOut()}}let i=c.get(e)??{outNames:new Map};for(let[e,t]of i.outNames.entries())r[e]=t;let a=e.compile({inputs:t,outputs:r,compile:n});u.push(a)}let d=[];for(let e in t)i[e]instanceof bt&&d.push(`${t[e]} = ${i[e].getLiteral()};`);return d.length>0&&u.push(d),{statements:u.flatMap((e,t)=>t===0?e:[``,...e])}}};function B(e,t,n,{update:r,globals:i}={}){return new Tt({inTypes:e,outTypes:t,construct:n,update:r,globals:i})}function Et({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){return new z({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o})}function Dt(e,t,n){let r=typeof t==`string`?t:t.type;if(!r)throw Error(`Invalid DynoType: ${String(t)}`);return`${r} ${e}${n==null?``:`[${n}]`}`}function V(e){let t=!1,n=e.split(`
|
| 2 |
`).map(e=>{let n=e.trimEnd();return t?n:n.length>0?(t=!0,n):null}).filter(e=>e!=null);for(;n.length>0&&n[n.length-1].length===0;)n.pop();if(n.length===0)return[];let r=n[0].match(/^\s*/)?.[0];if(!r)return n;let i=RegExp(`^${r}`);return n.map(e=>e.replace(i,``))}function H(e){return V(e).join(`
|
| 3 |
`)}var Ot=class extends z{constructor({a:e,outKey:t,outTypeFunc:n}){let r={a:vt(e)},i=n(vt(e));super({inTypes:r,outTypes:{[t]:i},inputs:{a:e}}),this.outKey=t}dynoOut(){return new R(this,this.outKey)}},kt=class extends z{constructor({a:e,b:t,outKey:n,outTypeFunc:r}){let i={a:vt(e),b:vt(t)},a=r(vt(e),vt(t));super({inTypes:i,outTypes:{[n]:a},inputs:{a:e,b:t}}),this.outKey=n}dynoOut(){return new R(this,this.outKey)}},At=Number.parseInt(`187`)>=179,jt=new Float32Array(1),Mt=new Uint32Array(jt.buffer),Nt=`Float16Array`in globalThis,Pt=Nt?new globalThis.Float16Array(1):null,Ft=new Uint16Array(Pt?.buffer);function It(e){return jt[0]=e,Mt[0]}function Lt(e){return Mt[0]=e,jt[0]}var U=Nt?Rt:zt,W=Nt?Bt:Vt;function Rt(e){return Pt[0]=e,Ft[0]}function zt(e){jt[0]=e;let t=Mt[0],n=t>>31&1,r=t>>23&255,i=t&8388607,a=n<<15;if(r===255)return i===0?a|31744:a|32767;let o=r-127+15;if(o>=31)return a|31744;if(o<=0)return o<-10?a:a|(i|8388608)>>1-o+13;let s=i>>13;return a|o<<10|s}function Bt(e){return Ft[0]=e,Pt[0]}function Vt(e){let t=e>>15&1,n=e>>10&31,r=e&1023,i;if(n===0){if(r===0)i=t<<31;else{let e=r,n=-14;for(;!(e&1024);)e<<=1,n--;e&=1023;let a=n+127,o=e<<13;i=t<<31|a<<23|o}}else if(n===31)i=r===0?t<<31|2139095040:t<<31|2143289344;else{let e=n-15+127,a=r<<13;i=t<<31|e<<23|a}return Mt[0]=i,jt[0]}function Ht(e){return Math.max(0,Math.min(255,Math.round(e*255)))}function Ut(e){let t=[],n=new Set;function r(e){e&&typeof e==`object`&&!n.has(e)&&(n.add(e),e instanceof ArrayBuffer?t.push(e):ArrayBuffer.isView(e)?t.push(e.buffer):Array.isArray(e)?e.forEach(r):Object.values(e).forEach(r))}return r(e),t}function Wt(e,t){return Array(e).fill(null).map((e,n)=>t(n))}function Gt(e,t){let n=0;for(let r of e)t(r)||(e[n++]=r);e.length=n}function Kt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=t*4,[_,v]=e;_[g]=It(n),_[g+1]=It(r),_[g+2]=It(i),_[g+3]=U(f),v[g]=U(p)|U(m)<<16,v[g+1]=U(h)|U(Math.log(a))<<16,v[g+2]=U(Math.log(o))|U(Math.log(s))<<16,v[g+3]=ln(c,l,u,d)}function qt(e,t){let n=Xt,r=t*4,[i,a]=e;return n.center.x=Lt(i[r]),n.center.y=Lt(i[r+1]),n.center.z=Lt(i[r+2]),n.opacity=W(i[r+3]&65535),n.color.r=W(a[r]&65535),n.color.g=W(a[r]>>>16),n.color.b=W(a[r+1]&65535),n.scales.x=Math.exp(W(a[r+1]>>>16)),n.scales.y=Math.exp(W(a[r+2]&65535)),n.scales.z=Math.exp(W(a[r+2]>>>16)),un(a[r+3],n.quaternion),n}function Jt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=g?.rgbMin??0,v=(g?.rgbMax??1)-_,y=Ht((p-_)/v),b=Ht((m-_)/v),x=Ht((h-_)/v),ee=Ht(g?.lodOpacity?.5*f:f),te=sn(Yt.set(c,l,u,d)),ne=te&255,S=te>>>8&255,C=te>>>16&255,w=g?.lnScaleMin??-12,re=254/((g?.lnScaleMax??9)-w),ie=a<ct?0:Math.min(255,Math.max(1,Math.round((Math.log(a)-w)*re)+1)),ae=o<ct?0:Math.min(255,Math.max(1,Math.round((Math.log(o)-w)*re)+1)),oe=s<ct?0:Math.min(255,Math.max(1,Math.round((Math.log(s)-w)*re)+1)),se=U(n),ce=U(r),le=U(i),T=t*4;e[T]=y|b<<8|x<<16|ee<<24,e[T+1]=se|ce<<16,e[T+2]=le|ne<<16|S<<24,e[T+3]=ie|ae<<8|oe<<16|C<<24}var Yt=new f,Xt={center:new o,scales:new o,quaternion:new f,color:new S,opacity:0};function Zt(e,t,n){let r=Xt,i=t*4,a=e[i],o=e[i+1],s=e[i+2],c=e[i+3],l=n?.rgbMin??0,u=(n?.rgbMax??1)-l;r.color.set(l+(a&255)/255*u,l+(a>>>8&255)/255*u,l+(a>>>16&255)/255*u),r.opacity=(a>>>24&255)/255,n?.lodOpacity&&(r.opacity=2*r.opacity),r.center.set(W(o&65535),W(o>>>16&65535),W(s&65535));let d=n?.lnScaleMin??-12,f=((n?.lnScaleMax??9)-d)/254,p=c&255;r.scales.x=p===0?0:Math.exp(d+(p-1)*f);let m=c>>>8&255;r.scales.y=m===0?0:Math.exp(d+(m-1)*f);let h=c>>>16&255;return r.scales.z=h===0?0:Math.exp(d+(h-1)*f),cn(s>>>16&65535|c>>>8&16711680,r.quaternion),r}function G(e){let t=M,n=Math.max(1,Math.min(N,Math.ceil(e/t))),r=Math.ceil(e/(t*n));return{width:t,height:n,depth:r,maxSplats:t*n*r}}function Qt(){return navigator.platform.toLowerCase().startsWith(`win`)?!1:navigator.maxTouchPoints>0||/Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/.test(navigator.userAgent)}function $t(){return/Android/.test(navigator.userAgent)||/Tizen/.test(navigator.userAgent)}function en(){return!!navigator.xr&&/Oculus/.test(navigator.userAgent)}function tn(){return/iPhone|iPad/.test(navigator.userAgent)}function nn(){return!!navigator.xr&&tn()&&/Safari/.test(navigator.userAgent)&&Qt()}var rn=H(`
|
| 4 |
precision highp float;
|
dist/environments/kitchen/scene.xml
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/environments/kitchen/tasks/index.json
CHANGED
|
@@ -236,14 +236,14 @@
|
|
| 236 |
"title": "Clearing the table",
|
| 237 |
"file": "clearing_the_table.bddl",
|
| 238 |
"instruction": "Clear the dining table: put the cup and the mug in the sink, and throw the empty blue can in the trash.",
|
| 239 |
-
"timeLimit":
|
| 240 |
},
|
| 241 |
{
|
| 242 |
"id": "making_a_fruit_bowl",
|
| 243 |
"title": "Making a fruit bowl",
|
| 244 |
"file": "making_a_fruit_bowl.bddl",
|
| 245 |
"instruction": "Put the apple, the orange and the lemon in the bowl.",
|
| 246 |
-
"timeLimit":
|
| 247 |
},
|
| 248 |
{
|
| 249 |
"id": "putting_away_groceries",
|
|
@@ -257,14 +257,14 @@
|
|
| 257 |
"title": "Setting the table",
|
| 258 |
"file": "setting_the_table.bddl",
|
| 259 |
"instruction": "Set the table: put the mug and the cup on the dining table, next to the plate.",
|
| 260 |
-
"timeLimit":
|
| 261 |
},
|
| 262 |
{
|
| 263 |
"id": "preparing_a_snack",
|
| 264 |
"title": "Preparing a snack",
|
| 265 |
"file": "preparing_a_snack.bddl",
|
| 266 |
"instruction": "Put the banana on the plate on the dining table and the cup next to the plate, and turn on the radio.",
|
| 267 |
-
"timeLimit":
|
| 268 |
},
|
| 269 |
{
|
| 270 |
"id": "tidying_up_the_kitchen",
|
|
|
|
| 236 |
"title": "Clearing the table",
|
| 237 |
"file": "clearing_the_table.bddl",
|
| 238 |
"instruction": "Clear the dining table: put the cup and the mug in the sink, and throw the empty blue can in the trash.",
|
| 239 |
+
"timeLimit": 200
|
| 240 |
},
|
| 241 |
{
|
| 242 |
"id": "making_a_fruit_bowl",
|
| 243 |
"title": "Making a fruit bowl",
|
| 244 |
"file": "making_a_fruit_bowl.bddl",
|
| 245 |
"instruction": "Put the apple, the orange and the lemon in the bowl.",
|
| 246 |
+
"timeLimit": 170
|
| 247 |
},
|
| 248 |
{
|
| 249 |
"id": "putting_away_groceries",
|
|
|
|
| 257 |
"title": "Setting the table",
|
| 258 |
"file": "setting_the_table.bddl",
|
| 259 |
"instruction": "Set the table: put the mug and the cup on the dining table, next to the plate.",
|
| 260 |
+
"timeLimit": 110
|
| 261 |
},
|
| 262 |
{
|
| 263 |
"id": "preparing_a_snack",
|
| 264 |
"title": "Preparing a snack",
|
| 265 |
"file": "preparing_a_snack.bddl",
|
| 266 |
"instruction": "Put the banana on the plate on the dining table and the cup next to the plate, and turn on the radio.",
|
| 267 |
+
"timeLimit": 130
|
| 268 |
},
|
| 269 |
{
|
| 270 |
"id": "tidying_up_the_kitchen",
|
dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
})();
|
| 21 |
</script>
|
| 22 |
<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." />
|
| 23 |
-
<script type="module" crossorigin src="./assets/index-
|
| 24 |
<link rel="stylesheet" crossorigin href="./assets/index-CwAlkvg1.css">
|
| 25 |
</head>
|
| 26 |
<body>
|
|
|
|
| 20 |
})();
|
| 21 |
</script>
|
| 22 |
<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." />
|
| 23 |
+
<script type="module" crossorigin src="./assets/index-DJo7AKiw.js"></script>
|
| 24 |
<link rel="stylesheet" crossorigin href="./assets/index-CwAlkvg1.css">
|
| 25 |
</head>
|
| 26 |
<body>
|
src/agent/agent.js
CHANGED
|
@@ -12,6 +12,7 @@ How to work:
|
|
| 12 |
- pick lifts the object 10 cm. Use method "policy" only when the user asks for the learned policy; otherwise "script".
|
| 13 |
- To put something in or on another object (a bowl, a plate), use place with "on".
|
| 14 |
- In the kitchen, observe also lists fixtures: surfaces (the kitchen island, the dining table, the pantry shelf), containers (the sink, the trash can) and switches (the radio). place "on" a fixture puts the object on a free spot of a surface, or lets it go into a container; press switches the radio on or off. pick and place drive where they need to.
|
|
|
|
| 15 |
- When the user started a household task (Tasks tab), the task tool tells its goal conditions and which hold; work through the ones that do not, and check with task at the end.
|
| 16 |
- The gripper opens to about 6 cm; wider objects cannot be picked up.
|
| 17 |
- If a tool fails, read its message and adapt; do not repeat the same call more than twice.
|
|
|
|
| 12 |
- pick lifts the object 10 cm. Use method "policy" only when the user asks for the learned policy; otherwise "script".
|
| 13 |
- To put something in or on another object (a bowl, a plate), use place with "on".
|
| 14 |
- In the kitchen, observe also lists fixtures: surfaces (the kitchen island, the dining table, the pantry shelf), containers (the sink, the trash can) and switches (the radio). place "on" a fixture puts the object on a free spot of a surface, or lets it go into a container; press switches the radio on or off. pick and place drive where they need to.
|
| 15 |
+
- Each arm holds one object, so the robot can carry two: when two objects go to the same place (or near each other), pick one, then the other with the other arm (pick's "arm"), and then place each; one trip instead of two.
|
| 16 |
- When the user started a household task (Tasks tab), the task tool tells its goal conditions and which hold; work through the ones that do not, and check with task at the end.
|
| 17 |
- The gripper opens to about 6 cm; wider objects cannot be picked up.
|
| 18 |
- If a tool fails, read its message and adapt; do not repeat the same call more than twice.
|
src/agent/tools.js
CHANGED
|
@@ -167,7 +167,7 @@ export function createTools(app) {
|
|
| 167 |
return {
|
| 168 |
scene: app.envInfo(),
|
| 169 |
robot: { x_m: round(x), y_m: round(y), heading_deg: round((yaw * 180) / Math.PI, 0) },
|
| 170 |
-
grippers: Object.fromEntries(["left", "right"].map((s) => [s, { open: robot.gripperOpening(s) > 0.5, holding:
|
| 171 |
objects,
|
| 172 |
...(fixtures ? { fixtures } : {}),
|
| 173 |
...(app.episode ? { task: app.episode.report() } : {}),
|
|
@@ -215,6 +215,11 @@ export function createTools(app) {
|
|
| 215 |
},
|
| 216 |
async pick({ object, arm, method = "script" }) {
|
| 217 |
const o = byName(object);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
const plan = graspPlan(app.robot, o.id, arm);
|
| 219 |
const tooWide = plan.reason && plan.info && plan.info.width > 0.065;
|
| 220 |
if (plan.reason && (method === "policy" || tooWide)) return { ok: false, message: `cannot grasp ${o.name}: ${plan.reason}${tooWide ? "" : ". Try go_to first."}` };
|
|
|
|
| 167 |
return {
|
| 168 |
scene: app.envInfo(),
|
| 169 |
robot: { x_m: round(x), y_m: round(y), heading_deg: round((yaw * 180) / Math.PI, 0) },
|
| 170 |
+
grippers: Object.fromEntries(["left", "right"].map((s) => { const held = heldBy(s); return [s, { open: !held && robot.gripperOpening(s) > 0.5, holding: held }]; })),
|
| 171 |
objects,
|
| 172 |
...(fixtures ? { fixtures } : {}),
|
| 173 |
...(app.episode ? { task: app.episode.report() } : {}),
|
|
|
|
| 215 |
},
|
| 216 |
async pick({ object, arm, method = "script" }) {
|
| 217 |
const o = byName(object);
|
| 218 |
+
// with one hand full, the other one (the full one would let go of what it holds)
|
| 219 |
+
const full = ["left", "right"].filter((s) => heldBy(s));
|
| 220 |
+
if (full.length === 2) return { ok: false, message: `both grippers hold something (${heldBy("left")}, ${heldBy("right")}); place one first` };
|
| 221 |
+
if (arm && full.includes(arm)) return { ok: false, message: `the ${arm} gripper holds the ${heldBy(arm)}; use the other arm or place it first` };
|
| 222 |
+
if (!arm && full.length === 1) arm = full[0] === "left" ? "right" : "left";
|
| 223 |
const plan = graspPlan(app.robot, o.id, arm);
|
| 224 |
const tooWide = plan.reason && plan.info && plan.info.width > 0.065;
|
| 225 |
if (plan.reason && (method === "policy" || tooWide)) return { ok: false, message: `cannot grasp ${o.name}: ${plan.reason}${tooWide ? "" : ". Try go_to first."}` };
|
src/robots/nav.js
CHANGED
|
@@ -1024,10 +1024,11 @@ export class ContactWatch {
|
|
| 1024 |
* `during` = {distance, start}: when the last drive has `distance` metres to go (or the last move begins,
|
| 1025 |
* if it is a turn), start() returns a generator that runs alongside, one step per control period, and is
|
| 1026 |
* finished before this returns (an arm reaching out as the base arrives).
|
| 1027 |
-
*
|
| 1028 |
-
* {ok:
|
|
|
|
| 1029 |
*/
|
| 1030 |
-
export function* followPath(robot, moves, { fp, watch, speed = 0.4, reverseSpeed = 0.25, turnRate = 1.6, during = null } = {}) {
|
| 1031 |
const cmd = { v: 0, w: 0 }; // what the base was last told: changes are rate limited
|
| 1032 |
let side = null;
|
| 1033 |
let sideDone = false;
|
|
@@ -1046,7 +1047,7 @@ export function* followPath(robot, moves, { fp, watch, speed = 0.4, reverseSpeed
|
|
| 1046 |
// A turn ends on the planned heading, which takes out what the drive before it left over; it
|
| 1047 |
// still goes the way the planner checked.
|
| 1048 |
const delta = m.kind === "turn" ? m.delta + wrap(m.heading - (robot.pose()[2] + m.delta)) : 0;
|
| 1049 |
-
const move = m.kind === "turn" ? turnBy(robot, delta, { fp, watch, rate: turnRate, cmd }) : track(robot, m.points, m.dir, { fp, watch, speed: m.dir > 0 ? speed : reverseSpeed, cmd, progress });
|
| 1050 |
let r;
|
| 1051 |
for (;;) {
|
| 1052 |
const step = move.next();
|
|
@@ -1111,7 +1112,7 @@ function nearLimits(clear) {
|
|
| 1111 |
const ramp = (from, want, rate, dt) => from + clamp(want - from, -rate * dt, rate * dt);
|
| 1112 |
|
| 1113 |
/** Turn in place by `delta` radians (positive left), the way given, however far. */
|
| 1114 |
-
export function* turnBy(robot, delta, { fp, watch, rate = 1.2, cmd = { v: 0, w: 0 } } = {}) {
|
| 1115 |
const dt = robot.sim.controlDt;
|
| 1116 |
const axle = fp?.fp.axle ?? 0;
|
| 1117 |
let last = robot.pose()[2];
|
|
@@ -1133,9 +1134,9 @@ export function* turnBy(robot, delta, { fp, watch, rate = 1.2, cmd = { v: 0, w:
|
|
| 1133 |
if (touch) return { ok: false, touched: touch, message: `the ${touch.robot} touched the ${touch.other} while turning` };
|
| 1134 |
let top = rate;
|
| 1135 |
if (fp) top = Math.min(top, nearLimits(fp.clearance(...pose, 0.2))[1]);
|
| 1136 |
-
const want = Math.sign(err) * Math.min(top, Math.sqrt(2 * 2.2 * Math.abs(err)) + 0.03);
|
| 1137 |
cmd.v = ramp(cmd.v, 0, ACCEL * 1.5, dt);
|
| 1138 |
-
cmd.w = ramp(cmd.w, want,
|
| 1139 |
if (fp && closing(fp, pose, ahead(pose, cmd.v, cmd.w, Math.min(LOOKAHEAD, Math.abs(err / (cmd.w || 1e-3))), axle))) {
|
| 1140 |
robot.stopBase();
|
| 1141 |
cmd.v = 0;
|
|
@@ -1150,10 +1151,10 @@ export function* turnBy(robot, delta, { fp, watch, rate = 1.2, cmd = { v: 0, w:
|
|
| 1150 |
|
| 1151 |
/**
|
| 1152 |
* Follow axle points [[x, y, heading], ...] forward (dir 1) or backward (dir -1): pure pursuit, the speed
|
| 1153 |
-
* held under the clearance, the bend and the distance left to stop in, and ramped
|
| 1154 |
-
* says how far there is to go.
|
| 1155 |
*/
|
| 1156 |
-
export function* track(robot, points, dir, { fp, watch, speed = 0.4, cmd = { v: 0, w: 0 }, progress = {} }) {
|
| 1157 |
const dt = robot.sim.controlDt;
|
| 1158 |
const axle = fp?.fp.axle ?? 0;
|
| 1159 |
// cumulative length along the points
|
|
@@ -1229,7 +1230,7 @@ export function* track(robot, points, dir, { fp, watch, speed = 0.4, cmd = { v:
|
|
| 1229 |
const lx = Math.cos(heading) * dx + Math.sin(heading) * dy;
|
| 1230 |
const ly = -Math.sin(heading) * dx + Math.cos(heading) * dy;
|
| 1231 |
const curvature = (2 * ly) / Math.max(1e-4, lx * lx + ly * ly);
|
| 1232 |
-
let [vTop, wTop] = [speed,
|
| 1233 |
if (fp) {
|
| 1234 |
const [vn, wn] = nearLimits(fp.clearance(...pose, 0.2));
|
| 1235 |
vTop = Math.min(vTop, vn);
|
|
@@ -1248,10 +1249,10 @@ export function* track(robot, points, dir, { fp, watch, speed = 0.4, cmd = { v:
|
|
| 1248 |
if (lx < 0.02) want = 0.02; // target beside or behind: mostly turn
|
| 1249 |
want = Math.min(want, wTop / Math.max(Math.abs(curvature), 1e-3));
|
| 1250 |
// speed up gently; slow down as fast as needed
|
| 1251 |
-
cmd.v = want < cmd.v ? want : ramp(cmd.v, want,
|
| 1252 |
// turning: in the frame of travel the curvature turns the heading the same way forward and backward
|
| 1253 |
const wWant = clamp(cmd.v * curvature, -wTop, wTop);
|
| 1254 |
-
cmd.w = ramp(cmd.w, wWant,
|
| 1255 |
if (fp && closing(fp, pose, ahead(pose, dir * cmd.v, cmd.w, Math.min(LOOKAHEAD, (remaining + 0.01) / Math.max(cmd.v, 1e-3)), axle))) {
|
| 1256 |
robot.stopBase();
|
| 1257 |
cmd.v = 0;
|
|
|
|
| 1024 |
* `during` = {distance, start}: when the last drive has `distance` metres to go (or the last move begins,
|
| 1025 |
* if it is a turn), start() returns a generator that runs alongside, one step per control period, and is
|
| 1026 |
* finished before this returns (an arm reaching out as the base arrives).
|
| 1027 |
+
* `accel` and `spinAccel` limit how fast it speeds up and turns faster (gently with something in a
|
| 1028 |
+
* gripper). Returns {ok: false} if the base strays from the path, stalls, would touch or touches
|
| 1029 |
+
* furniture; {ok: true} at the end.
|
| 1030 |
*/
|
| 1031 |
+
export function* followPath(robot, moves, { fp, watch, speed = 0.4, reverseSpeed = 0.25, turnRate = 1.6, accel = ACCEL, spinAccel = SPIN_ACCEL, during = null } = {}) {
|
| 1032 |
const cmd = { v: 0, w: 0 }; // what the base was last told: changes are rate limited
|
| 1033 |
let side = null;
|
| 1034 |
let sideDone = false;
|
|
|
|
| 1047 |
// A turn ends on the planned heading, which takes out what the drive before it left over; it
|
| 1048 |
// still goes the way the planner checked.
|
| 1049 |
const delta = m.kind === "turn" ? m.delta + wrap(m.heading - (robot.pose()[2] + m.delta)) : 0;
|
| 1050 |
+
const move = m.kind === "turn" ? turnBy(robot, delta, { fp, watch, rate: turnRate, spinAccel, cmd }) : track(robot, m.points, m.dir, { fp, watch, speed: m.dir > 0 ? speed : reverseSpeed, turnRate, accel, spinAccel, cmd, progress });
|
| 1051 |
let r;
|
| 1052 |
for (;;) {
|
| 1053 |
const step = move.next();
|
|
|
|
| 1112 |
const ramp = (from, want, rate, dt) => from + clamp(want - from, -rate * dt, rate * dt);
|
| 1113 |
|
| 1114 |
/** Turn in place by `delta` radians (positive left), the way given, however far. */
|
| 1115 |
+
export function* turnBy(robot, delta, { fp, watch, rate = 1.2, spinAccel = SPIN_ACCEL, cmd = { v: 0, w: 0 } } = {}) {
|
| 1116 |
const dt = robot.sim.controlDt;
|
| 1117 |
const axle = fp?.fp.axle ?? 0;
|
| 1118 |
let last = robot.pose()[2];
|
|
|
|
| 1134 |
if (touch) return { ok: false, touched: touch, message: `the ${touch.robot} touched the ${touch.other} while turning` };
|
| 1135 |
let top = rate;
|
| 1136 |
if (fp) top = Math.min(top, nearLimits(fp.clearance(...pose, 0.2))[1]);
|
| 1137 |
+
const want = Math.sign(err) * Math.min(top, Math.sqrt(2 * Math.min(2.2, spinAccel) * Math.abs(err)) + 0.03);
|
| 1138 |
cmd.v = ramp(cmd.v, 0, ACCEL * 1.5, dt);
|
| 1139 |
+
cmd.w = ramp(cmd.w, want, spinAccel, dt);
|
| 1140 |
if (fp && closing(fp, pose, ahead(pose, cmd.v, cmd.w, Math.min(LOOKAHEAD, Math.abs(err / (cmd.w || 1e-3))), axle))) {
|
| 1141 |
robot.stopBase();
|
| 1142 |
cmd.v = 0;
|
|
|
|
| 1151 |
|
| 1152 |
/**
|
| 1153 |
* Follow axle points [[x, y, heading], ...] forward (dir 1) or backward (dir -1): pure pursuit, the speed
|
| 1154 |
+
* held under the clearance, the bend and the distance left to stop in, and ramped, turning no faster than
|
| 1155 |
+
* `turnRate`. `progress.remaining` says how far there is to go.
|
| 1156 |
*/
|
| 1157 |
+
export function* track(robot, points, dir, { fp, watch, speed = 0.4, turnRate = 1.6, accel = ACCEL, spinAccel = SPIN_ACCEL, cmd = { v: 0, w: 0 }, progress = {} }) {
|
| 1158 |
const dt = robot.sim.controlDt;
|
| 1159 |
const axle = fp?.fp.axle ?? 0;
|
| 1160 |
// cumulative length along the points
|
|
|
|
| 1230 |
const lx = Math.cos(heading) * dx + Math.sin(heading) * dy;
|
| 1231 |
const ly = -Math.sin(heading) * dx + Math.cos(heading) * dy;
|
| 1232 |
const curvature = (2 * ly) / Math.max(1e-4, lx * lx + ly * ly);
|
| 1233 |
+
let [vTop, wTop] = [speed, turnRate];
|
| 1234 |
if (fp) {
|
| 1235 |
const [vn, wn] = nearLimits(fp.clearance(...pose, 0.2));
|
| 1236 |
vTop = Math.min(vTop, vn);
|
|
|
|
| 1249 |
if (lx < 0.02) want = 0.02; // target beside or behind: mostly turn
|
| 1250 |
want = Math.min(want, wTop / Math.max(Math.abs(curvature), 1e-3));
|
| 1251 |
// speed up gently; slow down as fast as needed
|
| 1252 |
+
cmd.v = want < cmd.v ? want : ramp(cmd.v, want, accel, dt);
|
| 1253 |
// turning: in the frame of travel the curvature turns the heading the same way forward and backward
|
| 1254 |
const wWant = clamp(cmd.v * curvature, -wTop, wTop);
|
| 1255 |
+
cmd.w = ramp(cmd.w, wWant, spinAccel, dt);
|
| 1256 |
if (fp && closing(fp, pose, ahead(pose, dir * cmd.v, cmd.w, Math.min(LOOKAHEAD, (remaining + 0.01) / Math.max(cmd.v, 1e-3)), axle))) {
|
| 1257 |
robot.stopBase();
|
| 1258 |
cmd.v = 0;
|
src/robots/skills.js
CHANGED
|
@@ -720,6 +720,11 @@ function graspApproach(robot, side, plan, lift = GRASP.liftHeight) {
|
|
| 720 |
* Returns ok when the object rose by at least 4 cm and is between the fingers.
|
| 721 |
*/
|
| 722 |
export function* pick(robot, bodyId, { side, lift = GRASP.liftHeight } = {}) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
const plan = graspPlan(robot, bodyId, side);
|
| 724 |
if (plan.reason) return { ok: false, message: `cannot grasp: ${plan.reason}`, plan };
|
| 725 |
// Lifted at least to counter height and a little: picked from a low table, it is carried over what
|
|
@@ -1027,6 +1032,14 @@ export function comfortable(robot, bodyId, side, { at, info } = {}) {
|
|
| 1027 |
return { ok: !plan.reason && ahead <= 0.305, plan, ahead };
|
| 1028 |
}
|
| 1029 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1030 |
/** Free bodies the grippers hold now. */
|
| 1031 |
function heldBodies(robot) {
|
| 1032 |
return robot.sim.freeBodies([robot.root]).filter((o) => holding(robot, "left", o.id) || holding(robot, "right", o.id)).map((o) => o.id);
|
|
@@ -1221,9 +1234,12 @@ function* driveToReach(robot, target, reaches, { side, what, prepare = null, exc
|
|
| 1221 |
// The arm reaches out over the last stretch: whole-body, the base and the arm arrive together.
|
| 1222 |
const reachOut = prepare?.(goal);
|
| 1223 |
const during = reachOut ? { distance: 0.35, start: reachOut } : null;
|
| 1224 |
-
|
|
|
|
|
|
|
|
|
|
| 1225 |
if (run.ok) {
|
| 1226 |
-
yield* settle(robot, fp, goal.pose);
|
| 1227 |
return { ok: true, side: goal.side, message: `drove ${plan.length.toFixed(1)} m` };
|
| 1228 |
}
|
| 1229 |
last = run.message;
|
|
@@ -1237,9 +1253,9 @@ function* driveToReach(robot, target, reaches, { side, what, prepare = null, exc
|
|
| 1237 |
* At the end of a path: square up to the goal's heading and close the distance along it. Both moves
|
| 1238 |
* look ahead and stop short of furniture.
|
| 1239 |
*/
|
| 1240 |
-
function* settle(robot, fp, goal) {
|
| 1241 |
const dyaw = wrap(goal[2] - robot.pose()[2]);
|
| 1242 |
-
if (Math.abs(dyaw) > 0.03) yield* turnBy(robot, dyaw, { fp });
|
| 1243 |
const p = robot.pose();
|
| 1244 |
const along = (goal[0] - p[0]) * Math.cos(p[2]) + (goal[1] - p[1]) * Math.sin(p[2]);
|
| 1245 |
if (Math.abs(along) > 0.012) {
|
|
@@ -1270,11 +1286,14 @@ function* backAway(robot, fp) {
|
|
| 1270 |
*/
|
| 1271 |
export function* approach(robot, bodyId, { side } = {}) {
|
| 1272 |
const sim = robot.sim;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1273 |
let check = comfortable(robot, bodyId, side);
|
| 1274 |
if (check.ok) return { ok: true, message: `already in reach of the ${check.plan.side} arm`, side: check.plan.side };
|
| 1275 |
const name = sim.bodyNames[bodyId];
|
| 1276 |
-
const info = objectInfo(sim, bodyId);
|
| 1277 |
-
const graspable = info.width <= GRASP.maxWidth;
|
| 1278 |
// Standing where the arm grasps it comfortably is preferred; at the edge of its workspace it still can.
|
| 1279 |
const reaches = (at, s) => {
|
| 1280 |
if (!graspable) return placeReach(robot, s, [info.center[0], info.center[1], info.bottom + 0.012], at, Math.max(0, info.width / 2 - 0.045));
|
|
|
|
| 720 |
* Returns ok when the object rose by at least 4 cm and is between the fingers.
|
| 721 |
*/
|
| 722 |
export function* pick(robot, bodyId, { side, lift = GRASP.liftHeight } = {}) {
|
| 723 |
+
// never with a hand that holds something: it would let go of it
|
| 724 |
+
const full = ["left", "right"].filter((s) => armHolds(robot, s));
|
| 725 |
+
if (full.length === 2) return { ok: false, message: "both grippers hold something" };
|
| 726 |
+
if (side && full.includes(side)) return { ok: false, message: `the ${side} gripper holds something` };
|
| 727 |
+
if (!side && full.length === 1) side = full[0] === "left" ? "right" : "left";
|
| 728 |
const plan = graspPlan(robot, bodyId, side);
|
| 729 |
if (plan.reason) return { ok: false, message: `cannot grasp: ${plan.reason}`, plan };
|
| 730 |
// Lifted at least to counter height and a little: picked from a low table, it is carried over what
|
|
|
|
| 1032 |
return { ok: !plan.reason && ahead <= 0.305, plan, ahead };
|
| 1033 |
}
|
| 1034 |
|
| 1035 |
+
/** Whether a gripper holds an object now. */
|
| 1036 |
+
function armHolds(robot, side) {
|
| 1037 |
+
return robot.sim.freeBodies([robot.root]).some((o) => holding(robot, side, o.id));
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
/** How the base drives with something in a gripper: slower, and turning slower and more smoothly. */
|
| 1041 |
+
export const CARRY = { speed: 0.22, reverseSpeed: 0.12, turnRate: 0.45, accel: 0.25, spinAccel: 1.2 };
|
| 1042 |
+
|
| 1043 |
/** Free bodies the grippers hold now. */
|
| 1044 |
function heldBodies(robot) {
|
| 1045 |
return robot.sim.freeBodies([robot.root]).filter((o) => holding(robot, "left", o.id) || holding(robot, "right", o.id)).map((o) => o.id);
|
|
|
|
| 1234 |
// The arm reaches out over the last stretch: whole-body, the base and the arm arrive together.
|
| 1235 |
const reachOut = prepare?.(goal);
|
| 1236 |
const during = reachOut ? { distance: 0.35, start: reachOut } : null;
|
| 1237 |
+
// Gently with something in a gripper: turning fast, and starting or stopping a turn abruptly, swings
|
| 1238 |
+
// it out of the fingers.
|
| 1239 |
+
const gentle = carrying ? CARRY : {};
|
| 1240 |
+
const run = yield* stepping(followPath(robot, plan.moves, { fp, watch, during, ...gentle }), fold.step);
|
| 1241 |
if (run.ok) {
|
| 1242 |
+
yield* settle(robot, fp, goal.pose, gentle);
|
| 1243 |
return { ok: true, side: goal.side, message: `drove ${plan.length.toFixed(1)} m` };
|
| 1244 |
}
|
| 1245 |
last = run.message;
|
|
|
|
| 1253 |
* At the end of a path: square up to the goal's heading and close the distance along it. Both moves
|
| 1254 |
* look ahead and stop short of furniture.
|
| 1255 |
*/
|
| 1256 |
+
function* settle(robot, fp, goal, gentle = {}) {
|
| 1257 |
const dyaw = wrap(goal[2] - robot.pose()[2]);
|
| 1258 |
+
if (Math.abs(dyaw) > 0.03) yield* turnBy(robot, dyaw, { fp, ...(gentle.turnRate ? { rate: gentle.turnRate, spinAccel: gentle.spinAccel } : {}) });
|
| 1259 |
const p = robot.pose();
|
| 1260 |
const along = (goal[0] - p[0]) * Math.cos(p[2]) + (goal[1] - p[1]) * Math.sin(p[2]);
|
| 1261 |
if (Math.abs(along) > 0.012) {
|
|
|
|
| 1286 |
*/
|
| 1287 |
export function* approach(robot, bodyId, { side } = {}) {
|
| 1288 |
const sim = robot.sim;
|
| 1289 |
+
const info = objectInfo(sim, bodyId);
|
| 1290 |
+
const graspable = info.width <= GRASP.maxWidth;
|
| 1291 |
+
// With one hand full: the free arm to grasp it; the full one to put what it holds in or on it.
|
| 1292 |
+
const full = ["left", "right"].filter((s) => armHolds(robot, s));
|
| 1293 |
+
if (!side && full.length === 1) side = graspable ? (full[0] === "left" ? "right" : "left") : full[0];
|
| 1294 |
let check = comfortable(robot, bodyId, side);
|
| 1295 |
if (check.ok) return { ok: true, message: `already in reach of the ${check.plan.side} arm`, side: check.plan.side };
|
| 1296 |
const name = sim.bodyNames[bodyId];
|
|
|
|
|
|
|
| 1297 |
// Standing where the arm grasps it comfortably is preferred; at the edge of its workspace it still can.
|
| 1298 |
const reaches = (at, s) => {
|
| 1299 |
if (!graspable) return placeReach(robot, s, [info.center[0], info.center[1], info.bottom + 0.012], at, Math.max(0, info.width / 2 - 0.045));
|
src/robots/xlerobot.js
CHANGED
|
@@ -310,12 +310,19 @@ export class XLeRobot {
|
|
| 310 |
this.#gripLock();
|
| 311 |
}
|
| 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
/**
|
| 314 |
* MuJoCo's friction is soft: an object held in a gripper creeps out under its own weight, and a ball can
|
| 315 |
* slide out as the arm lifts it. While a gripper squeezes something (commanded more closed than it is,
|
| 316 |
* and no longer closing), the noslip solver holds it. While the jaws close it stays off, so the object
|
| 317 |
* slides between them and centres; with it on, the jaw tips can sweep a small object away. It costs
|
| 318 |
-
* about
|
| 319 |
*/
|
| 320 |
#gripLock() {
|
| 321 |
const { model, data } = this.sim;
|
|
@@ -324,7 +331,7 @@ export class XLeRobot {
|
|
| 324 |
const jaw = "Jaw" + arm.suffix;
|
| 325 |
if (data.ctrl[this.act[jaw]] < data.qpos[this.qpos[jaw]] - 0.08 && Math.abs(data.qvel[this.qvel[jaw]]) < 0.5) squeezing = true;
|
| 326 |
}
|
| 327 |
-
const iterations = squeezing ?
|
| 328 |
if (model.opt.noslip_iterations !== iterations) model.opt.noslip_iterations = iterations;
|
| 329 |
}
|
| 330 |
|
|
@@ -471,7 +478,8 @@ export class XLeRobotTeleop {
|
|
| 471 |
t.roll += axis(keys.roll) * CONTROL.rollRate * dt;
|
| 472 |
this.cooldown[side] = Math.max(0, this.cooldown[side] - dt);
|
| 473 |
if (k(keys.grip) && this.cooldown[side] === 0) {
|
| 474 |
-
|
|
|
|
| 475 |
t.jaw = open ? CONTROL.gripperOpen : CONTROL.gripperClosed;
|
| 476 |
this.cooldown[side] = CONTROL.gripperCooldown;
|
| 477 |
}
|
|
|
|
| 310 |
this.#gripLock();
|
| 311 |
}
|
| 312 |
|
| 313 |
+
/**
|
| 314 |
+
* Noslip solver iterations while a gripper squeezes something (#gripLock). With 3, an object lifted high
|
| 315 |
+
* (the gripper tilted, the wrist at its limit) still creeps along the fingers as the base turns in place,
|
| 316 |
+
* and falls out; 10 hold it, for no more time per step.
|
| 317 |
+
*/
|
| 318 |
+
static gripIterations = 10;
|
| 319 |
+
|
| 320 |
/**
|
| 321 |
* MuJoCo's friction is soft: an object held in a gripper creeps out under its own weight, and a ball can
|
| 322 |
* slide out as the arm lifts it. While a gripper squeezes something (commanded more closed than it is,
|
| 323 |
* and no longer closing), the noslip solver holds it. While the jaws close it stays off, so the object
|
| 324 |
* slides between them and centres; with it on, the jaw tips can sweep a small object away. It costs
|
| 325 |
+
* about 2.2x per physics step, only while something is held.
|
| 326 |
*/
|
| 327 |
#gripLock() {
|
| 328 |
const { model, data } = this.sim;
|
|
|
|
| 331 |
const jaw = "Jaw" + arm.suffix;
|
| 332 |
if (data.ctrl[this.act[jaw]] < data.qpos[this.qpos[jaw]] - 0.08 && Math.abs(data.qvel[this.qvel[jaw]]) < 0.5) squeezing = true;
|
| 333 |
}
|
| 334 |
+
const iterations = squeezing ? XLeRobot.gripIterations : 0;
|
| 335 |
if (model.opt.noslip_iterations !== iterations) model.opt.noslip_iterations = iterations;
|
| 336 |
}
|
| 337 |
|
|
|
|
| 478 |
t.roll += axis(keys.roll) * CONTROL.rollRate * dt;
|
| 479 |
this.cooldown[side] = Math.max(0, this.cooldown[side] - dt);
|
| 480 |
if (k(keys.grip) && this.cooldown[side] === 0) {
|
| 481 |
+
// by what it was told, not how far it is open: closed on something wide, it can be over half open
|
| 482 |
+
const open = t.jaw < (CONTROL.gripperOpen + CONTROL.gripperClosed) / 2;
|
| 483 |
t.jaw = open ? CONTROL.gripperOpen : CONTROL.gripperClosed;
|
| 484 |
this.cooldown[side] = CONTROL.gripperCooldown;
|
| 485 |
}
|
src/tasks/household.js
CHANGED
|
@@ -457,6 +457,13 @@ export class Household {
|
|
| 457 |
// -------------------------------------------------------------------------------------------------
|
| 458 |
// Where to put things
|
| 459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
/** The surface entity an object stands on now, or null. */
|
| 461 |
supportOf(name) {
|
| 462 |
return Object.values(this.entities).find((e) => (e.kind === "surface" || e.kind === "object") && e.name !== name && this.#ontop(this.entities[name], e)) ?? null;
|
|
|
|
| 457 |
// -------------------------------------------------------------------------------------------------
|
| 458 |
// Where to put things
|
| 459 |
|
| 460 |
+
/** A point standing for where a target is: an object's place, a surface's reachable band, a container's opening. */
|
| 461 |
+
targetPoint(name) {
|
| 462 |
+
const e = this.entities[name];
|
| 463 |
+
if (e.id !== undefined) return this.sim.bodyPos(e.id);
|
| 464 |
+
return this.site((e.zones ?? e.sites)[0]).c;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
/** The surface entity an object stands on now, or null. */
|
| 468 |
supportOf(name) {
|
| 469 |
return Object.values(this.entities).find((e) => (e.kind === "surface" || e.kind === "object") && e.name !== name && this.#ontop(this.entities[name], e)) ?? null;
|
src/tasks/solver.js
CHANGED
|
@@ -2,23 +2,54 @@
|
|
| 2 |
// the robot's skills, as the BEHAVIOR Challenge's human demonstrations show each task can be done. For
|
| 3 |
// `ontop` and `inside` it picks the object up (driving to it if it is out of reach) and puts it on or in
|
| 4 |
// the target (driving there): on a surface at a free spot the arms reach, next to what a `nextto` literal
|
| 5 |
-
// for it names; into a container, let go over its opening.
|
| 6 |
-
//
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
import { show } from "./bddl.js";
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
/**
|
| 11 |
-
* Do an episode's task (a generator for the skill runner). `log(text)` hears what it is doing
|
| 12 |
-
* when the episode ends (the goal holds, or time
|
|
|
|
| 13 |
*/
|
| 14 |
-
export function* solve(household, episode, { log = () => {} } = {}) {
|
| 15 |
const objects = episode.task.problem.objects;
|
|
|
|
| 16 |
for (let round = 0; round < 2 && !episode.outcome; round++) {
|
| 17 |
for (const goal of episode.goals) {
|
| 18 |
if (episode.outcome) break;
|
| 19 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
log(goal.label);
|
| 21 |
-
const r = yield*
|
| 22 |
log(`${goal.label}: ${r.message}`);
|
| 23 |
}
|
| 24 |
}
|
|
@@ -26,52 +57,121 @@ export function* solve(household, episode, { log = () => {} } = {}) {
|
|
| 26 |
return { ok: s.success, message: `${s.satisfied} of ${s.total} goal conditions hold` };
|
| 27 |
}
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
// a `nextto` literal for the same object says where on the surface
|
| 35 |
const near = episode.goals.map((g) => g.expr).find((e) => e[0] === "nextto" && e[1] === a)?.[2] ?? null;
|
| 36 |
-
return
|
| 37 |
}
|
| 38 |
-
if (
|
| 39 |
const support = household.supportOf(b);
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
return { ok: false, message: `no skill for ${show(expr)}` };
|
| 44 |
}
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
/**
|
| 47 |
-
* Pick an object up (unless a gripper has it
|
| 48 |
-
*
|
| 49 |
*/
|
| 50 |
-
function*
|
| 51 |
const { robot, sim } = household;
|
| 52 |
-
const obj = household.entities[name];
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
| 58 |
if (graspPlan(robot, obj.id, arm).reason) {
|
| 59 |
const went = yield* approach(robot, obj.id, { side: arm });
|
| 60 |
if (!went.ok) return { ok: false, message: `could not get to the ${obj.label}: ${went.message}` };
|
| 61 |
}
|
| 62 |
const info = objectInfo(sim, obj.id);
|
| 63 |
-
from = [info.center[0], info.center[1], info.bottom];
|
| 64 |
const got = yield* pick(robot, obj.id, { side: arm ?? graspPlan(robot, obj.id).side });
|
| 65 |
-
if (got.ok)
|
| 66 |
-
|
| 67 |
}
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
let done = null;
|
| 70 |
const avoid = [];
|
| 71 |
for (let attempt = 0; attempt < 3; attempt++) {
|
| 72 |
-
const spot = household.placeTarget(name, pred, target, { near, from: robot.pose(), avoid });
|
| 73 |
if (!spot) {
|
| 74 |
-
done ??= { ok: false, message: `no free spot ${pred === "inside" ? "in" : "on"} the ${household.entities[target].label}` };
|
| 75 |
break;
|
| 76 |
}
|
| 77 |
done = yield* place(robot, side, robot.toRobot(spot.world), obj.id, { slack: spot.slack, onto: spot.onto ?? null, drop: Boolean(spot.drop) });
|
|
|
|
| 2 |
// the robot's skills, as the BEHAVIOR Challenge's human demonstrations show each task can be done. For
|
| 3 |
// `ontop` and `inside` it picks the object up (driving to it if it is out of reach) and puts it on or in
|
| 4 |
// the target (driving there): on a surface at a free spot the arms reach, next to what a `nextto` literal
|
| 5 |
+
// for it names; into a container, let go over its opening. With both hands: when another object goes to
|
| 6 |
+
// the same place or near it, the other hand picks that one up too before the robot goes there, so one trip
|
| 7 |
+
// carries two (of the objects a hand holds securely: light ones, not balls). A switch is pressed until it is as
|
| 8 |
+
// the goal says. Literals that hold are skipped; a second round retries what failed.
|
| 9 |
+
import { GRASP, approach, graspPlan, objectInfo, pick, place, press } from "../robots/skills.js";
|
| 10 |
import { show } from "./bddl.js";
|
| 11 |
|
| 12 |
+
/** Two places this close (m) are one trip for two objects. */
|
| 13 |
+
const SAME_TRIP = 1.2;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Whether an object is held well enough to stay in one hand while the other picks something up or puts
|
| 17 |
+
* it down: light (at most 100 g) and not a ball. A heavier one (a juice box, a yogurt pot, a full bottle)
|
| 18 |
+
* creeps along the fingers and tilts over a long carry, and a ball (an apple, an orange) held at two
|
| 19 |
+
* points rolls out as the base turns; those go on their own.
|
| 20 |
+
*/
|
| 21 |
+
function secure(household, id) {
|
| 22 |
+
const { model } = household.sim;
|
| 23 |
+
let ball = true;
|
| 24 |
+
for (let g = model.body_geomadr[id]; g < model.body_geomadr[id] + model.body_geomnum[id]; g++) {
|
| 25 |
+
if ((model.geom_contype[g] || model.geom_conaffinity[g]) && model.geom_type[g] !== 2) ball = false;
|
| 26 |
+
}
|
| 27 |
+
return !ball && model.body_mass[id] <= 0.1 + 1e-9;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
/**
|
| 31 |
+
* Do an episode's task (a generator for the skill runner). `log(text)` hears what it is doing;
|
| 32 |
+
* `bothHands: false` carries one object at a time. Stops when the episode ends (the goal holds, or time
|
| 33 |
+
* is up).
|
| 34 |
*/
|
| 35 |
+
export function* solve(household, episode, { log = () => {}, bothHands = true } = {}) {
|
| 36 |
const objects = episode.task.problem.objects;
|
| 37 |
+
const holds = (goal) => household.check(goal.expr, objects);
|
| 38 |
for (let round = 0; round < 2 && !episode.outcome; round++) {
|
| 39 |
for (const goal of episode.goals) {
|
| 40 |
if (episode.outcome) break;
|
| 41 |
+
if (holds(goal)) continue;
|
| 42 |
+
const job = jobOf(household, episode, goal);
|
| 43 |
+
// another object for the other hand, going to the same place or near it
|
| 44 |
+
const partner = job && bothHands ? partnerFor(household, episode, job, holds) : null;
|
| 45 |
+
if (partner) {
|
| 46 |
+
log(`${goal.label}, and ${partner.goal.label}`);
|
| 47 |
+
const [ra, rb] = yield* carryTwo(household, job, partner);
|
| 48 |
+
log(`${goal.label}: ${ra.message}${rb ? `; ${partner.goal.label}: ${rb.message}` : ""}`);
|
| 49 |
+
continue;
|
| 50 |
+
}
|
| 51 |
log(goal.label);
|
| 52 |
+
const r = job ? yield* move(household, job) : yield* achieve(household, goal.expr);
|
| 53 |
log(`${goal.label}: ${r.message}`);
|
| 54 |
}
|
| 55 |
}
|
|
|
|
| 57 |
return { ok: s.success, message: `${s.satisfied} of ${s.total} goal conditions hold` };
|
| 58 |
}
|
| 59 |
|
| 60 |
+
/**
|
| 61 |
+
* What moving an object takes for a goal literal: {goal, name, pred, target, near}, or null for a literal
|
| 62 |
+
* that is not about where an object is (a switch).
|
| 63 |
+
*/
|
| 64 |
+
function jobOf(household, episode, goal) {
|
| 65 |
+
const expr = goal.expr;
|
| 66 |
+
if (expr[0] === "not") return null;
|
| 67 |
+
const [pred, a, b] = expr;
|
| 68 |
+
if (pred === "ontop" || pred === "inside") {
|
| 69 |
// a `nextto` literal for the same object says where on the surface
|
| 70 |
const near = episode.goals.map((g) => g.expr).find((e) => e[0] === "nextto" && e[1] === a)?.[2] ?? null;
|
| 71 |
+
return { goal, name: a, pred, target: b, near };
|
| 72 |
}
|
| 73 |
+
if (pred === "nextto") {
|
| 74 |
const support = household.supportOf(b);
|
| 75 |
+
return support ? { goal, name: a, pred: "ontop", target: support.name, near: b } : null;
|
| 76 |
+
}
|
| 77 |
+
return null;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* A second job to do with the other hand on the same trip: a later goal not holding yet, for another
|
| 82 |
+
* object that is free, graspable and held well (as the first must be), going to the same place or near
|
| 83 |
+
* it; of those, the one whose object is nearest the first.
|
| 84 |
+
*/
|
| 85 |
+
function partnerFor(household, episode, job, holds) {
|
| 86 |
+
const { sim } = household;
|
| 87 |
+
const first = household.entities[job.name];
|
| 88 |
+
if (household.heldBy(first.id) || !secure(household, first.id)) return null;
|
| 89 |
+
const busy = ["left", "right"].some((s) => household.busy(s));
|
| 90 |
+
if (busy) return null; // a hand is taken already
|
| 91 |
+
const there = household.targetPoint(job.target);
|
| 92 |
+
const from = sim.bodyPos(first.id);
|
| 93 |
+
let best = null;
|
| 94 |
+
for (const goal of episode.goals.slice(episode.goals.indexOf(job.goal) + 1)) {
|
| 95 |
+
if (holds(goal)) continue;
|
| 96 |
+
const other = jobOf(household, episode, goal);
|
| 97 |
+
if (!other || other.name === job.name) continue;
|
| 98 |
+
const obj = household.entities[other.name];
|
| 99 |
+
if (household.heldBy(obj.id) || objectInfo(sim, obj.id).width > GRASP.maxWidth || !secure(household, obj.id)) continue;
|
| 100 |
+
const p = household.targetPoint(other.target);
|
| 101 |
+
if (Math.hypot(p[0] - there[0], p[1] - there[1]) > SAME_TRIP) continue;
|
| 102 |
+
const q = sim.bodyPos(obj.id);
|
| 103 |
+
const d = Math.hypot(q[0] - from[0], q[1] - from[1]);
|
| 104 |
+
if (!best || d < best.d) best = { job: other, d };
|
| 105 |
}
|
| 106 |
+
return best ? { ...best.job } : null;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
function* achieve(household, expr) {
|
| 110 |
+
const neg = expr[0] === "not";
|
| 111 |
+
const [pred, a] = neg ? expr[1] : expr;
|
| 112 |
+
if (pred === "toggled_on") return yield* toggle(household, a);
|
| 113 |
return { ok: false, message: `no skill for ${show(expr)}` };
|
| 114 |
}
|
| 115 |
|
| 116 |
+
/** One object to where it goes. */
|
| 117 |
+
function* move(household, job) {
|
| 118 |
+
const got = yield* fetch(household, job);
|
| 119 |
+
if (!got.ok) return got;
|
| 120 |
+
return yield* deliver(household, job, got);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Two objects on one trip: the first in one hand, the second in the other, then each where it goes. If
|
| 125 |
+
* the second cannot be picked up, the first goes on its own (the second is tried again later).
|
| 126 |
+
*/
|
| 127 |
+
function* carryTwo(household, a, b) {
|
| 128 |
+
const ga = yield* fetch(household, a);
|
| 129 |
+
if (!ga.ok) return [ga, null];
|
| 130 |
+
const gb = yield* fetch(household, b, ga.side === "left" ? "right" : "left");
|
| 131 |
+
const ra = yield* deliver(household, a, ga);
|
| 132 |
+
const rb = gb.ok ? yield* deliver(household, b, gb) : gb;
|
| 133 |
+
return [ra, rb];
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
/**
|
| 137 |
+
* Pick an object up (unless a gripper has it), with `side` or the free arm, driving to it if it is out of
|
| 138 |
+
* reach; two tries. Returns {ok, side, from} (from: where it stood, to put it back).
|
| 139 |
*/
|
| 140 |
+
function* fetch(household, job, side) {
|
| 141 |
const { robot, sim } = household;
|
| 142 |
+
const obj = household.entities[job.name];
|
| 143 |
+
const holding = household.heldBy(obj.id);
|
| 144 |
+
if (holding) return { ok: true, side: holding, from: null };
|
| 145 |
+
const busy = ["left", "right"].find((s) => household.busy(s));
|
| 146 |
+
const arm = side ?? (busy ? (busy === "left" ? "right" : "left") : undefined);
|
| 147 |
+
let last = null;
|
| 148 |
+
for (let attempt = 0; attempt < 2; attempt++) {
|
| 149 |
if (graspPlan(robot, obj.id, arm).reason) {
|
| 150 |
const went = yield* approach(robot, obj.id, { side: arm });
|
| 151 |
if (!went.ok) return { ok: false, message: `could not get to the ${obj.label}: ${went.message}` };
|
| 152 |
}
|
| 153 |
const info = objectInfo(sim, obj.id);
|
| 154 |
+
const from = [info.center[0], info.center[1], info.bottom];
|
| 155 |
const got = yield* pick(robot, obj.id, { side: arm ?? graspPlan(robot, obj.id).side });
|
| 156 |
+
if (got.ok) return { ok: true, side: got.side, from };
|
| 157 |
+
last = got;
|
| 158 |
}
|
| 159 |
+
return { ok: false, message: `could not pick up the ${obj.label}: ${last?.message}` };
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Put a held object where its job says, trying another spot if the base cannot get to where an arm
|
| 164 |
+
* reaches one; if it cannot go there, back where it was.
|
| 165 |
+
*/
|
| 166 |
+
function* deliver(household, job, { side, from }) {
|
| 167 |
+
const { robot } = household;
|
| 168 |
+
const obj = household.entities[job.name];
|
| 169 |
let done = null;
|
| 170 |
const avoid = [];
|
| 171 |
for (let attempt = 0; attempt < 3; attempt++) {
|
| 172 |
+
const spot = household.placeTarget(job.name, job.pred, job.target, { near: job.near, from: robot.pose(), avoid });
|
| 173 |
if (!spot) {
|
| 174 |
+
done ??= { ok: false, message: `no free spot ${job.pred === "inside" ? "in" : "on"} the ${household.entities[job.target].label}` };
|
| 175 |
break;
|
| 176 |
}
|
| 177 |
done = yield* place(robot, side, robot.toRobot(spot.world), obj.id, { slack: spot.slack, onto: spot.onto ?? null, drop: Boolean(spot.drop) });
|
tools/eval_tasks.mjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
| 3 |
// end (Q, partial credit), whether all do, and the efficiency measures (simulated time, base and hand
|
| 4 |
// distance).
|
| 5 |
//
|
| 6 |
-
// usage: node tools/eval_tasks.mjs [instances=5] [task ...] (VERBOSE=1 prints what the demonstrator did
|
|
|
|
| 7 |
import { readFileSync } from "node:fs";
|
| 8 |
import { join } from "node:path";
|
| 9 |
import { ASSETS, loadScene } from "./node_env.mjs";
|
|
@@ -35,7 +36,7 @@ for (const task of household.tasks) {
|
|
| 35 |
const episode = new Episode(household, task, seed);
|
| 36 |
const log = [];
|
| 37 |
const wall = performance.now();
|
| 38 |
-
runSkill(sim, robot, solve(household, episode, { log: (m) => log.push(` ${episode.time.toFixed(1)} s: ${m}`) }), {
|
| 39 |
maxSeconds: task.timeLimit + 30,
|
| 40 |
onTick: () => {
|
| 41 |
household.update();
|
|
|
|
| 3 |
// end (Q, partial credit), whether all do, and the efficiency measures (simulated time, base and hand
|
| 4 |
// distance).
|
| 5 |
//
|
| 6 |
+
// usage: node tools/eval_tasks.mjs [instances=5] [task ...] (VERBOSE=1 prints what the demonstrator did;
|
| 7 |
+
// ONE_HAND=1 has it carry one object at a time)
|
| 8 |
import { readFileSync } from "node:fs";
|
| 9 |
import { join } from "node:path";
|
| 10 |
import { ASSETS, loadScene } from "./node_env.mjs";
|
|
|
|
| 36 |
const episode = new Episode(household, task, seed);
|
| 37 |
const log = [];
|
| 38 |
const wall = performance.now();
|
| 39 |
+
runSkill(sim, robot, solve(household, episode, { bothHands: !process.env.ONE_HAND, log: (m) => log.push(` ${episode.time.toFixed(1)} s: ${m}`) }), {
|
| 40 |
maxSeconds: task.timeLimit + 30,
|
| 41 |
onTick: () => {
|
| 42 |
household.update();
|
tools/make_kitchen.py
CHANGED
|
@@ -590,7 +590,7 @@ def main() -> None:
|
|
| 590 |
</mujoco>
|
| 591 |
"""
|
| 592 |
OUT.parent.mkdir(parents=True, exist_ok=True)
|
| 593 |
-
OUT.write_text(xml, encoding="utf-8")
|
| 594 |
print(f"wrote {OUT} ({len(xml) / 1000:.1f} kB)")
|
| 595 |
|
| 596 |
|
|
|
|
| 590 |
</mujoco>
|
| 591 |
"""
|
| 592 |
OUT.parent.mkdir(parents=True, exist_ok=True)
|
| 593 |
+
OUT.write_text(xml, encoding="utf-8", newline="\n")
|
| 594 |
print(f"wrote {OUT} ({len(xml) / 1000:.1f} kB)")
|
| 595 |
|
| 596 |
|