Welcome to BIOENG 456: Controlling Behavior in Animals and Robots (CoBAR)! In this course, we will program NeuroMechFly 2.0 (a digital twin of the adult fruit fly Drosophila melanogaster) to interact with the environment and perform complex behaviors.
To begin with the course materials, ensure you have Git, uv, FFmpeg, and Visual Studio Code installed.
Git is essential for version control and collaboration. Download and install Git from git-scm.com.
uv is a Python package manager that simplifies the installation of Python packages and their dependencies. See the uv installation guide for installation instructions.
FFmpeg is used for encoding and saving videos of simulations. Check if FFmpeg is already installed by running:
ffmpeg -versionIf FFmpeg is not installed, follow the instructions for your operating system:
macOS (using Homebrew):
brew install ffmpegWindows (using winget):
winget install --id Gyan.FFmpeg -e --source wingetAfter installation, restart your terminal for the ffmpeg command to become available.
Linux (Debian/Ubuntu):
sudo apt update && sudo apt install ffmpegLinux (Fedora):
sudo dnf install ffmpeg-freeVerify the installation by running:
ffmpeg -version- Download and install Visual Studio Code
- Open Visual Studio Code and navigate to the Extensions view by clicking on the Extensions icon in the Activity Bar on the left side of the window (or by pressing
Ctrl+Shift+Xon Windows/Linux andCmd+Shift+Xon Mac). - Search for "Python" and install the Python extension provided by Microsoft.
- Search for "Jupyter" and install the Jupyter extension provided by Microsoft.
git clone https://github.com/NeLy-EPFL/cobar-2026.git
cd cobar-2026
uv syncOpen the cobar-2026 folder with Visual Studio Code: File > Open...
Open the Explorer view in Visual Studio Code by clicking on the Explorer icon in the Activity Bar on the left side of the window (or by pressing Ctrl+Shift+E on Windows/Linux and Cmd+Shift+E on Mac).
Open one of the .ipynb files within the Explorer view (e.g., notebooks/week1/kinematic_replay.ipynb)
Change the kernel to flygym (for how to change kernel, refer to https://code.visualstudio.com/docs/datascience/jupyter-kernel-management)
For more instructions on how to work with Jupyter Notebooks in Visual Studio Code, refer to https://code.visualstudio.com/docs/datascience/jupyter-notebooks.
New materials will be released every week. Update the repository by:
cd cobar-2026
git pullIf you are using a machine without a display (e.g., a server), you will need to change the renderer to EGL. This requires setting the following environment variables before running FlyGym. We recommend adding these lines to the .venv/bin/activate file to ensure they are set every time you activate the virtual environment:
echo 'export MUJOCO_GL=egl' >> .venv/bin/activate
echo 'export PYOPENGL_PLATFORM=egl' >> .venv/bin/activate