Skip to content

Commit 58d8e8c

Browse files
committed
Update README
1 parent 07c65a5 commit 58d8e8c

2 files changed

Lines changed: 82 additions & 31 deletions

File tree

README.md

Lines changed: 82 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
![Crazyflow Logo](https://github.com/utiasDSL/crazyflow/docs/img/logo.png)
2+
3+
--------------------------------------------------------------------------------
4+
5+
Fast, parallelizable simulations of Crazyflies with JAX and MuJoCo.
6+
7+
[![Python Version]][Python Version URL] [![Ruff Check]][Ruff Check URL] [![Documentation Status]][Documentation Status URL] [![Tests]][Tests URL]
8+
9+
[Python Version]: https://img.shields.io/badge/python-3.10+-blue.svg
10+
[Python Version URL]: https://www.python.org
11+
12+
[Ruff Check]: https://github.com/utiasDSL/crazyflow/actions/workflows/ruff.yml/badge.svg?style=flat-square
13+
[Ruff Check URL]: https://github.com/utiasDSL/crazyflow/actions/workflows/ruff.yml
14+
15+
[Documentation Status]: https://readthedocs.org/projects/crazyflow/badge/?version=latest
16+
[Documentation Status URL]: https://crazyflow.readthedocs.io/en/latest/?badge=latest
17+
18+
[Tests]: https://github.com/utiasDSL/crazyflow/actions/workflows/testing.yml/badge.svg
19+
[Tests URL]: https://github.com/utiasDSL/crazyflow/actions/workflows/testing.yml
20+
21+
22+
## Architecture
23+
24+
Crazyflow is a high-performance simulation framework for Crazyflie drones that leverages JAX for efficient parallelization and automatic differentiation. The architecture is designed around a flexible pipeline that can be configured at initialization time, enabling users to swap out physics backends, control methods, and integration schemes.
25+
26+
### Core Components
27+
28+
#### Simulation Pipeline
29+
The simulation is built as a pipeline of functions that are composed at initialization time based on the configuration. This approach avoids runtime branching and allows JAX to optimize the entire pipeline as a single computation. Users can insert their own pure functions into the pipeline to modify the simulation behavior while maintaining compatibility with JAX's optimizations.
30+
31+
#### Physics Backends
32+
Multiple physics models are supported:
33+
- analytical: A first-principles model based on physical equations
34+
- sys_id: A system-identified model trained on real drone data
35+
- mujoco: MuJoCo physics engine for more complex interactions
36+
37+
#### Control Modes
38+
Different control interfaces are available:
39+
- state: High-level control of position, velocity, and yaw
40+
- attitude: Mid-level control of collective thrust and orientation
41+
- thrust: Low-level control of individual motor thrusts
42+
43+
#### Integration Methods
44+
For analytical and system-identified physics:
45+
- euler: Simple first-order integration
46+
- rk4: Fourth-order Runge-Kutta integration for higher accuracy
47+
48+
### Parallelization
49+
Crazyflow supports massive parallelization across:
50+
- Worlds: Independent simulation environments that can run in parallel
51+
- Drones: Multiple drones within each world
52+
- Devices: Computations can be executed on CPU or GPU
53+
This parallelization is achieved through JAX's vectorization capabilities, allowing thousands of simulations to run simultaneously with minimal overhead.
54+
55+
### Domain Randomization
56+
The framework supports domain randomization through the crazyflow/randomize module, allowing parameters like mass to be varied across simulations to improve sim-to-real transfer.
57+
58+
### Functional Design
59+
The simulation follows a functional programming paradigm: All state is contained in immutable data structures. Updates create new states rather than modifying existing ones. All functions are pure, enabling JAX's transformations (JIT, grad, vmap) and thus automatic differentiation through the entire simulation, making it suitable for gradient-based optimization and reinforcement learning.
60+
61+
## Examples
62+
The repository includes several example scripts demonstrating different capabilities:
63+
| Example | Description |
64+
| ----------------------------------------- | ----------------------------------------------------------- |
65+
| [`hover.py`](examples/hover.py) | Basic hovering using state control |
66+
| [`thrust.py`](examples/thrust.py) | Direct motor control using thrust commands |
67+
| [`render.py`](examples/render.py) | Visualization of multiple drones with motion traces |
68+
| [`contacts.py`](examples/contacts.py) | Collision detection between drones |
69+
| [`gradient.py`](examples/gradient.py) | Computing gradients through the simulation for optimization |
70+
| [`change_pos.py`](examples/change_pos.py) | Manipulating drone positions programmatically |
71+
72+
73+
74+
## Known Issues
75+
- `"RuntimeError: MUJOCO_PATH environment variable is not set"` upon installing this package. This error can be resolved by using `venv` instead of `conda`. Somtimes the `mujoco` install can [fail with `conda`](https://github.com/google-deepmind/mujoco/issues/1004).
76+
- If using `zsh` don't forget to escape brackets when installing additional dependencies: `pip install .\[gpu\]`.
77+
178
### Using the project with VSCode devcontainers
279

380
**Running on CPU**: by default the containers run on CPU. You don't need to take any action.
@@ -6,11 +83,11 @@
683

784

885
**Linux**
9-
0. Make sure to be in a X11 session ([link](https://askubuntu.com/questions/1410256/how-do-i-use-the-x-window-manager-instead-of-wayland-on-ubuntu-22-04)), otherwise rendering of the drone will fail.
10-
1. Install [Docker](https://docs.docker.com/engine/install/) (, and make sure Docker Daemon is running)
11-
2. Install [VSCode](https://code.visualstudio.com/), with [devcontainer extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers), and [remote dev pack](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker).
12-
3. Clone this project's code. Rename `/.devcontainer/devcontainer.linux.json` to `/.devcontainer/devcontainer.json`.
13-
4. Open this project in VSCode. VSCode should automatically detect the devcontainer and prompt you to `Reopen in container`. If not, see [here](https://code.visualstudio.com/docs/devcontainers/containers#_quick-start-open-an-existing-folder-in-a-container) to open manually. Note: Opening the container for the first time might take a while (up to 15 min), as the container is pulled from the web and build.
86+
1. Make sure to be in a X11 session ([link](https://askubuntu.com/questions/1410256/how-do-i-use-the-x-window-manager-instead-of-wayland-on-ubuntu-22-04)), otherwise rendering of the drone will fail.
87+
2. Install [Docker](https://docs.docker.com/engine/install/) (, and make sure Docker Daemon is running)
88+
3. Install [VSCode](https://code.visualstudio.com/), with [devcontainer extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers), and [remote dev pack](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker).
89+
4. Clone this project's code. Rename `/.devcontainer/devcontainer.linux.json` to `/.devcontainer/devcontainer.json`.
90+
5. Open this project in VSCode. VSCode should automatically detect the devcontainer and prompt you to `Reopen in container`. If not, see [here](https://code.visualstudio.com/docs/devcontainers/containers#_quick-start-open-an-existing-folder-in-a-container) to open manually. Note: Opening the container for the first time might take a while (up to 15 min), as the container is pulled from the web and build.
1491

1592
**Windows** (requires Windows 10 or later)
1693

@@ -34,29 +111,3 @@ ____________
34111
Known Issues:
35112
- if building docker container fails at `RUN apt-get update`, make sure your host systems time is set correct: https://askubuntu.com/questions/1511514/docker-build-fails-at-run-apt-update-error-failed-to-solve-process-bin-sh
36113

37-
# crazyflow
38-
Fast, parallelizable simulations of Crazyflies with JAX and MuJoCo.
39-
40-
[![Python Version]][Python Version URL] [![Ruff Check]][Ruff Check URL] [![Documentation Status]][Documentation Status URL] [![Tests]][Tests URL]
41-
42-
[Python Version]: https://img.shields.io/badge/python-3.10+-blue.svg
43-
[Python Version URL]: https://www.python.org
44-
45-
[Ruff Check]: https://github.com/utiasDSL/crazyflow/actions/workflows/ruff.yml/badge.svg?style=flat-square
46-
[Ruff Check URL]: https://github.com/utiasDSL/crazyflow/actions/workflows/ruff.yml
47-
48-
[Documentation Status]: https://readthedocs.org/projects/crazyflow/badge/?version=latest
49-
[Documentation Status URL]: https://crazyflow.readthedocs.io/en/latest/?badge=latest
50-
51-
[Tests]: https://github.com/utiasDSL/crazyflow/actions/workflows/testing.yml/badge.svg
52-
[Tests URL]: https://github.com/utiasDSL/crazyflow/actions/workflows/testing.yml
53-
54-
55-
## Architecture
56-
57-
<img src="/docs/img/architecture.png" width="75%" alt="Architecture">
58-
59-
60-
## Known Issues
61-
- `"RuntimeError: MUJOCO_PATH environment variable is not set"` upon installing this package. This error can be resolved by using `venv` instead of `conda`. Somtimes the `mujoco` install can [fail with `conda`](https://github.com/google-deepmind/mujoco/issues/1004).
62-
- If using `zsh` don't forget to escape brackets when installing additional dependencies: `pip install .\[gpu\]`.

docs/img/logo.png

244 KB
Loading

0 commit comments

Comments
 (0)