3.1. Determination of the Degrees of Freedom of the Flapping Wing Drive Mechanism
Since the mechanism is center-symmetric, the topological space of the right wing drive mechanism can be taken as the research object, according to the Kutzbach–Grubler degree of freedom formula, which is as follows:
Under the condition that all joint constraints are independent, for a mechanism consisting of (
N) components (including the base), let (
J) denote the number of kinematic pairs, (
m) the degrees of freedom of a rigid body (with 
 for planar mechanisms and 
 for spatial mechanisms), and 
 the degrees of freedom associated with the (
i)-th kinematic pair. In this mechanism, since points 
 move within the same plane, we have 
, and 
. Therefore, the degrees of freedom of this flapping-wing drive mechanism can be calculated as
Therefore, the degree of freedom of the flap drive is 1. Therefore, the motion of the right flap drive mechanism can be determined by a single DC motor drive.
  3.2. Flap Drive Mechanism Modelling
  3.2.1. Five-Bar Mechanism Modelling
The right-wing drive mechanism is projected onto the 
 plane. Taking the crank rotation axis 
 as the origin of the coordinate system, the frame direction 
 is defined as the 
z-axis, and the direction perpendicular to the 
z-axis intersecting at point 
 is defined as the 
y-axis, thereby establishing a planar rectangular coordinate system, as shown in 
Figure 9.
Let the length of the crank  be , the length of the connecting rod  be , and the right-angled bent rod act as the rocker, with the right-angle vertex designated as E. The length  is , the length  is , and  is . The crank rotation angle is , the rocker rotation angle is , and the angle between the line  and the y-axis is .
Based on the planar rectangular coordinate system established in 
Figure 8, the right-wing drive mechanism is placed within this coordinate system, and by defining the lengths of the respective rods, the coordinates of each point can be determined as follows: 
 The relationship between angle 
 and angle 
 is given by
Using the method of kinematic chain decomposition [
29,
30], the relationship between the crank rotation angle 
 and the rocker rotation angle 
 is established. Based on the geometric constraints of the right-angled bent rod 
 and the link 
, the motion constraint equation of the connecting rod 
 can be derived as
By substituting the horizontal and vertical coordinates of points 
 and 
, listed above, into the motion constraint equation of the connecting rod and then solving the resulting system of equations through elimination and simplification, an expression for 
 as a function of the lengths of the rods and the angle 
 can be obtained.
The expressions for 
A, 
B, and 
C are as follows:
  3.2.2. Sensitivity Analysis of Rod Length on Key Parameters of a Five-Bar Mechanism
Based on the relationship between the rocker angle 
 and the crank rotation angle 
 derived in 
Section 3.2.1, a sensitivity analysis was conducted on the rod lengths with respect to the designed five-bar mechanism’s motion range, motion smoothness, and mass characteristics. A set of parameters satisfying the formation conditions of the designed five-bar mechanism was selected for the nominal parameters, as listed in 
Table 1.
The One Factor at a Time (OFAT) method was employed. Rods from 
 to 
 were sequentially selected as the variables for analysis. Based on a certain percentage of nominal values, a reasonable length variation range 
 was set for each variable, with ±15% chosen to avoid potential singularities or computational difficulties and to ensure that the rod lengths remain positive. Within each length variation range, six sampling points were selected as test points for sensitivity analysis of the respective rods. The corresponding plots are shown in 
Figure 10a–e.
Based on the analysis of the result graphs, it is evident that increasing the length of the  rod amplifies the amplitude of the curve, thereby increasing both the upper and lower limit angles of the  rod’s motion. Increasing the lengths of the  and  rods causes the entire curve to shift upward, which increases the upper limit angle and decreases the lower limit angle of the  rod’s motion. Increasing the length of the  rod results in a slight upward shift of the curve, slightly increasing the upper limit angle and decreasing the lower limit angle of the  rod’s motion. Increasing the length of the  rod significantly raises the peak value of the curve and slightly elevates the trough value, increasing the upper limit angle and slightly increasing the lower limit angle of the  rod’s motion.
The absolute peak value of the angular acceleration of joystick 
 is selected as the core metric for evaluating motion smoothness. A smaller value of this metric indicates smoother joystick movement with less impact. With the crank rotation frequency set to 6 Hz, the lengths of the individual links are varied sequentially for analysis. The results are shown in 
Figure 10f.
Increasing the lengths of the  rod and the  rod will increase the absolute peak value of angular acceleration, thereby reducing motion smoothness. Increasing the lengths of the  rod and the  rod will decrease the absolute peak value of angular acceleration, also reducing motion smoothness. Changes in the length of  have almost no effect on the absolute peak value of angular acceleration, with motion smoothness remaining nearly unchanged.
Due to the varying shapes of the rods, the lengths of each component were modified in SOLIDWORKS software to obtain the mass of the components at different rod lengths. The fitted graph is shown in 
Figure 11.
The functional curves of mass with respect to changes in rod length in the image are shown in 
Table 2.
  3.3. Optimization of Rod Length Selection for Flapping-Wing Drive Mechanism
