# RoboCerebra

  The commands below run the simulator locally. To keep its dependencies away from your policy's, serve it instead with `lerobot-env-server --config_path=docker/sim/configs/robocerebra.yaml --sim.task= --docker=true`, where `` is the command's `--env.task`, and run the command with `--env.type=robocerebra --env.server.endpoint=tcp/127.0.0.1:7448`. A server runs the task it was started with (see [Simulation: local or served](./simulation)).

[RoboCerebra](https://robocerebra.github.io/) 是一个长时程操作基准，用于评估 VLA 中的**高层推理、规划和记忆**能力。每个回合将多个子目标串联起来，并包含基于语言的中间指令，其构建基于 LIBERO 的模拟器栈（MuJoCo + robosuite，Franka Panda 7-DOF）。

- 论文：[RoboCerebra：用于长时程机器人操作评估的大规模基准](https://arxiv.org/abs/2506.06677)
- 项目网站：[robocerebra.github.io](https://robocerebra.github.io/)
- 数据集：[`lerobot/robocerebra_unified`](https://huggingface.co/datasets/lerobot/robocerebra_unified) — LeRobot v3.0，6,660 个片段 / 571,116 帧，帧率为 20 fps，包含 1,728 个基于语言的子任务。
- 预训练策略: [`lerobot/smolvla_robocerebra`](https://huggingface.co/lerobot/smolvla_robocerebra)

## 可用任务

RoboCerebra 复用了 LIBERO 的模拟器，因此评估在 LIBERO 的 `libero_10` 长时程任务套件上运行：

| 套件     | CLI 名称    | 任务 | 描述                                                   |
| --------- | ----------- | ----- | ------------------------------------------------------------- |
| LIBERO-10 | `libero_10` | 10    | 长时程厨房/客厅任务，串联 3–6 个子目标 |

数据集中的每个 RoboCerebra 片段都被分割为多个带有自然语言指令的子任务，统一数据集将这些子任务作为独立的监督信号暴露出来。

## 安装

RoboCerebra 基于 LIBERO 构建，因此您只需要 `libero` 附加组件：

```bash
pip install -e ".[libero]"
```

RoboCerebra 需要 Linux（MuJoCo / robosuite）。在训练或评估之前，请设置渲染后端：

```bash
export MUJOCO_GL=egl  # for headless servers (HPC, cloud)
```

## 评估

RoboCerebra 的评估运行针对 LIBERO 的 `libero_10` 套件，采用 RoboCerebra 的相机命名方式（`image` + `wrist_image`），并额外包含一个空相机槽位，以确保经过三视图训练的策略能够接收到预期的输入布局：

```bash
lerobot-eval \
  --policy.path=lerobot/smolvla_robocerebra \
  --env.type=libero \
  --env.task=libero_10 \
  --env.fps=20 \
  --env.obs_type=pixels_agent_pos \
  --env.observation_height=256 \
  --env.observation_width=256 \
  '--env.camera_name_mapping={"agentview_image": "image", "robot0_eye_in_hand_image": "wrist_image"}' \
  --eval.batch_size=1 \
  --eval.n_episodes=10 \
  --eval.use_async_envs=false \
  --policy.device=cuda \
  '--rename_map={"observation.images.image": "observation.images.camera1", "observation.images.wrist_image": "observation.images.camera2"}' \
  --policy.empty_cameras=1
```

### 推荐的评估回合

在 `libero_10` 套件中，每个任务包含 **10 个回合**（共 100 个回合），以实现可复现的基准测试。这与 RoboCerebra 论文中使用的协议一致。

## 策略输入和输出

**观察：**

- `observation.state` — 8 维本体感觉状态（7 个关节位置 + 夹爪）
- `observation.images.image` — 第三人称视角，256×256 HWC uint8
- `observation.images.wrist_image` — 手腕摄像头视角，256×256 HWC uint8

**操作：**

- `Box(-1, 1, shape=(7,))` 中的连续控制 — 末端执行器增量（6D）+ 夹爪（1D）

## 训练

位于 [`lerobot/robocerebra_unified`](https://huggingface.co/datasets/lerobot/robocerebra_unified) 的统一数据集提供了两个 RGB 流以及基于语言的子任务标注：

| 功能                          | 形状         | 描述          |
| -------------------------------- | ------------- | -------------------- |
| `observation.images.image`       | (256, 256, 3) | 第三人称视角    |
| `observation.images.wrist_image` | (256, 256, 3) | 手腕佩戴式相机 |
| `observation.state`              | (8,)          | 关节位置 + 夹爪  |
| `action`                         | (7,)          | EEF 增量 + 夹爪  |

在其基础上微调 SmolVLA 基础模型：

```bash
lerobot-train \
  --policy.path=lerobot/smolvla_base \
  --policy.repo_id=${HF_USER}/smolvla_robocerebra \
  --policy.empty_cameras=1 \
  --dataset.repo_id=lerobot/robocerebra_unified \
  '--rename_map={"observation.images.image": "observation.images.camera1", "observation.images.wrist_image": "observation.images.camera2"}' \
  --env.type=libero \
  --env.task=libero_10 \
  '--env.camera_name_mapping={"agentview_image": "image", "robot0_eye_in_hand_image": "wrist_image"}' \
  --output_dir=outputs/smolvla_robocerebra
```

`smolvla_base` 要求相机的名称为 `camera1`–`camera3`，因此相机参数与 [Evaluation](#evaluation) 命令中的相同：`--rename_map` 将数据集中的相机映射到这些名称，而 `--env.camera_name_mapping` 则在训练期间的评估中为 LIBERO 相机指定数据集的名称。

## 复现已发表的结果

发布的检查点 [`lerobot/smolvla_robocerebra`](https://huggingface.co/lerobot/smolvla_robocerebra) 是在 `lerobot/robocerebra_unified` 上训练的，并使用 [评估](#evaluation) 部分中的命令进行评估。CI 会在每个涉及该基准测试的 PR 上，使用 `--eval.n_episodes=1` 运行相同的命令作为冒烟测试。

