|
| 1 | +# crazyflow |
| 2 | +Fast, parallelizable simulations of Crazyflies with JAX and MuJoCo. |
| 3 | + |
| 4 | +[![Python Version]][Python Version URL] [![Ruff Check]][Ruff Check URL] [![Documentation Status]][Documentation Status URL] [![Tests]][Tests URL] |
| 5 | + |
| 6 | +[Python Version]: https://img.shields.io/badge/python-3.10+-blue.svg |
| 7 | +[Python Version URL]: https://www.python.org |
| 8 | + |
| 9 | +[Ruff Check]: https://github.com/utiasDSL/crazyflow/actions/workflows/ruff.yml/badge.svg?style=flat-square |
| 10 | +[Ruff Check URL]: https://github.com/utiasDSL/crazyflow/actions/workflows/ruff.yml |
| 11 | + |
| 12 | +[Documentation Status]: https://readthedocs.org/projects/crazyflow/badge/?version=latest |
| 13 | +[Documentation Status URL]: https://crazyflow.readthedocs.io/en/latest/?badge=latest |
| 14 | + |
| 15 | +[Tests]: https://github.com/utiasDSL/crazyflow/actions/workflows/testing.yml/badge.svg |
| 16 | +[Tests URL]: https://github.com/utiasDSL/crazyflow/actions/workflows/testing.yml |
| 17 | + |
| 18 | + |
| 19 | +## Architecture |
| 20 | + |
| 21 | +<img src="/docs/img/architecture.png" width="75%" alt="Architecture"> |
| 22 | + |
| 23 | + |
| 24 | +## Using the project with VSCode devcontainers |
| 25 | + |
| 26 | +**Running on CPU**: by default the containers run on CPU. You don't need to take any action. |
| 27 | + |
| 28 | +**Running on GPU**: The devcontsainers can easily run using your computer's NVIDIA GPU on Linux and Windows. This makes sense if you want to accelerate simulation by running thousands of simulation in parallel. In order to work you need to install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local), [NVIDIA Container runtime](https://developer.nvidia.com/container-runtime) for your computer. Finally, enable GPU access to the devcontainers by setting the commented out `"--gpus=all"` and `"--runtime=nvidia"` flags in `devcontainer.json`. |
| 29 | + |
| 30 | + |
| 31 | +### Linux |
| 32 | + |
| 33 | +1. Install [Docker](https://docs.docker.com/engine/install/) (, and make sure Docker Daemon is running) |
| 34 | +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). |
| 35 | +3. Clone this project's code. Rename `/.devcontainer/devcontainer.linux.json` to `/.devcontainer/devcontainer.json`. |
| 36 | +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. |
| 37 | + |
| 38 | +### Windows (requires Windows 10 or later) |
| 39 | + |
| 40 | +For windows, we require WSL2 to run the devcontainer. (So its actually Linux with extra steps.) Full instructions can be found [in the official docs](https://code.visualstudio.com/blogs/2020/07/01/containers-wsl#_getting-started). Here are the important steps: |
| 41 | +1. Install [Docker](https://docs.docker.com/desktop/setup/install/windows-install/), and WSL2, and Ubuntu 22.04 LTS (, and make sure Docker Daemon is running) |
| 42 | +2. Docker will recognize that you have WSL installed and prompt you via Windows Notifications to enable WSL integration -> confirm this with `Enable WSL integration`. If not, open `Docker Desktop`, navigate to the settings, and manually enable WSL integration. (There are TWO setting options for this. Make sure to enable BOTH!) |
| 43 | +3. Install [VSCode](https://code.visualstudio.com/), with the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl), [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). |
| 44 | +4. Clone the source code for the exercises in the WSL2 file system to `/home` (`~`), or wherever you like. (Performance when working on the WSL file system is much better compared to Windows file system). You can access the WSL filesystem either by starting a WSL/Ubuntu console, or via the Windows File Explorer at `\\wsl.localhost\Ubuntu\home` (replace `Ubuntu` with your distro, if necessary). |
| 45 | +7. Rename `/.devcontainer/devcontainer.windows.json` to `/.devcontainer/devcontainer.json`. |
| 46 | +8. Open this project in VSCode. The easiest way to do so is by starting a WSL/Ubuntu shell, navigating via `cd` to the source code, then type `code .` to open 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. |
| 47 | + |
| 48 | + |
| 49 | +### MacOS |
| 50 | + |
| 51 | +Unfortunately, we did not get the devcontainer to work with MacOS yet, even after following [those](https://gist.github.com/sorny/969fe55d85c9b0035b0109a31cbcb088) steps. We expect that the issue is related to Mujoco rendering from inside the Docker container and display forwarding with X11. There is also an [unresolved Issue](https://github.com/google-deepmind/mujoco/issues/1047) on GitHub. If you manage to make it work, please let us know. |
| 52 | + |
| 53 | +Until then, MacOS users are required to install this project using an python environment manager such as [conda](https://docs.anaconda.com/anaconda/install/) or [mamba](https://mamba.readthedocs.io/en/latest/). If you use conda, these are the required commands: ```conda create --name crazyflow -c conda-forge python=3.11```, ```conda activate crazyflow```, ```conda install pip```, ```pip install -e .```. |
| 54 | + |
| 55 | +____________ |
| 56 | + |
| 57 | +Known Issues: |
| 58 | + - 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 |
| 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\]`. |
0 commit comments