{"slug": "turagalab-flybody-mujoco-fruit-fly-body-model-and-locomotion-rl-tasks", "title": "TuragaLab/flybody: MuJoCo fruit fly body model and locomotion RL tasks", "summary": "Google DeepMind and HHMI Janelia Research Campus released flybody, an anatomically detailed fruit fly (Drosophila melanogaster) body model for the MuJoCo physics simulator and reinforcement learning applications, accompanied by a publication in Nature. The model supports walking, flight, and vision-guided flight RL task environments, with a 59-dimensional walking action space, and can be trained using a distributed RL script that parallelizes the DMPO agent via Ray. The project is installable in three modes — core, ML extension with TensorFlow and Acme, and a Ray training extension — under Python 3.10.", "body_md": "`flybody` is an anatomically-detailed body model of the fruit fly [*Drosophila melanogaster*](https://en.wikipedia.org/wiki/Drosophila_melanogaster) for [MuJoCo](https://github.com/google-deepmind/mujoco) physics simulator and reinforcement learning applications.\n\nThe fly model was developed in a collaborative effort by Google DeepMind and HHMI Janelia Research Campus.\n\nWe envision our model as a platform for fruit fly biophysics simulations and for modeling neural control of sensorimotor behavior in an embodied context; see our accompanying [publication](https://www.nature.com/articles/s41586-025-09029-4).\n\nThe fruit fly body model lives in [this directory](https://github.com/TuragaLab/flybody/tree/main/flybody/fruitfly/assets). To visualize it, you can drag-and-drop `fruitfly.xml` or `floor.xml` to MuJoCo's `simulate` viewer.\n\nInteracting with the fly via Python is as simple as:\n\n``` python\nimport numpy as np\nimport mediapy\n\nfrom flybody.fly_envs import walk_imitation\n\n# Create walking imitation environment.\nenv = walk_imitation()\n\n# Run environment loop with random actions for a bit.\nfor _ in range(100):\n   action = np.random.normal(size=59)  # 59 is the walking action dimension.\n   timestep = env.step(action)\n\n# Generate a pretty image.\npixels = env.physics.render(camera_id=1)\nmediapy.show_image(pixels)\n```\n\nThe quickest way to get started with `flybody` is to take a look at a [tutorial notebook](https://github.com/TuragaLab/flybody/blob/main/docs/getting-started.ipynb) or [.](https://colab.research.google.com/github/TuragaLab/flybody/blob/main/docs/getting-started.ipynb)\n\nAlso, [this notebook](https://github.com/TuragaLab/flybody/blob/main/docs/fly-env-examples.ipynb) shows examples of the flight, walking, and vision-guided flight RL task environments.\n\nTo train the fly, try the [distributed RL training script](https://github.com/TuragaLab/flybody/blob/main/flybody/train_dmpo_ray.py), which uses [Ray](https://github.com/ray-project/ray) to parallelize the [DMPO](https://github.com/google-deepmind/acme/tree/master/acme/agents/tf/dmpo) agent training.\n\nFollow these steps to install `flybody`:\n\n1. \nClone this repo and create a new conda environment: \n\n```\ngit clone https://github.com/TuragaLab/flybody.git\ncd flybody\nconda create --name flybody -c conda-forge python=3.10 pip ipython cudatoolkit=11.8.0\nconda activate flybody\n```\n\n `flybody` can be installed in one of the three modes described next. Also, for installation in editable (developer) mode, use the commands as shown. For installation in regular, not editable, mode, drop the`-e` flag.\n2. \n**Core installation** : minimal installation for experimenting with the\nfly model in MuJoCo or prototyping task environments. ML dependencies such as[Tensorflow](https://github.com/tensorflow/tensorflow) and[Acme](https://github.com/google-deepmind/acme) are not included and policy rollouts and training are not automatically supported.\n\n```\npip install -e .\n```\n\n3. \n**ML extension (optional)** : same as core installation, plus ML dependencies (Tensorflow, Acme) to allow running\npolicy networks, e.g. for inference or for training using third-party agents not included in this library.\n\n```\npip install -e .[tf]\n```\n\n4. \n**Ray training extension (optional)** : same as core installation and ML extension, plus[Ray](https://github.com/ray-project/ray) to also enable\ndistributed policy training in the fly task environments.\n\n```\npip install -e .[ray]\n```\n\n1. Create a new conda environment:\nProceed with installation in one of the three modes (described above):\n\n```\nconda create --name flybody -c conda-forge python=3.10 pip ipython cudatoolkit=11.8.0\nconda activate flybody\n```\n\n2. **Core installation** :\n\n```\npip install git+https://github.com/TuragaLab/flybody.git\n```\n\n3. **ML extension (optional)** :\n\n```\npip install \"flybody[tf] @ git+https://github.com/TuragaLab/flybody.git\"\n```\n\n4. **Ray training extension (optional)** :\n\n```\npip install \"flybody[ray] @ git+https://github.com/TuragaLab/flybody.git\"\n```\n\n1. \nYou may need to set [MuJoCo rendering](https://github.com/google-deepmind/dm_control/tree/main?tab=readme-ov-file#rendering) environment varibles, e.g.:\n\n```\nexport MUJOCO_GL=egl\nexport MUJOCO_EGL_DEVICE_ID=0\n```\n\n2. \nAlso, for the ML and Ray extensions, `LD_LIBRARY_PATH` may require an update, e.g.:\n\n``` python\nCUDNN_PATH=$(dirname $(python -c \"import nvidia.cudnn;print(nvidia.cudnn.__file__)\"))\nexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib\n```\n\n3. \nYou may want to run `pytest` to test the main components of the`flybody` installation.\n\nSee our accompanying [publication](https://www.nature.com/articles/s41586-025-09029-4). Thank you for your interest in our fly model:)\n\n```\n@article{flybody,\n  title = {Whole-body physics simulation of fruit fly locomotion},\n  author = {Roman Vaxenburg and Igor Siwanowicz and Josh Merel and Alice A Robie and\n            Carmen Morrow and Guido Novati and Zinovia Stefanidi and Gert-Jan Both and\n            Gwyneth M Card and Michael B Reiser and Matthew M Botvinick and\n            Kristin M Branson and Yuval Tassa and Srinivas C Turaga},\n  journal = {Nature},\n  volume = {643},\n  pages = {1312--1320},\n  year = {2025},\n  doi = {https://doi.org/10.1038/s41586-025-09029-4},\n  url = {https://www.nature.com/articles/s41586-025-09029-4},\n}\n```\n\n", "url": "https://wpnews.pro/news/turagalab-flybody-mujoco-fruit-fly-body-model-and-locomotion-rl-tasks", "canonical_source": "https://github.com/TuragaLab/flybody", "published_at": "2026-09-13 07:09:45+00:00", "updated_at": "2026-09-13 07:26:59.989077+00:00", "lang": "en", "topics": ["robotics", "ai-research", "machine-learning", "ai-tools", "developer-tools"], "entities": ["Google DeepMind", "HHMI Janelia Research Campus", "flybody", "MuJoCo", "Drosophila melanogaster", "Ray", "DMPO", "TensorFlow"], "alternates": {"html": "https://wpnews.pro/news/turagalab-flybody-mujoco-fruit-fly-body-model-and-locomotion-rl-tasks", "markdown": "https://wpnews.pro/news/turagalab-flybody-mujoco-fruit-fly-body-model-and-locomotion-rl-tasks.md", "text": "https://wpnews.pro/news/turagalab-flybody-mujoco-fruit-fly-body-model-and-locomotion-rl-tasks.txt", "jsonld": "https://wpnews.pro/news/turagalab-flybody-mujoco-fruit-fly-body-model-and-locomotion-rl-tasks.jsonld"}}