## 1. Introduction

This chapter describes the different steps of designing, building, simulating, and testing an intelligent flight control module for an increasingly popular unmanned aerial vehicle (UAV), known as a quadrotor. It presents an in-depth view of the modeling of the kinematics, dynamics, and control of such an interesting UAV. A quadrotor offers a challenging control problem due to its highly unstable nature. An effective control methodology is therefore needed for such a unique airborne vehicle.

The chapter starts with a brief overview on the quadrotor's background and its applications, in light of its advantages. Comparisons with other UAVs are made to emphasize the versatile capabilities of this special design. For a better understanding of the vehicle's behavior, the quadrotor's kinematics and dynamics are then detailed. This yields the equations of motion, which are used later as a guideline for developing the proposed intelligent flight control scheme.

In this chapter, fuzzy logic is adopted for building the flight controller of the quadrotor. It has been witnessed that fuzzy logic control offers several advantages over certain types of conventional control methods, specifically in dealing with highly nonlinear systems and modeling uncertainties. Two types of fuzzy inference engines are employed in the design of the flight controller, each of which is explained and evaluated.

For testing the designed intelligent flight controller, a simulation environment was first developed. The simulations were made as realistic as possible by incorporating environmental disturbances such as wind gust and the ever-present sensor noise. The proposed controller was then tested on a real test-bed built specifically for this project. Both the simulator and the real quadrotor were later used for conducting different attitude stabilization experiments to evaluate the performance of the proposed control strategy. The controller's performance was also benchmarked against conventional control techniques such as input-output linearization, backstepping and sliding mode control strategies. Conclusions were then drawn based on the conducted experiments and their results.

### 1.1. Quadrotor background

Louis Bréguet and Jacques Bréguet, two brothers working under the guidance of Professor Charles Richet, were the first to construct a quadrotor, which they named Bréguet Richet Gyroplane No. 1 Breguet-Richet-1907. The first flight demonstration of Gyroplane No. 1 with no control surfaces was achieved on 29 September 1907. Figure 1 shows the huge quadrotor with double layered propellers being prepared for its first manned flight.

Later, two additional designs were developed and experimental flights were conducted. The first, by Georges de Bothezat and Ivan Jerome in 1922, had six-bladed rotors placed at each end of an X-shaped truss structure, as shown in Figure 2.

The second, shown in Figure 3, was built by Étienne Œ hmichen in 1924, and set distance records, including achieving the first kilometer long helicopter flight.

At present, apart from military endeavours, UAVs are also being employed in various commercial and industrial applications. In particular, these include the use of unmanned helicopters for crop dusting or precision farming Sugiura et al. (2003), and microwave autonomous copter systems for geological remote sensing Archer et al. (2004). STARMAC Waslander et al. (2005) is a multi-agent autonomous rotorcraft, which has potential in security-related tasks, such as remote inspections and surveillance. The commercially available quadrotor kit called DraganFlyer Inc. (2008) has become a popular choice for aerial mapping and cinematography.

UAVs are subdivided into two general categories, fixed wing UAVs and rotary wing UAVs. Rotary winged crafts are superior to their fixed wing counterparts in terms of achieving higher degree of freedom, low speed flying, stationary flights, and for indoor usage. A quadrotor, as depicted in Figure 4, is a rotary wing UAV, consisting of four rotors located at the ends of a cross structure. By varying the speeds of each rotor, the flight of the quadrotor is controlled. Quadrotor vehicles possess certain essential characteristics, which highlight their potential for use in search and rescue applications. Characteristics that provide a clear advantage over other flying UAVs include their Vertical Take Off and Landing (VTOL) and hovering capability, as well as their ability to make slow precise movements. There are also definite advantages to having a four rotor based propulsion system, such as a higher payload capacity, and impressive maneuverability, particularly in traversing through an environment with many obstacles, or landing in small areas.

