Skip to main content

[!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.

Metadata

Release files for flygym 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flygym 2.1.0
File Size Uploaded
flygym-2.1.0.tar.gz 3.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for flygym 2.1.0
File Interpreter ABI Platform
flygym-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.3 MB

Release files / flygym-2.1.0.tar.gz

Download URL flygym-2.1.0.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
0670aceae078773cb16e003a8f647880c1db62f219912e005e98b2b2f7fb1618
BLAKE2b-256 checksum
How to use checksums
d3dc86344d6bc26da005b192695528c53dd5049c0f6077ac9538d11ca11fa89a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / flygym-2.1.0-py3-none-any.whl

Download URL flygym-2.1.0-py3-none-any.whl
Size 3.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3ba7292683c1be73897b7f5585612ff57fb9eec28381178efbc0e4368c0e46fd
BLAKE2b-256 checksum
How to use checksums
f5272c6e130f16e8f187b3036c6d7555f933bfac4a323f73bef60aa126d07fb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page