https://github.com/novix-science/mlx-sim
https://github.com/novix-science/mlx-sim
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/novix-science/mlx-sim
- Owner: novix-science
- Created: 2026-03-21T07:37:38.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-03-21T15:21:58.000Z (3 months ago)
- Last Synced: 2026-03-22T00:14:03.390Z (3 months ago)
- Language: Python
- Size: 1.24 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.md
- Roadmap: docs/roadmap.md
Awesome Lists containing this project
- awesome - novix-science/mlx-sim - (<a name="Python"></a>Python)
README
# mlx-sim
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://support.apple.com/en-us/HT211814)
[](https://github.com/mlx-sim/mlx-sim/actions/workflows/ci.yml)
**Apple-Silicon-first robotics simulation platform.**
mlx-sim is a high-performance physics simulator built from the ground up for Apple Silicon, using Metal GPU compute for rendering and designed for reinforcement learning workflows.
## Features
- **Metal GPU acceleration** — native Apple Silicon rendering and compute
- **Rigid body dynamics** — impulse-based solver with GJK/EPA collision detection
- **Articulated bodies** — Featherstone ABA forward dynamics, RNEA inverse dynamics
- **URDF & MJCF loading** — import robots and scenes from standard formats
- **Gymnasium environments** — drop-in RL environments with vectorized parallel execution
- **Sensor pipeline** — IMU, camera (RGB), and depth sensors with noise models
- **Domain randomization** — built-in sim-to-real transfer support
- **Python bindings** — full API access via pybind11
## Installation
```bash
pip install mlx-sim
```
With RL environment support:
```bash
pip install "mlx-sim[rl]"
```
### From Source
```bash
git clone https://github.com/mlx-sim/mlx-sim.git
cd mlx-sim
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
pip install -e ".[rl,dev]"
```
### Requirements
- macOS with Apple Silicon (M1+)
- CMake >= 3.24
- Xcode Command Line Tools
- Python >= 3.10
## Quick Example
```python
import mlx_sim
# Create a simulation world
world = mlx_sim.World({"timestep": 0.002, "n_substeps": 4})
world.load_urdf("robot.urdf")
# Run simulation
for _ in range(1000):
world.step()
positions = world.get_body_positions() # (N, 3) numpy array
print(f"Bodies: {world.n_bodies}, Time: {world.time:.3f}s")
```
### Gymnasium RL Environment
```python
import gymnasium as gym
import mlx_sim.envs
env = gym.make("MlxSimReach-v0")
obs, info = env.reset(seed=42)
for _ in range(200):
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
obs, info = env.reset()
env.close()
```
### Vectorized Training
```python
from mlx_sim.envs import ReachEnv, MlxSimVecEnv
import numpy as np
vec_env = MlxSimVecEnv(lambda: ReachEnv(), num_envs=8)
obs, infos = vec_env.reset()
for _ in range(1000):
actions = np.random.randn(8, vec_env.single_action_space.shape[0])
actions = np.clip(actions, -1, 1).astype(np.float32)
obs, rewards, terminateds, truncateds, infos = vec_env.step(actions)
vec_env.close()
```
## Project Structure
| Directory | Description |
|---|---|
| `src/core/` | Math types, ECS, core utilities |
| `src/physics/` | Rigid body dynamics, collision detection |
| `src/render/` | Metal renderer, shaders |
| `src/runtime/` | Simulation loop, scene management |
| `src/python/` | pybind11 Python bindings |
| `python/` | Python package (envs, viewer) |
| `tests/` | Unit tests |
| `viewer/` | MetalKit viewer app |
| `docs/` | Documentation |
## Documentation
Full documentation: [https://mlx-sim.github.io/mlx-sim/](https://mlx-sim.github.io/mlx-sim/)
- [Getting Started](docs/getting-started.md)
- [Tutorials](docs/tutorials/first-simulation.md)
- [API Reference](docs/api/core.md)
- [Contributing](docs/contributing.md)
## License
MIT