6. System design

Figure 5 depicts the block diagram of our system. The feedback is implied through the conglomerate controller/plant emulator artificial neural network (ANN) using the backpropagation algorithm.

The plant (quadrotor) block is simulated based on the model described in Section 2.

Two errors are generated:

$$\text{Model error: } y\_{plant} - y\_{model} \tag{20}$$

6.1. Selecting the reference model

The transfer functions are as follows:

6.2. Designing the plant emulator block

to compute the errors on the control signals.

controller was used for the z channel.

6.2.1. Selecting the inputs and outputs of the network

The reference model consists of transfer functions for roll, pitch, yaw and z of the quadrotor.

Model Reference Adaptive Control of Quadrotor UAVs: A Neural Network Perspective

roll and pitch: G sð Þ¼ <sup>0</sup>:<sup>5</sup>

yaw: G sð Þ¼ <sup>0</sup>:<sup>5</sup>

<sup>z</sup>: G sð Þ¼ <sup>1</sup>

The transfer functions are chosen to have a quick response to changing set points. Quadrotors are non-linear systems, yet we model the reference using first order transfer functions because we hold machine learning algorithms to the standard of an expert human operator. An expert helicopter pilot would not oscillate to attain a target altitude or attitude and neither should our controller.

The plant emulator ANN predicts the next state of the plant given the control signal of the controller and the current state of the plant, thereby providing a channel for backpropagation

The plant emulator ANN needs to be pre-trained to a certain extent to ensure stability of the quadrotor while the controller ANN is learning in the air. Additionally the design of the plant emulator should be optimal for the application – accurate enough to model complexities and

To verify a good design for the plant emulator ANN, data was collected over several simulations run with varying set points for roll, pitch, yaw and z, separately and simultaneously. The control signals and plant states were mapped gathering a dataset of 8000 entries. This data was used to train the plant emulator ANN; hence set points were not mapped. In these simulations, de-centralized PID controllers were used for roll, pitch and yaw channels while a cascaded PID

The standard procedure in an offline setting is to divide the available tagged data into three parts (randomizing them if each entry is independent, which is not the case here) - the training set (~60%), the cross validation set (~20%) and the test set (~20%). The error on the cross validation set is monitored to select the hyperparameters (like λ or α) of the network and the test error (generalization error) is used to gauge its performance on unseen data. For the purpose of offline pre-training in this chapter, the true test is the actual system; hence we divide the data into training and cross validation sets only to make those design choices that are fixed in-flight.

The naive approach to this problem would be to demand all states of the plant – x, y, z,f, θ and ψ, their derivates and double derivatives as output and to give as input, the previous

agile enough to respond quickly. Refer to Figure 6 for the final plant emulator ANN.

<sup>s</sup> <sup>þ</sup> <sup>0</sup>:<sup>5</sup> (22)

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

147

<sup>s</sup> <sup>þ</sup> <sup>0</sup>:<sup>5</sup> (23)

<sup>s</sup> <sup>þ</sup> <sup>1</sup> (24)

$$\text{References error: } y\_{r\text{reference}} - y\_{plant} \approx y\_{r\text{reference}} - y\_{model} \tag{21}$$

When approaching convergence, both errors tend to zero and the approximation in the reference error becomes increasingly accurate. The extended ANN has two functions – making an adaptive estimate of the next state of the plant given the current state and computing the control signals required by the plant to minimize reference error.

Figure 5. Block diagram of model reference adaptive control using artificial neural networks.

#### 6.1. Selecting the reference model

The second problem is predictability. Just as the human brain is an enigma that man has been trying to understand and find patterns in, the fact remains, humans are still unpredictable to quite an extent. Similarly, as far as machine learning algorithms go, neural networks are a black box and no one fully understands the functions that have been mapped in them once trained. Therefore no one can predict when they might fail and it is not always possible to justify the results produced as opposed to a rule-based classification method such as decision trees. Yet, neural networks have proved to be a great tool and are widely used by organizations today.

Figure 5 depicts the block diagram of our system. The feedback is implied through the conglomerate controller/plant emulator artificial neural network (ANN) using the backpropagation algo-

When approaching convergence, both errors tend to zero and the approximation in the reference error becomes increasingly accurate. The extended ANN has two functions – making an adaptive estimate of the next state of the plant given the current state and computing the

Model error: yplant ymodel (20)

Reference error: yreference yplant ≈ yreference ymodel (21)

The plant (quadrotor) block is simulated based on the model described in Section 2.

control signals required by the plant to minimize reference error.

Figure 5. Block diagram of model reference adaptive control using artificial neural networks.

6. System design

146 Adaptive Robust Control Systems

Two errors are generated:

