The role of optic flow pooling in insect flight control in cluttered environments

Flight through cluttered environments, such as forests, poses great challenges for animals and machines alike because even small changes in flight path may lead to collisions with nearby obstacles. When flying along narrow corridors, insects use the magnitude of visual motion experienced in each eye to control their position, height, and speed but it is unclear how this strategy would work when the environment contains nearby obstacles against a distant background. To minimise the risk of collisions, we would expect animals to rely on the visual motion generated by only the nearby obstacles but is this the case? To answer this, we combine behavioural experiments with numerical simulations and provide the first evidence that bumblebees extract the maximum rate of image motion in the frontal visual field to steer away from obstacles. Our findings also suggest that bumblebees use different optic flow calculations to control lateral position, speed, and height.

the animal makes equally proportional changes in both speed and altitude. Thus, exactly how insects control their vertical position and where they measure the optic flow used for this remains unclear.
Bees routinely forage in cluttered natural environments, such as around bushes or in forests, where the risk of colliding with obstacles is high. The obstacles that pose the greatest collision risk in clutter are those in front. These would generate higher magnitudes of optic flow than the more distant background, but would subtend only a minor portion of the visual field. If the value for the magnitude of optic flow that is used for flight control is averaged across the output of motion detectors across a broad visual field, then information about the proximity of obstacles in front of the agent will be lost. Thus, how and where in the visual field optic flow is calculated will severely affect the performance of any vision-based flight control and collision avoidance strategies. Previous work provides little insight into how insects measure optic flow for flight control because the pattern of optic flow generated in the experimental corridors that are typically used in these studies is qualitatively independent of viewing angle and the nearest obstacles (the walls) occur only in the lateral visual field.
To investigate how insects control flight in cluttered environments and to identify the optic flow pooling strategies they use to do so, we recorded the trajectories of bumblebees flying through corridors in which the density and placement of obstacles were varied. We then calculated the response of different optic flow pooling methods to our different experimental environments and compared this to the measured data. We find that lateral position and speed control are being regulated by an optic flow pooling strategy that extracts optic flow from nearby obstacles in the frontal visual field but that height control is being regulated by a value of optic flow derived by averaging optic flow across a wide lateral field of view. Overall, our findings suggest that rather than calculating optic flow only across a wide visual field, bees selectively react to nearby obstacles for centring and speed control and that optic flow for different flight control behaviours may be mediated by parallel processing streams in the insect visual system.