As illustrated by the conceptual diagram in Figure 4, the quadrotor attitude is controlled by varying the rotation speed of each motor. The front rotor (Mf) and back rotor (Mb) pair rotates in a clockwise direction, while the right rotor (Mr) and left rotor (Ml) pair rotates in a counter-clockwise direction. This configuration is devised in order to balance the drag created by each of the spinning rotor pairs. Figure 5 shows the basic four maneuvers that can be accomplished by changing the speeds of the four rotors. By changing the relative speed of the right and left rotors, the roll angle of the quadrotor is controlled. Similarly, the pitch angle is controlled by varying the relative speeds of the front and back rotors, and the yaw angle by varying the speeds of clockwise rotating pair and counter-clockwise rotating pair. Increasing or decreasing the speeds of all four rotors simultaneously controls the collective thrust generated by the robot. A roll motion can be achieved while hovering by increasing the speed of the right rotor, while decreasing the speed of the left rotor by the same amount. Hence, the overall thrust is kept constant.

In the past few years, much research has already been conducted on the modeling and control of quadrotors. Many control techniques, as summarized in Table 1, are proposed in the literature, however, excluding STARMAC, their primary focus is mostly for indoor flight control and therefore do not account for uncertainties and external disturbances. Lyapunov stability theory is used for stabilization and control of the quadrotor in Bouabdallah et al. (2004a) and Dzul et al. (2004). Conventional PD2 feedback and PID structures are used for simpler implementation of control laws, and comparison with LQR based optimal control theory is presented in Tayebi and McGilvray (2006) and Bouabdallah et al. (2004b). Backstepping control is also proposed with the drawback of higher computational loads in Guenard et al. (2005). Visual feedback is applied in many cases, using onboard or offboard cameras for pose estimation by Altug et al. (2002) and Guenard et al. (2008). Fuzzy logic control techniques have also been proposed Coza and Macnab (2006), along with neural networks Tarbouchi et al. (2004) and reinforcement learning Waslander et al. (2005).

Many quadrotor test-beds have been constructed in different research projects, where simulators are also developed for testing the control laws beforehand. In Kivrak (2006), LQR is used for attitude stabilization of a commercially available Draganflyer Vti quadrotor model in MATLAB Simulink. In another project, the modeling, design, and control of a Miniature Flying Robot (MFR), named OS4 was accomplished Bouabdallah (2007), where a mathematical model was developed for the simulation and control of a mini quadrotor using linear and nonlinear control methods.

## 2. Quadrotor's kinematics and dynamics

Mathematical modelling provides a description of the behaviour of a system. The flight behaviour of a quadrotor is determined by the speeds of each of the four motors, as they vary in concert, or in opposition with each other. Hence, based on its inputs, a mathematical representation of the system can be used to predict the position and orientation of the quadrotor. The same can further be used to develop a control strategy, whereby manipulating the speeds of individual motors results in achieving the desired motion.

Table 1. Quadrotor flight control techniques used in various projects.To derive the full mathematical model of the quadrotor, we need to define its kinematics and dynamics first. The kinematic equations provide a relation between the vehicle's position and velocity, whereas the dynamic model defines the relation governing the applied forces and the resulting accelerations.

### 2.1. Reference frames

Before getting into the equations of kinematics and dynamics of the quadrotor, it is necessary to specify the adopted coordinate systems and frames of reference, as well as how transformations between the different coordinate systems are carried out.

The use of different coordinate frames is essential for identifying the location and attitude of the quadrotor in six degrees of freedom (6 DOF). For example, in order to evaluate the equations of motion, a coordinate frame attached to the quadrotor is required. However, the forces and moments acting on the quadrotor, along with the inertial measurement unit (IMU) sensor values, are evaluated with reference to the body frame. Finally, the position and speed of the quadrotor are evaluated using GPS measurements with respect to an inertial frame located at the base station.

Thus, three main frames of reference are adopted, as shown in Figure 6:

The inertial frame, , is an earth-fixed coordinate system with the origin located on the ground, for example, at the base station. By convention, the x-axis points towards the north, the y-axis points towards the east, and the z-axis points towards the center of the earth.

