Skip to content

ldg810/crazyflow

 
 

Repository files navigation

Crazyflow Logo

Fast, parallelizable simulations of Quadrotor drones with JAX.

Python arXiv Tests Ruff Docs

Crazyflow is a research simulator for quadrotors. It runs batched, differentiable simulations on CPU and GPU via JAX, with analytical and abstracted models for the Crazyflie 2.x family.

import numpy as np
from crazyflow.sim import Sim
from crazyflow.control import Control

sim = Sim(n_worlds=4096, n_drones=1, control=Control.state)
cmd = np.zeros((4096, 1, 13))
cmd[..., 2] = 0.5  # hover at 0.5 m across all worlds

for _ in range(100):
    sim.state_control(cmd)
    sim.step(sim.freq // sim.control_freq)
    sim.render()

Documentation

learnsyslab.github.io/crazyflow — installation, user guide, examples, and API reference.

Features

  • n_worlds x n_drones — batched over independent environments and multi-drone swarms simultaneously
  • GPU-accelerated — up to 914 M steps/s on an RTX 4090 (first-principles physics, 262 K worlds)
  • Differentiablejax.grad works through the full dynamics and control pipeline
  • First-principles models — physics model using first-principles equations and parameters identified from real-world measurements
  • Abstracted models — three physics models fitted from real Crazyflie flight data
  • Modular pipelines — step and reset are tuples of plain JAX functions; insert anything, anywhere
  • MuJoCo integration — onscreen and offscreen rendering, raycasting, and contact detection via MJX

Fork additions

This fork adds multi-drone wake interaction probes for dense swarm experiments:

  • Attitude-aware downwash — an optional pipeline stage that applies wake forces along each upstream drone's body-z direction instead of assuming a fixed vertical wake.
  • Literature-calibrated wake spread — the default model follows the far-field turbulent-jet fit reported by Bauersfeld et al. for small quadrotor downwash.
  • GUI and offscreen examples — scripts for two-drone, five-drone, ten-drone, and 1000-drone visual checks.
  • Large-swarm GPU benchmark — a 10x10x10 layered 1000-drone scenario where each layer translates left-right with a different phase.

The downwash model can be attached to any Sim instance:

from crazyflow.sim import DownwashConfig, Sim, use_downwash

sim = Sim(n_worlds=1, n_drones=10, device="gpu")
use_downwash(sim, DownwashConfig())

Useful examples:

# Five drones in the interactive MuJoCo viewer
python examples/five_drone_gui.py --mode human --duration 20

# Two-drone calibrated downwash sweep with offscreen GIF output
MUJOCO_GL=egl python examples/downwash_sweep.py \
  --duration 6 \
  --fps 15 \
  --gif /tmp/downwash_sweep.gif

# Ten-drone upper/lower ring downwash test
MUJOCO_GL=egl python examples/ten_drone_downwash_ring.py \
  --duration 12 \
  --device gpu \
  --gif /tmp/ten_drone_downwash_ring.gif

# 1000-drone layered GPU benchmark, headless by default
python examples/thousand_drone_layers.py \
  --duration 1.0 \
  --device gpu \
  --fused-mjx-model

# 1000-drone offscreen GUI smoke render
MUJOCO_GL=egl python examples/thousand_drone_layers.py \
  --duration 0.4 \
  --device gpu \
  --fused-mjx-model \
  --mode rgb_array \
  --fps 5 \
  --gif /tmp/thousand_drone_layers.gif

Installation

pip install crazyflow           # CPU
pip install "crazyflow[gpu]"    # GPU (Linux x86-64, CUDA 12)

Developer install with editable submodules (pixi required):

git clone --recurse-submodules git@github.com:ldg810/crazyflow.git
cd crazyflow
pixi shell

If the submodules were cloned without editable installs, install them before the main package:

pip install -e submodules/drone-models -e submodules/drone-controllers
pip install -e .

Performance

First-principles physics, one drone. CPU: AMD Ryzen 9 7950X. GPU: NVIDIA RTX 4090.

n_worlds CPU steps/s GPU steps/s
64 3.3 M 1.2 M
1 024 9.2 M 18.7 M
16 384 11.9 M 257 M
65 536 15.6 M 678 M
262 144 12.6 M 914 M

Full benchmarks including multi-drone scaling are in the documentation.

Related packages

Crazyflow is built on two companion packages that can also be used independently:

Package Description
drone-models Drone dynamics models (first-principles and fitted) compatible with NumPy, JAX, and PyTorch. Used by Crazyflow as the physics backend.
drone-controllers Reference controller implementations including the Mellinger geometric controller. Used by Crazyflow to provide the state and attitude control modes.

Both are installed automatically as dependencies. For development, they are included as submodules in submodules/ and installed in editable mode by the pixi environment.

Citation

@misc{schuck2026crazyflow,
      title={Crazyflow: An Accurate, GPU-Accelerated, Differentiable Drone Simulator in JAX}, 
      author={Martin Schuck and Marcel P. Rath and Yufei Hua and AbhisheK Goudar and SiQi Zhou and Angela P. Schoellig},
      year={2026},
      eprint={2606.01478},
      archivePrefix={arXiv},
      primaryClass={cs.RO},
      url={https://arxiv.org/abs/2606.01478}, 
}

About

Scalable drone simulation using JAX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.0%
  • Dockerfile 1.0%