Drone Controllers is a Python library providing faithful reimplementations of onboard drone controllers that can be used for simulation and modelling.
- Array API Standard — Controllers work with NumPy, JAX, PyTorch, and other array libraries
- Pure Functions — All controllers are implemented as pure functions for easy JIT compilation
- Batching Support — Built-in support for arbitrary batch dimensions via broadcasting
- Research-focused — Designed specifically for robotics research with quadrotor UAVs
- Type-safe — Full type hints for better development experience
Installation is simple with pip:
pip install drone-controllersHere's a basic example using the Mellinger controller:
import numpy as np
from drone_controllers import parametrize
from drone_controllers.mellinger import state2attitude
# Get controller parameters for a specific drone model
controller = parametrize(state2attitude, "cf2x_L250")
# Define state and command
pos = np.array([0.0, 0.0, 1.0]) # position [x, y, z]
quat = np.array([0.0, 0.0, 0.0, 1.0]) # quaternion [x, y, z, w]
vel = np.array([0.0, 0.0, 0.0]) # velocity [vx, vy, vz]
ang_vel = np.array([0.0, 0.0, 0.0]) # angular velocity [wx, wy, wz]
# Command: [x, y, z, vx, vy, vz, ax, ay, az, yaw, r_rate, p_rate, y_rate]
cmd = np.array([1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
# Compute control output
rpyt, pos_err_i = controller(pos, quat, vel, ang_vel, cmd)
print(f"Roll-Pitch-Yaw-Thrust command: {rpyt}")- Mellinger Controller — Geometric tracking controller based on the original Crazyflie implementation
- cf2x_L250 — Crazyflie 2.x with 250mm frame
- More models coming soon!
- Parameter System — Automatic controller parametrization for different drone models
- Transform utilities — Conversions between motor forces, rotor speeds, and PWM
- Drone registry — Centralized catalog of supported drone platforms
The library implements controllers as a pipeline of pure functions:
- State → Attitude: Convert desired state to attitude commands
- Attitude → Force/Torque: Convert attitude commands to desired forces and torques
- Force/Torque → Rotor Speeds: Convert desired forces/torques to individual motor commands
This modular design allows mixing and matching different components while maintaining compatibility.
All controllers support the Python Array API standard, meaning you can use them with:
- NumPy — Standard numerical computing
- JAX — JIT compilation and automatic differentiation
- PyTorch — Deep learning integration
- CuPy — GPU acceleration
- Read the Getting Started guide
- Browse the API Reference
- Check out Concepts for theory
- Report issues on GitHub