Skip to content

Commit f763f67

Browse files
committed
Merged
2 parents abae398 + af4568c commit f763f67

84 files changed

Lines changed: 3812 additions & 2539 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup pixi
27+
uses: prefix-dev/setup-pixi@v0.8.1
28+
with:
29+
pixi-version: v0.49.0
30+
cache: true
31+
32+
- name: Build documentation
33+
run: pixi run -e docs mkdocs build
34+
35+
- name: Setup Pages
36+
uses: actions/configure-pages@v3
37+
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v4
40+
with:
41+
path: ./site
42+
43+
deploy:
44+
environment:
45+
name: github-pages
46+
url: ${{ steps.deployment.outputs.page_url }}
47+
runs-on: ubuntu-latest
48+
needs: build
49+
if: github.ref == 'refs/heads/main'
50+
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

.github/workflows/testing.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
cache: true # enable caching of installed envs
1515
# only write new caches on main pushes (optional)
1616
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
17-
# ensure the 'test' environment(s) are installed
18-
environments: test
17+
# ensure the 'tests' environment(s) are installed
18+
environments: tests
1919
# don't activate env (we'll call pixi run -e test explicitly)
2020
activate-environment: false
2121
# prefer using existing lockfile if present (faster, deterministic)
@@ -24,4 +24,4 @@ jobs:
2424
- name: Verify pixi and run tests
2525
run: |
2626
pixi --version
27-
pixi run -e test pytest
27+
pixi run -e tests tests -v

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $$
66

77
Drone models @ LSY. Contains symbolic (CasADi) and numeric (ArrayAPI, i.e., NumPy, JAX, ...) versions as well as meshes of each model.
88

9-
[![Python Version]][Python Version URL] [![Ruff Check]][Ruff Check URL] [![Tests]][Tests URL]
9+
[![Python Version]][Python Version URL] [![Ruff Check]][Ruff Check URL] [![Tests]][Tests URL] [![Docs]][Docs URL]
1010