The body frame, with its origin located at the center of gravity (COG) of the quadrotor, and its axes aligned with the quadrotor structure such that the x-axis is along the arm with front motor, the y-axis is along the arm with right motor, and the z-axis, where ‘x ’ denotes the cross product.

The vehicle frame, , is the inertial frame with the origin located at the COG of the quadrotor. The vehicle frame has two variations, Fϕ and FӨ. Fϕ is the vehicle frame, Fv, rotated about its z-axis by an angle v so that and are aligned with and, respectively. FӨ is frame Fϕ rotated about its y-axis, , by a pitching angle,Ө , such that and are aligned with and, respectively.

Translation and rotation matrices are used to transform one coordinate reference frame into another desired frame of reference. For example, the transformation from Fi to Fv provides the displacement vector from the origin of the inertial frame to the center of gravity (COG) of the quadrotor. Also, the transformation from Fv to Fb is rotational in nature, therefore yielding the roll, pitch and yaw angles.

### 2.2. Quadrotor's kinematics

Let and denote the quadrotor's position and orientation within a given frame F. The relation between the quadrotor's speed in the three predefined frames is expressed as Where is the rotation matrix that maps frame Fb to frame Fv and is defined by

with sӨ = sinӨ and cӨ = cosӨ. The same notation applies for sϕ, cϕ, sv, and cv.

The rotational motion relationship can therefore be derived using the appropriate state variables, such as the vehicle frame angles (ϕ, Ө, and v) and the body frame angular rate (, and). However, in order to do so, these variables need to be brought into one common frame of reference. Using rotation matrices to transform vehicle frames Fϕ, FӨ, and Fv into the body frame of reference Fb, we get

It follows that,

Equations (1) and (2) represent the quadrotor’s equations of motion.

### 2.3. Quadrotor’s dynamics

To build the dynamic model of the quadrotor we will use Newton-Euler formalism, while adopting the following assumptions:

1. The quadrotor structure is a rigid body.

2. The quadrotor frame is symmetrical.

3. The COG of the quadrotor coincides with the center of the rigid frame.

The moment of inertia is calculated by assuming the quadrotor as a central sphere of radius r and mass Mo surrounded by four point masses representing the motors. Each motor is supposed to have a mass m and attached to the central sphere through an arm of length l, as shown in Figure 7.

Due to the symmetry of the quadrotor about all three axes, its inertial matrix becomes symmetrical and is defined by

where

The dynamics of the quadrotor under external forces applied to its COG and expressed in the body frame is derived by applying Newton-Euler formulation Beard (2008)

where M is the quadrotor’s total mass, and FT = [fx fy fz] and are the external force and torque vectors applied on the quadrotor’s COG. The terms, , and are the roll, pitch and yaw torques respectively.Thus, the translational dynamic model can be written as

while the rotational model is

### 2.4. Aerodynamic forces and torques

With the derived kinematic and dynamic model, we will now define the forces and torques acting on the quadrotor. The forces include the aerodynamic lift generated by each rotor, and the gravitational pull acting in counter to the total lift generated. The moments are the torques generated in order to achieve the roll, pitch and yaw movements. The following forces and torques are produced:

Upward Force (Thrust): The total quadrotor thrust is the sum of the thrust produced by each propeller, as depicted in Figure 8(a):

Rolling Torque: This is the torque produced by increasing the left rotor’s thrust while decreasing that of the right rotor, or vice versa, as shown in Figure 8(b):

Pitching Torque: The pitching torque in Figure 8(c) is produced by increasing the front rotor’s thrust while decreasing that of the back rotor, or vice versa:

Yawing Torque: The yawing torque is the result of all four individual torques generated due to the spinning rotors. The front and back rotors spin in the clockwise direction, while the left and right rotors spin in the counterclockwise direction. As shown in Figure 8(d), an imbalance between these two pairs results in a yawing torque causing the quadrotor to rotate about its z-axis:

Gravitational Force (weight): Along with the other forces, the gravitational force acts on the COG of the quadrotor. In the vehicle frame this force is expressed as

