Adaptive Nonlinear Control For Perching of a Bioinspired Ornithopter

This work presents a model-free nonlinear controller for an ornithopter prototype with bioinspired wings and tail. The size and power requirements have been thought to allocate a customized autopilot on board. To assess the functionality and performance of the full mechatronic design, a controller has been designed and implemented to execute a prescribed perching 2D trajectory. Although functional, its ’handmade’ nature forces many imperfections that cause uncertainty that hinder its control. Therefore, the controller is based on adaptive backstepping and does not require any knowledge of the aerodynamics. The controller is able to follow a given reference in flight path angle by actuating only on the tail deflection. A novel space-dependent nonlinear guidance law is also provided to prescribe the perching trajectory. Mechatronics, guidance and control system performance is validated by conducting indoor flight tests.


I. INTRODUCTION
Nature boasts many examples of animal flight locomotion with flapping wings like birds and flying mammals. Although in Robotics, there are some examples of flying robots with wings-so called ornithopters-, they are still very limited in comparison with the flying animal locomotion. Bioinspired flapping wing robots are designed to achieve better performance in terms of energy consumption, flight endurance, and safety when comparing with conventional multirotors. In this way, we move a step forward in the development of aerial vehicles, moving from multirotor platforms to bioinspired aerial locomotion with flapping wings, as part of the current GRIFFIN European project under funding scheme ERC Advanced Grant [1]. Thus, although electricpowered multirotor platforms have been demonstrated to be very efficient for manipulation, unfortunately they still suffer some technology deficiencies, as e.g. the well known relatively short flight missions of about few minutes and other inherent limitations when interacting at the proximity of people like noise and hazard situations.
In particular, we are concerned with the design and control of a bioinspired ornithopter for a 2D perching maneuver. Perching is characterized by its highly nonlinear and unsteady aerodynamics. From a control point of view, the control system needs to consider the time varying effects that appear during the maneuver. In this work we present a nonlinear guidance law for trajectory tracking and an adaptive model-free controller applied to perching of a newly designed prototype. There already are a number of available and mature ornithopter designs, namely: the Smartbird made by Festo [2] and the Robird [3]. Both of them use modified Vtail configurations which are typical in fixed wing aircrafts as they provide good stability and control. On the other hand, simpler bio-inspired tails (e.g. delta tails) are typically employed in handmade ornithopters [4] [5].
Perching is a landing maneuver that allows birds to land at very specific point and it is among the most complex maneuvers. It is usually fast and done in a short space. This maneuver results in complex nonlinear unsteady aerodynamics, where high angles of attack are achieved either momentarily or permanently throughout the landing. In [6] an experimental characterization of a successful perching maneuver is obtained. The authors show that a largely 3D flow appears for angles of attack close to 30°with a fully separated flow region. In [7] the authors compare three different perching model structures and proved that an unsteady nonlinear aerodynamic model which accounts for deep stall is the most adequate. These conditions make finding a suitable model for control design a hard task. To solve this, is common to resort to system identification techniques. A fully nonlinear model for perching is identified in [8]. This model reflects relevant transient aerodynamic effects using nonlinear basis functions, which results in relatively simple expressions, useful for simulation and control design. A 2D successful controlled perching maneuver is presented in [9]. First, the authors conduct an unsteady system identification by approximating the aerodynamic coefficients as a linear combination of nonlinear basis functions. Then, they formulate the perching problem as an infinite-horizon optimal feedback control problem to obtain a full state feedback controller. In [10] 3D perching is achieved using the dihedral angle as a lateral-directional control variable and PI controllers. Although in the work cited before perching was achieved successfully, it was done for small scale and lightweight platforms designed specifically for gliding and perching, and not actual ornithopters capable of flapping flight.
The main contributions of this work are: 1) a new ornithopter prototype capable of flapping; 2) a space dependent nonlinear guidance law; and 3) an adaptive nonlinear modelfree control algorithm acting only on the tail and applied to perching while gliding, implemented in a customized autopilot. As stated above, the dynamics of perching are complex and time varying. This is why we propose an adaptive backstepping nonlinear controller for the flight-path angle to cover all flight regimes. This controller includes an adaptation law which estimates online the value of the unknown aerodynamics. A novel nonlinear guidance law is also designed, which provides the flight-path-angle controller with the appropriate references.
The control system is implemented in a customized autopilot based on a computer on board with high computation capabilities and connectivity, capable of indoor and outdoor flight. This contrast with some present day alternatives based on microcontrollers [11], [12]. We use the autopilot to validate the control system by conducting indoor flight tests using the Optitrack motion tracking system.

