Q1:
curl -L -o alpha_walking.onnx 网页前缀+alpha_walking.onnx下载超时
A1:
使用国内镜像站
curl -L -o alpha_walking.onnx https://hf-mirror.com/+源目录+alpha_walking.onnx
其他镜像备选:除hf-mirror.com外,还可尝试:
上海交大镜像:
https://hf-mirror.sjtu.edu.cn+网页名称清华大学镜像:
https://mirrors.tuna.tsinghua.edu.cn/huggingface/+网页名称中科大镜像:
https://mirrors.ustc.edu.cn/huggingface/models/+网页名称
Q2:
uv run scripts/infer_policy.py --walking policies/alpha_walking.onnx --standing
policies/alpha_stand.onnx --new-cmd-obs运行目录?
A2:
这个命令需要在包含scripts/infer_policy.py的项目根目录下运行。通常就是你克隆下来的microduck 代码仓库的根目录(该目录下应该有pyproject.toml、scripts/文件夹等)。
具体操作步骤:
find ~ -name infer_policy.py 2>/dev/null cd ~/microduck # 换成你实际克隆的路径 mkdir -p policies curl -L -o policies/alpha_stand.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_stand.onnx uv run scripts/infer_policy.py --walking policies/alpha_walking.onnx --standing policies/alpha_stand.onnx --new-cmd-obsQ3:
usage: infer_policy.py [-h] [--roller] [--scene SCENE] [--walking WALKING] [--standing STANDING] [--ground-pick GROUND_PICK] [--sit SIT] [--sitstand SITSTAND] [--slope SLOPE] [--kick-left KICK_LEFT] [--kick-right KICK_RIGHT] [--roulade ROULADE] [--kick-duration KICK_DURATION] [--roulade-duration ROULADE_DURATION] [--lin-vel-x LIN_VEL_X] [--lin-vel-y LIN_VEL_Y] [--ang-vel-z ANG_VEL_Z] [--action-scale ACTION_SCALE] [--raw-accelerometer] [--delay [DELAY ...]] [--debug] [--save-csv SAVE_CSV] [--record RECORD] [--switch-threshold SWITCH_THRESHOLD] [--ground-pick-period GROUND_PICK_PERIOD] [--new-cmd-obs] [--no-bam] [--vin VIN] [--vin-drop-gain VIN_DROP_GAIN] [--kp-fw KP_FW] [--current-limit CURRENT_LIMIT] [--foot-friction FOOT_FRICTION] [--foot-solref FOOT_SOLREF] [--odom-anchor-points [SETS]] [--odom-compare] infer_policy.py: error: argument --standing/-s: expected one argument ../policies/alpha_standing.onnx: line 1: Entry: command not foundA3:
这个报错是因为命令被换行截断了,不是模型文件本身的问题。
正确写法(两种任选)
写法一:整个命令写在一行(推荐)
uv run scripts/infer_policy.py --walking ./policies/alpha_walking.onnx --standing ./policies/alpha_standing.onnx --new-cmd-obs写法二:用反斜杠\续行(注意\后面不能有空格)
uv run scripts/infer_policy.py \ --walking ./policies/alpha_walking.onnx \ --standing ./policies/alpha_standing.onnx \ --new-cmd-obsQ4:
Loading MuJoCo model from: src/mjlab_microduck/robot/microduck/scene.xml BAM m6 actuators on 14 joints: kt=0.3660 R=2.8114 vin=7.40V kp_fw=200 vin_drop_gain=0.1 vin_min=6.0 max_current=None forcerange=+/-0.963Nm armature=1.81e-03 Loading walking policy from: ../policies/alpha_walking.onnx Walking policy input: obs, shape: [1, 61] Walking policy output: actions, shape: [1, 14] Loading standing policy from: ../policies/alpha_standing.onnx Traceback (most recent call last): File "/mnt/d/桌面/WSL/Ubuntu-22.04/microduck_rl/scripts/infer_policy.py", line 1820, in <module> main() File "/mnt/d/桌面/WSL/Ubuntu-22.04/microduck_rl/scripts/infer_policy.py", line 1324, in main policy = PolicyInference( ^^^^^^^^^^^^^^^^ File "/mnt/d/桌面/WSL/Ubuntu-22.04/microduck_rl/scripts/infer_policy.py", line 259, in __init__ self.standing_session = ort.InferenceSession(standing_onnx_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/d/桌面/WSL/Ubuntu-22.04/microduck_rl/.venv/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 504, in __init__ self._create_inference_session(providers, provider_options, disabled_optimizers) File "/mnt/d/桌面/WSL/Ubuntu-22.04/microduck_rl/.venv/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 599, in _create_inference_session sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from ../policies/alpha_standing.onnx failed:Protobuf parsing failed.A4:
这个InvalidProtobuf: Protobuf parsing failed错误,通常意味着 ONNX 模型文件本身损坏了,而不是代码或环境的问题。排查步骤按以下顺序来就行:
🔍 第一步:检查文件是否完整下载
最常见的原因就是文件下载不完整,尤其是在网络不稳定的情况下。
检查文件大小:在 WSL 终端里运行
ls -l命令,查看alpha_standing.onnx的实际大小。一个完整的官方 ONNX 策略文件大小应该在794 KB左右。
如果文件大小远小于这个值(比如只有几 KB),那基本可以确定是下载中断了。
检查文件哈希值(可选):为了更精确地验证,可以计算文件的 SHA-256 哈希值,并与官方源进行比对。虽然官方未直接提供此文件的哈希值,但这是一个可靠的验证方法。如果哈希值不匹配,说明文件已损坏。
bash
sha256sum ../policies/alpha_standing.onnx
📁 第二步:检查文件路径与符号链接
从你的报错路径../policies/alpha_standing.onnx来看,你使用了相对路径。请确认:
文件确实存在:在
scripts/目录的上一级,policies/目录下确实有alpha_standing.onnx这个文件。避免符号链接:如果你的项目是从 Git 仓库克隆的,且包含符号链接(symlink),在 Windows 或 WSL 环境下,链接可能未被正确保留,导致文件内容变成了一行文本路径。你可以用
cat命令检查文件内容:bash
cat ../policies/alpha_standing.onnx
如果输出的是一行路径文本(例如
../../gen/model/model.onnx),而不是乱码或二进制内容,就说明符号链接损坏了。
🔧 第三步:修复与重新下载
如果文件损坏或链接错误,最直接的解决方法是删除旧文件,并重新下载。
建议使用之前提到的hf-mirror.com镜像站进行下载,它更稳定,且支持断点续传。
bash
# 进入你存放模型的目录,例如 policies/ cd /mnt/d/桌面/WSL/Ubuntu-22.04/microduck_rl/policies/ # 删除损坏的文件 rm alpha_standing.onnx # 使用镜像站重新下载 curl -L -o alpha_standing.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_standing.onnx
下载完成后,再次用ls -l确认文件大小正确(约 794 KB)。
⚙️ 第四步:检查库版本兼容性
如果重新下载后问题依旧,可能是 Python 环境中的onnxruntime、onnx和protobuf库之间存在版本冲突。可以尝试在虚拟环境中重新安装或指定版本。
bash
# 在项目根目录,激活 uv 环境后 uv pip install --upgrade onnxruntime onnx protobuf
如果升级无效,可以尝试一个已知的兼容组合:onnxruntime==1.16.0配合protobuf<4.0.0。
💎 总结
建议先执行第一步的ls -l检查。如果文件大小异常,直接用第三步的方法重新下载即可解决。如果文件大小正常,再检查路径和符号链接。
Q5:
curl -L -o alpha_walking.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_walking.onnx,现在我要拉取standing的onnx
A5:
直接运行这条命令即可拉取 standing 的 ONNX:
bash
curl -L -o alpha_standing.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_standing.onnx
如果你当前在项目根目录,想直接放到policies/目录下:
bash
curl -L -o policies/alpha_standing.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_standing.onnx
如果之前下载中断过,想断点续传:
bash
curl -L -C - -o alpha_standing.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_standing.onnx
⚠️ 注意:如果之前的alpha_standing.onnx已经损坏(比如只有几 KB),建议先删掉再重新下载,不要直接续传:
bash
rm -f alpha_standing.onnx curl -L -o alpha_standing.onnx https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_standing.onnx
下载完后检查一下文件大小:
bash
ls -lh alpha_standing.onnx file alpha_standing.onnx
正常应该是几百 KB 到 1MB 左右,如果只有几 KB,说明还是没下载完整,需要重新下。
为啥这个standing文件只有1KB
你下载的alpha_standing.onnx只有 1KB,是因为它是一个 Git LFS 指针文件,而不是真正的模型文件。
🔍 为什么是 1KB?
Hugging Face 仓库使用 Git LFS 来管理大文件。当你用curl直接访问resolve/main/路径时,如果镜像站或网络环境没有正确触发 LFS 文件的真实下载,你拿到的就只是这个指向真实文件的文本指针。
你可以用cat命令查看一下它的内容,会看到类似这样的文本:
text
version https://git-lfs.github.com/spec/v1 oid sha256:1569268713e40deea795dd2922dba50d3621e15a872855408b6b1b125b1c094b size 793705
这明确说明了真实文件的大小是793,705 字节(约 794 KB),而你只拿到了描述它的“索引卡”。
⚠️ 为什么curl会拿到指针?
这通常和hf-mirror.com镜像站的 LFS 代理机制有关。某些情况下,镜像站返回的是 LFS 指针而非真实数据,或者curl没有携带正确的请求头来触发 LFS 重定向。
✅ 解决方案
删除这个 1KB 的损坏文件,改用huggingface-cli工具下载,它能自动正确处理 LFS 文件的解析和下载。
bash
# 1. 删除损坏的指针文件 rm policies/alpha_standing.onnx # 2. 使用 huggingface-cli 下载(会自动处理 LFS) export HF_ENDPOINT=https://hf-mirror.com huggingface-cli download pollen-robotics/microduck-policies alpha_standing.onnx --local-dir policies/
下载完成后,用ls -lh policies/alpha_standing.onnx确认大小在794 KB左右,就说明下载成功了。
huggingface-cli: command not found
huggingface-cli没有装,需要先安装。你在用uv,所以在项目根目录下执行:
方式一:用 uv 装(推荐,装进项目虚拟环境)
bash
uv pip install -U "huggingface_hub[cli]"
装完后,如果huggingface-cli还是提示找不到,可以用uv run前缀来调用:
bash
uv run huggingface-cli --help
或者用新的等价命令(新版 huggingface_hub 推荐):
bash
uv run hf --help
方式二:全局装(不依赖项目环境)
bash
pip install -U "huggingface_hub[cli]"
如果你的系统 Python 受 PEP 668 保护(Ubuntu 22.04 常见),需要加--break-system-packages或者用 pipx:
bash
pipx install "huggingface_hub[cli]"
安装完成后下载 standing 模型
bash
# 设置镜像 export HF_ENDPOINT=https://hf-mirror.com # 下载(用 uv run 确保调用的是项目环境里的) uv run huggingface-cli download pollen-robotics/microduck-policies alpha_standing.onnx --local-dir policies/
如果新版工具用的是hf命令:
bash
uv run hf download pollen-robotics/microduck-policies alpha_standing.onnx --local-dir policies/
验证
bash
ls -lh policies/alpha_standing.onnx
应该显示约 794 KB。如果还是 1KB,说明 LFS 没被正确解析,把cat policies/alpha_standing.onnx的输出发出来看看。
Warning: `huggingface-cli` is deprecated and no longer works. Use `hf` instead.
新版huggingface_hub已经用hf命令取代了huggingface-cli,直接改用hf就行:
下载 standing 模型
bash
export HF_ENDPOINT=https://hf-mirror.com uv run hf download pollen-robotics/microduck-policies alpha_standing.onnx --local-dir policies/
如果你想一次把 walking 和 standing 都拉下来(避免重复):
bash
uv run hf download pollen-robotics/microduck-policies alpha_walking.onnx alpha_standing.onnx --local-dir policies/
验证文件是否真的下载成功
bash
ls -lh policies/
正常应该是:
text
alpha_walking.onnx 约 794 KB alpha_standing.onnx 约 794 KB
如果某个文件还是 1KB,先删掉再重下:
bash
rm -f policies/alpha_standing.onnx uv run hf download pollen-robotics/microduck-policies alpha_standing.onnx --local-dir policies/
如果hf也提示找不到
说明装的时候没带上 CLI 组件,重新装一次:
bash
uv pip install -U "huggingface_hub[cli]"
然后再运行uv run hf --help确认能正常调用。
下载完成后跑仿真
bash
uv run scripts/infer_policy.py --walking ./policies/alpha_walking.onnx --standing ./policies/alpha_standing.onnx --new-cmd-obs
如果ls显示文件大小正常(794 KB 左右),这次就不会再报Protobuf parsing failed了。
Error: File not found in repository.
URL: https://hf-mirror.com/pollen-robotics/microduck-policies/resolve/main/alpha_standing.onnx
这个 404 错误说明仓库里没有alpha_standing.onnx这个文件,你之前下载的 1KB 文件只是一个指向不存在路径的 Git LFS 指针。
🔍 正确的文件名是什么?
根据 Pollen Robotics 官方仓库的记录,正确的文件名是alpha_stand.onnx(没有 "ing")。官方在代码中明确列出了这两个核心策略的对应关系:
| 角色名 (Role) | 仓库中的实际文件名 |
|---|---|
alpha_walking.onnx | BEST_alpha_walking_flat.onnx或BEST_alpha_walking_rough.onnx |
alpha_stand.onnx | BEST_alpha_stand.onnx |
所以你在infer_policy.py命令中应该使用alpha_stand.onnx,而不是alpha_standing.onnx。
✅ 正确的下载命令
先删除之前下载的损坏文件,再用正确的文件名重新下载:
bash
# 1. 删除损坏的 1KB 文件 rm -f policies/alpha_standing.onnx # 2. 用正确的文件名下载 export HF_ENDPOINT=https://hf-mirror.com uv run hf download pollen-robotics/microduck-policies alpha_stand.onnx --local-dir policies/
下载完成后验证文件大小:
bash
ls -lh policies/alpha_stand.onnx
正常应该是约 794 KB(官方记录的大小是 793,695 字节)。
⚠️ 注意:官方默认配置已变更
有一个重要变化需要留意:从2026-09-14起,官方的默认行走策略已经换成了velstand.onnx,站立网络(alpha_stand.onnx)不再默认加载。这意味着:
如果你使用的是
--walking+--standing的组合(即你当前命令的方式),仍然需要alpha_stand.onnx文件,可以继续按上述方式下载。但如果你希望使用官方最新的默认配置,
--standing参数可以省略,直接用velstand.onnx作为行走策略即可。
🚀 修正后的仿真命令
bash
uv run scripts/infer_policy.py --walking ./policies/alpha_walking.onnx --standing ./policies/alpha_stand.onnx --new-cmd-obs
成功打开Microduck的仿真界面了,如何操纵它
仿真界面打开后,你可以用键盘或游戏手柄来控制这只小鸭子。核心控制方式整理如下。
⌨️ 键盘控制
这是最直接的控制方式,主要按键功能如下:
| 按键 | 功能 |
|---|---|
| 方向键或WASD | 控制前进、后退和横向移动 |
| A / E | 向左 / 向右转(在 AZERTY 键盘上对应Q / E) |
| G | 触发“地面拾取”动作 |
| Y | 坐下 / 站起切换 |
| R | 前滚翻 |
| K / L | 左 / 右脚踢球 |
| O | 六秒前后劈叉,然后恢复 |
| Space | 清除当前速度指令,让鸭子停下 |
| Q | 退出仿真 |
| M | 在腿式行走和轮式移动模式间切换(需要按住约1秒) |
| C | 切换/锁定跟随摄像机(默认开启) |
小提示:用鼠标拖拽可以环绕观察视角,滚动滚轮可以拉近拉远。
🎮 游戏手柄控制
如果你有手柄,插上后会自动映射,控制逻辑和真机一致。
左摇杆:控制前进/后退和转向。
右摇杆:环绕摄像机视角(会自动解除跟随摄像)。
R3(右摇杆按下):重新开启跟随摄像机。
D-pad 下:坐下 / 站起切换。
D-pad 上:长按约1秒,切换腿式/轮式模式(真机需长按3秒)。
X:坐下/站起(腿式)或蹲伏滑行(轮式)。
A:地面拾取(腿式)。
Y:切换头部控制模式。
RB / LB:右 / 左脚踢球(仅腿式)。
右扳机:控制嘴巴(模拟量)并发出“嘎嘎”声。
💡 补充提示
关于策略文件:你当前只加载了
--walking和--standing两个策略,所以G、R、K、L、O这些依赖其他 ONNX 文件的动作可能不会响应。如果想体验完整功能,需要把对应的 ONNX 文件也下载下来,并在启动命令里通过--ground-pick、--roulade等参数指定路径。仿真速度:仿真在 CPU 上以50 Hz运行,操作反馈是实时的。
你可以先试试方向键和Y键,熟悉一下手感。如果某个按键没反应,很可能是对应的策略文件没有加载。
rad/s trunk_z=116.3 mm
[vel 1s avg] achieved/cmd fwd=+0.00/+0.00 lat=-0.00/+0.00 m/s yaw=-0.00/+0.00 rad/s trunk_z=116.3 mm
[vel 1s avg] achieved/cmd fwd=+0.00/+0.00 lat=+0.00/+0.00 m/s yaw=-0.00/+0.00 rad/s trunk_z=116.3 mm
achieved/cmd显示指令和目标速度全是0.00,这说明问题不在策略文件,而是键盘输入根本没有被发送到仿真程序。
结合你之前提到的“鼠标转视角没问题”,可以定位到两个最可能的原因。
🎯 原因一:键盘焦点被终端拦截(最可能)
这是最常见的情况。在 WSL 环境下,键盘输入可能被启动仿真的终端窗口截获了,而不是发送给 MuJoCo 的图形窗口。
现象:鼠标可以操作图形窗口,但键盘操作无效。
解决办法:不要点击仿真窗口,而是点击启动仿真的那个终端窗口(黑框),确保它是当前活动窗口,然后直接按方向键(↑↓←→)或
WASD。许多在 WSL 上运行 Microduck 的教程都强调了这一点:需要在黑色的控制台窗口里键入按键,而不是在 3D 渲染窗口里。
验证:在终端窗口按
F1,如果 MuJoCo 窗口弹出帮助菜单,说明键盘输入已经正确传递。
🖥️ 原因二:终端不是 TTY,导致键盘控制被禁用
infer_policy.py脚本在 Unix 系统上会检查标准输入(stdin)是否为一个 TTY(终端)。如果uv run以某种方式改变了 stdin 的指向,脚本会因检测到非 TTY 而主动禁用键盘控制,并在终端打印警告:WARNING: stdin is not a TTY — keyboard control disabled。
现象:终端可能出现警告,或者按键完全没反应。
解决办法:确保你在一个标准的、可交互的终端里运行命令。可以尝试:
直接在终端中运行,而不是通过 IDE(如 VS Code)的集成终端,有时 IDE 的终端会重定向 stdin。
如果问题依旧,可以尝试在命令前加上
script命令来强制分配一个伪终端(pty):bash
script -q -c "uv run scripts/infer_policy.py --walking ./policies/alpha_walking.onnx --standing ./policies/alpha_stand.onnx --new-cmd-obs" /dev/null
🔧 其他排查与确认
如果以上方法都无效,可以按顺序检查:
确认终端输出:启动仿真时,终端应显示
Using GLFW backend。如果显示的是OSMesa或EGL,则说明渲染后端不支持键盘输入。检查输入法:确保当前是英文输入法,中文输入法可能会拦截按键。
确认策略文件:再次确认
policies/目录下的 ONNX 文件大小正常(约 794 KB),排除 LFS 指针文件的可能。尝试无头模式(排查性能):如果终端有性能警告,可以尝试用
DUCK_SIM_VIEWER=0环境变量启动,在不渲染窗口的情况下测试策略是否能通过键盘指令行走,以排除渲染性能瓶颈。bash
DUCK_SIM_VIEWER=0 uv run scripts/infer_policy.py --walking ./policies/alpha_walking.onnx --standing ./policies/alpha_stand.onnx --new-cmd-obs
使用游戏手柄:如果手头有游戏手柄,可以尝试连接。手柄控制通常不受键盘焦点问题的影响,如果手柄能控制,则进一步确认是键盘输入路径的问题。
💎 总结
建议先点击启动仿真的终端窗口,然后按方向键试试。如果仍无效,再检查终端是否有stdin is not a TTY的警告,并尝试用script命令来运行。