Fly navigation in NeuroMechFly

Year
2026

TL;DR

Problem
Walk a simulated fruit fly to an attractive odor source through five levels of rising difficulty (obstacles, wind, hilly terrain, a predator), using only its on-board senses.
What we built
A priority-based controller on top of a CPG walking model: escape the predator, avoid obstacles, turn toward the odor, then track it, with posture correction throughout.
Result
One controller that fuses compound-eye vision, smell, antenna wind sensing and body tilt, built to handle all five levels.
Stack
Python, NumPy/SciPy, MuJoCo, flygym (NeuroMechFly v2)

How do you walk a simulated fly to its food when every sense tells a different story?

  • 4 SENSES · 5 LEVELS
  • Bio-inspired control
  • Sensor fusion
  • MuJoCo (flygym)
  • Python

The approach

  1. Walking. flygym’s CPG-based walking model turns two descending signals, a left and a right drive, into a six-legged gait. The controller only decides those two drives.
  2. Escape first. The predator shows up as red pixels in the compound eyes, and the fly sprints away from it.
  3. Avoid obstacles. Green-pixel density in the upper field of each eye flags grass ahead. The turn direction accounts for the wind, sensed as antenna deflection against a calibrated baseline, and for the hill tilt, read from the body’s roll and pitch.
  4. Find the food. Two olfactory sensors first turn the fly in place toward the odor, with a smooth fade-out, then keep it on course with a left/right steering bias.
  5. Stay upright. A pitch and roll posture correction is added on top of the drives the whole time.

What it achieved

  • Four senses, one controller. Compound-eye vision, smell, antenna wind sensing and body orientation feed a single priority-based decision tree.
  • Five levels. Odor tracking, grass obstacles, wind, hilly terrain and a dragonfly predator, all handled by the same controller.
  • My part: the pitch and roll posture correction, the odor-attraction module, and the movement logic for the first two levels.

Notes

NeuroMechFly, its CPG walking model, the arenas and the simulated senses come from the course framework (flygym). We wrote the controller as a team of 3. The code lives in a teammate’s repository.