# Predicting fruit fly’s sensing rate with insect flight simulations

See allHide authors and affiliations

Edited by William Bialek, Princeton University, Princeton, NJ, and approved May 27, 2014 (received for review August 12, 2013)

## Significance

To balance in air, insects not only need to generate enough lift, but also have to make subtle adjustments to their wing movement to stabilize themselves. The tiny changes during complex wing movement, together with the intricacy of the underlying neural feedback system, make it extremely difficult to observe the key changes and to tease out the internal control algorithms insects use to stabilize themselves. With computational simulations and analyses, we can now make predictions about how fast and how frequently a model insect must sense and act to stabilize itself. Our results offer a strategy for effective stabilization of flapping flight and lead us to conjecture that fruit flies sense their kinematic state every wing beat.

## Abstract

Without sensory feedback, flies cannot fly. Exactly how various feedback controls work in insects is a complex puzzle to solve. What do insects measure to stabilize their flight? How often and how fast must insects adjust their wings to remain stable? To gain insights into algorithms used by insects to control their dynamic instability, we develop a simulation tool to study free flight. To stabilize flight, we construct a control algorithm that modulates wing motion based on discrete measurements of the body-pitch orientation. Our simulations give theoretical bounds on both the sensing rate and the delay time between sensing and actuation. Interpreting our findings together with experimental results on fruit flies’ reaction time and sensory motor reflexes, we conjecture that fruit flies sense their kinematic states every wing beat to stabilize their flight. We further propose a candidate for such a control involving the fly’s haltere and first basalar motor neuron. Although we focus on fruit flies as a case study, the framework for our simulation and discrete control algorithms is applicable to studies of both natural and man-made fliers.

- quantitative study of organismal behavior
- stability of flapping flight
- discrete time-delayed controller
- b1 motor neuron

Uncontrolled flapping flight is often unstable. A fruit fly without its gyroscopic sensors, the halteres, will tumble and fall (1, 2). Robotic fliers have a similar fate unless they are passively stabilized (3) or actively controlled (4). Thus, even in steady flight, insects must adjust their wing motions to stabilize their flight.

Exactly how various sensory feedback controls work in flying insects is a complex puzzle to solve (1, 2, 5⇓⇓⇓⇓⇓⇓⇓–13). What do insects measure to stabilize their flight? What kinds of neural computations and muscle activities are involved to correct their flight course or to turn? How often and how fast do insects adjust their wings to remain stable? What are the theoretical limits on the timescales in the control algorithm, imposed not only by neural physiology, but also by the dynamics of flapping flight?

Recent works have shown that the stability of flapping flight can be related to the stability of fixed-wing airplanes (14) in the limit where the wing-beat frequency is much faster compared to that of body oscillations (15). In such a limit, the aerodynamic forces can be approximated by their time-averaged values over a wing-beat cycle. The governing equations for the body dynamics near equilibrium flight can be simplified into a set of linear equations (2, 15⇓⇓⇓–19). For longitudinal flight, the primary instability is associated with the body-pitching dynamics, resulting from the dynamic coupling between the forward and pitching motions of the body. This instability is seen both in linear stability analysis of averaged models and in direct numerical simulations where the instantaneous coupling between body and wings is taken into account (20).

In this work, we ask how to design an effective controller for flapping flight and what the controllability might reveal about the internal control schemes. In particular, how do the timescales in the control algorithm affect the stability? To quantify the stability and investigate the controllability of free flight, we need a computational tool that can simulate flight in both open-loop and closed-loop conditions. There are few existing results on dynamic stability and controllability in the nonlinear regime of flight, especially when the instantaneous coupling between the flapping wings and the body is treated exactly.

In what follows, we first describe our simulation of flapping flight. We then discuss the rationale behind our proposed discrete time-delayed linear control algorithm and study the effectiveness of such a controller. We find conditions on both the sensing rate and the sensory delay for effective controllers through examining the interplay between these two timescales. Moreover, using our phase diagram (see Fig. 5), together with the response time of fruit flies to body torque perturbations (12), we are able to give sharper theoretical bounds on the sensing rate and delay time in relation to the wing beat. These results led us to conjecture that fruit flies sense their body orientation every wing beat. We discuss the plausibility of a beat-to-beat sensor based on findings in neural studies of flies.