An improved method based on the optimization of four-bar mechanisms used in reference [
31] is applied to a five-bar mechanism. A multi-objective optimization of the designed flapping-wing drive five-bar mechanism is carried out using a genetic algorithm (NSGA-II).
According to existing research [
32], when the flapping angle of the butterfly wings is 90°, and the angle distribution between the wingbeats below and above the plane of the body is 1:2, the biomimetic butterfly can achieve better flight performance. At this point, the lower limit angle of the wingbeat displacement should be 30°, and the upper limit angle should be 60°, with the average flapping frequency being 6 Hz. The optimization objectives are determined as follows:
The range of motion of joystick  should be as close to 90° as possible in the positive direction.
The ratio of the absolute values of the upper and lower limit angles during the motion of joystick  should be close to 2.
We maximize the smoothness of joystick  motion.
We minimize the mass of the five-bar mechanism.
The objective function 
 of optimization objective 1 is shown in Equation (
7). The actual maximum range of motion is obtained by subtracting the lower limit deviation 
 from the upper limit deviation 
. The actual calculation is the absolute difference between the maximum motion range and the target of 90°. The smaller the value, the closer the upper limit deviation is to 90°.
The objective function 
 of optimization objective 2 calculates the difference between the absolute value of the upper limit deviation 
 and twice the absolute value of the lower limit deviation 
. The smaller the value, the closer the ratio of the two values is to 2, as shown in Equation (
8). This approach is more stable when 
 approaches 0.
The objective function 
 for optimization objective 3 is shown in Equation (
9), where the absolute value of the peak angular acceleration is used to evaluate the smoothness of joystick motion. The smaller the value, the less impact and the smoother the motion.
The objective function 
 for optimization objective 4 is shown in Equation (
10), where the total mass of all the rods is calculated based on the fitting results in 
Table 2. The smaller the value, the lighter the mechanism.
In summary, the multi-objective optimization function for the designed mechanism is shown in Equation (
11).
In the above equation, ; the value ranges for each parameter are determined based on the parts required for the mechanism to function properly. To ensure the values are strictly greater than the constraint conditions, a small positive number  is introduced: Crank  rod length , link 1  rod length , link 2  rod length , joystick  rod length , frame  rod length .
The parameters used in the genetic algorithm are shown in 
Table 3.
The output of NSGA-II is the first non-dominated front in the final generation of the population. Priority is given to ensuring that the motion range and distribution ratio of the joystick meet the requirements. The final selected optimization results are shown in 
Table 4.
  3.5. Analysis of Motion Smoothness in the Optimization Results of the Flapping Wing Drive Mechanism
Since Equations (3)–(6) are too complex for simultaneous differentiation, the mechanism is simplified by replacing the right-angle bent link 
 with a rigid rod 
. The simplified four-bar mechanism undergoes a coordinate transformation, and all variables are renamed accordingly. The link components are designated as 
, 
, 
, and 
. The angular displacement of the driver 
 is 
, with a constant angular velocity of 
. The angular displacement of the link 
 is 
, with angular velocity 
. The angular displacement of the rocker 
 is 
, with angular velocity 
, as illustrated in 
Figure 13.
Based on the method for studying angular velocity of linkages presented in reference [
33], by differentiating the independent motion equations of planar hinged four-bar mechanisms with respect to time, the expression for output velocity can generally be represented in matrix form as follows:
In the above equation,  represents the generalized input motions of the mechanism;  denotes the generalized output motions of the mechanism; and  corresponds to the n-independent motion equations.
The following expressions are given for 
 and 
:
When points 
, 
, and 
 are arranged in a clockwise direction, let 
; the parameters in the equation are as follows:
By substituting the expressions from Equations (13) and (14) into Equation (
12), the angular displacements 
 and 
 corresponding to a given 
 at a certain moment can be solved. Let 
 and 
; then,
By substituting the parameters from 
Table 1 and 
Table 4 and the average flapping frequency of butterfly wings during flight into the expression, the angular velocity of the rocker arm over two cycles can be plotted, as shown in 
Figure 14.
By comparing the angular velocity curve of the rocker 
 in 
Figure 14, it can be observed that, within one cycle, the curve contains one peak and one trough. The maximum upward angular velocity of the rocker 
 increased from 4.8549 rad· s
−1 before optimization to 6.5369 rad· s
−1 after optimization, an increase of 34.65%. The maximum angular velocity during the downward stroke increased from 7.089 rad· s
−1 to 11.4519 rad· s
−1, an increase of 61.54%. This significantly enhances the aerodynamic force generated by the wing during flapping. By comparing with the motion characteristic curves of flapping-wing drive mechanisms in reference [
34], we know that the motion characteristics of the rocker 
 conform to the flapping pattern of ornithopter wings.
Differentiating Equation (
12) with respect to time yields the general expression for output acceleration:
By substituting Equations (13)–(15) into Equation (
16), the expression for the angular acceleration 
 of the rocker 
 can be obtained:
The angular acceleration curve of rocker 
 versus time was plotted using MATLAB, as shown in 
Figure 15. Our analysis results reveal that optimization objectives 1, 2, and 4 increase from 107.9709 rad· s
−2 to 235.5187 rad· s
−2, an increase of 118.13%. Compared to the pre-optimized mechanism, the optimized design is subjected to higher inertial loads. Furthermore, although the smoothness of the angular acceleration curve decreased slightly, it remains generally continuous without abrupt transitions, indicating stable mechanical behavior and the absence of impact during flapping motion [
35].