Files
liyang aed6e20a90 双臂操作沙盒(MuJoCo WASM 浏览器版)首次入库
从 ~/mujoco-web-spike 抽出 manip.html 的依赖闭包:
- manip.html + src/{manip,autograsp,scene-bridge,math}.js
- scenes/so101_pair(桌面并排两台 SO-101,默认)与 scenes/p7_bimanual(P7 双臂 + SO-101 夹爪)
  —— 自包含 MJCF,网格已内联
- serve.py(COOP/COEP + no-store 的静态服务器)、start.sh、README
- tools/export_manip_scene.py 场景生成脚本(仅供参考,跑页面不需要)

快照对应 2026-08-31 的最后一次改动(自动抓取规划 autograsp.js 落地版)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016tgfYxR5mWNRKQ67PKga4T
2026-09-01 17:16:41 +08:00

32 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
跟 `python3 -m http.server` 一样零依赖,只多发两个头:
Cross-Origin-Opener-Policy: same-origin + Cross-Origin-Embedder-Policy: require-corp。
@mujoco/mujoco 这个 WASM 包是多线程(pthread)构建,启动时要用 SharedArrayBuffer
而浏览器只在"跨源隔离"cross-origin isolated)页面里才允许用 SharedArrayBuffer。
不发这两个头的话,WASM 会卡在 wasm-instantiate 那一步一直转,既不报错也不失败,
表现就是"初始化 MuJoCo…"卡死不动——console 里唯一线索是反复打印
"still waiting on run dependencies: dependency: wasm-instantiate"。
jsDelivr 给这个包的资源都带 Cross-Origin-Resource-Policy: cross-origin
所以跨源隔离页面照样能从 CDN 拉东西,不会被 COEP 卡住。
"""
import http.server
import sys
class Handler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
# 开发中的资源一律不缓存。ES 模块缓存得特别死:改完 src/*.js 普通刷新
# 照样跑旧代码,而且**不报错**,只在调用新方法时抛
# "xxx is not a function" —— 极难往缓存上想,已经浪费过一轮排查。
self.send_header('Cache-Control', 'no-store, must-revalidate')
super().end_headers()
if __name__ == '__main__':
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
http.server.test(HandlerClass=Handler, port=port)