## Simulation

### Three-Dimensional Dynamic Flight Simulation.

To investigate the control of 3D flapping flight, we develop a general algorithm to simulate 3D flapping flight where the aerodynamic forces are modeled in the quasi-steady limit. There are three new aspects of this framework in comparison with our previous models of yaw and pitch dynamics (2, 11, 12). First, it treats the instantaneous coupling between the dynamics of the wings and body explicitly, without averaging the aerodynamic forces over a wing period. Second, the stability and control of flight are analyzed in the regime where the dynamics are governed by the full nonlinear equations, instead of linearized equations about an equilibrium flight. Third, the method is formulated for the general problem in which the body has 6 df. The separate treatment of yaw dynamics, pitch dynamics in longitudinal flight, and roll dynamics in sideways flight can be viewed as special cases of this general framework. In this paper, we apply our method to the control of longitudinal flight.

Whereas there are multiple methods for simulating rigid body dynamics (21⇓⇓–24), our method for simulating the dynamics of free flight is based on the idea of treating each rigid body separately subject to internal forces. The internal forces are determined by kinematic constraints at the joints. This is conceptually simpler than methods that treat the coupling implicitly.

To simulate 3D free flight with flapping wings, we solve the Newton–Euler equations for the coupled wing–body system. The insect model consists of (*n* + 1) rigid bodies, with 1 insect body and *n* wings. Each wing is modeled as an ellipsoid connected to the body through a ball joint that allows for 3 df in rotation. The body kinematics are given by its position *ϕ*^{b} (yaw), *θ*^{b} (pitch), and *η*^{b} (roll); and angular velocity *ϕ*^{w}, *θ*^{w}, and *ψ*^{w}.

The governing equations for the body dynamics are*i*th wing are*b* denotes body, *w* denotes wing, *m* is mass, **I** is the moment of inertia tensor, *i*th wing root relative to the body center of mass, and *i*th wing root relative to the center of mass of the *i*th wing.

Because we have introduced the internal forces and torques at the joints, **1**–**4** together with the constraint Eqs. **5** and **6** can be cast into a linear system, [[*A*]][*X*] = [*R*], where the vector *A*]] contains *m*_{i} and **I**_{i}, and the vector [*R*] contains the known variables with *A*]] to find the body accelerations, and [[*A*]]^{−1} is determined by the standard lower–upper (L-U) decomposition.

Once the body accelerations

### Wing Motion.

The wing flaps back and forth along a horizontal stroke plane following a pattern similar to that observed in fruit flies. We use the generic description of these periodic motions based on our earlier work (25). The time dependences of the three rotational angles, *ϕ ^{w}*(

*t*), the stroke angle,

*θ*(

^{w}*t*), the deviation angle, and

*ψ*(

^{w}*t*), the wing-pitch angle (Fig. 1 and Fig. S2), are given by

*ϕ*

_{0},

*θ*

_{0}, and

*ψ*

_{0}are the constant offsets;

*ϕ*

_{m},

*θ*

_{m}, and

*ψ*

_{m}are amplitudes;

*f*is the wing-beat frequency;

*δ*

_{θ}and

*δ*

_{ψ}are the phase shifts; and

*n*= 1 or 2. 0 <

*K*< 1 and

*C*> 0 are waveform control parameters.

*n*= 1 corresponds to one vertical oscillation per stroke, and

*n*= 2 corresponds to a figure-eight motion.

*ϕ*becomes sinusoidal when

^{w}*K*is close to 0 and triangular when

*K*is close to 1.

*ψ*becomes sinusoidal at small

^{w}*C*and a step function at large

*C*.

### Aerodynamic Force Model on the Wing.

The modeling of aerodynamic force on a flapping wing at intermediate Reynolds numbers is a complex subject in itself (28). Previously, we examined the unsteady aerodynamics with direct numerical simulations (26, 27, 29⇓–31) and also constructed a revised quasi-steady model that included the key unsteady aerodynamic effects (32, 33). For this work, we need extended simulations for control analyses. The phase diagram (see Fig. 5) is based on 2,500 simulations, which would be infeasible to carry out with direct numerical simulations at the current computing speed. Moreover, the primary cause for the instability is the coupling between the body and wing motion and less so on the details of the forces. We have studied the effects of force coefficients on the pitching stability of flight in the averaged dynamic model and noted that the instability is insensitive to the choice of the force coefficients. Therefore, for these studies, we use a revised quasi-steady force model that takes into account the main unsteady effects, including the dynamic stall, the coupling between wing translation and rotation, and the added mass term. The specific form of the circulation and drag on each blade element is deduced from experiments and numerics of a free falling plate in fluid (32, 33) (*SI Text* and Fig. S3).

