Musculoskeletal simulation of limb movement biomechanics in Drosophila melanogaster

1École Polytechnique Fédérale de Lausanne (EPFL)
2Kempner Institute, Harvard University
3University of Bonn
*Equal contribution

Muscle-actuated imitation learning in MuJoCo: a PPO policy drives 15 muscle-tendon units to reproduce recorded Drosophila locomotion kinematics. Colors indicate activation level, ranging from blue (inactive) to red (fully active).

Interactive Demo

An interactive demo of our musculoskeletal model, running MuJoCo in your browser via MuJoCo WebAssembly. You can drag to rotate and scroll to zoom using your mouse. Click on the "Actuators" drop-down to visualize and modify muscle activations to see their effect on joint movements. Note that loading may take up to 30 seconds.

Loading simulation…
Pipeline to develop Drosophila leg musculoskeletal models

Pipeline overview: Anatomical X-ray data establishes the anatomical mapping in the musculoskeletal model; 3D pose estimation from behaving flies is then used to optimize the unknown parameters of the muscle model, and ultimately to drive muscle-actuated imitation learning in MuJoCo.

Abstract

Computational models are critical for advancing our understanding of how neural, biomechanical, and physical systems interact to orchestrate animal behaviors. Despite the availability of near-complete reconstructions of the Drosophila melanogaster central nervous system, musculature, and exoskeleton, anatomically and physically grounded models of fly leg muscles are still missing. These models provide an indispensable bridge between motor neuron activity and joint movements.

Here, we introduce the first 3D, data-driven musculoskeletal model of Drosophila legs, implemented in both OpenSim and MuJoCo simulation environments. Our model incorporates a Hill-type muscle representation based on high-resolution X-ray scans from multiple fixed specimens. We present a pipeline for constructing muscle models using morphological imaging data and for optimizing unknown muscle parameters specific to the fly. We then combine our musculoskeletal models with detailed 3D pose estimation data from behaving flies to achieve muscle-actuated behavioral replay in OpenSim. Simulations of muscle activity across diverse walking and grooming behaviors predict coordinated muscle synergies that can be tested experimentally. Furthermore, by training imitation learning policies in MuJoCo, we test the effect of different passive joint properties on learning speed and find that damping and stiffness facilitate learning. Overall, our model enables the investigation of motor control in an experimentally tractable model organism, providing insights into how biomechanics contribute to the generation of complex limb movements. Moreover, our model can be used to control embodied artificial agents to generate naturalistic and compliant locomotion in simulated environments.

Muscle Reconstructions

To reconstruct front leg muscles, we used multiple high-resolution X-ray datasets, each capturing different foreleg postures. We annotated muscle fibers spanning the thorax–coxa, coxa–trochanter, and femur–tibia joints, and modeled 15 muscle-tendon units (MTUs) per foreleg, capturing 12 of the 19 anatomically distinct muscle groups.

Front leg muscle reconstructions from X-ray data and OpenSim

Reconstructed muscle dataset and musculoskeletal model of the front legs: Front leg muscle reconstructions from high-resolution X-ray scans visualized in Blender (left), and corresponding muscle-tendon units implemented in OpenSim (right). Colors denote anatomically grouped muscles.

Muscle Model Optimization

Experimental data pertaining to muscle physiological parameters (e.g., maximum isometric force) in the fly legs are limited. We therefore explored parameter values through multi-objective optimization using NSGA-II in a biologically plausible value range per parameter. For each candidate parameter set, static optimization inferred muscle activations from reference joint angles, and forward dynamics simulated joint trajectories. To avoid overfitting, optimization was performed across two behaviors—antennal grooming and locomotion—retaining solutions that performed well for both. Our model correctly reproduces opposing moment arm signs for flexor and extensor muscles, consistent with their known functional roles.

Optimization and assessment of muscle model parameters

Hill-type muscle model and optimization of muscle parameters: Hill-type muscle model schematic (A) and optimization pipeline (B).

Kinematic replay of the ground truth joint angles (left) vs. forward dynamics simulation using optimized muscle parameters (right) in OpenSim.

Muscle Synergies During Walking and Grooming

Using OpenSim's static optimization, we estimated muscle activations during forward walking and grooming. Applying Non-negative Matrix Factorization (NMF), we find that just three muscle primitives explain over 90% of the variance in muscle activity across both behaviors. These synergies exhibit distinct temporal dynamics and task-specific muscle weights—predicting that the fly flexibly repurposes the same musculature for different behaviors by engaging distinct, task-specific synergies.

Predicting muscle synergies from simulated muscle activations in OpenSim

Investigating muscle synergies during walking and grooming: Simulated joint angle trajectories (A), muscle activation dynamics (B), variance explained by NMF synergies (C), synergy time courses (D), and synergy weight matrix (E) during locomotion and grooming.

Passive Joint Properties Facilitate Imitation Learning

To study muscle-driven control strategies, we trained PPO policies in MuJoCo to imitate animal kinematics. We systematically varied passive joint properties—stiffness, damping, and armature—across four conditions. We find that combining stiffness and damping yields the fastest learning and highest performance, supporting the hypothesis that passive mechanics offload control effort from the neural controller, allowing the policy to focus on producing coordinated muscle patterns rather than correcting instability.

The impact of passive joint properties on imitation learning

Joint passive properties facilitate imitation learning: Passive joint property conditions (A–B), imitation learning reward curves (C), early vs. late performance statistics (D), joint angle tracking (E), and time-averaged muscle activations (F).

Ground Locomotion

The muscle parameter optimization and imitation learning experiments described above were performed without contact forces: the fly model moves through free space while tracking recorded joint angle trajectories. Despite this, the optimized musculoskeletal model transfers to ground locomotion without any additional training or fine-tuning, suggesting that the muscles produces sufficent forces to support the body weight.

The muscle-actuated model walking on the ground in MuJoCo. The front legs are actuated by the muscle model while the middle and hind legs are actuated by direct torque control to provide support.

BibTeX

@misc{ozdil2025musculofly,
      title={Musculoskeletal simulation of limb movement biomechanics in Drosophila melanogaster},
      author={Pembe Gizem Özdil and Chuanfang Ning and Jasper S. Phelps and Sibo Wang-Chen and Guy Elisha and Alexander Blanke and Auke Ijspeert and Pavan Ramdya},
      year={2025},
      eprint={2509.06426},
      archivePrefix={arXiv},
      primaryClass={q-bio.NC},
      url={https://arxiv.org/abs/2509.06426},
}