"""Build a static HF browser with a full scene catalog and a Franka camera guide."""
from pathlib import Path
import json,re,sys
ROOT=Path(__file__).resolve().parents[1]
DATA=ROOT if (ROOT/'provenance/source.json').exists() else ROOT/'dataset'
OUT=ROOT/'space'
JS=r'''
const DATA=JSON.parse(document.getElementById('catalog').textContent);
const esc=x=>String(x??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
const media=p=>DATA.media_base+p.split('/').map(encodeURIComponent).join('/');
const file=p=>DATA.file_base+p.split('/').map(encodeURIComponent).join('/');
const link=(u,t)=>`${esc(t)} `;
const tasks=DATA.tasks,groups=[...new Set(tasks.map(t=>t.category))];
let current=null,query='',group='all',mode='combined';
function drawList(){
document.getElementById('groups').innerHTML=['all',...groups].map(g=>`${g==='all'?'全部':esc(g)}${g==='all'?28:tasks.filter(t=>t.category===g).length} `).join('');
const numeric=/^(C)?\d+$/i.test(query.trim());
const shown=tasks.filter(t=>(numeric||group==='all'||t.category===group)&&(numeric?t.catalog_number===Number(query.replace(/^C/i,'')):`${t.scene_key} ${t.official_scene_id} ${t.name} ${t.instruction}`.toLowerCase().includes(query.toLowerCase())));
document.getElementById('listCount').textContent=`${shown.length} / 28`;
document.getElementById('taskList').innerHTML=shown.map(t=>`C${String(t.catalog_number).padStart(2,'0')} ${esc(t.name)}${t.dataset_source?'MULTI-CAMERA DATA':t.gallery?'WEBSITE MP4':'CATALOG ONLY'} `).join('')||'
未找到场景。这里的 C01–C28 是官网目录辅助编号,不是 task_index。
';
document.querySelectorAll('[data-group]').forEach(b=>b.onclick=()=>{group=b.dataset.group;drawList()});document.querySelectorAll('[data-task]').forEach(b=>b.onclick=()=>{select(b.dataset.task);window.scrollTo({top:0})});
}
function select(key,historyUpdate=true){document.querySelectorAll('video').forEach(v=>v.pause());if(historyUpdate)history.replaceState({},'',`?task=${encodeURIComponent(key)}`);current=tasks.find(t=>t.scene_key===key);drawList();if(key==='camera-guide')drawCamera();else drawTask();document.querySelector('.task-link.active')?.scrollIntoView({block:'nearest'});}
function player(p,poster='',aspect=''){return ` `}
function pageHeader(){return `EmbodiedSWE / 28 SCENES / 30 DATA EPISODES / 26 WEBSITE CLIPS${link(DATA.repo_url,'HF 数据仓库 ↗')}${link('https://embodiedswe.github.io/#benchmark','官方项目 ↗')}
腕部相机说明 ↗ `}
function episode(s){
const n=s.views.length;
const content=mode==='combined'?`${s.views.map(v=>`${esc(v.label)} `).join('')}
${player(s.composite_path,s.preview_path,`${320*n}/268`)}
`:``;
return `EPISODE ${s.episode_index} · source task_index=${s.task_index} ${s.frame_count} frames · ${s.fps} FPS · ${(s.frame_count/s.fps).toFixed(2)} s
OFFICIAL HF DATA 该条数据的原始 instruction
${esc(s.instruction)}
${esc(s.source_repo)} ${content}
`;
}
function drawTask(){
if(!current){document.getElementById('main').innerHTML=pageHeader()+'请选择官网场景 ';bindCameraLinks();return}
const t=current,idx=tasks.indexOf(t),samples=DATA.samples.filter(s=>s.scene_key===t.scene_key);
document.title=`C${t.catalog_number} · ${t.name} · EmbodiedSWE`;
let html=pageHeader()+`C01–C28 是本浏览页的官网目录辅助编号。官方任务 ID 使用 suite.scene ;每个 HF 数据库的 task_index / episode_index 单独编号,不能跨库混用。
${esc(t.category)} · ${esc(t.difficulty)}
C${String(t.catalog_number).padStart(2,'0')}
${esc(t.name)} ${esc(t.official_scene_id)} ← 上一个 下一个 →
评分标准 ↓ 官网任务目标 / instruction
${esc(t.instruction)}
官网列出的 evaluated on${esc(t.catalog_embodiments)}
公开示教${samples.length?samples.length+' 条完整 HF episode':'未找到该场景的公开 HF 训练示教'}
评分来源${link(t.grader_url,'当前官方 grader 源码 ↗')}
`;
if(samples.length)html+=`官方多相机示教 完整 MP4,保持上游帧数与 FPS。${esc(samples[0].views.map(v=>v.label).join(' → '))}
同步合并 MP4 各路 MP4
单臂 Franka 的 WRIST 是一个腕部相机;没有虚构 LEFT / RIGHT。额外场景相机按实际名称展示。${link('https://huggingface.co/datasets/'+t.dataset_source.repo_id,'完整官方源数据 ↗')}
${samples.map(episode).join('')} `;
if(t.gallery)html+=`
官网演示 MP4 ${esc(t.name)} · WEBSITE DEMO RECORDED RENDER VIEW
${player(t.gallery.path)}
官网播放器设为 ${t.gallery.website_playback_rate}×;这里默认按公开 MP4 文件的 1× 播放。该片段没有提供配套腕部录像或动作轨迹,不能当成多相机训练 episode。
`;
else html+='官网暂无该场景的展示 MP4。 目前未找到对应的公开 HF 示教,因此保留任务说明与评分源码,不放入不相关视频。
';
html+=`
Rubric · 评分与成功条件 Stage 权重 / 占比 记录模式 ${t.rubric.map(r=>`${esc(r.stage)} ${r.weight} / ${(r.normalized_weight*100).toFixed(1)}% ${esc(r.mode)} `).join('')}
progress 是各阶段值的归一化权重和,范围 [0,1]。live 读当前值;once 记录历史最好值;final 在交付结束时评估。score 根据过程峰值与末端完整评估决定,success 还要满足 check_success() 和 final 阶段要求。
这里展示当前公开代码的评分规则,不是本条示教的实测成绩。原始训练库可能使用更早的 grader 版本;示例没有公开逐条 score / success,因此留空。
阶段定义与源码中的成功检查 ${esc(t.grader_description)} ${esc(t.success_source)} ${t.rubric_variants?`不同 goal 的 rubric 变体 ${esc(JSON.stringify(t.rubric_variants,null,2))} `:''} `;
document.getElementById('main').innerHTML=html;bindCameraLinks();bindVideos();
for(const [id,step] of [['previous',-1],['next',1]])document.getElementById(id).onclick=()=>{query='';document.getElementById('search').value='';select(tasks[idx+step].scene_key);window.scrollTo({top:0})};
document.querySelectorAll('[data-mode]').forEach(b=>b.onclick=()=>{const y=scrollY;document.querySelectorAll('video').forEach(v=>v.pause());mode=b.dataset.mode;drawTask();window.scrollTo({top:y})});
}
function bindVideos(){
document.querySelectorAll('.episode').forEach(el=>{const vs=[...el.querySelectorAll('video')],error=el.querySelector('.error');vs.forEach(v=>v.onerror=()=>{error.hidden=false;error.textContent='当前 MP4 加载失败,可用下方文件链接打开。'});if(!el.querySelector('[data-play]'))return;let timer=null;const pause=()=>{vs.forEach(v=>v.pause());clearInterval(timer);timer=null};el.querySelector('[data-play]').onclick=async()=>{try{vs.forEach(v=>{if(v.readyState)v.currentTime=vs[0].currentTime});await Promise.all(vs.map(v=>v.play()));clearInterval(timer);timer=setInterval(()=>{if(!el.isConnected){clearInterval(timer);return}for(const v of vs.slice(1))if(v.readyState&&Math.abs(v.currentTime-vs[0].currentTime)>.2)v.currentTime=vs[0].currentTime},300)}catch(e){pause();error.hidden=false;error.textContent='请点击各播放器或选择同步合并 MP4。'}};el.querySelector('[data-pause]').onclick=pause;el.querySelector('[data-reset]').onclick=()=>{pause();vs.forEach(v=>{if(v.readyState)v.currentTime=0})};vs[0].addEventListener('pause',pause);vs[0].addEventListener('ended',pause);});
}
function bindCameraLinks(){document.querySelectorAll('.camera-link').forEach(a=>a.onclick=e=>{e.preventDefault();select('camera-guide');window.scrollTo({top:0})})}
function drawCamera(){
document.title='Franka wrist camera · EmbodiedSWE';
const codeBase='https://github.com/EmbodiedSWE/EmbodiedSWE/blob/'+DATA.source.code_revision;
const guide='https://franka.de/hubfs/Setup%20Guide%20for%20Camera%20Mount%20on%20Franka%20Robots_1.1_EN.pdf?hsLang=en';
document.getElementById('main').innerHTML=pageHeader()+`CAMERA / SIMULATION & HARDWARE
Franka 腕部相机:需要吗,装在哪? 先分清使用方式
机械臂本身不要求必须装腕部相机。EmbodiedSWE 的编码代理可直接操作模拟器状态;已发布的视觉策略数据则包含 wrist,复现这些 VLA 输入时需要匹配原相机配置。
使用场景 腕部相机 Coding-agent benchmark 不是原始 env 接口的硬性图像输入。get_states / describe_stage 等可读取模拟器状态,图像观察由包装器决定。 复现已发布 VLA 数据 / 策略 本次精选的 10 个源库都包含 wrist。闭环评估须匹配训练时的相机名称、外参、分辨率和帧率;去掉 wrist 需要重新适配与验证。 实机自己的新任务 按感知方案选择外部相机、腕部相机或二者组合。腕部相机随末端移动,适合补充近距离手指 / 工件视角。
1. EmbodiedSWE 的仿真安装 官方 Franka 模型是 Panda + 平行夹爪。相机作为子节点挂在 panda_hand ,不是挂在指尖或世界坐标中;它随 hand 的位姿一起移动。代码注释将它描述为 D435 支架 / DROID 风格,位于手旁并沿接近方向观察。
panda_hand 随机器人移动的父 link 手旁的固定支架 / 光学位置 wrist 光轴沿 hand 的 +Z 朝夹爪接近工件的方向 坐标关系示意;非机械加工图,不代表实机朝向或螺丝孔位。 参数 源码值 parent link panda_hand eye(光心,link 局部坐标) (0.0465, -0.0200, 0.0360) m = (46.5, -20, 36) mm target(局部 look-at 点) (0.0465, -0.0200, 0.3000) m focal 10.5 mm;默认 20.955 mm 水平孔径下,约 90° 水平视场。 prim(单臂默认) {ENV_REGEX_NS}/Robot/panda_hand/wrist
${link(codeBase+'/robobench/robots/franka.py','Franka 相机声明 ↗')}${link(codeBase+'/data_engine/engine/replay.py','相机挂接与 look-at 实现 ↗')}
2. 实机安装:Franka 官方支架 官方 FR3 指南提供 D435/D435i 专用 STL 与通用相机支架。相机通过支架固定在 Franka Hand 与末端法兰附近的一侧 ,不是装在会开合的手指上。先固定相机到支架,再把支架组件接到 Hand / 末端法兰的指定 M6 安装位置;D435 相机侧使用 M3 螺钉,具体螺钉和扭矩依型号查指南。
这份指南的适用型号写明 FR3;EmbodiedSWE 的仿真资产是 Panda。Panda、FR3、Franka Hand、Robotiq 夹爪并非同一套机械接口,不能直接照抄螺钉长度或把仿真 eye 坐标当作安装孔位。
实机应根据夹爪和相机型号选兼容支架,让镜头覆盖手指间的操作区,并给数据线保留活动余量。安装后的相机内参 / 手眼外参应实际标定;不能直接拿仿真坐标替代。
${link(guide,'官方安装 PDF(图 1 / 图 4)↗')}${link('https://franka.de/models-and-simulation','官方 CAD / STL 下载 ↗')}${link('https://download.franka.de/camera_mount_guide.zip','官方可打印支架 ZIP ↗')}
`;
bindCameraLinks();
}
document.getElementById('search').oninput=e=>{query=e.target.value;drawList()};
select(new URLSearchParams(location.search).get('task')??'bulb',false);
'''
def build():
tasks=json.loads((DATA/'provenance/tasks.json').read_text(encoding='utf-8'));samples=json.loads((DATA/'provenance/samples.json').read_text(encoding='utf-8'));source=json.loads((DATA/'provenance/source.json').read_text(encoding='utf-8'))
preview='--preview' in sys.argv
pubpath=ROOT/'publication.json' if (ROOT/'publication.json').exists() else DATA/'provenance/media_publication.json'
pub=json.loads(pubpath.read_text(encoding='utf-8')) if not preview else {'dataset_commit_sha':'preview'}
revision=pub['dataset_commit_sha']
payload=dict(tasks=tasks,samples=samples,source=source,repo_url='https://huggingface.co/datasets/Travor278/EmbodiedSWE-Task-Examples',media_base=f'https://huggingface.co/datasets/Travor278/EmbodiedSWE-Task-Examples/resolve/{revision}/',file_base=f'https://huggingface.co/datasets/Travor278/EmbodiedSWE-Task-Examples/blob/{revision}/')
if preview:payload.update(media_base='http://127.0.0.1:8772/dataset/',file_base='http://127.0.0.1:8772/dataset/')
template=(ROOT/'browser/base.html').read_text(encoding='utf-8');template=re.sub(r'',template,flags=re.S);template=re.sub(r'',lambda m:'',template,flags=re.S);template=template.replace('RoboDojo','EmbodiedSWE').replace('工具演示 ','相机说明 ')
extra='.task-link small{display:block;font-size:8px;color:#8eaa93;letter-spacing:.6px;margin-top:4px}.big-id{font-size:48px;letter-spacing:-2px}.benchmark-note,.data-source-note{font-size:11px;line-height:1.8;padding:13px 16px;background:#e8ece1;color:var(--muted);margin-bottom:20px;border:1px solid var(--line)}.episode-instruction{padding:14px 16px;background:#faf9f1;border-bottom:1px solid var(--line);font-size:12px;line-height:1.65}.episode-instruction p{margin:7px 0}.episode-instruction span{font-size:10px;color:var(--muted);overflow-wrap:anywhere}.metadata{padding:14px 17px;border:1px solid var(--line);background:var(--white);margin:12px 0;font-size:12px}.metadata summary{cursor:pointer}.metadata pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:11px;line-height:1.7}.camera-diagram{margin:18px 0;padding:12px;background:var(--white);border:1px solid var(--line)}.camera-diagram svg{width:100%;height:auto}.toplinks{flex-wrap:wrap}.task-heading{flex-wrap:wrap}.combined video{aspect-ratio:auto}.facts strong{overflow-wrap:anywhere}'
template=template.replace('',extra+'');encoded=json.dumps(payload,ensure_ascii=False,separators=(',',':')).replace('','<\\/')
OUT.mkdir(exist_ok=True);(OUT/'index.html').write_text(template.replace('__DATA__',encoded),encoding='utf-8')
(OUT/'README.md').write_text('''---
title: EmbodiedSWE Task Examples
emoji: 🦾
colorFrom: green
colorTo: gray
sdk: static
app_file: index.html
fullWidth: true
---
# EmbodiedSWE task and camera browser
28 official catalog scenes, 26 website clips, 30 selected complete multi-camera dataset episodes.
The static app reads MP4s from the curated dataset without duplicating media or running a simulator.
Dataset: https://huggingface.co/datasets/Travor278/EmbodiedSWE-Task-Examples
Task links use `?task=bulb`, `?task=nut_thread`, etc. The Franka wrist-camera research guide is at `?task=camera-guide`.
''',encoding='utf-8')
print('Built 28-scene browser and Franka camera guide; media revision',revision)
if __name__=='__main__':build()