2.1. ESC + motor + propeller

The rotors of quadrotor are modeled by

$$T\_i = K \frac{\omega\_M}{s + \omega\_M} u\_i \tag{1}$$

by Cm, the earth-fixed inertial frame is denoted by Fe = {Fex, Fey, Fez}, the position in earth-fixed

To obtain the position of CM in the NED (North-East-Down) coordinate system with respect to the inertial frame Fe, we use the Euler angles (roll ϕ, pitch θ, yaw ψ) combined in a vector

is generated by differential thrust between M<sup>1</sup> and M3, and yaw angle is generated by diferential torque between clock wise and anticlock wise rotors, i.e., (M1� M<sup>2</sup> + M3� M4). This kind of device is considered an underactuated system with six degree of freedom (DOF). Rotation

> C<sup>ψ</sup> �S<sup>ψ</sup> 0 S<sup>ψ</sup> C<sup>ψ</sup> 0 0 01

C<sup>θ</sup> 0 S<sup>θ</sup> 0 10

�S<sup>θ</sup> 0 C<sup>θ</sup>

0 C<sup>ϕ</sup> �S<sup>ϕ</sup>

0 S<sup>ϕ</sup> C<sup>ϕ</sup>

10 0

, where roll angle is generated by differential thrust betweet M<sup>2</sup> and M4, pitch angle

1

CCA

1

CCA

1

CCCA

CψC<sup>θ</sup> CψSθS<sup>ϕ</sup> � SψC<sup>ϕ</sup> CψSθC<sup>ϕ</sup> þ SψS<sup>ϕ</sup>

1

(3)

CCCA

SψC<sup>θ</sup> SψSθS<sup>ϕ</sup> þ CψC<sup>ϕ</sup> SψSθC<sup>ϕ</sup> � CψS<sup>ϕ</sup>

�S<sup>θ</sup> CθS<sup>ϕ</sup> CθC<sup>ϕ</sup>

, four rotors denoted each one as Mi with i = (1, 2,…, 4).

Attitude Control of a Quadcopter Using Adaptive Control Technique

http://dx.doi.org/10.5772/intechopen.71382

103

T

matrix R is used to map from Fb to Fe, applying three consecutive rotations denoted by

0

BB@

0

BB@

0

BBB@

Rz ¼

Ry ¼

Rx ¼

0

BBB@

where S and C refer to sin and cos function, respectively.

inertial frame is given by a vectorrI = (x, y, z)

R ¼ Rz; Ry;Rx � � <sup>¼</sup>

Ω = (ϕ, θ,ψ)

T

Figure 1. Quadrotor configuration.

$$w\_i = \frac{\omega\_M}{s + \omega\_M} u\_i \tag{2}$$

For i = (1, 2…, 4), where ui represents the PWM input, the gain K > 0 and ω<sup>M</sup> are the rotor bandwidth, vi is the actuator dynamics. We assume K and ω<sup>M</sup> are the same for all rotors [5].

#### 2.2. Description of Quadrotor system

The configurations of quadrotor are described in Figure 1 and consist of a body-fixed frame denoted by Fb = {Fbx, Fby, Fbz}, the center mass that coincident with the body-frame origin denoted

Figure 1. Quadrotor configuration.

In the last decades, advances in technology and costs reduction permitted to adopt this technology in civil applications such as aerial photography, video and mapping, pollution and land monitoring, powerline inspection, fire detection, agriculture, and among other applications [1]. Quadrotors are a kind of mini-UAV's with vertical take-off and landing, controlled completed through four rotors mounted on each end of the crossed axes, which provide lift forces for the quadrotor move, this vehicle is very popular in the research community due to their special features like strong coupling subsystems, unknown physical parameters, and nonparametric uncertainties in inputs and external disturbances. Therefore, a suitable control system for stabilizing the closed loop control system is required; to do this, various control techniques, linear and nonlinear, have been implemented such as control PD [2, 3], control PID [4, 5], control of position and orientation

by vision [6], sliding mode control [1, 7], fuzzy logic [8, 9], and adaptive control in [10].

quadrotor are constant, and air density around the quadrotor is constant.

MRAC schema, and finally in Section 5, conclusions of this work are presented.

2. Mathematical model

102 Adaptive Robust Control Systems

2.1. ESC + motor + propeller

The rotors of quadrotor are modeled by

2.2. Description of Quadrotor system

The dynamic behavior of quadrotor has been published in varying complexity [11, 12]; particularly, the model we used is based on [13], where an extended mathematical description by the full consideration of nonlinear coupling between the axes is presented. We assume elastic deformations sufficient stiffness and realistic flight maneuvers were omitted, mass distributions of the quadrotor are symmetrical in the x-y plane, drag factor and thrust factor of the

In this work, we develop an adaptive control strategy to stabilize the attitude dynamics of a quadrotor UAV. The adaptive control permit deals with modeling errors and disturbance uncertainty, variations of the mass, inertia, actuators faults, nonlinear aerodynamics, etc.