Results and Discussion
First, we recorded the three-dimensional position of bumblebees flying along an experimental corridor in which we varied the density of obstacles placed along two lines parallel to the main axis of the corridor at a distance of 0.2 m from each wall. The experimental conditions are named according to the format α β |  where α and β represent the percentage of the corridor length occupied by obstacles on the left and right side, respectively, of a bee flying towards a feeder. For example, the corridor | 0 16  has no obstacles on the left side, and obstacles covering 16% of the tunnel length on the right side ( Fig. 1), while in the corridor  | 33 33 obstacles occupy 33% of the corridor length on both sides (Fig. 2a).
The effect of obstacle density on lateral position. In the conditions without obstacles,  | 0 0 and  | 0 100 (Fig. 2a), bumblebees maintain an equal distance to both walls. With obstacles on one side (conditions  | 0 16 and The corridor has the following dimensions: D is the half tunnel width, d is the lateral position of obstacles, l is the obstacle length, L is the period at which obstacles are distributed along the corridor. The condition shown here is  | 0 16 , with no obstacles on the left (l/L = 0%), and obstacles occupying 16% on the right side (l/L = 16%). The state of the agent is modelled by its longitudinal position x, its lateral position y, its flight speed V, and its vertical position z (z is not shown in this schematic). The viewing angles are defined by the angle Ψ between the x axis and a viewing direction. The projection on the y axis of the distance between the agent and obstacles is noted Δ and is used for the computation of optic flow in equation [1]. (b) View along the experimental corridor with obstacles on the right side. Table 1), they instead fly close to the safest position of y = 0.1 m (dashed grey line, Fig. 2), but as obstacle density decreases, they fly slightly closer to the obstacles (Fig. 2c).
Flights were also centred in corridors with symmetrically distributed obstacles ( | 16 16 and |

33
 ), with the lateral position being less variable (lower standard deviations) than in the corridor without obstacles  | 0 0 . This is likely due to the factor of 3 reduction in effective corridor width (0.2 m between the obstacles for | 16 16  and |

33
 , compared to 0.6 m between the walls in | 0 0  ), although the standard deviation decreased by a factor of 3.8 to 4.75 (Table 1). Similarly, even though the maximum width is higher in  | 16 16   The horizontal lines on the error bars denote the standard error of the mean. The uncapped bars denote the standard deviation. The statistical significance of the difference between measured data across two corridor conditions is tested using post-hoc Tukey HSD tests, with the null hypothesis that the mean recorded data is equal for both conditions. The horizontal grey lines indicate the p-value of the post-hoc Tukey HSD tests (*** when p ≤ 0.001, ** when 0.001 < p ≤ 0.01, * when 0.01 < p ≤ 0.05 and n.s. when 0.05 < p). (2019) 9:7707 | https://doi.org/10.1038/s41598-019-44187-2 www.nature.com/scientificreports www.nature.com/scientificreports/ The effect of obstacle density on flight speed. In the conditions without obstacles ( | 0 0 and  | 0 100 ), bumblebees adjust their flight speed to the corridor width (Fig. 2d). Indeed, speed control in flying insects is often modelled as maintaining the magnitude of optic flow-that is, the ratio between flight speed (V) and the distance to nearby surfaces (D)-at a predefined value (for a review see 23 ), which has been found experimentally to lie between 3.0 rad/s and 6.0 rad/s 17,18,20,24 for honeybees and bumblebees. In the 0.4 m wide corridor ( | 0 100 ), the average flight speed was 1.1 m/s, which would generate a lateral optic flow of magnitude 5.5 rad/s. In the 0.6 m wide corridor ( | 0 0 ), the average flight speed increased to 1.3 m/s, generating a lateral optic flow of magnitude 4.3 rad/s, representing a speed increase of 20%. This does not match the proportional increase of corridor width, which was 50% and suggests that lateral optic flow is not the only source of information used for flight speed control, a finding that is consistent with the findings of previous studies in both bumblebees 13 Table 1). This indicates that flight speed is controlled using optic flow on both sides and that it is affected by the presence and density of obstacles.
