Skip to main content

NeuroMechFly, a framework for simulating embodied sensorimotor control in adult Drosophila.

Project description

[!IMPORTANT] We introduced a new FlyGym 2.x.x API in March 2026, with a complete code rewrite and redesigned interface. This version delivers significantly improved performance:

  • ~10x speed-up for CPU-based simulations (~2x real-time throughput)
  • ~300x speed-up for GPU-based simulation via Warp/MJWarp (~60x real-time throughput)

Additional improvements include:

  • Improved scene composition workflow
  • Interactive viewer
  • Simplified dependency stack

This version is not backward compatible, and not all features from FlyGym 1.x.x are available. Feature requests can be submitted via Issues on the Github repository. See more information about the changes here.

Prefer the old version? FlyGym 1.x.x has been migrated to flygym-gymnasium. Its documentation has been migrated to gymnasium.neuromechfly.org.

Simulating embodied sensorimotor control with NeuroMechFly v2

Documentation | Paper | Discussion Board

overview_video

This repository contains the source code for FlyGym, the Python library for NeuroMechFly v2, a digital twin of the adult fruit fly Drosophila melanogaster that can see, smell, walk over challenging terrain, and interact with the environment (see our NeuroMechFly v2 paper).

NeuroMechFly consists of the following components:

  • Biomechanical model: The biomechanical model is based on a micro-CT scan of a real adult female fly (see our original NeuroMechFly publication). We have adjusted several body segments (in particular in the antennae) to better reflect the biological reality.
  • Vision: The fly has compound eyes consisting of individual units called ommatidia arranged on a hexagonal lattice. We have simulated the visual inputs on the fly’s retinas.
  • Olfaction: The fly has odor receptors in the antennae and the maxillary palps. We have simulated the odor inputs experienced by the fly by computing the odor/chemical intensity at these locations.
  • Hierarchical control: The fly’s Central Nervous System consists of the brain and the Ventral Nerve Cord (VNC), a hierarchy analogous to our brain-spinal cord organization. The user can build a two-part model — one handling brain-level sensory integration and decision making and one handling VNC-level motor control — with an interface between the two consisting of descending (brain-to-VNC) and ascending (VNC-to-brain) representations.
  • Leg adhesion: Insects have evolved specialized adhesive structures at the tips of the legs that enable locomotion vertical walls and overhanging ceilings. We have simulated these structures in our model. The mechanism by which the fly lifts the legs during locomotion despite adhesive forces is not well understood; to abstract this, adhesion can be turned on/off during leg stance/swing.
  • Mechanosensory feedback: The user has access to joint angles, actuator forces, contact forces, and user-defined anatomical joint-site positions.

This package is developed at the Neuroengineering Laboratory, EPFL.

Getting Started

For installation, see the documentation page.

To get started, follow tutorials here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flygym-2.0.1.tar.gz (9.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flygym-2.0.1-py3-none-any.whl (9.2 MB view details)

Uploaded Python 3

File details

Details for the file flygym-2.0.1.tar.gz.

File metadata

  • Download URL: flygym-2.0.1.tar.gz
  • Upload date:
  • Size: 9.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for flygym-2.0.1.tar.gz
Algorithm Hash digest
SHA256 d01f4e14d8960016f5eb051c1de4e2effb0763c60e8f672dda73d27ebc32e131
MD5 3155d7be355ccefd9f54368e1f697a6c
BLAKE2b-256 c2850599335b6429f29096b01646897ede18b41ddb69e7a0c8941eb4902760bb

See more details on using hashes here.

File details

Details for the file flygym-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: flygym-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for flygym-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b70c1c3150ccdcae38a37a9996a7a0bfd97b9fdf6d4e45859c0956366880881
MD5 94961c5dc01ef4dc3b588029e1845fee
BLAKE2b-256 fe47bed165a7b870272b29dd1cbf396046f5249fa162618b4cd1c48764dfbfd2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page