This chapter is organized as follows: Section 2 presents the mathematical model of the quadrotor obtained using Newton-Euler equations. Section 3 provides brief introduction about the adaptive control theory and the methodology used is based to obtain the adaptive law equations. In Section 4, simulations and analysis are presented to verify the performance of

Ti <sup>¼</sup> <sup>K</sup> <sup>ω</sup><sup>M</sup>

vi <sup>¼</sup> <sup>ω</sup><sup>M</sup> s þ ω<sup>M</sup>

For i = (1, 2…, 4), where ui represents the PWM input, the gain K > 0 and ω<sup>M</sup> are the rotor bandwidth, vi is the actuator dynamics. We assume K and ω<sup>M</sup> are the same for all rotors [5].

The configurations of quadrotor are described in Figure 1 and consist of a body-fixed frame denoted by Fb = {Fbx, Fby, Fbz}, the center mass that coincident with the body-frame origin denoted

s þ ω<sup>M</sup>

ui (1)

ui (2)

by Cm, the earth-fixed inertial frame is denoted by Fe = {Fex, Fey, Fez}, the position in earth-fixed inertial frame is given by a vectorrI = (x, y, z) T , four rotors denoted each one as Mi with i = (1, 2,…, 4).

To obtain the position of CM in the NED (North-East-Down) coordinate system with respect to the inertial frame Fe, we use the Euler angles (roll ϕ, pitch θ, yaw ψ) combined in a vector Ω = (ϕ, θ,ψ) T , where roll angle is generated by differential thrust betweet M<sup>2</sup> and M4, pitch angle is generated by differential thrust between M<sup>1</sup> and M3, and yaw angle is generated by diferential torque between clock wise and anticlock wise rotors, i.e., (M1� M<sup>2</sup> + M3� M4). This kind of device is considered an underactuated system with six degree of freedom (DOF). Rotation matrix R is used to map from Fb to Fe, applying three consecutive rotations denoted by

$$\begin{aligned} R\_z &= \begin{pmatrix} \mathsf{C}\_{\psi} & -S\_{\psi} & 0 \\ S\_{\psi} & \mathsf{C}\_{\psi} & 0 \\ 0 & 0 & 1 \end{pmatrix} \\ R\_{\mathcal{Y}} &= \begin{pmatrix} \mathsf{C}\_{\theta} & 0 & S\_{\theta} \\ 0 & 1 & 0 \\ -S\_{\theta} & 0 & \mathsf{C}\_{\theta} \end{pmatrix} \\ R\_x &= \begin{pmatrix} 1 & 0 & 0 \\ 0 & \mathsf{C}\_{\phi} & -S\_{\phi} \\ 0 & \mathsf{C}\_{\phi} & -S\_{\phi} \\ 0 & S\_{\phi} & \mathsf{C}\_{\phi} \end{pmatrix} \\ R &= \begin{pmatrix} \mathsf{C}\_{\psi}\mathsf{C}\_{\theta} & \mathsf{C}\_{\psi}\mathsf{S}\_{\theta}\mathsf{S}\_{\phi} - \mathsf{S}\_{\psi}\mathsf{C}\_{\phi} & \mathsf{C}\_{\psi}\mathsf{S}\_{\theta}\mathsf{C}\_{\phi} + \mathsf{S}\_{\psi}\mathsf{S}\_{\phi} \\ \mathsf{S}\_{\psi}\mathsf{C}\_{\theta} & \mathsf{S}\_{\psi}\mathsf{S}\_{\theta}\mathsf{S}\_{\phi} + \mathsf{C}\_{\psi}\mathsf{C}\_{\phi} & \mathsf{S}\_{\psi}\mathsf{S}\_{\theta}\mathsf{C}\_{\phi} - \mathsf{C}\_{\psi}\mathsf{S}\_{\phi} \\ -\mathsf{S}\_{\theta} & \mathsf{C}\_{\theta}\mathsf{S}\_{\phi} & \mathsf{C}\_{\theta}\mathsf{C}\_{\phi} \end{pmatrix} \end{aligned} (3)$$

where S and C refer to sin and cos function, respectively.

#### 2.3. Rigid body dynamics

The dynamics of a rigid body under external forces and moments in the f<sup>b</sup> can be formulated as follows [14]

$$
\hbar\omega\dot{v} = \sum F\_i \tag{4}
$$

where d is called drag factor and it is related with the air resistance, L is a parameter which represents the length of the lever between center of mass and the four rotors. MG is the vector of gyroscopic torques generated due to the propellers rotational movements and can be

> 0 0 1

1 CA

1

where JR represents the inertia of rotating rotors. The follow equations permit us to determine

<sup>0</sup> sin <sup>ϕ</sup> cos θ

The relationship that maps rotor angular velocities to forces and moments on the vehicle is

bb b b

0 b 0 �b b 0 �b 0 d �d d �d

where the variable u<sup>1</sup> = F<sup>1</sup> + F<sup>2</sup> + F<sup>3</sup> + F4. The variables u<sup>2</sup> and u<sup>3</sup> correspond the forces from rotors necessary to generate the pitch and roll moments, and u<sup>4</sup> represents the yaw

