Skip to content

Commit bd3023f

Browse files
committed
2 parents d4a08ef + e734a08 commit bd3023f

3 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎README_zh.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Robot.cpp是一个轻量化的on-device机器人模型推理框架,在llama.cpp的基础上进行开发,继承了其零依赖、轻量化的哲学,无需python相关的依赖配置,即可完成机器人模型推理,这使得其在跨平台尤其是环境配置复杂的边缘设备上具有优势。
66

7-
具体而言,robot.cpp最核心的概念是 `model-server`,其为最主要的统一模型接口。在实际工作,仅需要启动 `model-server`,其会监听机器人发送的推理请求,即接受机器人传来的observation,在下层model进行forward计算,返回model生成的action。整体通信设计上为了轻量化零依赖采用手写TCP协议的方式。
7+
具体而言,robot.cpp最核心的概念是 [`model-server`](robot_server/README_zh.md),其为最主要的统一模型接口。在实际工作,仅需要启动 `model-server`,其会监听机器人发送的推理请求,即接受机器人传来的observation,在下层model进行forward计算,返回model生成的action。整体通信设计上为了轻量化零依赖采用手写TCP协议的方式。
88

99
对于如何在机器人上使用,我们亦都提供了一些示例,分别提供了libero和低成本的SO-101的示例作为仿真与真机的使用模板。具体而言,我们采用以下概念组织:
1010

@@ -121,12 +121,12 @@ bash robot_client/shell/cpp_client_example.sh
121121

122122
| Model | Mac M4 Pro (CPU) | Mac M4 Pro (Metal) | RTX 4090 | RTX 3060 | A100 |
123123
| ---------------------- | ---------------- | ------------------ | -------- | -------- | ---- |
124-
| smolvla@libero (bf16*) | | 215 | | | 52 |
125-
| smolvla@libero (f32) | | 233 | | | 50 |
126-
| smolvla@so-101 (bf16*) | 339 | 145 | | | 35 |
127-
| smolvla@so-101 (f32) | 396 | 158 | | | 33 |
128-
| pi0@libero (f32) | | 720 | | | 78 |
129-
| pi0@libero (bf16*) | | 643 | | | 69 |
124+
| smolvla@libero (bf16*) | 555 | 216 | 28 | | 52 |
125+
| smolvla@libero (f32) | 577 | 236 | 32 | | 50 |
126+
| smolvla@so-101 (bf16*) | 339 | 145 | 23 | | 35 |
127+
| smolvla@so-101 (f32) | 396 | 158 | 24 | | 33 |
128+
| pi0@libero (f32) | | | | | 78 |
129+
| pi0@libero (bf16*) | | | | | 69 |
130130

131131
> `bf16*`:在 Mac上使用 f16 结果替代 bf16,因为当前 Mac对 bf16 的支持不够好。
132132

‎robot_server/README_zh.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ bash robot_server/shell/launch_robot_server_linux_cuda.sh
6565

6666
Windows 的 `.bat` 脚本:
6767

68+
### 故障排查
69+
70+
* `Tell CMake where to find the compiler by setting either the environment variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.`
71+
72+
这是因为CUDACXX变量没有被设置,通过以下方式设置环境变量即可(下面是一个案例,具体应当寻找对应机器的nvcc路径)
73+
74+
```
75+
export CUDACXX=/usr/local/cuda-12.4/bin/nvcc
76+
export PATH=/usr/local/cuda-12.4/bin:$PATH
77+
```
78+
6879
## 方法2:直接下载预编译发布
6980

7081
从release page下载之后,运行以下命令

‎src/readme_zh.md‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ STATE=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
114114
--task "pick up the fork"
115115
```
116116

117-
pi0 的 `--image-name` 必须和 checkpoint metadata 里的 `pi0.image_keys` 一致。LIBERO v044 split checkpoint 使用 `observation.images.image` 和 `observation.images.image2`。
117+
pi0 的 `--image-name` 必须和vit部分的metadata 里的 `pi0.image_keys` 一致。LIBERO v044 split checkpoint 使用 `observation.images.image` 和 `observation.images.image2`。
118118

119119
### `models/model.h`
120120

@@ -144,8 +144,6 @@ if (args.type == model_type::pi0) {
144144
}
145145
```
146146

147-
新增模型时通常需要在这里 include 新模型的 wrapper 头文件,并添加一条分发分支。
148-
149147
### `models/ggml_backend.*`
150148