The effect of obstacle density on vertical position. In the absence of obstacles, bumblebees maintain the same distance from the floor as they do from the wall: when the half-width of the corridor is 0.3 m ( | 0 0 ) the average vertical position is 0.29 m and, similarly, when the half-width of the corridor is 0.2 m, the average vertical position is 0.21 m. In other words, in corridors that do not contain obstacles, the magnitude of the lateral optic flow is held equal to the magnitude of the ventral optic flow.  www.nature.com/scientificreports www.nature.com/scientificreports/ In all conditions, the vertical position is quite variable with relatively high standard deviations (Fig. 2e) and there are few cases where the differences between the conditions were significant (Table 1). Interestingly, ventral optic flow (calculated by dividing the measured flight speed by the measured vertical position, Fig. 2f  . This is a surprising result because the optic flow profile generated in the ventral visual field is the same for all conditions, so ventral flow should not be affected by the density of obstacles in the lateral visual field. We would expect bumblebees to fly significantly lower in | 16 16  and  | 33 33 to compensate for the reduced flight speed and to maintain the ventral optic flow at a constant value. However, this is not what we observe (Fig. 2e,f), which suggests that vertical control might not be driven only by ventral optic flow, as previously modelled 21,[25][26][27] , but that it might be mediated by a combination of ventral and lateral optic flow.
Predicting the effect of obstacle density and optic flow pooling on flight control. The change in lateral position, flight speed, and vertical position in response to the density of nearby obstacles is likely a reflection of the way in which bumblebees pool optic flow from their panoramic field of view to control flight. Are they using a fixed spatial integration of optic flow across their entire visual field or are they selectively reacting to the nearby obstacles? To answer this question, we predict the lateral position, flight speed and vertical position in each of our experimental corridors for different methods of optic flow integration from different parts of the visual field. We then assess how well the results of each method agree with the experimental data from bumblebees to determine which method best explains the observed responses.
Predicted lateral position. Our predictions of the lateral position are based on the optic flow balancing control strategy in which a sideways force is applied based on the difference between the optic flow on the left and right sides 23 (for details, see equation [8]). Optic flow on the left and right side are pooled according to four of the most biologically plausible methods: average optic flow across lateral and fronto-lateral visual field (noted respectively avg and avgf), and maximum optic flow in lateral and fronto-lateral visual field (noted respectively max and maxf).

33
 ), all predictions match the measured lateral positions (Fig. 3a), because the predicted lateral position for these conditions does not depend on the optic flow pooling method and reveals little about the specific optic flow pooling strategy being used. In the asymmetric conditions that have obstacles only on one side ( | 0 16 and  | 0 33 ), the predicted lateral position does vary with the optic flow integration method. It is interesting to note that the predicted lateral positions for average optic flow (avg and avgf) do not vary with changes in the field of view (Fig. 3a). Also, the predictions made using maximum rate of optic flow (max and maxf) have a greater distance to obstacles than those made using averaged optic flow (avg and avgf). This is not surprising because, with the maximum optic flow, the agent selectively reacts to the nearby obstacles, while averaging causes the optic flow from the nearby obstacles to 'blend' into the background, reducing their influence on lateral position. The predictions made using the maximum optic flow in the frontal visual field lie the closest to the safest position (at y = 0.1 m, i.e. the lateral position at equal distance from the line of obstacles and the opposite wall), and yield lower error than the predictions made using average optic flow when compared to the bumblebee data (Fig. 3b). Optic flow pooling avg and avgf generate lateral positions much closer to the obstacles -and thus much less safe trajectories -than those performed by insects. This suggests that bumblebees use the maximum optic flow in the frontal visual field to control their lateral position, which is the optimal approach because (i) the frontal visual field is where incoming obstacles are the most likely to occur and (ii) selecting the maximum optic flow will ensure that the bees selectively react to the closest obstacles in the visual field.