The translation motion is obtained combining Eqs. (3), (7), (8), and (13), as a result, we have the

� CψSθC<sup>ϕ</sup> þ SψS<sup>ϕ</sup> � � u<sup>1</sup>

� SψSθC<sup>ϕ</sup> � CψS<sup>ϕ</sup> � � u<sup>1</sup>

> g � CθC<sup>ϕ</sup> � � u<sup>1</sup> m

On the other hand, if we assume small perturbations in hover flight, Ω\_ ≈ W and combining

1 tan θ sin ϕ tan θ cos ϕ

cos ϕ cos θ

1

0

BBBBBB@

m

1

CCCCCCCA

m

ω2 1 ω2 2 ω2 3 ω2 4 1

CCCCCCA

CCCCCCA

0 cos ϕ sin ϕ

CAð Þ <sup>ω</sup><sup>1</sup> � <sup>ω</sup><sup>2</sup> <sup>þ</sup> <sup>ω</sup><sup>3</sup> � <sup>ω</sup><sup>4</sup> (11)

Attitude Control of a Quadcopter Using Adaptive Control Technique

http://dx.doi.org/10.5772/intechopen.71382

W (12)

(13)

105

(14)

0 B@

MG ¼ JR W �

the rate of change of the Euler angles in the inertial frame Fe

<sup>Ω</sup>\_ <sup>¼</sup> <sup>H</sup>ð Þ <sup>Φ</sup> <sup>W</sup> <sup>¼</sup>

u1 u2 u3 u4 1

0

BBBBBB@

CCCCCCA ¼

0

BBBBBB@

u ¼

r € ¼

Eqs. (9), (11), and (13), we obtain the follow equations

x€

0

BBBBBBB@

y€

z€

moment.

follow equations

0 B@

calculated by the follow formula

$$J\dot{W} + W \times \text{JW} = \sum M\_i \tag{5}$$

where i = (1, 2,…, 4), ∑Fi∈ R<sup>3</sup> represent the sum of thrust forces from each rotor, ∑Mi∈ R<sup>3</sup> represent the sum of moments acting on the vehicle, v is the velocity in the Fb, m is the quadrotor mass, W = (wx, wy, wz) <sup>T</sup> determines the angular velocity vector which has its origin in at the center of mass of the rigid body, and J is the inertial tensor of the symmetric rigid body around its center of mass.

To obtain the thrust force contribution of each rotor applied to Fb, we use the following formula

$$F\_i = f\_{xi} + f\_{yi} + f\_{zi} = -k \,\omega\_i^2 \tag{6}$$

with fxi force from rotor i applied in Fb respect x axes, fyi force from rotor i applied in Fb respect y axes and fzi force from rotor i applied in Fb respect z axes, ω<sup>i</sup> as rotor's angle speed, k as proportional gain related with air density, the geometry of the rotor blade and its pitch angles. As fxi and fyi is zero, since they form an angle of 90 degrees respect to the rotor thrust, rewriting Eq. (6), we have

$$F\_i = -k\omega\_i^2 \left[ 0 \,\, 0 \,\, 1 \right]^T \tag{7}$$

By transforming Fi to F<sup>e</sup> and making use of the principle of linear momentum, the following equations can be introduced for a quadrotor of mass m under gravity g:

$$\ddot{r} = \begin{bmatrix} 0 \ 0 \ \mathbf{g} \end{bmatrix}^T + R \sum\_{1}^{4} \left( \frac{F\_i}{m} \right) \tag{8}$$

The rotatory moment of the body is described by Eq. (4) can be rewrite as

$$J\dot{\mathcal{W}} + \mathcal{W} \times \mathcal{J}\mathcal{W} = \mathcal{M}\_B - \mathcal{M}\_G \tag{9}$$

where MB is the vector of external torques and is composed of the thrust differences and drag moments of the individual rotors and under considerations of the rotatory directions and can be calculated by

$$M\_B = \begin{pmatrix} Lb\left(\omega\_2^2 - \omega\_4^2\right) \\ & Lb\left(\omega\_1^2 - \omega\_3^2\right) \\ & d\left(\omega\_1^2 - \omega\_2^2 + \omega\_3^2 - \omega\_4^2\right) \end{pmatrix} \tag{10}$$

where d is called drag factor and it is related with the air resistance, L is a parameter which represents the length of the lever between center of mass and the four rotors. MG is the vector of gyroscopic torques generated due to the propellers rotational movements and can be calculated by the follow formula

2.3. Rigid body dynamics

104 Adaptive Robust Control Systems

quadrotor mass, W = (wx, wy, wz)

around its center of mass.

be calculated by

follows [14]

The dynamics of a rigid body under external forces and moments in the f<sup>b</sup> can be formulated as

where i = (1, 2,…, 4), ∑Fi∈ R<sup>3</sup> represent the sum of thrust forces from each rotor, ∑Mi∈ R<sup>3</sup> represent the sum of moments acting on the vehicle, v is the velocity in the Fb, m is the

in at the center of mass of the rigid body, and J is the inertial tensor of the symmetric rigid body

