Metadata-Version: 2.4
Name: reaf-sim
Version: 1.1.0
Summary: Robotics Environment Authoring Framework - Simulation Modules.
License-Expression: Apache-2.0
Project-URL: Documentation, https://reaf-sim.readthedocs.io/
Project-URL: Repository, https://github.com/google-deepmind/reaf-sim
Project-URL: Issues, https://github.com/google-deepmind/reaf-sim/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Requires-Python: <3.15,>=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: absl-py
Requires-Dist: dm-env
Requires-Dist: dm-tree
Requires-Dist: gdm_robotics
Requires-Dist: immutabledict
Requires-Dist: mujoco[sysid]>=4.0.0
Requires-Dist: mujoco_warp>=4.0.0
Requires-Dist: numpy
Requires-Dist: reaf>=1.1.2
Requires-Dist: torch<2.16,>=2.7.0
Requires-Dist: warp-lang<1.18.1,>=1.18.0
Requires-Dist: warp-optix>=0.3.0; python_version == "3.12" and (sys_platform == "linux" or sys_platform == "win32") and (platform_machine == "x86_64" or platform_machine == "AMD64")
Dynamic: license-file

# `reaf-sim`

[![CI](https://github.com/google-deepmind/reaf-sim/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/google-deepmind/reaf-sim/actions/workflows/ci.yml?query=branch%3Amain)
[![PyPI version](https://img.shields.io/pypi/v/reaf-sim)](https://pypi.org/project/reaf-sim/)
[![Documentation Status](https://img.shields.io/readthedocs/reaf-sim/latest)](https://reaf-sim.readthedocs.io/en/latest/?badge=latest)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/notebooks/quickstart.ipynb)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)

`reaf-sim` is a [PyTorch](https://pytorch.org/) simulation framework built by the MuJoCo team on top of [MuJoCo](https://github.com/google-deepmind/mujoco) and [MuJoCo Warp](https://github.com/google-deepmind/mujoco_warp), and using the [Robotics Environment Authoring Framework (REAF)](https://github.com/google-deepmind/reaf).

`reaf-sim` is designed explicitly for sim-to-real robotics workflows. To achieve this, we decouple hardware and sensor I/O from task logic. The hardware layer is called the [`DeviceLayer`](https://reaf-sim.readthedocs.io/en/latest/user_guide/device_layer.html), which wraps sim in an interface that is consistent with physical hardware. The task logic is implemented in the [`TaskLayer`](https://reaf-sim.readthedocs.io/en/latest/user_guide/task_layer.html), which handles MDP processing of actions, observations, terminations, and rewards. Critically, the `TaskLayer` has no access to privileged simulation state, which makes sim workflows portable to real hardware.

> [!NOTE]
> For a full suite of sim and real robotic examples, check out [MuJoCo Playground](https://github.com/google-deepmind/mujoco_playground), which showcases `reaf-sim` across a variety of tasks, or try the interactive [Quickstart Colab](https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/notebooks/quickstart.ipynb)!

This project adheres to the [GDM Robotics Environment interface](https://github.com/google-deepmind/gdm_robotics/blob/main/src/gdm_robotics/interfaces/environment.py).

## Installation

Install [`reaf-sim`](https://pypi.org/project/reaf-sim/) from PyPI (Python 3.12+):

```bash
uv pip install "reaf-sim>=1.0"
```

> [!NOTE]
> On Linux with CUDA 12 drivers, install with `--index https://download.pytorch.org/whl/cu129 -f https://github.com/NVIDIA/warp/releases/expanded_assets/v1.18.0 "warp-lang==1.18.0+cu12" "reaf-sim>=1.0"`.

## Cartpole Example

For a quick preview into `reaf-sim`, let's create an environment controlling a cartpole alongside a camera rendering RGB observations across 16 parallel environments on GPU (`impl="warp"`). Step the environments with control commands and capture visual rollouts:

```python
import mujoco
from reaf.simulation.torch import ActuatorDevice, CameraDevice, flat_scene
from reaf.simulation.torch.examples.cartpole import CARTPOLE_XML
import torch

spec = mujoco.MjSpec.from_string(CARTPOLE_XML)

# configure the environment
config = flat_scene.Environment(
    base_scene=spec,
    sim=flat_scene.Sim(
        nworld=16,
        xpu_device="cuda:0",
        impl="warp",
        simulation_timestep=0.01,
        control_timestep=0.05,
    ),
    device_layer=flat_scene.DeviceLayer(
        devices={
            "slider": flat_scene.Component(
                ActuatorDevice, targets=["slider"]
            ),
            "camera": flat_scene.Component(
                CameraDevice,
                cam_name="fixed",
                cam_resolution=(160, 120),
                render_rate_hz=20.0,
                output_name_prefix="camera/",
            ),
        }
    ),
    observation_adapter={
        "camera/fixed_rgb": flat_scene.ObsGroup(
            terms={
                "rgb": flat_scene.Obs("camera/fixed_rgb").configure(
                    output_shape=(120, 160, 3), dtype="uint8"
                ),
            }
        ),
    },
)

# build the environment
env = flat_scene.build_env(config)

# step the environment with batched actions and extract camera frames
timestep = env.reset()
for _ in range(100):
  commands = torch.rand((env.nworld, 1), device="cuda:0") * 2.0 - 1.0
  timestep = env.step({"slider/ctrl": commands})
  camera_frames = timestep.observation["camera/fixed_rgb"]  # (16, 120, 160, 3)
```

For the complete, runnable script that loads the Cartpole model and generates the tiled grid video below, see [`reaf/simulation/torch/examples/cartpole.py`](reaf/simulation/torch/examples/cartpole.py).

<p align="center">
  <img src="https://www.gstatic.com/reaf-sim/cartpole/0/cartpole_grid_rollout.gif" alt="16-environment parallel Cartpole rollout on GPU" width="100%">
</p>

## Documentation & Contributing

- **Documentation:** See the [reaf-sim documentation](https://reaf-sim.readthedocs.io/en/latest/) for the [user guide](https://reaf-sim.readthedocs.io/en/latest/user_guide/index.html) and [API reference](https://reaf-sim.readthedocs.io/en/latest/api.html).
- **Contributing:** See the [contributing guide](https://reaf-sim.readthedocs.io/en/latest/contributing.html) for contribution guidelines.
- **Changelog:** See the [changelog](https://reaf-sim.readthedocs.io/en/latest/changelog.html).

## Citation

If you use `reaf-sim` in your work, please cite it as follows (see the [GitHub contributors page](https://github.com/google-deepmind/reaf-sim/graphs/contributors?all=1) for the full list of contributors):

```bibtex
@software{reaf_sim_2026,
  author = {{reaf-sim Contributors}},
  title = {{reaf-sim: Robotics Environment Authoring Framework - Simulation}},
  url = {https://github.com/google-deepmind/reaf-sim},
  year = {2026},
}
```

## Acknowledgements

We are grateful to all members of the MuJoCo team for their support in developing `reaf-sim`. Additionally, we thank the authors of REAF, mjlab, and Isaac Lab for inspiring `reaf-sim`.

## License & Disclaimer

`reaf-sim` is released under the Apache 2.0 license. See [LICENSE](LICENSE) for details.

This is not an official Google product.
