You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Collection of different drone dynamics models. Also includes meshes of each model.
24
+
25
+
`drone-models` provides quadrotor dynamics as pure Python functions, from full physics-based implementations to lightweight data-driven approximations. All models support NumPy, JAX, and any [Array API](https://data-apis.org/array-api/latest/) backend, plus [CasADi](https://web.casaid.org/) symbolic variants for optimization-based control. Pre-fitted parameters are included for several Crazyflie platforms.
26
+
27
+
**Available models** — ranging from high-fidelity to lightweight:
28
+
29
+
| Model | Description |
30
+
|---|---|
31
+
|`first_principles`| Full rigid-body physics with optional rotor dynamics and aerodynamic drag |
32
+
|`so_rpy_rotor_drag`| Data-driven, attitude as roll/pitch/yaw, with rotor dynamics and drag |
33
+
|`so_rpy_rotor`| Data-driven, attitude as roll/pitch/yaw, with rotor dynamics |
34
+
|`so_rpy`| Lightest data-driven model, attitude as roll/pitch/yaw, no rotor dynamics |
35
+
36
+
**Pre-fitted configurations** for Crazyflie 2.x (brushed) and Crazyflie 2.1 Brushless:
3. Install locally with `pip install -e .` or the pixi environment with `pixi install`, which can be activated with `pixi shell`
41
+
```bash
42
+
pip install drone-models
43
+
```
31
44
45
+
For system identification (fitting parameters from your own flight data):
46
+
47
+
```bash
48
+
pip install "drone-models[sysid]"
49
+
```
50
+
51
+
> **Note:**`drone_models` must be imported before SciPy to enable Array API support. If you encounter a `RuntimeError`, either import `drone_models` first or set `export SCIPY_ARRAY_API=1` in your shell.
32
52
33
53
## Usage
34
-
`from drone_models import TODO`
35
54
55
+
### Basic
56
+
57
+
Bind parameters to a drone configuration with `parametrize`, then call the model with state and command arrays:
58
+
59
+
```python
60
+
import numpy as np
61
+
from drone_models import parametrize
62
+
from drone_models.first_principles import dynamics
63
+
64
+
model = parametrize(dynamics, drone_model="cf2x_L250")
The model returns continuous-time state derivatives $\dot{x} = f(x, u)$. Integrate with any ODE solver (e.g. `scipy.integrate.solve_ivp`) to simulate forward in time.
79
+
80
+
### Switching backends
81
+
82
+
Pass any Array API-compatible array and the output type follows automatically — no code changes needed:
83
+
84
+
```python
85
+
import jax.numpy as jnp
86
+
from drone_models import parametrize
87
+
from drone_models.first_principles import dynamics
88
+
89
+
model = parametrize(dynamics, drone_model="cf2x_L250", xp=jnp)
90
+
# Pass jax arrays — get jax arrays back
91
+
```
92
+
93
+
Arbitrary leading batch dimensions work out of the box: stack states for a thousand drones and evaluate them in one call.
94
+
95
+
### Symbolic models (CasADi)
96
+
97
+
Every model exposes a `symbolic_dynamics` function returning CasADi `MX` expressions, for use in MPC, trajectory optimization, or estimation:
98
+
99
+
```python
100
+
from drone_models import parametrize
101
+
from drone_models.first_principles import symbolic_dynamics
0 commit comments