To obtain the thrust force contribution of each rotor applied to Fb, we use the following formula

Fi <sup>¼</sup> <sup>f</sup> xi <sup>þ</sup> <sup>f</sup> yi <sup>þ</sup> <sup>f</sup> zi ¼ �<sup>k</sup> <sup>ω</sup><sup>2</sup>

with fxi force from rotor i applied in Fb respect x axes, fyi force from rotor i applied in Fb respect y axes and fzi force from rotor i applied in Fb respect z axes, ω<sup>i</sup> as rotor's angle speed, k as proportional gain related with air density, the geometry of the rotor blade and its pitch angles. As fxi and fyi is zero, since they form an angle of 90 degrees respect to the rotor thrust, rewriting Eq. (6), we have

By transforming Fi to F<sup>e</sup> and making use of the principle of linear momentum, the following

where MB is the vector of external torques and is composed of the thrust differences and drag moments of the individual rotors and under considerations of the rotatory directions and can

Lb ω<sup>2</sup>

Lb ω<sup>2</sup>

d ω<sup>2</sup> <sup>1</sup> � <sup>ω</sup><sup>2</sup>

<sup>2</sup> � <sup>ω</sup><sup>2</sup> 4 � �

<sup>1</sup> � <sup>ω</sup><sup>2</sup> 3 � �

<sup>2</sup> <sup>þ</sup> <sup>ω</sup><sup>2</sup>

� �

<sup>3</sup> � <sup>ω</sup><sup>2</sup> 4

X 4

Fi m � �

JW\_ <sup>þ</sup> <sup>W</sup> � JW <sup>¼</sup> MB � MG (9)

1

CCCA

1

Fi ¼ �kω<sup>2</sup>

€ <sup>¼</sup> ½ � 0 0 <sup>g</sup> <sup>T</sup> <sup>þ</sup> <sup>R</sup>

equations can be introduced for a quadrotor of mass m under gravity g:

r

The rotatory moment of the body is described by Eq. (4) can be rewrite as

0

BBB@

MB ¼

mv\_ <sup>¼</sup> <sup>X</sup>Fi (4)

<sup>i</sup> (6)

(8)

(10)

<sup>i</sup> ½ � <sup>001</sup> <sup>T</sup> (7)

JW\_ <sup>þ</sup> <sup>W</sup> � JW <sup>¼</sup> <sup>X</sup>Mi (5)

<sup>T</sup> determines the angular velocity vector which has its origin

$$M\_G = J\_R \left( W \times \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix} \right) (\omega\_1 - \omega\_2 + \omega\_3 - \omega\_4) \tag{11}$$

where JR represents the inertia of rotating rotors. The follow equations permit us to determine the rate of change of the Euler angles in the inertial frame Fe

$$\dot{\boldsymbol{\Omega}} = \boldsymbol{H}(\boldsymbol{\Phi}) \boldsymbol{W} = \begin{bmatrix} 1 & \tan \theta \sin \phi & \tan \theta \cos \phi \\ 0 & \cos \phi & \sin \phi \\ 0 & \frac{\sin \phi}{\cos \theta} & \frac{\cos \phi}{\cos \theta} \end{bmatrix} \boldsymbol{W} \tag{12}$$

The relationship that maps rotor angular velocities to forces and moments on the vehicle is

$$u = \begin{pmatrix} u\_1 \\ u\_2 \\ u\_3 \\ u\_4 \\ u\_5 \end{pmatrix} = \begin{pmatrix} b & b & b & b \\ 0 & b & 0 & -b \\ b & 0 & -b & 0 \\ d & -d & d & -d \end{pmatrix} \begin{pmatrix} \omega\_1^2 \\ \omega\_2^2 \\ \omega\_3^2 \\ \omega\_4^2 \end{pmatrix} \tag{13}$$

where the variable u<sup>1</sup> = F<sup>1</sup> + F<sup>2</sup> + F<sup>3</sup> + F4. The variables u<sup>2</sup> and u<sup>3</sup> correspond the forces from rotors necessary to generate the pitch and roll moments, and u<sup>4</sup> represents the yaw moment.

The translation motion is obtained combining Eqs. (3), (7), (8), and (13), as a result, we have the follow equations

$$
\ddot{\boldsymbol{r}} = \begin{bmatrix} \ddot{\boldsymbol{x}} \\ \ddot{\boldsymbol{y}} \\ \ddot{\boldsymbol{y}} \\ \ddot{\boldsymbol{z}} \end{bmatrix} = \begin{pmatrix} -\left(\mathbf{C}\_{\psi}\mathbf{S}\_{\theta}\mathbf{C}\_{\phi} + \mathbf{S}\_{\psi}\mathbf{S}\_{\phi}\right)\frac{\boldsymbol{u}\_{1}}{m} \\\\ -\left(\mathbf{S}\_{\psi}\mathbf{S}\_{\theta}\mathbf{C}\_{\phi} - \mathbf{C}\_{\psi}\mathbf{S}\_{\phi}\right)\frac{\boldsymbol{u}\_{1}}{m} \\\\ \mathbf{g} - \left(\mathbf{C}\_{\theta}\mathbf{C}\_{\phi}\right)\frac{\boldsymbol{u}\_{1}}{m} \end{pmatrix} \tag{14}
$$

