Skip to content

Commit ef2b026

Browse files
committed
Improve README
1 parent c813262 commit ef2b026

File tree

1 file changed

+94
-9
lines changed

1 file changed

+94
-9
lines changed

README.md

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $$
44

55
---
66

7-
Drone models @ LSY. Contains symbolic (CasADi) and numeric (array API, i.e., NumPy, JAX, ...) drone dynamics.
7+
Physics-based and data-driven quadrotor dynamics models for estimation, control, and simulation.
88

99
[![Python Version]][Python Version URL] [![Ruff Check]][Ruff Check URL] [![Tests]][Tests URL] [![Docs]][Docs URL]
1010

@@ -21,19 +21,104 @@ Drone models @ LSY. Contains symbolic (CasADi) and numeric (array API, i.e., Num
2121
[Docs URL]: https://utiasdsl.github.io/drone-models/
2222

2323
## Overview
24-
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:
37+
`cf2x_L250`, `cf2x_P250`, `cf2x_T350`, `cf21B_500`
2538

2639
## Installation
2740

28-
1. Clone repository `git clone git@github.com:utiasDSL/drone-models.git`
29-
2. Enter repository `cd drone-models`
30-
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+
```
3144

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.
3252
3353
## Usage
34-
`from drone_models import TODO`
3554

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")
65+
66+
pos = np.zeros(3)
67+
quat = np.array([0., 0., 0., 1.]) # xyzw, identity
68+
vel = np.zeros(3)
69+
ang_vel = np.zeros(3)
70+
rotor_vel = np.ones(4) * 12_000. # current motor RPMs
71+
cmd = np.full(4, 15_000.) # commanded motor RPMs
72+
73+
pos_dot, quat_dot, vel_dot, ang_vel_dot, rotor_vel_dot = model(
74+
pos, quat, vel, ang_vel, cmd, rotor_vel
75+
)
76+
```
77+
78+
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
102+
103+
sym_model = parametrize(symbolic_dynamics, drone_model="cf2x_L250")
104+
```
105+
106+
## Development
107+
108+
Clone and install with [pixi](https://pixi.sh):
109+
110+
```bash
111+
git clone https://github.com/utiasDSL/drone-models.git
112+
cd drone-models
113+
pixi install
114+
```
115+
116+
Run tests:
117+
118+
```bash
119+
pixi run -e tests tests
120+
```
121+
122+
## Citation
36123

37-
## Testing
38-
1. Install testing environment with `pixi install -e test`
39-
1. Run tests with `pixi run -e test pytest`
124+
Citation information coming soon. See the [docs](https://utiasdsl.github.io/drone-models/) for updates.

0 commit comments

Comments
 (0)