with g being the gravitational constant. Therefore, in the body frame, the weight can be written as

Including the forces and torques acting on the system, the equations of motion become as defined below.

## 3. Flight controller design

This section details the development of a fuzzy logic flight controller for the quadrotor. A generalized overview of fuzzy logic control and the advantages it offers for nonlinear control applications are presented. Based on the dynamics and kinematics derived in the previous section, the autonomous flight control strategy is thereby introduced. The proposed fuzzy logic controller is implemented with two types of inference engines for comparison.

### 3.1. Fuzzy logic control

Since its inception in Zadeh (1965), fuzzy logic has been applied to various fields of engineering, manufacturing, business, and medicine, among others. Within the area of engineering, control systems offer significant applications for fuzzy logic, designated as fuzzy logic control. Before getting into details with regards to fuzzy logic control, we would first like to provide some basic facts about fuzzy systems.

Fuzzy logic control offers a great advantage over some conventional control methods which heavily depend on the exact mathematical model of the control system, specifically in dealing with nonlinear systems subjected to various types of uncertainties. Being independent of the plant’s parameters sets fuzzy controllers apart from their conventional counterparts. Fuzzy controllers in general can be designed intuitively in light of the knowledge acquired on the behavior of the system in hand. This knowledge is often gained through experience and common sense, regardless of the mathematical model of the dynamics governing this behavior. For example, in learning how to ride a bike, humans try to build a set of common sense rules and learn from their failures without paying any attention to the dynamic model of the bike. Fuzzy logic control tries to mimic this type of human-like reasoning and embrace it within a pre-defined mathematical model to automate the control of complex systems characterized by ill-defined mathematical models, for example.

### 3.2. Flight control algorithm

The quadrotor is an under-actuated system with four actuators controlling its six degrees-of-freedom position/orientation. The flight controller is responsible for achieving two challenging goals simultaneously: (i) controlling the quadrotor’s position, while (ii) stabilizing its attitude, i.e., orientation (roll, pitch and yaw angles). More specifically, given a desired position (px, py, pz) and yaw angle , the goal is to design a controller to force these control states to converge to their respective desired values, while maintaining the pitch and roll angles as close to zero as possible.

Let PWMmot denote the PWM value of motor mot ∈ {f, r, b, l} for the front, right, back, and left motors, respectively. Then, the thrust and torque applied on the quadrotor by motor mot can be expressed as

where KT and Kτ are motor-dependent parameters. This yields

withThe above equations provide a basic understanding of how the angular speed of each motor contribute to the overall thrust and torques exerted on the quadrotor. This knowledge will serve as a guideline in developing a rule base of the direct fuzzy logic controller, as depicted in Figure 9.

Three fuzzy controllers are designed to control the quadrotor’s roll (ϕ), pitch (Ө) and yaw (v) angles, denoted by FLCϕ, FLCӨ, and FLCv, respectively, with the former two serving as attitude stabilizers. Three fuzzy controllers, FLCx, FLCy and FLCz, are further designed to control the quadrotor’s position. All six fuzzy controllers have identical inputs, (i) the error, which is the difference between the desired signal (.)d and its actual value (.), and (ii) the error rate. The first input (error) is normalized to the interval [−1,+1], while the second (error rate) is normalized to the interval [−3,+3].

In this control strategy, the desired pitch and roll angles, Өd and ϕd, are not explicitly provided to the controller. Instead, they are continuously anticipated by controllers FLCx FLCy in such a way that they stabilize the quadrotor’s attitude. The input and output membership functions (Figure 11) of each FLC are tuned empirically and are finalized as follows:

A unified rule base comprising nine IF-THEN rules is developed and is presented in Table 2.

For it to be modular and independent of the quadrotor’s parameters, the fuzzy logic controllers are bounded by pre-processing and post-processing blocks (Figure 9). The pre-processing module calculates the error e and error rate

where ‘Offset’ is a priori-defined bias to counter balance the weight of the quadrotor. The resultant PWM values are saturated to a maximum threshold that depends on the maximum possible speed of the motors used.