On the other hand, if we assume small perturbations in hover flight, Ω\_ ≈ W and combining Eqs. (9), (11), and (13), we obtain the follow equations

$$\begin{aligned} \ddot{\phi} &= \dot{\theta}\dot{\psi} \left( \frac{I\_y - I\_z}{I\_x} \right) - \left( \frac{I\_r}{I\_x} \right) \dot{\theta}h(u) + \frac{L}{Jx} u\_2 \\ \ddot{\theta} &= \dot{\phi}\dot{\psi} \left( \frac{I\_z - I\_x}{I\_y} \right) + \left( \frac{I\_r}{I\_y} \right) \dot{\phi}h(u) + \frac{L}{Jy} u\_3 \\ \ddot{\psi} &= \dot{\phi}\dot{\theta} \left( \frac{I\_x - I\_y}{I\_z} \right) - \frac{1}{I\_z} u\_4 \end{aligned} \tag{15}$$

#### 2.4. Linearization of quadrotor dynamics

To simplify the earlier equations, we have linearized the rotatory system around hover state assuming small change in Euler angles, u<sup>1</sup> ≈ mg in x and y directions, cos(α) = 1, sin(α) = α and neglected the gyroscopic torques; therefore,

$$\begin{aligned} \ddot{x} &= -\theta \mathbf{g} \\ \ddot{y} &= \phi \mathbf{g} \\ \ddot{z} &= u\_1 - m \mathbf{g} \\ \ddot{\phi} &= \frac{L}{f\_x} u\_2 \\ \ddot{\theta} &= \frac{L}{f\_y} u\_3 \\ \ddot{\psi} &= \frac{1}{f\_z} u\_4 \end{aligned} \tag{16}$$

This work only considers the angular momentum corresponding to the orientation of the vehicle, so that the displacement in (x, y, z) axes will not be used for mathematical analysis.

Therefore, the transfer function for dynamic correspondence of orientation is expressed as

$$\begin{aligned} \phi(s) &= \frac{L}{s^2 f\_x} u\_2 \\ \theta(s) &= \frac{L}{s^2 f\_y} u\_3 \\ \psi(s) &= \frac{1}{s^2 f\_z} u\_4 \end{aligned} \tag{17}$$

where Kp<sup>1</sup> = Lkϕ/Jx, Kp<sup>2</sup> = Lkθ/Jy, Kp<sup>3</sup> = Lkψ/Jz. These parametres were computed for a X4-flyer and have the following values: Kp<sup>1</sup> =Kp<sup>2</sup> = 33.23, Kp<sup>3</sup> = 16.95, a<sup>ϕ</sup> = a<sup>θ</sup> = a<sup>ψ</sup> = 4.1 and τ = 0.017. This mathematical model will be used to synthesize the control law to stabilize the closed-loop

Attitude Control of a Quadcopter Using Adaptive Control Technique

http://dx.doi.org/10.5772/intechopen.71382

107

The overall control schema is showed in Figure 2, where position and attitude control are presented. This schema consist in two loops, first one is used to perform the quadrotor tracking of desired trajectory rd, while the second one is used to achieve the desired Euler (ϕd,θd,ψd). Due that we are only interested in attitude control, the above schema is redrawn as is showed in Figure 3.

The adaptive control is an advance control technique which provides a systematic approach for automatic adjustment of controllers in real time, in order to achieve or to maintain a desired level of control system performance, when the parameters of the plant dynamic model are unknown and/or change in time [16]. Two different approaches can be distinguished: indirect and direct approaches. In the first approach, the plant parameters are estimate online and used

system [15].

Figure 2. Overall control system.

3. Adaptive controller design

Figure 3. Attitude control system of a quadrotor.

and adding rotor's model, we have

$$G(s, e^{-rs}) = \begin{pmatrix} \frac{K\_{p1}}{s^2 \left(s + a\_\phi\right)} & 0 & 0\\ \\ 0 & \frac{K\_{p2}}{s^2 \left(s + a\_\theta\right)} & 0\\ \\ 0 & 0 & \frac{K\_{p3}}{s^2 \left(s + a\_\psi\right)} \end{pmatrix} \tag{18}$$

Figure 2. Overall control system.

<sup>ϕ</sup>€ <sup>¼</sup> <sup>θ</sup>\_ψ\_ Jy � Jz

<sup>θ</sup>€ <sup>¼</sup> <sup>ϕ</sup>\_ <sup>ψ</sup>\_ Jz � Jx

<sup>ψ</sup>€ <sup>¼</sup> <sup>ϕ</sup>\_ <sup>θ</sup>\_ Jx � Jy

2.4. Linearization of quadrotor dynamics

106 Adaptive Robust Control Systems

neglected the gyroscopic torques; therefore,

and adding rotor's model, we have

G s;e �τ<sup>s</sup> ð Þ¼

Jx � �

Jy !

Jz � � � Jr Jx � �

<sup>þ</sup> Jr Jy !

� 1 Jz u4

To simplify the earlier equations, we have linearized the rotatory system around hover state assuming small change in Euler angles, u<sup>1</sup> ≈ mg in x and y directions, cos(α) = 1, sin(α) = α and

> x€ ¼ �θg y€ ¼ ϕg

<sup>ϕ</sup>€ <sup>¼</sup> <sup>L</sup> Jx u2

<sup>θ</sup>€ <sup>¼</sup> <sup>L</sup> Jy u3

<sup>ψ</sup>€ <sup>¼</sup> <sup>1</sup> Jz u4

ϕð Þ¼ s

θð Þ¼ s

ψð Þ¼ s

Kp<sup>1</sup> s<sup>2</sup> s þ a<sup>ϕ</sup>

0

BBBBBBBB@

0

0 0

This work only considers the angular momentum corresponding to the orientation of the vehicle, so that the displacement in (x, y, z) axes will not be used for mathematical analysis. Therefore, the transfer function for dynamic correspondence of orientation is expressed as

> L s<sup>2</sup>Jx u2

L s<sup>2</sup>Jy u3

1 s<sup>2</sup>Jz u4

� � 0 0

Kp<sup>2</sup> s<sup>2</sup>ð Þ s þ a<sup>θ</sup>

0

1

CCCCCCCCA

Kp<sup>3</sup> s<sup>2</sup> s þ a<sup>ψ</sup> � �

z€ ¼ u<sup>1</sup> � mg

<sup>θ</sup>\_ h uð Þþ <sup>L</sup>

<sup>ϕ</sup>\_ h uð Þþ <sup>L</sup>

Jx <sup>u</sup><sup>2</sup>

Jy <sup>u</sup><sup>3</sup>

(15)

(16)

(17)

(18)

Figure 3. Attitude control system of a quadrotor.

where Kp<sup>1</sup> = Lkϕ/Jx, Kp<sup>2</sup> = Lkθ/Jy, Kp<sup>3</sup> = Lkψ/Jz. These parametres were computed for a X4-flyer and have the following values: Kp<sup>1</sup> =Kp<sup>2</sup> = 33.23, Kp<sup>3</sup> = 16.95, a<sup>ϕ</sup> = a<sup>θ</sup> = a<sup>ψ</sup> = 4.1 and τ = 0.017. This mathematical model will be used to synthesize the control law to stabilize the closed-loop system [15].

The overall control schema is showed in Figure 2, where position and attitude control are presented. This schema consist in two loops, first one is used to perform the quadrotor tracking of desired trajectory rd, while the second one is used to achieve the desired Euler (ϕd,θd,ψd). Due that we are only interested in attitude control, the above schema is redrawn as is showed in Figure 3.

## 3. Adaptive controller design

The adaptive control is an advance control technique which provides a systematic approach for automatic adjustment of controllers in real time, in order to achieve or to maintain a desired level of control system performance, when the parameters of the plant dynamic model are unknown and/or change in time [16]. Two different approaches can be distinguished: indirect and direct approaches. In the first approach, the plant parameters are estimate online and used to calculate the controller parameters. In the second, the plant model is parameterized in terms of the controller parameters that are estimated directly without intermediate calculations involving plant parameter estimates [17].

The model reference adaptive control or MRAC is a direct adaptive strategy which consists of some adjustable controller parameters and an adjusting mechanism to adjust them. The goal of the MRAC approach is adjusting the controller parameters so that the output of the plant tracks the output of the reference model having the same reference input. The MRAC schema is combine two loops: the inner or primary loop where controller and plant are feedback as in normal loop and outer loop or also called adjustment loop where some adaptive mechanisms and a model reference are used to obtain the some performance [18]. In Figure 4, an overall MRAC schema is presented.

This section presents the design of an adaptive controller MRAC using the Lyapunov's stability theory. This allows us to ensure the tracking trajectory of an X4 to our reference model and makes the system insensitive to parameter variation and external disturbances, leading the state error to zero. Based on this, the process model can be represented by state space as follows:

$$
\dot{\mathbf{x}} = A\_p \mathbf{x} + B\_p \mathbf{u} \tag{19}
$$

$$y = \mathbb{C}x\tag{20}$$

y ¼ Cmxm (22)

http://dx.doi.org/10.5772/intechopen.71382

109

Attitude Control of a Quadcopter Using Adaptive Control Technique

e ¼ x � xm (25)

dt <sup>¼</sup> Ax <sup>þ</sup> Bu � Amxm � Bmuc (26)

Að Þ� θ Am ¼ 0 (28)

Bð Þ� θ Bm ¼ 0 (29)

<sup>T</sup> (31)

dt <sup>¼</sup> Ame <sup>þ</sup> ð Þ <sup>A</sup> � Am <sup>x</sup> <sup>þ</sup> ð Þ <sup>B</sup> � Bm uc (27)

u ¼ Lruc � Lx ¼ θ4uc � θ1x<sup>1</sup> � θ2x<sup>2</sup> � θ3x<sup>3</sup> (23)

