RL with RoboCasa Benchmark
==========================

.. |huggingface| image:: /_static/svg/hf-logo.svg
   :width: 16px
   :height: 16px
   :class: inline-icon

.. figure:: https://raw.githubusercontent.com/RLinf/misc/main/pic/robocasa.jpeg
   :align: center
   :width: 90%

   RoboCasa (image: `RoboCasa <https://robocasa.ai/>`__).

`RoboCasa <https://robocasa.ai/>`__ is a robosuite-based kitchen manipulation
benchmark with diverse layouts, objects, and atomic tasks. You'll use RLinf to
PPO-fine-tune an OpenPI π₀ policy on the RoboCasa ``CloseDrawer`` task.

Overview
--------

Fine-tune OpenPI π₀ on a mobile-manipulation kitchen task in RoboCasa.

.. grid:: 2 4 4 4
   :gutter: 2

   .. grid-item-card:: Models
      :text-align: center

      π₀

   .. grid-item-card:: Algorithms
      :text-align: center

      PPO

   .. grid-item-card:: Tasks
      :text-align: center

      CloseDrawer

   .. grid-item-card:: Hardware
      :text-align: center

      1 node · 8 GPUs

| **You'll do:** install → download kitchen assets + model → launch ``run_embodiment.sh`` → watch ``env/success_once``.
| **Prerequisites:** :doc:`Installation </rst_source/start/installation>` · RoboCasa kitchen assets · an SFT checkpoint.

Tasks
~~~~~

.. list-table::
   :header-rows: 1
   :widths: 34 66

   * - Task
     - Description
   * - ``CloseDrawer``
     - Close a kitchen drawer with the PandaOmron mobile manipulator.

Observation and Action
~~~~~~~~~~~~~~~~~~~~~~

.. list-table::
   :header-rows: 1
   :widths: 18 82

   * - Field
     - Specification
   * - Observation
     - Two RGB views by default (``base_image`` and ``wrist_image`` at 224×224) plus a 25-dim proprioceptive state.
   * - Action
     - 12-dim continuous action: arm position delta, arm rotation delta, gripper, base control, and mode selection.
   * - Reward
     - Sparse task-completion reward.
   * - Prompt
     - Natural-language instruction generated by the RoboCasa task.

.. note::

   RoboCasa includes more atomic tasks, but the public RLinf recipe currently
   targets ``CloseDrawer`` with ``examples/embodiment/config/robocasa_closedrawer_ppo_openpi.yaml``.

Installation
------------

.. include:: _setup_common.rst

**Docker image**

.. code:: bash

   docker run -it --rm --gpus all \
      --shm-size 32g \
      --network host \
      --name rlinf \
      -v .:/workspace/RLinf \
      rlinf/rlinf:agentic-rlinf0.3-robocasa

   # For mainland China users:
   # docker.1ms.run/rlinf/rlinf:agentic-rlinf0.3-robocasa

Switch to the OpenPI virtual environment inside the image:

.. code:: bash

   source switch_env openpi

**Custom environment**

Install RoboCasa with the OpenPI dependencies:

.. code:: bash

   # Mainland China users can add --use-mirror.
   bash requirements/install.sh embodied --model openpi --env robocasa
   source .venv/bin/activate

Download the kitchen assets after installing RoboCasa:

.. code:: bash

   python -m robocasa.scripts.download_kitchen_assets

.. warning::

   The RoboCasa kitchen assets are about 5 GB. Download them once before launching training.

Download the Model
------------------

Download the OpenPI π₀ checkpoint:

.. code-block:: bash

   cd /path/to/save/model

   git lfs install
   git clone https://huggingface.co/RLinf/RLinf-Pi0-RoboCasa

   # Or use huggingface-hub:
   # export HF_ENDPOINT=https://hf-mirror.com
   pip install huggingface-hub
   hf download RLinf/RLinf-Pi0-RoboCasa --local-dir RLinf-Pi0-RoboCasa

.. include:: _model_path.rst

Run It
------

Launch the CloseDrawer recipe:

.. list-table::
   :header-rows: 1
   :widths: 28 46 26

   * - Recipe
     - Config
     - Command suffix
   * - OpenPI π₀ + PPO
     - ``examples/embodiment/config/robocasa_closedrawer_ppo_openpi.yaml``
     - ``robocasa_closedrawer_ppo_openpi``

.. code:: bash

   bash examples/embodiment/run_embodiment.sh robocasa_closedrawer_ppo_openpi

What this does:

1. Starts the embodied training entrypoint with the RoboCasa Hydra config.
2. Creates Ray workers for the actor, rollout, and RoboCasa env components.
3. Runs PPO rollouts, computes sparse task rewards, and updates the OpenPI policy.

For standalone evaluation, use the unified :doc:`Evaluation CLI
<../../evaluations/reference/cli>` with config fallback and the same suffix,
``robocasa_closedrawer_ppo_openpi``.

.. note::

   The default config uses ``actor,env,rollout: all``. Tune
   ``env.train.total_num_envs``, ``env.eval.total_num_envs``, and
   ``actor.global_batch_size`` for your GPU memory budget.

Visualization and Results
-------------------------

Launch TensorBoard from the RLinf repo root:

.. code:: bash

   tensorboard --logdir ../results --port 6006

The key signal is ``env/success_once``. For every logged metric, see
:doc:`Training metrics <../../reference/metrics>`.

Enable video in the env config when you want rollout videos:

.. code:: yaml

   video_cfg:
     save_video: True
     info_on_video: True
     video_base_dir: ${runner.logger.log_path}/video/train

Enable W&B or SwanLab by adding logger backends:

.. code:: yaml

   runner:
     logger:
       logger_backends: ["tensorboard", "wandb"]  # or swanlab

.. note::

   This page does not publish a fixed RoboCasa success-rate table yet. Use
   ``env/success_once`` and evaluation videos to compare your runs.