It is important to note that this control scheme does not depend on the kinematic and dynamic equations derived in section 2. Those equations are only used to build the quadrotor’s model in the simulator, which would be unnecessary with a real quadrotor. Being independent of the plant’s parameters sets the fuzzy controllers apart from conventional control systems, which depend in one way or the other on the plant’s mathematical model. The fuzzy controllers are designed in light of the knowledge acquired on the quadrotor’s behavior and from its dynamic model. Therefore, changing the quadrotor or some of its physical parameters like the mass and inertia does not require redesigning the fuzzy logic controller. Instead, the postprocessing module may need to be fine-tuned to optimize the controller’s performance, such as to calibrate the offset, for instance.

Two different fuzzy inference engines are implemented: (i) a Mamdani, and (ii) a Takagi-Sugeno-Kang (TSK) fuzzy model. The Mamdani fuzzy inference method uses a min-max operator for the aggregation and the centroid of area method for defuzzification. One known problem with this type of controller is the high computational burden associated to it, especially when implemented on an embedded system. To alleviate this problem, a zero order TSK fuzzy inference engine is implemented for comparison. In this model, the output membership functions of the Mamdani fuzzy controller are replaced with three fuzzy singletons N = −1, Z = 0 and P = +1.

## 4. Numerical and experimental results

To test the proposed fuzzy logic flight controller with both inference engines and study their performances, a simulation environment is first developed. After satisfactory performance results are attained, the controller is implemented on a quadrotor testbed. The details of the quadrotor simulator and the real-world test-bed are presented in the following subsections.

### 4.1. Simulation results

The quadrotor simulator is implemented in MATLAB Simulink, as shown in Figure 12. The equations of motion derived earlier are used to model the quadrotor. The inputs to the quadrotor are taken as the four PWM speed values of the motors. To make the simulations more realistic, sensory noise and environmental disturbances such as wind are also taken into account. Medium wind gust speeds are generated based on real data from Canada Weather Statistics, Statistics (2009). The wind disturbance is incorporated as two further inputs representing the north and east wind condition. The quadrotor model outputs are the linear and angular accelerations that are integrated twice to obtain the position and orientation vectors. The angular accelerations, , and are degraded with a white noise and then used as a feedback to the fuzzy controller.

The values used for the quadrotor’s dynamic parameters are: M = 0.765 Kg, l = 0.61 m, Jx = Jy = 0.08615 Kg·m2, Jz = 0.1712 Kg·m2, KT = 5.45, Ktau = 0.0549, Offset = Mg/(4KT ) = 0.344.

The six identical fuzzy controllers are developed using the MATLAB Fuzzy Logic Toolbox. The input and output variables with membership functions described earlier are set accordingly. The fuzzy controllers are used in a configuration as shown in Figure 10. The inputs and outputs of the flight controller are pre- and post-processed, respectively.

The environmental disturbances are introduced such that a white noise is added to the angular accelerations, , and for emulating the inertial measurement unit (IMU) sensor. The IMU signals are further processed through rate transitions to incorporate the ADC sampling rate.The user-defined inputs are the desired translatory coordinates with respect to the inertial frame, and the desired yaw angle v. The desired pitch and roll angles are implicitly set to zero to achieve attitude stabilization.Three simulations are conducted to test the performance of the proposed fuzzy logic flight controllers with both inference engines. The system’s initial states are set to zero, while the desired quadrotor’s position and orientation are set to = [10, 10, 25] m and = [0, 0, 30] degrees in all three simulations. The purpose of the simulation is to assess the performance of the fuzzy logic controller and compare the accuracy of the two fuzzy inference engines under different disturbance conditions. The first simulation is run without any disturbances. In the second simulation, the controller is subjected to sensor noise. In the third simulation, it is subjected to sensor noise and medium north-east wind gust of 10 m/s.The simulation results presented in Figures 13 and 14, demonstrate the satisfactory performance of the proposed controller despite the presence of sensor noise and wind disturbances. The Mamdani fuzzy controller converges to the desired states relatively faster than its TSK counterpart. The yaw angle drift under wind disturbance is clearly visible with the TSK controller.