<sup>x</sup>\_ <sup>¼</sup> Ap � BpL <sup>x</sup> <sup>þ</sup> BpLruc <sup>¼</sup> <sup>A</sup>ð Þ <sup>θ</sup> <sup>x</sup> <sup>þ</sup> <sup>B</sup>ð Þ <sup>θ</sup> uc (24)

where Lr and L are the matrix containing the parameters of the controller, which can be freely

If we assume that the closed-loop system can be described by (Eq. (14)), where the matrices A and B depend on the parameter θ, and it is some combination of Lr and L, then we can define

where P∈ R<sup>3</sup>x<sup>3</sup> is a positive definite matrix and V is a positive definite function. If its first derivative to time V is not positive definite, then V is Lyapunov function. Now we can solve the

TPe <sup>þ</sup> tr Að Þ ð Þ� <sup>θ</sup> Am TQað Þþ <sup>A</sup>ð Þ� <sup>θ</sup> Am tr Bð Þ ð Þ� <sup>θ</sup> Bm TQbð Þ <sup>B</sup>ð Þ� <sup>θ</sup> Bm (30)

<sup>m</sup>Pe <sup>þ</sup> <sup>2</sup>tr Að Þ � Am <sup>T</sup> QaA\_ <sup>þ</sup> PexT <sup>þ</sup> <sup>2</sup>tr Bð Þ � Bm <sup>T</sup> QbB\_ <sup>þ</sup> Peuc

Substituting (Eq. (22)) in (Eq. (18)), the closed loop system is expressed as follows:

Then, the control law is selected as:

selected, and uc is the reference signal.

Now we introduce the error equation as follows

The error goes to zero if Am is stable and

V ¼ e

derivative of V to time t.

TPAme <sup>þ</sup> <sup>e</sup>

TAT

dV dt <sup>¼</sup> <sup>e</sup>

Differentiating the error with respect to time, we obtain:

de dt <sup>¼</sup> dx

and adding Amx and subtracting to the left side of the equation de

the following Lyapunov function for the parameter adaptation law:

where Q is a positive definite matrix such that meet the follow equation:

dt � dxm

where Ap and Bp represent the matrix and the vector of unknown constant parameters of the system, u is the output signal of the controller, and x is the state vector.

The reference model is defined as follows:

$$
\dot{\mathbf{x}}\_m = A\_m \mathbf{x}\_m + B\_m \boldsymbol{u}\_c \tag{21}
$$

Figure 4. MRAC control schema.

Attitude Control of a Quadcopter Using Adaptive Control Technique http://dx.doi.org/10.5772/intechopen.71382 109

$$y = \mathsf{C}\_{m}\mathfrak{x}\_{m}\tag{22}$$

Then, the control law is selected as:

to calculate the controller parameters. In the second, the plant model is parameterized in terms of the controller parameters that are estimated directly without intermediate calculations

The model reference adaptive control or MRAC is a direct adaptive strategy which consists of some adjustable controller parameters and an adjusting mechanism to adjust them. The goal of the MRAC approach is adjusting the controller parameters so that the output of the plant tracks the output of the reference model having the same reference input. The MRAC schema is combine two loops: the inner or primary loop where controller and plant are feedback as in normal loop and outer loop or also called adjustment loop where some adaptive mechanisms and a model reference are used to obtain the some performance [18]. In Figure 4, an overall

This section presents the design of an adaptive controller MRAC using the Lyapunov's stability theory. This allows us to ensure the tracking trajectory of an X4 to our reference model and makes the system insensitive to parameter variation and external disturbances, leading the state error to zero. Based on this, the process model can be represented by state space as

where Ap and Bp represent the matrix and the vector of unknown constant parameters of the

system, u is the output signal of the controller, and x is the state vector.

x\_ ¼ Apx þ Bpu (19)

x\_<sup>m</sup> ¼ Amxm þ Bmuc (21)

y ¼ Cx (20)

involving plant parameter estimates [17].

The reference model is defined as follows:

Figure 4. MRAC control schema.

MRAC schema is presented.

108 Adaptive Robust Control Systems

follows:

$$
\mu = L\_{\tau} \mu\_{\varepsilon} - L\mathbf{x} = \theta\_{4}\mu\_{\varepsilon} - \theta\_{1}\mathbf{x}\_{1} - \theta\_{2}\mathbf{x}\_{2} - \theta\_{3}\mathbf{x}\_{3} \tag{23}
$$

where Lr and L are the matrix containing the parameters of the controller, which can be freely selected, and uc is the reference signal.

Substituting (Eq. (22)) in (Eq. (18)), the closed loop system is expressed as follows:

$$\dot{\mathbf{x}} = \left(A\_p - B\_p L\right)\mathbf{x} + B\_p L\_r \mathbf{u}\_c = A(\theta)\mathbf{x} + B(\theta)\mathbf{u}\_c \tag{24}$$

Now we introduce the error equation as follows

$$
\boldsymbol{e} = \boldsymbol{\mathfrak{x}} - \boldsymbol{\mathfrak{x}}\_m \tag{25}
$$