### Model Parameters.

To compare with related studies, we use the morphological parameters similar to those of fruit flies, *Drosophila melanogaster* in our calculations: body weight = 1.1 mg, body length = 2.4 mm, body width = 1.2 mm, wing weight = 3.6 × 10^{−3} mg, wing span = 2 mm, maximal wing chord = 1 mm, and maximal wing thickness = 0.1 mm. We use the following parameters in modeling the wing motion during uncontrolled flight: *f* = 250 Hz, *ϕ*_{m} = 63°, *ϕ*_{0} = 0°, *K* = 0.7, *θ*_{m} = *θ*_{0} = 0°, *ψ*_{m} = 53°, *ψ*_{0} = 90°, *δ*_{ψ} = −72.4°, and *C*_{ψ} = 2.4. For simplicity, we have neglected the deviation from the mean stroke plane, and we select the phase shift in *ψ ^{w}*(

*t*) so that the wing pitches in advance of the wing stroke reversal. The wing stroke amplitude is estimated so that the mean aerodynamic lift balances the body weight.

## Results

### Pitch Instability of Uncontrolled Flight.

We simulate the body dynamics according to Eqs. **1**–**12** in the cases where the left and right wings beat symmetrically following the motion given above (Eqs. **13**–**15**) (Movie S1, uncontrolled flight). By symmetry, the body translates in a vertical plane and is free to pitch up and down. The state of the body is described by the horizontal and vertical positions and velocities, the pitching angle, and the pitching rate. The insect is hovering initially with forces in balance. However, the flight eventually becomes unstable due to a pitch instability, similar to those found in the linearized averaged models (2, 15). We note that the instability appears to be insensitive to model parameters, including the body and wing inertia, as well as the force coefficients. A subtle difference between these nonlinear results and those from the linearized models is that the insect reaches a steady state in the nonlinear model, instead of having exponentially growing velocities. In the steady state, the insect is tumbling downward, and the body weight is largely balanced by the vertical drag due to the coupling between the descending velocity and the wing motion.

The cause of the pitching instability is the dynamic coupling between the forward and pitching motions. Fig. 2 illustrates the onset of this instability during a typical flight. The first four segments in Fig. 2, *Bottom* correspond to initial nose-down and -up oscillations in the body pitch. During the first phase, the aerodynamic torque pitches the body nose down (*A* → *B*). Thus, the aerodynamic lift tilts forward and drives the insect forward (*B* → *C*). The forward motion couples with the back-and-forth wing motion and results in a drag that pitches the body up (*C* → *D*). The drag and the horizontal component of the lift decelerate the body, and the body eventually moves backward (*D* → *E*). The backward motion is coupled with the wing motion to produce a nose-down torque (*E* → *F*). The body pitch oscillates as a result of this coupling between the horizontal and the body-pitch motions. The amplitude of the oscillation increases, and the body accelerates in descent. After a transient period, the body reaches a steady descent with a terminal speed ∼50 cm/s and a body oscillation amplitude ∼48°. Because of the body-pitch oscillation, the mean vertical lift due to the flapping motion is smaller than the body weight, and the weight balance requires a significant descent velocity to induce a vertical drag force. In the body frame, the velocity component along the longitudinal axis oscillates twice as fast as the component along the dorsal–ventral axis, consistent with the ratio between the frequencies of the driving forces along those directions. All of the oscillations are in phase. It is also worth noting that the oscillation period is about 20 wing beats.

### Controller for Stabilizing Body Pitch.

To overcome the pitching instability, an insect must generate a corrective torque during its flight. Insects are equipped with various sensory systems to measure their self-kinematics, and control decisions can be made based on the measurements (10). A fruit fly can correct its body posture by modulating the center position of the stroke (6, 34, 35). The center position is shifted forward to correct a nose-down body pitch and backward to correct a nose-up body pitch.