II. ORNITHOPTER DESIGN
This section describes the ornithopter platform used for the control experiments. The ornithopter has been designed and built from scratch to maximize payload (Fig. 2). This translates into the final design being large in wingspan and wing surface for maximum lift and thrust, and very optimized in weight with respect to available ornithopters of similar size. The parameters of the custom ornithopter are given in Table I. The aerodynamic surfaces are made of a lightweight  For the structure, 4 mm rods are mounted in the spanwise direction of the wings, and 2 mm in the chordwise direction of the wing and in the tail. The nylon cloth is adhered to the carbon fiber rod structure with cyanoacrylate. The spanwise rods are connected to the flapping mechanism. A positive mean dihedral angle is desired to increase lateral stability, but it is kept to minimum to avoid greater lift loses. The mechanism is powered by an electric brushless motor through a 2-stage reduction gearbox. The materials used are: aluminium for gears, gear crank mechanism; carbon fiber for the two plates where the axes of rotation lean on; and steel for the axes of rotation, bearings, nuts and bolts. For the tail, a bioinspired flat delta shaped morphology is chosen, where the entire surface is deflected as the servos are actuated. The tail mechanism is allocated at the junction of the tail to the fuselage, also serving as a link to the backside of the wing. This results in two control variables: tail pitch δ e and roll δ r as shown in Fig. 3. The tail is a major erodynamic surface of the aircraft, with more than 1/5th of the wing surface. This greatly affects the lift and torque generated by the tail, so the longitudinal stability and control of the ornithopter is very sensitive to δ e . Therefore, a fourbar mechanism transmission is used to achieve a reduction of approximately 2:1.
The lateral-directional dynamics of the ornithopter are controlled by δ r . The axis of rotation for δ r is always contained within the symmetry plane of the aircraft due to the kinematic configuration of the tail mechanism. Directional control with δ r relies on tail lift, which at the same time is related to δ r . As so, the bioinspired tail configuration causes the longitudinal and lateral-directional control variables to be coupled.

III. ORNITHOPTER DYNAMIC MODEL
Let x E and z E denote the Cartesian coordinates in an earth-fixed reference frame (see Fig. 4), so that the longitudinal kinematic equations are given by [13]: where V is the aerodynamic velocity and γ is the flight path angle. On the other hand, the longitudinal dynamic equations for an ornithopter read [13]: where θ the pitch angle, q the pitch rate and δ e the tail deflection angle; m and I are the mass and inertia; D, L, and M are the aerodynamic drag, lift, and pitch moment respectively (see Fig. 4). The angle of attack, α, is defined as α := θ − γ. Notice that, unlike in standard aircraft the influence of the tail deflection is present in all the aerodynamic forces and moments, making its control much more involved. This is due to the fact that in this design, the whole surface of the tail deflects rather than just a rudder or elevator. This implies that the contribution δ e to the aerodynamic coefficients is not negligible. The aerodynamic drag, lift and moment are defined through their nondimensional coefficients: where ρ is the air density, S is the wing surface, c the mean chord, and C L , C D , C m are the lift, drag, and pitch moment coefficients respectively. Since this approach is only for the gliding mode, i.e. not flapping, we follow the classical reference models for these coefficients used in aircraft but with the exception that they all depend on δ e . Thus, differently from aircraft (see e.g. [14] and references therein) they are all modeled with a contribution of δ e as: where C Lα , C L δe , C D0 , k, C m0 , C mα , C mq and C m δe are aerodynamic coefficients which are all unknown. Control problem statement: Consider the ornithopter kinematics (1) and their nonlinear and uncertain flight-path-angle dynamics (2)-(4). The control objective is split into two: 1) a flight path angle controller actuating only with δ e and; 2) given a perching trajectory (z E (t), z E (t)), t ≥ 0, a guidance law providing the desired flight path angle reference γ ref .
All the variables are measured or estimated.