Differentiating the error with respect to time, we obtain:

$$\frac{d\mathbf{e}}{dt} = \frac{d\mathbf{x}}{dt} - \frac{d\mathbf{x}\_m}{dt} = A\mathbf{x} + Bu - A\_m\mathbf{x}\_m - B\_m\mathbf{u}\_c \tag{26}$$

and adding Amx and subtracting to the left side of the equation

$$\frac{d\varepsilon}{dt} = A\_m \varepsilon + (A - A\_m)\chi + (B - B\_m)u\_\varepsilon \tag{27}$$

The error goes to zero if Am is stable and

$$A(\theta) - A\_m = 0\tag{28}$$

$$B(\theta) - B\_{\text{ff}} = 0 \tag{29}$$

If we assume that the closed-loop system can be described by (Eq. (14)), where the matrices A and B depend on the parameter θ, and it is some combination of Lr and L, then we can define the following Lyapunov function for the parameter adaptation law:

$$V = e^T P e + \text{tr}(A(\theta) - A\_m)^T Q\_a (A(\theta) - A\_m) + \text{tr}(B(\theta) - B\_m)^T Q\_b (B(\theta) - B\_m) \tag{30}$$

where P∈ R<sup>3</sup>x<sup>3</sup> is a positive definite matrix and V is a positive definite function. If its first derivative to time V is not positive definite, then V is Lyapunov function. Now we can solve the derivative of V to time t.

$$\frac{dV}{dt} = e^T P A\_m e + e^T A\_m^T P e + 2tr(A - A\_m)^T \left(Q\_a \dot{A} + P \text{ex}^T\right) + 2tr(B - B\_m)^T \left(Q\_b \dot{B} + P e u\_c^T\right) \tag{31}$$

where Q is a positive definite matrix such that meet the follow equation:

$$A\_m^T P + PA\_m = -Q \tag{32}$$

dθ<sup>3</sup>

dθ<sup>4</sup>

This section presents several simulations test made to prove the performance of MRAC controller to stabilize a mini-UAV quadrotor. As mentioned before, only orientation dynamic (angle position, angular velocity and acceleration) are considered. Analyzing Eq. (18), it is easy to see that roll, pitch, and yaw dynamics are very similar; for this reason, only roll moment is

The test begins considering controller parameters are unknown and by using an online adaptive mechanism to determine the values that permit the convergence of plant response to reference model response. It is important to note that the MRAC approach seeks to keep the tracking error (x � xm) equal to zero by an adjustment of the controller parameters and do not

Figures 6–8 shows a comparative between the states response of the plant and the state response of the model reference, where can be observer than all states of the plant converge asymptotical to the reference model states. To verify this, the Figures 9–11 are presented; these figures show the tracking error of states goes to zero. Additionally, in Figure 12, the reference

Then, the resulting control diagram is shown in Figure 5.

to seek to identify the real parameters of the plant.

input is compared to the plant and model reference output.

4. Simulation and analysis

used as example in simulation.

Figure 6. Comparison between x<sup>1</sup> and xm1.

dt <sup>¼</sup> <sup>p</sup>11e1x<sup>3</sup> <sup>þ</sup> <sup>p</sup>12e2x<sup>3</sup> <sup>þ</sup> <sup>p</sup>13e3x<sup>3</sup> (36)

Attitude Control of a Quadcopter Using Adaptive Control Technique

http://dx.doi.org/10.5772/intechopen.71382

111

dt ¼ � <sup>p</sup>11e1<sup>r</sup> <sup>þ</sup> <sup>p</sup>12e2<sup>r</sup> <sup>þ</sup> <sup>p</sup>13e3<sup>r</sup> (37)

Therefore, if we choose a stable Am matrix, we will get always a P and Q positive definite matrix.

Accordingly, the derivative to time of function V is

$$\frac{dV}{dt} = -e^T \mathcal{Q} e\tag{33}$$

Where the function V is a Lyapunov function negative semi-definite ensures the output error between the real system and the reference model will tend to be zero, and the system is asymptotically stable.

Thus, we obtain the following parameter adaptation laws

$$\frac{d\theta\_1}{dt} = p\_{11}e\_1\mathbf{x}\_1 + p\_{12}e\_2\mathbf{x}\_1 + p\_{13}e\_3\mathbf{x}\_1\tag{34}$$

$$\frac{d\theta\_2}{dt} = p\_{11}e\_1\mathbf{x}\_2 + p\_{12}e\_2\mathbf{x}\_2 + p\_{13}e\_3\mathbf{x}\_2\tag{35}$$

Figure 5. MRAC control of quadrotor: block diagram.

$$\frac{d\theta\_3}{dt} = p\_{11}e\_1\mathbf{x}\_3 + p\_{12}e\_2\mathbf{x}\_3 + p\_{13}e\_3\mathbf{x}\_3\tag{36}$$

$$\frac{d\theta\_4}{dt} = -\left(p\_{11}e\_1r + p\_{12}e\_2r + p\_{13}e\_3r\right) \tag{37}$$

Then, the resulting control diagram is shown in Figure 5.