In designing the control algorithm, we build in two key features relevant to mechano-sensory feedback circuitries. First, whereas the continuous limit is convenient for mathematical analyses using differential equations, natural and physical systems often have discrete actions at small timescales. In the case of neural feedback circuitry, even when the physical stimulus acts continuously, the neural firing patterns are discrete, and there is no a priori reason to assume that the sensing and action occur continuously. Second, the time delay between sensing and actuation is likely to play a critical role in the effectiveness of the controller. The maximal delay imposed by controllability may further provide a clue to the timescales involved in insects’ neural feedback circuitry.

Based on these considerations, we construct a time-delayed discrete linear controller that adjusts the center of the wing stroke (Fig. 3*A*) according to the body pitch and body-pitching rate measured at a previous time. A general form for such a controller can be described as *ϕ*_{0}(*t*) = *k*_{u}*u*(*t* − *τ*) + *k*_{v}*v*(*t* − *τ*) + *k*_{θ}*θ*^{b}(*t* − *τ*) + *k*_{ω}*ω*^{b}(*t* − *τ*), where *ϕ*_{0} is the shift in the wing stroke from its center position (Fig. 3*A*) and *u*, *v*, *θ*^{b}, and *ω*^{b} are perturbed kinematics away from hovering, with (*u*, *v*) the horizontal and vertical velocities and *θ*^{b} and *ω*^{b} body pitch and pitching rate. *k*_{u}, *k*_{v}, *k*_{θ}, and *k*_{ω} are the controller gains, and *τ* is the time delay. Based on the physical picture of the instability discussed earlier (Fig. 2), in this paper, we set *k*_{u} = *k*_{v} = 0; i.e., the controller depends only on *θ*^{b} and *ω*^{b}. The controller is a proportional-integral control, with *ω*^{b} the directly sensed variable by the mechanosensory organ, the haltere, and *θ*^{b} is its integration in time.

We focus on the effect of the sampling interval and time delay on the controllability. Fig. 3*B* illustrates the sequence of events in our controller. At the beginning of a sampling interval, *T*_{s}, the insect senses its body kinematics. The control algorithm computes the shift of the center of the stroke, Δ*ϕ*_{0} = *ϕ*_{0,n+1} − *ϕ*_{0,n}, which takes a time interval of *T*_{d} to execute. The transition from *ϕ*_{0,n} to *ϕ*_{0,n+1} consists of an initially quiescent period *T*_{d,1} mimicking the reaction time followed by a ramp-up function over a time *T*_{d,2} mimicking the actuation. The actuation can be modeled in different ways; here, for simplicity, we use the polynomial *t*_{n} is the time at the *n*th measurement. The polynomial function,

Fig. 4 displays the longitudinal body pitch in a controlled flight with *k*_{θ} = 0.206, *k*_{ω} = 0.005, *T*_{s} = 1, and *T*_{d} = 2, in comparison with the simulation from uncontrolled flight. With the control, the body pitch gradually settles down to an undulating steady state with the same frequency as that of the wing motion. The control command also converges to a constant. The same controller is able to correct for a large torque perturbation, indicating its robustness (Movie S2).

### Constraints on the Sensing Rate and Time Delay in the Control Algorithm.

With these simulations, we can now answer the question of how fast and how often the controller should act to stabilize flapping flight. Fig. 5 shows the effectiveness of the controller in the parametric space spanned by the sampling interval, *T*_{s}, and the sensory delay, *T*_{d}. In these simulations, *T*_{s} ≥ *T*_{d,2} so that successive control commands do not overlap. We also constrain |*ϕ*| ≤ (90° − *ϕ*_{m}) so that the wing stroke amplitude does not exceed 90°. Color indicates the effectiveness of control quantified by the SD of body pitch, Δ*θ*^{b}, which characterize the oscillation amplitude. For well-controlled flight (blue region in Fig. 5), Δ*θ*^{b} is a few degrees.