IV. FLIGHT PATH ANGLE ADAPTIVE CONTROLLER
In this section the backstepping feedback control law for the flight path angle is obtained. The methodology is similar to the one employed in [14] but as it has been aforementioned it is not directly applicable, because unlike aircraft, in the ornithopter θ and γ dynamics are coupled by (δ e ). The control will aim to follow a flight path angle reference γ ref , given that γ ref is a reachable state, i.e. in the flight envelope. Moreover, to simplify the design we make the following reasonable assumptions for the perching maneuver.
For clarity, let us define C f := 1/2ρV 2 S and the function: which recall that it is unknown and hence not available for feedback. Thus, the system (2)-(4) can be expressed as: where we have also defined the key parameter β γ := C f c/I. The following weak assumption is considered for the lift coefficient: The lift coefficient as a function of α satisfies α C L (α) ≥ 0, i.e. C L (α) = C L (α, δ * e ) and δ * e fixed. Assumption 2 provides the function (8) with the property: Property 1: Let α 0 be the trim angle of attack that makes f (α, δ * e ) zero, i.e. f (α 0 , δ * e ) = 0 for a given γ ref . Defining the scalar function η(x) := f (x + α 0 , δ * e ), by Assumption 2 the following holds x · η(x) ≥ 0, ∀x ∈ R.
Remark 1: We underscore that the function (8) is unknown and hence α 0 is not computable. Under the assumption of the time-scale separation, the value δ * e corresponds to the quasi-steady state of the fast dynamics, i.e. δ * e := −(C m0 + C mα α)/C m δe . From the latter it is easy to see that the quasy-steady state makes C L , f and η be functions only of α. The tail deflection δ * e corresponds to the trim angle of attack α 0 .
Let z := col(z 1 , z 2 , z 3 ) define the error coordinates as and hence the system (2)-(4) shifted to the origin readṡ The system (10)-(12) with δ * e defined in Remark 1 forces η to be a function of α, i.e. η(α) = η(z 2 −z 1 ), where δ e appears only in (12). From the control point of view, the reduced dynamics (10)- (12) are in strict-feedback form which is the backbone of adaptive backstepping control technique. The adaptive nonlinear controller designed for these dynamics (10)- (12) is an adapted version from the result of [14] for small aircrafts. Thus, the stability result is summarized in the proposition below, where for the sequential steps of the adaptive backstepping approach to (10)-(12) the error definition are defined asz 2 = z 2 + k 1 z 1 andz 3 = z 3 + z 1 and k 1 constant.
Proposition 2: Consider the flight path angle dynamics (2)-(4), or equivalently (10)- (12), under Assumptions 1 and 2, with the vector estimates and measures defined as Then, the adaptive-state feedback given by guarantees global boundeness of (γ, θ, q) andΘ Θ Θ and asymptotic stability of (γ ref , θ ref , 0), for any λ > 1 and Γ > 0. Proof: Proposition 3.3 [14]. The reduced system can now be stabilized at any flight path angle reference γ ref . It is important to note that γ ref must be a reachable state in the flight envelope, and then γ ref should be less than the gliding maximum flight path angle γ max .
As it was aforecommented in Remark 1, the previous adaptive controller is made for the reduced system (10)- (12). The small parameter that makes this reduction a good approximation is := 1/β γ 1 1 . The systems with this property are called singularly perturbed (see e.g. [15] for details) by the small parameter 0 < 1. Roughly speaking, Singular Perturbation theory is based on timescale separation and it states that if the equilibrium of the reduced dynamics at = 0 is asymptotically stable, then, it is reasonable to expect that its solution for small will reach an O( ) neighbourhood 2 of the equilibrium during the boundarylayer transient. The timescale separation can be seen as a decoupling between both slow and fast dynamics. The strongest result is that, under certain conditions the (local) stability of the reduced system guarantees the stability of the whole system for 0 < 1. Remark 3: A local analisys shows that the equilibrium of the boundary-layer dynamics is stable at = 0. As it is well known (see e.g. [15]) the result of Proposition 2 for the reduced system is not enough to conclude stability for the whole system. To this end, the stronger property of exponential stability of the equilibrium of the boundary-layer dynamics is required. For now, we could only prove that such equilibrium is stable but not exponentially. Current research is underway to prove this stronger result because is the key property that differentiates aircrafts from ornithopters control and dynamics.

V. GUIDANCE LAW
In this section the guidance law which provides the reference input γ ref to the controller designed in the previous section is presented. The objective of the guidance law is to calculate the γ ref from a cartesian trajectory in the space (see block diagram in Fig. 5). Since the controller is a 2D longitudinal controller, the trajectory comes in the form of an altitude profile z ref (t). However, in practice it is not possible to guarantee that a trajectory will be followed with time restrictions for any ornithopter gliding i.e. without flapping. To solve this, z ref is expressed as a function of space z ref (x E ) similarly to [10] where the authors used spacedependent control laws for perching. The z E -coordinate kinematic equation in an inertial earth fixed reference (see Fig. 4) system is given by (1). Defining the altitude error as It is straightforward to see that a candidate to Lyapunov function becomes V e = e 2 z /2, whose derivative yieldṡ which can be made negative by choosing the input γ ref as Since V e > 0 andV e = −k z e 2 z < 0 for k z > 0, provided that |k γ e z −ż ref /V | < 1, then the guidance law ensures that the error equilibrium e z = 0 is asymptotically stable.