Predicted flight speed. Our predictions of flight speed are based on an optic flow regulation strategy in which a longitudinal force derived from the difference between lateral optic flow and a reference optic flow value is applied 20,23 (for details, see equation [8]). The agent accelerates if the lateral optic flow is lower than the reference optic flow, it decelerates if the lateral optic flow is higher than the reference optic flow, and remains at a constant speed when they are equal. The lateral optic flow is calculated by pooling optic flow on the left and right sides, then taking the mean of the two resulting signals. For the reference optic flow, we use a value of 5.5 rad/s, which is close to the values obtained in previous studies 17,18,20,24 , and is close to the magnitude of lateral optic flow experienced by bumblebees in  | 0 100 (Fig. 2d, Table 1). In conditions without obstacles ( | 0 0  and  | 0 100 ), the same speed is predicted with all pooling methods (Fig. 3c) and explains why data from simple corridors alone is insufficient for testing hypotheses about how insects pool optic flow for flight control. The predicted speed in | 0 100  (1.10 m/s) is close to the measured speed (1.09 m/s), which is not surprising given that the reference optic flow value lies close to the optic flow value known to be used by bumblebees. However, the predicted speed for  | 0 0 is 1.65 m/s, which is significantly higher than the measured value of 1.34 m/s (p ≤ 0.001). This discrepancy between measured and predicted flight speed in | 0 0  may be explained by additional sensory feedback -such as airspeed -which is likely combined with optic flow for speed control 28 . However, there is currently no existing model for how airspeed and optic flow are combined to control flight speed in freely-flying insects.
The most interesting conditions for studying the effect of optic flow pooling on flight speed are those in which obstacles are present: | 0 16  , and  | 33 33 . In these conditions, average pooling avg and avgf generates the highest predicted speeds because maximum pooling max and maxf (Fig. 3c) selects optic flow generated by the closest objects, leading to a reduced flight speed.
The variation of predicted flight speed with varying obstacle density suggests that, as with lateral position control, flight speed is regulated using maximum optic flow pooling. The flight speed predicted using maximum (2019) 9:7707 | https://doi.org/10.1038/s41598-019-44187-2 www.nature.com/scientificreports www.nature.com/scientificreports/ optic flow shows very little variation between  | 0 16 and | 0 33  (Fig. 3c), which is also the case for the measured flight speeds (Table 1). On the contrary, the flight speed predicted using average optic flow shows a steeper decrease with increasing obstacle density in | 0 16  and  | 0 33 . Furthermore, the predicted flight speed with average pooling is higher in | 16 16  than in  | 0 100 , unlike measured flight speeds which show a non-significant decrease in flight speed ( Table 1). The proximity of obstacles in | 16 16  is higher than in  | 0 100 and it would thus be more sensible to reduce flight speed in this condition, as predicted by maximum pooling.
The predicted speeds lie closer to the measured speeds with maximum pooling than with average pooling (Fig. 3c). The error with maxf pooling is the lowest and is more than 4 times lower than with avgf pooling (Fig. 3d). These results suggest that -similar to lateral control -bees use maximum optic flow pooling in the frontal visual field to control their speed. This makes sense from a biological point of view because it selects the visual motion generated by the closest obstacles, which represent the main collision threats. Also, incoming obstacles are more likely to occur in the frontal visual field, which is coherent with the fact that predictions are more accurate with maxf pooling than with max pooling (Fig. 3d).
Predicted vertical position. Our predictions of vertical position are based on an optic flow regulation strategy in which a vertical force is applied based on the difference between the ventral optic flow and a reference optic flow value obtained from honeybees 21 (similar data does not exist for bumblebees; for details, see equation [8]). Note that honeybees use the dorsal flow for controlling vertical position when they are closer to the ceiling than to the ground and ventral flow when flying closer to the ground 22 , we thus consider only the ventral flow in our predictions because the ceiling is located approximately 2 m above the 0.6 m high experimental tunnel. In our test environments, there are no obstacles between the agent and the floor; the ventral optic flow is thus independent www.nature.com/scientificreports www.nature.com/scientificreports/ of the elevation angle and all optic flow pooling methods provide the same result. We therefore modelled ventral optic flow as the ratio between the flight speed and the vertical position: OF down = V/z, and do not apply pooling.
In the conditions that do not contain obstacles ( | 0 0  and | 0 100  ), the predicted vertical positions match the measurements (Fig. 3e) and are equal to the corridor half-widths (0.2 m in  | 0 100 and 0.3 m in | 0 0  ). This is because flight speed is regulated so that the mean of the pooled optic flow on left and right sides is equal to the reference optic flow value. In obstacle-free corridors, the agent tends to fly at an equal distance from both walls, meaning that pooled optic flow on the left and right sides take the same value, equal to the reference value. Finally, as the vertical position is regulated so that ventral optic flow is equal to the same reference value, the vertical position is equal to the distance between the agent and the walls.
Although no pooling is performed on ventral flow, the predicted vertical position is affected by flight speed, which in turn is affected by the presence of obstacles and thus also the pooling method used. The predicted vertical position is lower when maximum pooling is used on the lateral optic flow than when average pooling is used (Fig. 3e) because the agent flies slower and must reduce its height to maintain ventral optic flow at the reference value.
It is interesting to note that in  | 16 16 and  | 33 33 -i.e. with obstacles on both sides -the predicted vertical positions with max pooling are close to 0.1 m, which is half the distance between the rows of obstacles. Similarly, in | 0 16  and  | 0 33 -i.e. with obstacles on one side only -the predicted vertical positions with max pooling are close to 0.2 m. Thus, when it comes to vertical control with maximum pooling, the agent acts as if the row of obstacles were a wall, which is not consistent with the behaviour of bumblebees (Fig. 2d,e).
The predictions that best match the experimental data are with average pooling, which yield prediction errors (Fig. 3f) that are approximately 5 times lower than with maximum pooling, suggesting that bees use average pooling of lateral optic flow to control their vertical position.