The phase diagram reveals two key results. First, for each sampling interval (*T*_{s}), there is a critical sensory delay time (*T*_{cd}) below which the flight can be controlled. The boundary between the regions of well-controlled and poorly controlled flight is sharp and can be approximated by a linear relation, *T*_{cd} = 3.0 − 0.5*T*_{s}, as shown by the dashed line in Fig. 5. For a fixed *T*_{s} = 1, Fig. 6*A* shows the transition from a stable flight at *T*_{d} = 2.8, to an unstable flight at *T*_{d} = 2.9, to a more unstable flight at *T*_{d} = 3.2. At *T*_{d} = 3.2, the insect tumbles and falls in a similar way to that seen in the open-loop simulation.

Another conspicuous feature of the phase diagram is that the most effective control occurs at sampling intervals that are integer multiples of half a wing beat, *T*_{s} = 0.5, 1, … , 4.5, 5 wing beats. This is especially pronounced when *T*_{s} > 2, as indicated by the isolated dark blue bars in Fig. 5*B*. For example, near *T*_{s} = 2, a small variation in *T*_{s} leads to qualitatively different controlled flight (Fig. 6*B*). This sensitivity to the discrete value of *T*_{s} reflects the underlying wing-flapping timescale. Because the aerodynamic force and torque have a fast oscillation on the wing-beat timescale, *θ*^{b} also contains this fast oscillation on top of a slower variation. If the dynamic state is measured at a frequency commensurate with the wing-beat frequency, the samples are taken at the same phase during the wing beat. This eliminates the fluctuations of *θ*^{b} due to variations within a wing beat and allows the sensor to measure the change of *θ*^{b} over a longer timescale, which is the signal that needs to be controlled. In general, sampling at a fractional number of wing beats leads to worse control. One exception is when the sampling time is a multiple of half a wing beat (e.g., *T*_{s} = 3.5 or 4.5). Because the induced *θ*^{b} oscillation starts from the neutral position, the variation is also mostly eliminated in half a wing beat, similar to the case where the sampling interval is an integer number of wing beats.

## Predictions

### Beat-to-Beat Sensing Rate.

If the proposed controller turns out to be a good approximation of the control strategy used by fruit flies, we can go a step farther to infer that fruit flies sense their kinematic state every wing beat. Our reasoning is based on the phase diagram (Fig. 5), together with the measurements of fruit flies’ reaction time to external mechanical perturbation (12). When subject to a sudden torque perturbation, fruit flies respond by adjusting their wing kinematics after about three wing beats. This imposes additional constraints in the parameter space, marked by solid lines in Fig. 5. Two of the three solid lines are deduced based on Fig. 7. Suppose that the torque perturbation occurs shortly after the sensing; the observed three-wing-beat delay would imply that *T*_{d} + *T*_{s} > 3, giving the inclined solid line in Fig. 5. On the other hand, suppose that the perturbation occurs just before the sensing, and the observed three-wing-beat delay would imply *T*_{d} < 3, giving the solid line on the topmost boundary. The rightmost boundary at *T* = 3 corresponds to the limit beyond which the controller is less robust and works only at an integer number of wing beats. This leaves two integer choices for the sampling interval, *T*_{s} = 1 and *T*_{s} = 2. If we further examine the controllability in their vicinity, we note that the controller is most robust around *T*_{s} = 1. At *T*_{s} = 2, a small deviation from *T*_{s} can lead to considerable body oscillations (Fig. 6*B*). These considerations lead us to conjecture that fruit flies sense their kinematic states every wing beat.

### A Candidate for Beat-to-Beat Sensing in Fruit Flies.

It remains to be tested whether a fruit fly senses its body kinematics every wing beat to stabilize its flight. At the very least, such a beat-to-beat controller requires a fast neural pathway. One potential candidate for this is the neural circuitry between halteres and the first basalar (b1) muscle in flies (36, 37). Halteres are wing-like appendages that beat at wing frequency and act as gyroscopic sensors of body rotation by measuring the Coriolis force (1). They provide fast inputs to the motor neuron of b1 via a monosynaptic electrical pathway, as shown in the studies of blowflies (36). Unique among all steering muscles, b1 is the only one that fires a single action potential nearly every wing beat, even during steady flight, whereas other muscles are active only during turning maneuvers (36, 38). In light of our current results, we suggest that the first basalar muscle functions as a flight stabilizer by making a small adjustment to the wing motion, with sensory inputs from the halteres at a sampling rate of one wing beat.