VI. FLIGHT TESTS A. Experimental Setup
In this section the experimental setup for the perching flight tests is described. Knowing that the ornithopter is laterally unstable, a PI controller is used to control the roll angle set to zero. This allows to achieve a quasi-two dimensional flight. The lateral controller was adjusted by trial and error. During the experiments the tail pitch and roll actuators are saturated to ±40°and ±15°deg respectively.
The customised autopilot is based on the NanoPi Neo Air. It is a high performance and lightweight computer on board with good connectivity and OS support. A customized PCB was attached to the NanoPi acting as a carrier with an STM32 microcontroller and with the option of an inertial navigation system (INS). The microcontroller is used to regulate the PWM signals to the servos and is connected to a Futaba RC receiver, allowing to change between manual and automatic control. Thus, this autopilot can be used for indoor and outdoor tests. Here the experiments are indoor and the INS is not used.
Flight data is recorded using an Optitrack motion capture system, consisting of 28 infrared cameras. The cameras track a series of active tags. These active tags are infrared LEDs placed on the ornithopter and can provide an estimation of the position with an accuracy of 1 mm. The Optitrack is connected to a local network and emits data at 120 Hz using a VRPN protocol. This data is received by the flight computer using the same protocol and the control computations are executed at 100 Hz. A schematic of the flight computer architecture and communications can be seen in Fig. 6. The real-time data stream contains the inertial position (x E , y E , z E ) and the orientation quaternion following a ZY X rotation sequence, from which the yaw, pitch, and roll (ψ, θ, φ) are obtained. The inertial velocity (ẋ E ,ẏ E ,ż E ) and pitch rate q are obtained using a finite difference scheme. The angle of attack for the longitudinal dynamics is obtained as α = θ − γ. All of these magnitudes are filtered to eliminate noise.

B. Experimental Results
The experiment consisted of a series of 30 flight tests in which the aircraft was thrown by hand from an approximate altitude of 3 m (see attached video). Before each test both angles of the tail are trimmed to a specific position. These trim angles guarantee for a quasi-rectilinear flight in very short periods and the lateral PI controller acts around this point. The trim condition was obtained through trial and error.
When the ornithopter is released, a rectilinear trajectory is calculated from the launching point to a specific perching point. This trajectory is z ref (  The parameters for the adaptation law during the experiment are Γ = diag[−0.003 − 0.005 − 0.005 − 0.0005], the guidance law gain is k γ = 0.85 and λ = 2. It can be seen clearly from Fig. 7 that the launching conditions vary heavily from test to test. The z coordinate varies from 3 to 2.3 m, and γ varies from 21°to -26°, this proving that controller performance remains acceptable in a wide range of initial conditions. Fig. 7 also shows that as the ornithopter tries to follow the trajectory, α varies in a wide range from −10°to 35°deg. With such a wide range of α, aerodynamics can be considered nonlinear and variable [6] and [7]. However, the adaptation law is able to estimate online the parameters to meet the control objective. Fig. 8 shows the response for five of the best tests. It can be seen that as the ornithopter gets closer to the perching point, the convergence with respect to the reference trajectory improves. The error distribution shows very good agreement with the followed trajectory. However, is important to note that the guidance and control strategy presented here only control the error in z E , and not in x E tending this to be bigger.  Fig. 9 shows the output of the guidance law γ ref based on the instantaneous error with respect to the prescribed trajectory e z . When the aircraft is flying over the prescribed trajectory, the commanded γ ref is lower than the γ corresponding to the prescribed trajectory and vice versa. When the error e z tends to zero, γ ref is equal to that of the prescribed trajectory. This can be observed in the final instants close to the point of contact around 1.8 s. Note that both values, γ and γ ref , are very similar for each test. This is reflected in the e γ plot which behaves similar to an underdamped system for each test.
It is also worth mentioning that this prototype has been designed such that a rapid deceleration by saturating the tail and a sudden pitch up as in [10] could not be achieved without increasing greatly e γ .

VII. CONCLUSIONS
In this work we demonstrate that a 2D perching maneuver can be done successfully with a very tight space and time constraint, by a large and heavy ornithopter with a bioinspired tail. Perching maneuvers have been demonstrated with success in the literature. However, these where done by lightweight and small aircraft that are not capable of flapping flight and are suited for agressive maneuvering. We design and built an ornithopter with improved payload, capable of flapping and with autopilot. Adaptive backstepping control strategy that estimates the unknown model parameters online is designed. This accounts for the time varying nonlinear nature of perching maneuvers. A novel nonlinear guidance law is also provided. The controller was implemented in a customised autopilot capable of indoor and outdoor flights. We conducted 30 indoor controlled flight tests using an Optitrack motion capture system. The results show good convergence with the reference trajectory close to the perching point for a wide range of initial conditions. Current work is underway to extend these results to the 3D perch, complete the stability proof and improve the design of the ornithopter to achieve speed control.