Keywords

1 Introduction

Quadrotor has great practical value and wide development prospects as a kind of vertical take-off and landing (VTOL) aircraft with excellent performance. Rotorcraft has interested the robotics and control community in recent years. Quadrotor, as the representative of the rotorcraft, has always been a hotspot in research of rotorcraft. Featured with multi-variable, nonlinearity, strong coupling and sensitivity of interference, quadrotor achieves six degrees of freedom (position and attitude) of aircraft movement by adjusting the four motor speeds [1].

The autonomous flight control circuit can generally be divided into three parts, namely position control, speed control and attitude control (Fig. 1). Attitude stability control (internal loop control) is the basis of micro flying platform for autonomous flight, the control result of which is of great importance to the aircraft flight characteristics. Thus the performance of attitude control is the key to the overall flight control. In these days, many researchers have being conducted on this field. The typical methods include PID control [1], adaptive control [2, 3], the sliding mode variable structure control [4, 5], back-stepping control [6, 7], robust control [8] and neural network control [9].

Fig. 1.
figure 1

The control structure of quadrotor

The BPNN based PID control proposed in this article combines the advantages of PID control and neural network control. With the identification results of the BPNN, the selection and setting of proportion, integral and differential parameters are conducted.

2 Dynamic Modeling for a Quadrotor

A quadrotor conventional structure is composed of four perpendicular arms which have motor and rotor, respectively (Fig. 2). The four rotors provide upwards propulsion as well as the direction control. In order to balance the effect of torque, the micro quadrotor system is divided into two opposite rotor pairs (rotor 1, 3 and rotor 2, 4) where one pair rotates clockwise while the other pair counters clockwise (Fig. 3) [1]. Vertical ascending (descending) flight is obtained by increasing (decreasing) thrust forces. By applying speed difference between front and rear rotors, we will have pitching motion which is defined as a rotation motion around Y axis. Using the same analogy in rolling motion, we will have a rotation motion around X axis. Yaw rotation, which is defined as a rotation motion around Z axis, is obtained through increasing (decreasing) speed of rotors (1.3) while decreasing (increasing) speed of rotors (2.4). Unlike pitch and roll motions, yaw rotation is the result of reactive torques produced by rotors rotation.

Fig. 2.
figure 2

Inertia and body coordinate system of the quadrotor

Fig. 3.
figure 3

BPNN based PID control structure

2.1 System Dynamics

The derivation of the dynamics is based on inertial and body frames. The quadrotor has six degrees of freedom, Cartesian \( \left( {x,y,z} \right) \) and angular \( \left( {\phi ,\theta ,\psi } \right) \). Using the formalism of Newton-Euler and assuming that the quadrotor has a symmetrical structure, the thrust and the drag forces are proportional to the square of the rotors speed, the dynamic model of quadrotor can be expressed as [10]:

$$ \left\{ \begin{aligned} & I_{xx} \dot{p} = qr\left( {I_{yy} - I_{zz} } \right) + J_{r} q\Omega _{r} + lU_{1} \\ & I_{yy} \dot{q} = pr\left( {I_{zz} - I_{xx} } \right) - J_{r} p\Omega _{r} + lU_{2} \\ & I_{zz} \dot{r} = pq\left( {I_{xx} - I_{yy} } \right) + J_{r} {\dot{\varOmega }}_{r} + U_{3} \\ & m{\ddot{\textit{x}}} = \left( {\sin \psi \sin \phi + \cos \psi \sin \theta \cos \phi } \right)U_{4} - K_{1} \dot{x} \\ & m{\ddot{\textit{y}}} = \left( { - \cos \psi \sin \phi + \sin \psi \sin \theta \cos \phi } \right)U_{4} - K_{1} \dot{y} \\ & m{\ddot{\textit{z}}} = \cos \psi \cos \phi U_{4} + K_{2} \dot{z} + mg \\ \end{aligned} \right. $$
(1)

Where:

  • \( p,q,r \) is the angular velocity around the x, y, z axis in body coordinate respectively

  • \( I_{xx,yy,zz} \) is the inertia of the x, y, z axis respectively

  • \( J_{r} \) is the inertia of the quadrotor

  • \( l \) is the lever length

  • \( \Omega _{r} =\Omega _{2} +\Omega _{4} -\Omega _{1} -\Omega _{3} \), \( \Omega _{1,2,3,4} \) is angular velocity of rotor 1, 2, 3, 4, respectively

  • \( U_{1} ,U_{2} ,U_{3} ,U_{4} \) are the defined control signals instead of use rotor speeds as control inputs, \( b \) is the thrust coefficient, \( d \) is the drag coefficient and \( F_{1,2,3,4} \) is the rotor lift, \( F_{i} = b\Omega _{i}^{2} \)

$$ \left\{ \begin{aligned} & U_{1} = b(\Omega _{4}^{2} -\Omega _{2}^{2} ) \\ & U_{2} = b(\Omega _{1}^{2} -\Omega _{3}^{2} ) \\ & U_{3} = d( -\Omega _{1}^{2} +\Omega _{2}^{2} -\Omega _{3}^{2} +\Omega _{4}^{2} ) \\ & U_{4} = \sum\nolimits_{i = 1}^{4} F_{i} = - b(\Omega _{1}^{2} +\Omega _{2}^{2} +\Omega _{3}^{2} +\Omega _{4}^{2} ) \\ \end{aligned} \right. $$
(2)

From the above analysis, we can safely draw the conclusion that the attitude control of quadrotor is independent and the displacement control is affected by the attitude control.

2.2 Attitude Modeling

Due to the symmetrical structure of quadrotor, the design of the roll controller and the pitch controller can be exactly the same, so this paper just considers the specific design method of roll control.

If quadrotor is close to hover state, then the dynamic can be linearized as the gyroscopic effect and air resistance can be ignored [11]. Meanwhile, the attitude angular is very small in which case \( (p,q,r) \approx (\dot{\phi },\dot{\theta },\dot{\psi }) \). The linearized attitude model is:

$$ \left\{ \begin{aligned} & I_{xx} \ddot{\phi } = lU_{1} \\ & I_{yy} \ddot{\theta } = lU_{2} \\ & I_{zz} \ddot{\psi } = U_{3} \\ \end{aligned} \right. $$
(3)

It can be seen from the linear attitude model that there is no coupling between the attitude channels, the controllers can be designed separately.

Extract the attitude equation from Eq. (3):

$$ I\ddot{\varphi } = \tau $$
(4)

\( \tau \) is proportional to the difference of the square of the rotor angular velocity, \( I \) is the inertia of the quadrotor and \( \varphi \) is the attitude angular. Assuming the transform function of command signal to the motor and the actual speed difference output is first-order inertia link [12], the transfer function of motor instruction signal and the attitude angular can be obtained as

$$ G_{\varphi u} = \frac{\varphi (s)}{u(s)} = \frac{{k_{\varphi } }}{{s^{2} (\tau s + 1)}} $$
(5)

The unknown parameters can be identified through manual flight inputs and outputs data fitting. The roll channel transfer function is identified as:

$$ G_{\phi u} = \frac{53.46}{{s^{3} + 12.05s^{2} + 101.8s}} $$
(6)

And the yaw channel transfer function is identified as:

$$ G_{\psi u} = \frac{1.6762}{{0.1256s^{3} + 0.7087s^{2} + s}} $$
(7)

3 BPNN Based PID Control Strategy

Attitude control is the core of the quadrotor control and its control performance will greatly affect the flight stability. BPNN based PID is introduced as attitude control method due to its effective transient and steady performance. The BPNN based PID controller can reduce the computation load and improve the system response speed [13]. According to the decoupled linear model, the roll channel, pitch channel and yaw channel BPNN based PID controllers can be designed independently.

The BPNN based PID controller (Fig. 3) is introduced to eliminate the inverse error adaptively and improve the robustness of the controller.

The typical PID control algorithm is as follow:

$$ u\left( t \right) = k_{p} \left[ {e\left( t \right) + \frac{1}{{T_{I} }}\int_{0}^{t} {e\left( t \right)dt + T_{D} \frac{de\left( t \right)}{dt}} } \right] $$
(8)

For the convenience of simulation, using the typical incremental digital PID control equation:

$$ u(k) = u(k - 1) + kp(e(k) - e(k - 1)) + kie(k) + kd(e(k) - 2e(k - 1) + e(k - 2)) $$
(9)

\( kp \), \( ki \), \( kd \) stands for proportional, integral, differential coefficient respectively. Regard \( kp \), \( ki \), \( kd \) as dependent coefficients based on the adjustments of system operating status. Therefore Eq. (9) can be described as:

$$ u(k) = f[u(k - 1),kp,ki,kd,e(k),e(k - 1),e(k - 2)] $$
(10)

\( f(.) \) is a nonlinear function of \( kp \), \( ki \), \( kd \), u(k-1), e(k). Such a control law \( u(k) \) can be obtained by BPNN training and learning as it has the ability to approximate any nonlinear function.

BPNN is one of the most widely used neural network model currently. BPNN is the multilayer feedforward network based on the training of error back propagation algorithm. BPNN can learn and store a lot of input - output model mapping without the knowledge of mathematical equations of the mapping relationship. The learning rule is that using the steepest descent method to minimize the error sum of squares of the network by back propagation, which can constantly adjust the network weights and threshold [14]. BPNN topological structures include input layer, hidden layer and output layer (Fig. 4).

Fig. 4.
figure 4

BPNN topological structure

The inputs of the network input layer:

$$ \mathop o\nolimits_{j}^{(1)} = x(j),j = 1,2 \ldots m $$
(11)

The inputs and outputs of the network hidden layer:

$$ net_{i}^{(2)} (k) = \sum\limits_{j = 1}^{m} {w_{ij}^{(2)} o_{j}^{(1)} } ,j = 1,2 \ldots m,i = 1,2 \ldots q $$
(12)
$$ \mathop o\nolimits_{i}^{(2)} (k) = f(net_{i}^{(2)} (k)),i = 1,2 \ldots q $$
(13)

\( \left\{ {w_{ij}^{(2)} } \right\} \) stand for the hidden layer weighted coefficient, superscript (1), (2), (3) represent the input layer, hidden layer and output layer, \( f(x) = (e^{x} - e^{ - x} )/(e^{x} + e^{ - x} ) \).

The inputs and outputs of the network output layer:

$$ net_{l}^{(3)} (k) = \sum\limits_{i = 1}^{q} {w_{li}^{(3)} o_{{_{i} }}^{(2)} } (k) $$
(14)
$$ o_{l}^{(3)} (k) = g(net_{l}^{(3)} (k)),l = 1,2,3 $$
(15)
$$ o_{1}^{(3)} (k) = kp,o_{2}^{(3)} (k) = ki,o_{3}^{(3)} (k) = kd $$
(16)

\( \{ w_{li}^{(3)} \} \) stand for the output layer weighted coefficient, the output layer neuron activation function is the nonnegative function Sigmoid \( g(x) = e^{x} /(e^{x} + e^{ - x} ) \).

Take a performance index function:

$$ E(k) = \frac{1}{2}(rin(k) - yout(k))^{2} $$
(17)

Modify the weights of the network according to the gradient descent method with an inertia item that speeds up the convergence search:

$$ \Delta w_{li}^{(3)} (k) = - \eta \frac{\partial E(k)}{{\partial w_{li}^{(3)} }} + \gamma\Delta w_{li}^{(3)} (k - 1) $$
(18)

Where \( \eta \) is the learning coefficient and \( \gamma \) is the Inertia coefficient.

$$ \frac{\partial E(k)}{{\partial w_{li}^{(3)} }} = \frac{\partial E(k)}{\partial y(k)}.\frac{\partial y(k)}{\partial u(k)}.\frac{\partial u(k)}{{\partial o_{l}^{(3)} (k)}}.\frac{{\partial o_{l}^{(3)} (k)}}{{\partial net_{l}^{(3)} (k)}}.\frac{{\partial net_{l}^{(3)} (k)}}{{\partial w_{li}^{(3)} }} $$
(19)

Using \( \text{sgn} \left( {\frac{{y\left( k \right) - y\left( {k - 1} \right)}}{{u\left( k \right) - u\left( {k - 1} \right)}}} \right) \) to approximately representative \( \frac{\partial y(k)}{\partial u(k)} \).

According to Eq. (9):

$$ \begin{aligned} & \frac{\partial u(k)}{{\partial o_{1}^{(3)} (k)}} = e(k) - e(k - 1) \\ & \frac{\partial u(k)}{{\partial o_{2}^{(3)} (k)}} = e(k) \\ & \frac{\partial u(k)}{{\partial o_{3}^{(3)} (k)}} = e(k) - 2e(k - 1) + e(k - 2) \\ \end{aligned} $$
(20)

The output layer weight can be obtained:

$$ \Delta w_{li}^{(3)} (k) = \eta \delta_{l}^{(3)} o_{i}^{(2)} (k) + \gamma\Delta w_{li}^{(3)} (k - 1) $$
(21)
$$ \delta_{l}^{(3)} = e(k)\frac{{\partial \widehat{y}(k)}}{\partial u(k)}\frac{\partial u(k)}{{\partial o_{l}^{(3)} (k)}}g^{{\prime }} (net_{l}^{(3)} (k)),l = 1,2,3 $$
(22)

Similarly, the hidden layer weight can be obtained:

$$ \Delta w_{ij}^{(2)} (k) = \eta \delta_{i}^{(2)} o_{j}^{(1)} (k) + \gamma\Delta w_{li}^{(2)} (k - 1) $$
(23)
$$ \delta_{i}^{(2)} = f^{{\prime }} (net_{i}^{(2)} (k))\sum\limits_{l = 1}^{3} {\delta_{l}^{(3)} } w_{li}^{(3)} (k),i = 1,2, \ldots q $$
(24)

The steps of BPNN based PID algorithm:

Step 1: Determine the structure of BP network, the input layer node number M, the number of hidden layer nodes Q; the weighted coefficient of each layer and the selected learning rate and inertia coefficient are initialized; k = 1 for this step

Step 2: Sampling to get \( rin(k) \), \( yout(k) \); Calculate \( error(k) = rin(k) - yout(k) \)

Step 3: Calculate the inputs and outputs of each layer, the outputs of output layer are the parameters \( kp \), \( ki \), \( kd \)

Step 4: Calculate u(k) of the PID controller

Step 5: Do neural network learning to adjust the weighted coefficient to realize the adaptive adjustment of PID control parameters; Back to Step 2.

4 Simulations

4.1 Attitude Model Validations

The compared results of the model outputs and the real flight outputs are presented in Fig. 5. The figures demonstrate the validation of the attitude model.

Fig. 5.
figure 5

Attitude model validations

4.2 Attitude Control Simulations

The neural network structure of the roll channel simulations consists of 3 input layer nodes, 4 hidden layer nodes and 3 output layer nodes. The initial values of the rate and inertia coefficient are 0.3 and 0.05 respectively.

The roll channel simulation results are in the following Figs. 6 and 7. Figure 6 shows that roll channel can follow the step signal with quite low overshot of 5 % and shorter rise time of 0.4 s in comparison of typical PID control of 1 s.

Fig. 6.
figure 6

The step response of roll channel

Fig. 7.
figure 7

The step response of roll channel with model uncertainty

Furthermore, in order to test the capacity of resisting model uncertainty, the transfer function is slightly changed in the simulation of Fig. 7. The typical PID control can not follow the step signal with expected performance. Nevertheless, the BPNN based PID method can still follow the step signal with desired overshot and rising time due to the adaptability of the PID coefficient values. The theory presented in the paper is tested as having good robustness.

The neural network structure of the yaw channel simulations consists of 3 input layer nodes, 4 hidden layer nodes and 3 output layer nodes. The initial values of the rate and inertia coefficient are 0.25 and 0.05 respectively.

Similarly, the yaw channel simulation results are in the following Figs. 8 and 9. Figure 8 shows that roll channel can follow the step signal with quite low overshot of 5 % and shorter rise time of 0.3 s in comparison of typical PID control of 0.9 s.

Fig. 8.
figure 8

The step response of yaw channel

Fig. 9.
figure 9

The step response of yaw channel with model uncertainty

The BPNN based PID method can still follow the step signal with desired overshot and rising time due to the adaptability of the PID coefficient values while the typical PID control performs not so well (Fig. 9).

The simulation results demonstrate that attitude angular can follow the step signal with quite low overshot and shorter rise time in comparison of typical PID control. Besides, taking the modeling uncertainty into consideration, the transfer functions indentified before may have a certain error. The capacity of resisting model uncertainty through the BPNN based PID method is tested in the above simulations.

5 Conclusions

This paper proposed a BPNN based PID control of quadrotor attitude. Quadrotor dynamic model and attitude model were established. Furthermore, BPNN based PID controller was designed toachieve the adaptive adjustment of PID parameters by neural network back propagation. Considering the precision, adaptability and robustness of the control law, Matlab/Simulink based simulations were conducted. The performances of the control law were validated by simulation results.