151149
这组文件封装 ggml 后端、buffer、scheduler 等公共能力。多个模型都可能复用这层代码,避免每个模型目录里重复处理 ggml 初始化、设备选择和内存管理。
@@ -170,7 +168,7 @@ SmolVLA 的模型实现目录。当前主要分为两层:
170168

171169
### `models/pi0/`
172170

173-
pi0 的模型实现目录,也采用“模型专用 engine + `Model` wrapper”的结构:
171+
pi0 的模型实现目录,也采用“模型专用 engine + `Model` 子类”的结构:
174172

175173
* `pi0_engine.*`:模型专用 runtime API,例如 `pi0_params`、`pi0_context`、`pi0_init()`、`pi0_predict_raw_rgb()`、`pi0_reset()`、`pi0_free()`。
176174
* `pi0_model.*`:把 `pi0_engine` 适配到 `robotcpp::Model`。
@@ -324,7 +322,7 @@ bool make_model(const model_args & args, std::unique_ptr<Model> & out, std::stri
324322
* `print_usage()`:补充新模型的参数说明。
325323
* 参数解析循环:解析新模型需要的 CLI 参数,并写入 `model_args`。
326324

327-
如果新模型对 image name、state 维度或 task 文本有特殊要求,尽量在 wrapper 的 `predict()` 或初始化校验里返回明确错误信息,方便 CLI 和 server 复用。
325+
如果新模型对 image name、state 维度或 task 文本有特殊要求,尽量在子类的 `predict()` 或初始化校验里返回明确错误信息,方便 CLI 和 server 复用。
328326

329327
### 6. 修改 CMake
330328

@@ -340,8 +338,6 @@ add_library(robotcpp STATIC
340338
)
341339
```
342340

343-
如果新模型内部 runtime 足够大、需要单独测试,或要复用已有 ggml/llama 链接配置,也可以建立自己的 target,再让 `robotcpp` 链接它。是否叫 `newmodel_engine` 不重要,重点是外部仍通过 `robotcpp::Model` 创建和调用模型。
344-
345341
### 7. 验证
346342

347343
#### 新模型最小验证模板
@@ -353,25 +349,21 @@ add_library(robotcpp STATIC
353349
--model-type newmodel \
354350
--image /path/to/image.png \
355351
--image-name image \
356-
--state 0,0,0 \
352+
--state 0,0,0,0,0,0 \
357353
--task "grab the block." \
358354
--threads 4 \
359355
--newmodel-weights /path/to/newmodel.gguf
360356
```
361357

362-
如果 `model-server` 也要使用该模型,还需要确认 server 启动参数能把新模型所需字段传到 `model_args`。通常应保持 server 和 CLI 使用同一套 `make_model()` 路径,以避免两边行为不一致。
358+
如果 `model-server` 也要使用该模型,还需要确认 server 启动参数能把新模型所需字段传到 `model_args`。
363359

364360
## 新模型接入检查清单
365361

366362
* `tools/hf2gguf/<model_name>/` 已能把原始 checkpoint 或 `.pt` 转成 C++ runtime 使用的 GGUF。
367363
* `tools/quant/config/<model_name>_origin.yaml` 已覆盖新模型的所有 GGUF component 和 tensor group。
368-
* `src/models/<model_name>/` 下有清晰的 `Model` wrapper;只有在确实需要时才拆出内部 runtime 或 engine。
364+
* `src/models/<model_name>/` 下有清晰的 `Model` ==子类==;只有在确实需要时才拆出内部 runtime 或 engine。
369365
* `model_type` 已增加新枚举。
370366
* `model_args` 已包含新模型初始化所需参数。
371367
* `model_factory.cpp` 已接入新模型。
372368
* `model-cli.cpp` 已支持 `--model-type <model_name>` 和必要参数。
373369
* `CMakeLists.txt` 已加入新模型源文件,并让 `robotcpp` 能链接到必要的内部组件。
374-
* `predict()` 会校验输入图片、state、task,并通过 `error` 返回可读错误。
375-
* `model_result.actions`、`chunk_size`、`action_dim` 的含义与现有模型保持一致。
376-
* `reset()` 在模型有 cache 或时序状态时能正确清理状态。
377-
* `model-cli` 和 `model-server` 走同一套 wrapper,不额外绕过 `robotcpp::Model`。

0 commit comments

Comments
 (0)