rithm.

The reference model consists of transfer functions for roll, pitch, yaw and z of the quadrotor. The transfer functions are as follows:

$$\text{I roll and pitch: } G(s) = \frac{0.5}{s + 0.5} \tag{22}$$

$$\text{yaw: } G(s) = \frac{0.5}{s + 0.5} \tag{23}$$

$$\text{z: G}(\mathbf{s}) = \frac{1}{\mathbf{s} + 1} \tag{24}$$

The transfer functions are chosen to have a quick response to changing set points. Quadrotors are non-linear systems, yet we model the reference using first order transfer functions because we hold machine learning algorithms to the standard of an expert human operator. An expert helicopter pilot would not oscillate to attain a target altitude or attitude and neither should our controller.

#### 6.2. Designing the plant emulator block

The plant emulator ANN predicts the next state of the plant given the control signal of the controller and the current state of the plant, thereby providing a channel for backpropagation to compute the errors on the control signals.

The plant emulator ANN needs to be pre-trained to a certain extent to ensure stability of the quadrotor while the controller ANN is learning in the air. Additionally the design of the plant emulator should be optimal for the application – accurate enough to model complexities and agile enough to respond quickly. Refer to Figure 6 for the final plant emulator ANN.

To verify a good design for the plant emulator ANN, data was collected over several simulations run with varying set points for roll, pitch, yaw and z, separately and simultaneously. The control signals and plant states were mapped gathering a dataset of 8000 entries. This data was used to train the plant emulator ANN; hence set points were not mapped. In these simulations, de-centralized PID controllers were used for roll, pitch and yaw channels while a cascaded PID controller was used for the z channel.

The standard procedure in an offline setting is to divide the available tagged data into three parts (randomizing them if each entry is independent, which is not the case here) - the training set (~60%), the cross validation set (~20%) and the test set (~20%). The error on the cross validation set is monitored to select the hyperparameters (like λ or α) of the network and the test error (generalization error) is used to gauge its performance on unseen data. For the purpose of offline pre-training in this chapter, the true test is the actual system; hence we divide the data into training and cross validation sets only to make those design choices that are fixed in-flight.

#### 6.2.1. Selecting the inputs and outputs of the network

The naive approach to this problem would be to demand all states of the plant – x, y, z,f, θ and ψ, their derivates and double derivatives as output and to give as input, the previous

6.2.2. Selecting depth of the network – accuracy vs. agility

parameters and reduces agility of the network.

Ref. [8] for more detailed reading on deep learning.

6.2.3. Selecting the width of the network

0

50

100

150

200

250

300

350

400

450

A two hidden layer network was selected due to its ability to model most non-linear practical systems [7]. Increasing depth increases complexity of the network, which increases number of

Model Reference Adaptive Control of Quadrotor UAVs: A Neural Network Perspective

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

149

The field of deep learning is dedicated to using neural networks with deeper architectures, which are very powerful as we saw in Section 5.4. However, in deeper networks some of the design principles change, for example, in Section 5.3 the possibility of attenuation of information was pointed out in sigmoid-based neural networks, therefore in deeper implementations the rectified linear unit (ReLU) activation function is preferred. Architectural changes are also prevalent in deep learning such as convolutional/recursive/recurrent neural networks. Refer to

Performance with rectangular configurations in neural networks has been found to be equal to or better than performance with pyramid or inverted pyramid configurations [7] and therefore

As part of pre-training, the neural network performance was mapped against number of hidden units as seen in Figure 7 and the elbow of the curve was found at 44 nodes (without

> Jtrain Jcv

0 10 20 30 40 50 60 70 80 90 100

Figure 7. Costs on training and cross validation sets against hidden layer size.

we have same number of hidden units in both hidden layers of our network.

Figure 6. The double hidden layer plant emulator artificial neural network: First layer is the input, second and third layers are for computation, they comprise nodes with sigmoid activation applied and fourth layer is the output.

states of these 18 variables and the control signals. This playing-it-safe approach is costly as we place an undue burden on our algorithm.

Firstly – what is the output required from our network? The plant emulator should accurately predict the next state of the control variables of the system. Therefore the output should be the four control variables - z, f, θ and ψ.

Secondly – what information would a human expert require to calculate the output? The previous states of z, f, θ and ψ, their derivatives and the control signals would be required. Note that we do not need to give system information like the mass/inertia as input. The neural network will deduce such information based on the data. Interestingly, these 12 inputs are insufficient, x\_ and y\_ are required to model the dynamic thrust and drag coefficients by the model and therefore they must be given as inputs here.

If the initial choice of input/output variables is suboptimal leading to poor performance of the network, this step must be revisited.