Combining multiple optic flow pooling methods for different aspects of flight control.
Our model predictions suggest that bumblebees use maximum optic flow pooling in the frontal visual field to control both their lateral position and flight speed but that vertical position is controlled by average optic flow pooling in the lateral visual field. An agent using only maxf would correctly replicate bumblebee lateral position and flight speed, but would not fly at the same vertical position and an agent using only average pooling would correctly replicate bumblebee vertical position, but would not fly at the same lateral position and flight speed. How can we reconcile this contradiction?
Given the parallel nature of neural systems, the same piece of information can be processed by several circuits in the brain, each circuit implementing a different function. For example, the optomotor response and centring behaviour are known to be mediated by two distinct movement detecting pathways in the honeybee visual system 29 . Thus, optic flow from a wide field of view may be processed (or pooled) several times in parallel according to different functions -like average and maximum pooling -and across different visual fields before it is used to control different aspects of flight.
To test this hypothesis, we generated predictions using different optic flow pooling methods in parallel. Namely, in the formulation of the three forces driving the control of lateral position, flight speed and vertical position (equation [8]), we allowed different pooling methods to be used for each axis. While we applied the same control strategies for lateral position and flight speed as before, we modified the control strategy for vertical position. Instead of regulating the ventral optic flow so that it is equal to a fixed reference value, we regulate it according to a value generated from the lateral optic flow (and therefore coupled to flight speed, see equation [9]).
We tested all combinations of optic flow pooling ( x ,  y ,  z ) and compared the prediction accuracy. While using multiple optic flow pooling methods did not improve the accuracy of our predictions when the control of speed and vertical position were uncoupled (equation [8] and Supplementary Fig. S1), the predictions were more accurate when the control of flight speed and vertical position were coupled (equation [9] and Fig. 4). Interestingly, the best prediction is achieved with maximum optic flow pooling in the frontal visual field for speed and lateral control (  = With   = x y = maxf and z  = avgf, the predicted lateral position is the same as when maxf pooling is used on all axes (purple and blue dots on Fig. 5a). The predicted flight speed is the same as when maxf pooling is used on all axes (purple and blue dots on Fig. 5c). The predicted vertical position is the same as when avgf pooling is used on all axes (purple and red dots on Fig. 5e). Furthermore, the contradiction described earlier is solved because the prediction made with   = x y = maxf and  z = avgf achieves the lowest prediction error on all axes.

Conclusion
In this study, we investigate the effect of clutter on flight control in bumblebees and use mathematical models to understand how and where optic flow is being measured for this. We find that lateral position is controlled by balancing the maximum optic flow in the frontal visual field. This would ensure that even small obstacles in the flight path will be detected and used to control position, enabling rapid and effective collision avoidance responses. For speed control, the same pooling method is used to calculate the optic flow value that is then compared to a reference value, presumably set by the optimum sensitivity of specific speed-regulating neurons. Detecting the maximum optic flow output across an array of motion detectors is a biologically plausible operation which could easily be implemented in neural systems using a Winner-Take-All network 30 or using differentiation and zero-crossing 31 , and is supported by previous behavioural 32 and analytical 33 studies. Interestingly, we find that bees are most likely using a different pooling method for controlling vertical position. Instead of adjusting their height to maintain the ventral optic flow at a fixed reference value, as suggested for honeybees 21 , we find www.nature.com/scientificreports www.nature.com/scientificreports/ that bumblebees regulate the ventral flow to a non-constant reference value equal to the average optic flow in the fronto-lateral visual field. It is possible that this finding is specifically related to our experimental situation, which contained vertical obstacles that could not be avoided by changing vertical position. It would be interesting for future investigations to examine the responses to horizontally-oriented obstacles and to model the pooling of lateral and ventral optic flow across varying azimuth and elevation angles. Taken together, our results suggest that bumblebees pool optic flow from the frontal visual field using two methods in parallel -averaging and maximum pooling -to control different aspects of flight. This has important implications for the design of flying robots because our findings suggest that a single forward pointed camera covering the frontal visual field is sufficient to replicate bumblebee behaviour.

Materials and Methods
Experimental setting. Bumblebees (Bombus terrestris) were trained to fly along an experimental corridor between their nest and a food source. Bumblebees accessed the corridor through small holes and neither the nest nor the food source were visible from the inside. The experimental corridor was 3 m long, 0.6 m wide with 0.6 m high walls (Fig. 1). Each row of obstacles was located d = 0.1 m off the center-line of the experimental tunnel. The obstacles consisted of 0.03 m × 0.004 m × 0.6 m vertical plates and were equally distributed along the tunnel. The spacing between the obstacles was varied between infinity (no obstacles), 0.15 m, 0.06 m, and 0 m (a wall without gap).
The walls, floor, and obstacles were covered with a red and white pattern (to improve detection of the bee in the camera images) providing visual contrast in all orientations and thus enabling the insects to measure image motion around them 13,[33][34][35] . This pattern -called dead leaves -has the same frequency content as natural images and is rotation and scale invariant. The scale invariance of the dead leaves pattern implies that nearby obstacles appear with the same frequency content as the more distant background. This ensures that the only way to distinguish the obstacles from the background is the difference of their relative motion. Obstacles can thus be distinguished from the background based on dynamic cues but not based on static cues. For each combination, the prediction error on each axis is computed according to equation [14], then combined into a single error according to equation [13]. The predictions are made according to the control method shown in equation [9], where the reference optic flow used for vertical control is not constant but is computed from the lateral optic flow. The predictions are made using different pooling  x ,  y , and z  for the control of flight speed, lateral position, and vertical position, respectively. Contrary to the uncoupled case (see Supplementary Fig. S1), the best prediction is achieved when combining different optic flow pooling methods. With maximum optic flow pooling in the frontal visual field for forward and lateral control ( = x y   = maxf) and average optic flow pooling in the frontal visual field for vertical control ( z = avgf), the prediction error is the lowest, and is 50% smaller than with = = x y y www.nature.com/scientificreports www.nature.com/scientificreports/ Flights to the feeder were filmed with two high-speed cameras at 200 fps and the 3D trajectories reconstructed. The flight trajectories were mostly rectilinear along the x axis, with a constant speed V and altitude z, and minor oscillations along the lateral y axis. We therefore model bee trajectories as straight trajectories at a constant speed, parallel to the x axis.
Geometrical expression of translational optic flow. The magnitude of optic flow perceived by an agent when moving along an experimental corridor can be predicted geometrically 10,11 according to equation [1].
2 where x, y and z are the longitudinal, lateral, and vertical positions of the agent in the corridor, respectively. The lateral position is equal to 0 when the agent is in the center of the corridor and y > 0 when the agent is offset towards the left side of the corridor. The vertical position z is equal to zero when the agent touches the ground and z > 0 when the agent is above the ground. V is the forward velocity. Ψ is the viewing angle at which optic flow is measured. The angle Ψ is equal to zero for the viewing direction pointed straight ahead, and Ψ > 0 when looking on the left side of the agent. Δ is the projection onto the y axis of the distance between the agent and the closest object (see Fig. 1). In our experimental corridors (conditions  | 0 0 to  | 33 33 ), the distance Δ can be the distance from the agent to the left wall, right wall, left line of obstacles, or right line of obstacles (Fig. 1).  Fig. 2, the horizontal lines on the error bars denote standard error of the mean. The uncapped bars denote the standard deviation. Predictions are displayed as solid coloured circles. Note that predictions are shifted horizontally for better presentation. (b,d,f) Each prediction is compared with experimental data. The resulting error is scaled according to the standard deviation of the experimental data as shown in equation [14]. This scaling allows comparing prediction errors between conditions where bees controlled their flight with variable precision. The scaled errors are then averaged over conditions  | 0 0 ,  | 0 16 , | www.nature.com/scientificreports www.nature.com/scientificreports/ Optic flow pooling. We define optic flow pooling as the operation  that consists in computing an optic flow value  OF x y z V ( , , , ) that does not depend on the viewing direction Ψ from a panoramic optic flow field OF(x, y, z, V, Ψ). We consider four pooling methods, noted  avg ,  avgf , max  and  maxf , that differ in the extent of the field of view (either complete or frontal field of view) and in their pooling function (either average or maximum pooling) as described below.
The average optic flow pooling used in this paper is noted avg  and computed according to equation [2] for viewing angles Ψ ∈ [0, π] and Ψ ∈ [−π, 0].  Ventral optic flow is modelled as the ratio between flight speed and vertical position: down Force field for flight control. The optic flow balancing behaviour of bees is here modelled as a force field.
The force field → f : 4 3   defines three forces f x , f y and f z for every agent state (x, y, z, V).
x y z The forces f x , f y and f z respectively drive the agent along the x axis (i.e. controls flight speed), the y axis (i.e. controls the lateral position), and the z axis (i.e. controls the vertical position).
Force field for predictions of lateral position, vertical position, and flight speed. The predictions with uncoupled forward and vertical control ( Fig. 3 and Supplementary Fig. S1) are made using the force field presented in equation [8]. where  x and  y are the optic flow pooling methods used for lateral control and speed control,  OF left and  OF right are the optic flow pooled using the pooling method  on the left and right side, according to equations (2)(3)(4)(5), OF down is the ventral optic flow computed according to equation [6], and OF ref is a constant reference value. Note that this commonly accepted control scheme -although valid in a constrained environment like the one used in this study -would suffer from a scaling issue in an open, flat environment. Indeed, without objects on the sides, the lateral optic flow would be null and the agent would accelerate forward and upward infinitely, trying to match www.nature.com/scientificreports www.nature.com/scientificreports/ the reference OF ref . In order to solve this inconsistency, our study may be extended to include viewing directions pointed slightly above and below the horizontal plane into the calculations of the lateral optic flow, in which case the ground would remain visible in a portion of the lateral visual field when flying in an open environment. Furthermore, bumblebees are likely to rely on a additional control mechanism involving the measurement of airspeed; this is, however, outside of the scope of our study.
Force field for predictions with coupled vertical and forward control. The predictions with coupled forward and vertical control (Figs 5 and 4) are made using the force field presented in equation [9]. where x  , y  and  z are the optic flow pooling methods used for lateral control, speed control, and vertical control, OF left  and OF right  are the optic flow pooled using the pooling method  on the left and right side, according to equations (2)(3)(4)(5), OF down is the ventral optic flow computed according to equation [6], and OF ref is a constant reference value. For vertical control-unlike in the uncoupled case (equation [8]) -the ventral flow is compared to a non-constant reference value computed from lateral optic flow.
Prediction method. Lateral position y pred , vertical position z pred , and speed V pred are predicted using an iterative gradient descent approach. As a first step, (y, z, V) are given initial values (y 0 , z 0 , V 0 ). The initial values are found using a grid search with rough resolution in order to avoid local minima later in the gradient descent algorithm. The initial values are those where the average force applied to an agent while it is flying along the longitudinal axis of the corridor is the lowest. At the k-th iteration, the current lateral position, vertical position and flight speed (y k , z k , V k ) define a straight trajectory flown at constant speed along the longitudinal axis x of the corridor. In order to know whether this trajectory is an equilibrium point -the predicted trajectory -or whether the agent will be pushed away from this trajectory by the applied forces, the force field is evaluated and summed along the trajectory. The iterative process described in equations [11] and [12] is repeated until a minimum number of iterations are performed and the increments dV, dy and dz are below a small threshold (10 −6 in our case). www.nature.com/scientificreports www.nature.com/scientificreports/ where  ×|× indicates each one of the N  tested conditions. V pred , y pred , and z pred are the predicted flight speed, lateral position and vertical position. μ V , μ y and μ z are the mean of the measured flight speed, lateral position and vertical position for each condition. σ V , σ y and σ z are the standard deviations of the measured flight speed, lateral position and vertical position for each condition.
In equation [14], the error between predicted values and mean of the measured values is divided by the standard deviation of the measured values. This allows us to compare errors on different axes, even though they have different scales and units. In addition, dividing the prediction errors by the standard deviation of the measured data puts more emphasis on predictions in cases where bees behaved in a consistent manner (i.e. low standard deviation) compared to the cases where bees had more variable behaviour (i.e. large standard deviation).

Data Availability
The datasets generated during and/or analysed during the current study are available from the corresponding author on request.