### 4.2. Quadrotor test-bed and experimental results

The quadrotor test-bed, as shown in Figure 15, comprises light weight carbon fiber rods of length 0.61 m connected to a center piece forming the desired cross structure for the frame. The four propulsion units are made of brushless DC motors connected to electronic speed controllers to provide actuation. Different propellers are also tested to find the optimal thrust to power consumption ratio. The system is powered by a 2100 mAh, 11.1-Volt lithium polymer battery. The quadrotor’s specifications are summarized in Table 3.

The IMU is designed using a triple axis 3g accelerometer ADXL330, a dual axis 500 degree-per-sec rate gyroscope IDG300 for pitch and roll angle rates. The yaw angle acceleration is measured using a single axis 300 degree-per-sec ADXRS300 gyroscope. The bandwidths of all the sensors are trimmed to 10 Hz. The MEMS inertial sensors are combined with complementary filtering techniques for the online estimation of the attitude angles.

The processing is accomplished with a 34-gram Axon board based on ATmega640 microcontroller running at 16 MHz clock. The IMU data is sampled using an onboard 10-bit ADC. The proposed flight control is implemented using the TSK fuzzy controllers converted to a look-up table for a higher computational efficiency. The flight controller, elaborated in Algorithm 1, is set to operate at a bandwidth of 100 Hz.

The first experiment is designed to test the quadrotor’s hovering and attitude stabilization capabilities. So, the desired position is pre-defined as the quadrotor’s current position. Both, experimental and simulation results are reported in Figure 16. In simulation, the controller managed to keep the pitch and roll angles within the interval of [−3,+4] degrees. However, in reality, the errors of these angles were fluctuating between −8 and +7 degrees for the pitch, and −6 and +12 degrees for the roll. The main difference between the simulation and experimental results stems from the vibration of the frame from which the test-bed was made. In addition, the 0.61-m long carbon fiber arms were bending and twisting when excited by the motors. This put the fuzzy logic controller to a higher challenge than what was originally anticipated. Yet, it was successful in forcing the pitch and roll angles to within an acceptable range.

In the second experiment, the controller was tested under harsher conditions so as to evaluate its behavior if the quadrotor collides into an obstacle, or if it is faced with other types of disturbances. Hence, the previous experiment was repeated, but this time one of the quadrotor’s arms is abruptly tapped in the middle of the flight. The results are shown in Figure 17. As can be seen, the controller was able to quickly bring the pitch and roll angle errors back to within a safe range.

## 5. Conclusion and future directions

This chapter addressed the problem of autonomous flight control of a quadrotor UAV. It was conducted as a research project at the School of Information Technology and Engineering (S.I.T.E.), University of Ottawa. Detailed mathematical modeling of the quadrotor’s kinematics and dynamics was provided. A modular fuzzy logic approach was proposed for the autonomous control of quadrotors in general, without the need for a precise mathematical model of their complex and ill-defined dynamics. The fuzzy technique was implemented through Mamdani and TSK inference engines for comparison purposes. The controller comprises six individual fuzzy logic modules designated for the control of the quadrotor’s position and orientation. The investigation on the two types of control methodologies was conducted in a simulator environment, where disturbances such as wind conditions and sensor noise were incorporated for a more realistic simulation. The fuzzy flight controller was eventually implemented on a quadrotor test-bed specifically designed and built for the project.

The experiments were first conducted on the simulator before being validated on the test-bed. The results demonstrated a successful control performance especially with the Mamdani inference engine. When compared to other conventional techniques applied for a similar purpose Altug et al. (2002), Bouabdallah et al. (2004b), the proposed methodology showed a higher robustness despite the induced disturbances.

The future work is directed towards achieving fully autonomous flight in outdoor environments. Furthermore, adaptive fuzzy control techniques will be investigated to automatically tune some of the controller’s parameters online, to further optimize its performance.