## Concluding Remarks

Our simulations demonstrate that it is possible to stabilize flapping flight in the nonlinear regime with a discrete time-delayed linear control algorithm. In our cases, stabilization does not require prediction. Although this does not rule out the use of prediction in actual flies, the controller without using prediction gives a parsimonious description for a reflex controller such as the one discussed here.

We also note that the wing modulation needed for stabilization is small, which would have been difficult to discern from direct observation of flight. Whereas we focused on control of pitch instability, the computational framework lends itself to studies of control in other degrees of freedom, as well the effect of noise, turbulence, and other disturbances. Of course, the methodology for simulating flapping flight in 6 df is applicable to both natural and robotic fliers. The parameter space for controllability offers a guide for designing controllers of robotic fliers.

Our study further poses general questions on neural sensing and actuation insects use during free flight. We argued that a discrete control feedback is a more appropriate conceptual framework for modeling the underlying sensing and actuation, even though the continuous limit is convenient for mathematical analyses using differential equations. At small timescales, the firing patterns are discrete even when the physical stimulus acts continuously. The decisions and actions are based on computations of these discrete events. There is no a priori reason to assume that the control is continuous at these finer timescales. For voluntary turns, our previous study of fruit fly’s yaw turn found evidence that the actuation occurs in a step-like fashion (11). Our current simulations suggest that given the underlying time-periodic flight system, the controller for stability is more effective if it senses and acts in concert with the natural measure of time, the wing beat.

Finally, a main motivation for our work is to make connections between the internal neural control mechanisms and the macroscopic physical laws that govern the behavior of organisms. The computational modeling described here gives us a means to examine why insects must control their flight and why they need to evolve fast neural circuitry, in addition to how they control their flight. Although direct measurements of neural activity of insects in free flight remain a challenge, by making testable predictions on fruit fly’s sensing rate and the role of the first basalar (b1) muscle, we hope to stimulate new experimental work probing the relevant neural circuitries during free flight.

## Acknowledgments

We thank Leif Ristroph, Attila Bergou, Gordon Berman, John Guckenheimer, Itai Cohen, and Andy Ruina for discussions during the initial part of this work. This research is supported in part by the National Science Foundation.

## Footnotes

- ↵
^{1}To whom correspondence should be addressed. Email: jane.wang{at}cornell.edu.

Author contributions: Z.J.W. designed research; S.C. and Z.J.W. performed research; S.C. and Z.J.W. analyzed data; and Z.J.W. wrote the paper.

The authors declare no conflict of interest.

This article is a PNAS Direct Submission.

This article contains supporting information online at www.pnas.org/lookup/suppl/doi:10.1073/pnas.1314738111/-/DCSupplemental.

## References

- ↵
- Pringle JWS

- ↵
- Ristroph L,
- et al.

- ↵
- ↵
- Ma KY,
- Chirarattananon P,
- Fuller SB,
- Wood RJ

- ↵
- ↵
- Ellington CP

- ↵
- ↵
- Dudley R

- ↵
- Dickinson MH,
- et al.

- ↵
- ↵
- ↵
- Ristroph L,
- et al.

- ↵
- Cheng B,
- Deng X,
- Hedrick TL

- ↵
- Etkin B,
- Reid LD

- ↵
- ↵
- Taylor GK,
- Thomas ALR

- ↵
- Sun M,
- Xiong Y

- ↵
- Sun M,
- Wang JK

- ↵
- ↵
- Wu JH,
- Sun M

- ↵
- Goldstein H

- ↵
- Udwadia FE,
- Kalaba RE

- ↵
- Featherstone R

- ↵
- ↵
- ↵
- Wang ZJ

- ↵
- ↵
- ↵
- ↵
- ↵
- ↵
- ↵
- ↵
- Hollick FSJ

- ↵
- Zanker JM

*drosophila melanogaster*. iii. Control. Philos Trans R Soc B 327(1238):45–64. - ↵
- Fayyazuddin A,
- Dickinson MH

- ↵
- Fayyazuddin A,
- Dickinson MH

- ↵
- Heide G,
- Götz KG

## Citation Manager Formats

## Article Classifications

- Physical Sciences
- Applied Mathematics

- Biological Sciences
- Biophysics and Computational Biology