1111
[Python Version]: https://img.shields.io/badge/python-3.10+-blue.svg
1212
[Python Version URL]: https://www.python.org
@@ -17,6 +17,9 @@ Drone models @ LSY. Contains symbolic (CasADi) and numeric (ArrayAPI, i.e., NumP
1717
[Tests]: https://github.com/utiasDSL/drone-models/actions/workflows/testing.yml/badge.svg
1818
[Tests URL]: https://github.com/utiasDSL/drone-models/actions/workflows/testing.yml
1919

20+
[Docs]: https://github.com/utiasDSL/drone-models/actions/workflows/docs.yml/badge.svg
21+
[Docs URL]: https://utiasdsl.github.io/drone-models/
22+
2023
## Installation
2124

2225
1. Clone repository `git clone git@github.com:utiasDSL/drone-models.git`
@@ -30,4 +33,4 @@ Drone models @ LSY. Contains symbolic (CasADi) and numeric (ArrayAPI, i.e., NumP
3033

3134
## Testing
3235
1. Install testing environment with `pixi install -e test`
33-
1. Run tests with `pixi run -e test pytest`
36+
1. Run tests with `pixi run -e test pytest`

docs/cite.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Citation
2+
3+
If you use Drone Models in your research, please cite our work.
4+
5+
## BibTeX Entry
6+
7+
!!! info "Coming Soon"
8+
BibTeX entry will be provided here.
9+
10+
## Related Publications
11+
12+
!!! info "Coming Soon"
13+
List of related publications will be added here.
14+
15+
## Acknowledgments
16+
17+
!!! info "Coming Soon"
18+
Acknowledgments and funding information will be added here.

docs/concepts/drone-models.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Drone Models
2+
3+
Drone Models provides several model types with different complexity levels and capabilities. Understanding these differences will help you choose the right model for your application.
4+
5+
## Model Types Overview
6+
7+
| Model | Rotor Dynamics | Complexity | Physics Level | Best For |
8+
|-------|----------------|------------|---------------|----------|
9+
| `first_principles` | Yes | High | Full rigid body | High-fidelity simulation, MPC |
10+
| `so_rpy` | No | Low | Simplified | Fast simulation, learning |
11+
| `so_rpy_rotor` | Yes | Medium | Simplified + rotors | Balanced performance |
12+
| `so_rpy_rotor_drag` | Yes | High | Simplified + effects | High-speed flight |
13+
14+
## Physics-Based Models
15+
16+
### First Principles Model
17+
18+
The most comprehensive model based on full rigid body dynamics with quaternion representation.
19+
20+
**Features:**
21+
- Quaternion-based attitude representation (no singularities)
22+
- Full 6-DOF rigid body dynamics
23+
- Rotor spin-up dynamics with time constants
24+
- External force and torque disturbances
25+
- Mixing matrix for arbitrary motor configurations
26+
27+
**When to use:**
28+
- High-fidelity simulations
29+
- Model Predictive Control (MPC)
30+
- Research requiring accurate dynamics
31+
- Hardware-in-the-loop testing
32+
33+
```python
34+
from drone_models.first_principles import dynamics
35+
from drone_models.core import parametrize
36+
37+
# Create parametrized model
38+
model = parametrize(dynamics, "cf2x_L250")
39+
40+
# Use with rotor dynamics
41+
pos_dot, quat_dot, vel_dot, ang_vel_dot, rotor_vel_dot = model(
42+
pos, quat, vel, ang_vel, cmd, rotor_vel=rotor_vel
43+
)
44+
```
45+
46+
### SO(3) Roll-Pitch-Yaw Models
47+
48+
Simplified models using Euler angle representation for faster computation.
49+
50+
#### `so_rpy` - Basic Model
51+
- Direct thrust/torque mapping (no rotor dynamics)
52+
- Euler angle representation
53+
- Fastest execution
54+
55+
#### `so_rpy_rotor` - With Rotor Dynamics
56+
- Adds rotor spin-up dynamics
57+
- Models motor response delays
58+
- Good balance of speed and accuracy
59+
60+
#### `so_rpy_rotor_drag` - With Aerodynamic Effects
61+
- Includes drag and aerodynamic forces
62+
- Most complete simplified model
63+
- Better at high speeds
64+
65+
**When to use:**
66+
- Real-time applications requiring speed
67+
- Reinforcement learning training
68+
- Educational demonstrations
69+
- Rapid prototyping
70+
71+
```python
72+
from drone_models.so_rpy import dynamics as so_rpy_dynamics
73+
from drone_models.so_rpy_rotor import dynamics as so_rpy_rotor_dynamics
74+
75+
# Fast model without rotor dynamics
76+
basic_model = parametrize(so_rpy_dynamics, "cf2x_L250")
77+
78+
# Balanced model with rotor dynamics
79+
balanced_model = parametrize(so_rpy_rotor_dynamics, "cf2x_L250")
80+
```
81+
82+
## Data-Driven Models
83+
84+
While the current focus is on physics-based models, the framework is designed to support data-driven approaches:
85+
86+
**Planned features:**
87+
- Neural network residual models
88+
- Gaussian Process corrections
89+
- System identification tools
90+
- Sim-to-real adaptation
91+
92+
## Model Capabilities
93+
94+
### Rotor Dynamics
95+
96+
Models with rotor dynamics (`first_principles`, `so_rpy_rotor`, `so_rpy_rotor_drag`) include:
97+
98+
- **Motor time constants**: Realistic spin-up/spin-down behavior
99+
- **Command to thrust mapping**: Non-instantaneous response
100+
- **Rotor state tracking**: Additional state variables for rotor velocities
101+
102+
### Symbolic Variants
103+
104+
Each model provides both numeric and symbolic implementations:
105+
106+
```python
107+
# Numeric for simulation
108+
from drone_models.first_principles import dynamics
109+
110+
# Symbolic for optimization
111+
from drone_models.first_principles import symbolic_dynamics
112+
113+
# Generate CasADi function for MPC
114+
X_dot, X, U, Y = symbolic_dynamics(model_rotor_vel=True)
115+
f = cs.Function('dynamics', [X, U], [X_dot])
116+
```
117+
118+
### External Disturbances
119+
120+
All models support external force and torque disturbances:
121+
122+
```python
123+
# Add wind disturbance
124+
wind_force = np.array([2.0, 0.0, 0.0]) # 2 N force in x-direction
125+
turbulence_torque = np.array([0.1, 0.1, 0.0]) # Small torque disturbance
126+
127+
derivatives = model(pos, quat, vel, ang_vel, cmd, rotor_vel,
128+
dist_f=wind_force, dist_t=turbulence_torque)
129+
```
130+
131+
## Choosing the Right Model
132+
133+
### For Real-Time Control
134+
- **Fast control loops (>500 Hz)**: `so_rpy`
135+
- **Standard control (100-200 Hz)**: `so_rpy_rotor`
136+
- **High-fidelity control**: `first_principles`
137+
138+
### For Simulation
139+
- **Educational/demos**: `so_rpy` or `so_rpy_rotor`
140+
- **Research simulation**: `first_principles`
141+
- **Large-scale studies**: `so_rpy` for speed
142+
143+
### For Optimization (MPC)
144+
- **Real-time MPC**: `so_rpy_rotor` symbolic
145+
- **High-fidelity MPC**: `first_principles` symbolic
146+
- **Trajectory optimization**: Any symbolic variant
147+
148+
### For Machine Learning
149+
- **RL training**: `so_rpy` for speed
150+
- **Sim-to-real**: `first_principles` + planned data-driven extensions
151+
- **System identification**: `first_principles` as ground truth
152+
153+
## Performance Considerations
154+
155+
### Computational Cost (relative)
156+
1. `so_rpy`: 1x (baseline)
157+
2. `so_rpy_rotor`: ~1.5x
158+
3. `so_rpy_rotor_drag`: ~2x
159+
4. `first_principles`: ~3x
160+
161+
### Memory Usage
162+
- All models have minimal memory footprint
163+
- Batching scales linearly with batch size
164+
- GPU memory usage depends on batch size and backend
165+
166+
### Accuracy Trade-offs
167+
- **Highest accuracy**: `first_principles`
168+
- **Good accuracy**: `so_rpy_rotor_drag`
169+
- **Acceptable accuracy**: `so_rpy_rotor`
170+
- **Basic accuracy**: `so_rpy`
171+
172+
---
173+
174+
*Choose your model based on the trade-off between accuracy, computational cost, and your specific application requirements.*

0 commit comments

Comments
 (0)