Auto-tuning for cascade PID height position controller of rotorcraft

In this article, we present a method for tuning controller parameters for cascade PID based on the step response performance characteristics of a closed loop system with application to an unmanned aerial vehicle(UAV). With specifically designed system identification procedures, a neural network mapping is obtained automatically when the UAV is flying around the target height. With this network system model, a gradual regression and optimization algorithm is proposed to tune the controller. The regression model primly illustrated the relation between PID parameters with controller performance, and the construction for optimization cost function takes the physical significance of step response performance of flying machine into account. Experimental data collected from fight experiment when auto-tuner is implemented on a quadrotorcraft demonstrate the efficiency of the proposed method.


Introduction
In the past decades, the automatic parameter tuning for the controller has been a pursuit for researchers and engineers [1] [2][3] [4]. Amount of these studies are based on adequate prior knowledge of the control plant, for example the system model has always been used as a key information to solve the problem of auto-tuning [5]. The system model with explicit expression such as transfer function or state transition matrix has several advantages. In some circumstance, the parameters of controller can be obtained directly by certain calculation (usually there is no need to do any iteration). Some researchers use the identified equation of open-loop system directly to calculate the feedback coefficients of Linear Quadratic Regulator (LQR) controllers [6] [7], which is a representative approach to obtain the optimal control parameters without iteration computation. Another approach is to use the identified transfer function of plant to analyze the amplitude and phase figures of open-loop and closed-loop systems, so that PID controller with desired amplitude and phase characteristics can be designed [8]. In many situations, however, the system model (explicit functions) can not be acquired, even a linearized approach will make enormous effort to implement open loop response experiment to identify an approximate system transfer function. A simplified approximate model may be useful to determine rough controller parameters, but the desired result usually can not be realized the optimized parameters are applied to a practical system. Some researchers considered about tuning the controller without any system model ， this form of method can be conclude as obtaining the optimal control parameters by valuating a series of practical experiment results corresponding to different system settings [9]. Relay feedback tuning is one good application of this kind of idea [10]. By temporarily replacing feedback controller by a relay, most systems will oscillate and a point on Nyquist curve can be obtained. Based on the positions of these points, the designer can choose the ideal PID parameters according to the phase and amplitude margin. This method has also been implemented in the system with cascade controller [11]. This method is a considerable choice for systems with difficulty in system identification, it requires the system to oscillate under various magnitudes in the open-loop control process, which is unrealistic for some systems and easy to cause safety problems in the process of tuning.
The key motivation of this paper is to design a highly matching auto-tuning algorithm for cascade controller which is applied on integrating system like UAV.
Step response performance characteristics provide available criteria for controller design [12]. A nonlinear black-box system modeling [13] is a suitable bridge effectively for obtaining the mapping from controller parameters to performance characteristics. The black-box identification for UAV height input-output response is well designed to ensure the safety of all the procedures. The procedure of optimal parameter seeking depends on varying controller parameters and collecting the step response performance data in a virtual environment, so there is no risk of controlling the UAV under unstable parameter setting. This new optimal seeking method combines the physical features of different performance characteristics to achieve visualized ideal results, and a gradual regression and optimization method contributes to the accuracy and efficiency simultaneously.

Controller and system structure
In the auto-tuner design, a specific cascade closed-loop controller for the rotorcraft height control is built. A black-box identification algorithm using Gaussian Random Signal is embedded in to the control system. The complete system is presented in figure 1, the outer loop is controlled by a PD controller with limited output, and the inner loop is controlled by a PID controller. This choice is made according to the different physical features between outer loop and inner loop. Compared with the position stabilization, the inner loop control determines the value thrust, which compensates the varying of system bias error due to electrical energy consumption. Based on these, the integral item is essential while it is not required in the outer loop. Fig. 1. UAV auto-tuning control system block diagram.

Initial setting for controller
By setting a group of rough height controller parameters, the aircraft can fly stably around a target altitude (with no consideration about response speed or other performance characteristics). These initial parameters can be calculated regarding the take-off thrust which is equal to the weight of UAV. In the calculation of rough initial inner loop PID parameters, the differential coefficient is set to 0, the relation between proportional coefficient, integral coefficient and the basic take-off thrust is: Kd are the rough proportional, integral and differential coefficient of inner controller; max v e is the output limit of outer loop( target velocity limit of inner loop) ; b Th is the basic bias control value which can generate a thrust to meet the weight of rotorcraft. 0 t is the integral time, the value of it determine the speed of removing the constant control system error, here it is set to 30 seconds, because in the procedure of system identification, converging time will not affect the result.
As for the outer loop, the idea for rough setting is quite similar, where the reference value is the target speed allowed for system self-stabilization. The relation can be illustrated as follows where out Kp , out Ki are the rough proportional, integral of outer controller; max p e is the input limitation ( position error limitation ) for the outer loop controller, max p de is the error is the allowed maximum movement velocity for position stabilization.
The formula (1) and (2) provide an estimation for rough control parameters to make sure the UAV can keep stable before tuning algorithm. After the calculation, an insurance procedure should be implemented by disabling the outer loop control and set target velocity to zero. Then the initial parameter will be validated when the UAV can be controlled stably with no vertical speed.

Neural network black-box system identification
Now, consider about the black box system identification block in figure 1, the control signal ( ) u k and estimation velocity valueˆ( ) v k will be used as the identification data. Considering the control plant as a nonlinear dynamic system, it can be represent as following discrete equation [14], where ( ) n x k R  , ( ), ( ) u k y k R  , , f g C  are unknown function. If the linearized system around the equilibrium point is observable, the input-output equation can be represented by [15] : Equation (4) means that there is a black box  that can map from the historical system outputs (historical speed values), current input and historical input to the current output value. Back Propagation Neural Network (BPNN) is a model that is used to illustrate the mapping. The training of model is shown in figure 3. The BPNN model mainly contains input layer, hidden layer and output layer. The length of buffers for control signal and UAV velocity determine the size of input layer. The Data Set (DS) collecting is a crucial part for the neural network training. In order to cover a variety of input and motion situations [16] , the Gauss random signal is added to a constant value as identification input signal. The control signal mixer can judge whether the aircraft has reached the steady state, and then switch to the identification signal to disturb the system. The logic for the signal mixer is presented in figure 3. There is a switch between the open-loop control and closed-loop control to ensure system safety. When the controller is switched to open-loop, the constant value used for mixer is the control input value which stabilizes the system around the equilibrium point. In this way, the constant value always compensates the drifting of system bias ( it is caused by the consuming of electrical energy).

Auto tuning algorithm
The predominant idea of tuning algorithm is to obtain the relation (a function with explicit equation) between PID parameters and the control performance characteristics. For the selection of performance criteria, some previous existed controllers had concerned about the physical meanings of performance characteristics, no matter in auto-tuning [17] or experimental tuning [18] . The value of overshoot reflects the stability and security of a system [19]. The settling time is another important performance characteristic of the control system, which reflects the response speed of the controller, it is often referred in systems requiring dynamic tracking [20]. Integral square error(ISE) can also reflect the stability of a system, which is a more comprehensive value. ISE considers both the time and tracking error. Moreover it reflects the total energy consuming during the control process [21], so it is a frequently-used criteria in control design and tuning.
The proposed tuner synthetically utilizes the above three characteristics. Since the importance of these performance characteristics are different to the inner loop and outer loop of the proposed controller, the cost function will be designed depending on all of them. The physical meaning of performance characteristics is not the only one that needs to be considered about in cost function choosing, but the precision of fitting and extreme value problem should also be taken into account.

Objective functions for optimization
As for the inner loop, the speed of response is the main concern, so the settling time state is the most important criteria to the PID controller. It is not necessary to overemphasis the stability of the inner loop, and the inner loop has one more parameter (integral parameter), which means it needs to reduce the computation. Based on that, the overshoot is used as the restriction So the optimization problem of inner loop controller is: where w and z are the functions of settling time and overshoot with respect to PID controller parameters. This objective function will lead to a minimized settling time s t with the overshoot over e no more than 10% of the target velocity. As for the outer loop, it determines the final overall performance of the UAV height control. Even though the inner loop control still has some defects, such as the settling time and overshoot can not be satisfied at the same time, the optimal outer loop control parameters can make sure the control system performs as desired(it can set reasonable target speed for inner loop). The objective function of outer loop is: where the settling time s t is still the key criteria, y and  are the functions of settling time and ISE with respect to PD parameters. The aim of this objective function is to ensure the response speed, smoothness and stability simultaneously.

Performance characteristic functions regression
Based on the black-box system model, two groups of Data Sets are created by controlling the plant model in a virtual environment. The first group is generated with a step response on input-output speed model, which is used for inner loop performance functions regression and tuning.
Choosing an appropriate regression hypothesis can ensure the fitting accuracy. We have tried several hypothesis including linear regression model and nonlinear regression model. Commonly, a linear model should be tested prior to a nonlinear one because it is time saving in computation( no iteration is needed). The model for inner loop overshoot is a linear regression model, the fitting results show that the precision is sufficient for optimization limitation. This linear regression model is: Solve the equation with least square method [22], the hypothesis coefficients is obtained: However, for the regression for settling time function, linear regression does not have an ideal result in practical application. In order to realize a highly fitted regression, a nonlinear regression model is used to improve the accuracy: This is a ratio model which can better reflect complex relationships. The drawback is that it need iteration computation to solve the problem of regression, Gauss-Newton method is applied in the solution [23], the algorithm is illustrated in table 1.
As for the outer loop, the structure is similar to that of the inner loop. The outer loop only has PD parameters, and the settling time is used for the cost function, the regression model is: The limitation function for outer loop refers to the ISE value, data set of ISE in control process is calculated by: where ( , , ) ( ) ( ) out out p e k P D r k p k   is the control error of step response. 0 k is the discrete time point when system reaches its peak, s k is the point of settling time. Similarly, since the requirement for limitation function is not demanding, a linear regression model is enough: Regarding the importance of the outer loop control parameters, the optimization algorithm here will be improved to enhance the accuracy. An iterative gradual regression and optimization method is a good one which can maintain the efficiency of the algorithm.  (2) are used as the initial parameters of the optimization algorithm, and a relatively larger vector 1 l is set as initial varying step , and a certain threshold (which is small enough to ensure the accuracy) is given as the break condition. By gradual decreasing the length of boundary and increase the sample density, less point of data set is required, that means there is less step responses is generated and evaluated in the tuning algorithm.

Experimental validation
The quadrotor-craft consists of four main components: RC transmitter/receiver, IMU/GPS/barometer sensor navigation system, micro-processor and actuators. The RC transmitter is to send control-position information and receive controller parameters. The navigation system provides the sensor information for aircraft position and attitude estimation. The micro-processor is to process data and generate control signals. Actuators are to generate thrust and torques, which consist of motor drives, DC motors, gearboxes and blades. The experimental platform is shown in figure 4.

Fitting and optimization
The performance characteristics functions of the inner loop (settling time and overshoot) have three variables (Kp, Ki and Kd), so the 3D thermal chart is used to show the relation between controller parameters and performance characteristics, which is shown in figure 5. The brightness of a point repents the magnitude of a dependent variable value, it can be seen that the figure of inner settling time function has a brighter outside, it's a convex function which can be used for extreme point seeking; The overshoot function is not a convex one, but it's used for limitation. The regression Root Mean Squared Error (RMSE), optimal controller parameters, step response settling time and overshoot of inner loop are presented in table 3. The optimized inner loop parameters can perform well in the test on a velocity model. Then it is fixed when outer parameters is optimized on a position model(integral of velocity model). For this iteration method, the dataset generation, regression and optimization will be repeated in the extremum seeking process. A rational initial setting will ensure the convergence of the algorithm. The regression result of PD controller performance characteristics (settling time and Integral Square Error ) are shown in figure 6. Because of limited regression accuracy, the result of first step may be not the most ideal one. Figure 7 shows the difference value of parameter optimization results of each step, the results converged after about 200 steps (about half a minutes). The ideal PD parameters lead to a settling time of 4.3 second and ISE 0.009(normalized) in simulation on the black box neural network system model.   The optimized parameters are verified with step response, which is shown in figure 8. The first chart compares the control results by initial parameters, parameters optimized by first regression step, and parameters of final tuning result. The second chart illustrates the variation of target speed and actual speed tracking in the control process. It is worth mentioning that the optimized result of first step has reduced the settling time and ISE value significantly, however, after the iterated optimization procedure, the final group of parameters given by tuner are more ideal than that of the first step.

Parameters application on practical UAV system
The rotorcraft is controlled with designed cascade PID controller and flying in an outdoor open space. Before the tuner works, the UAV is given a varying target height, the height and velocity tracking result is shown in figure 9. The flight tracking performance is improved after the auto-tuning algorithm, which is shown in figure 10. It is apparent that both in the outer loop (height tracking) and inner loop(velocity tracking), the response speed is increased. The tracking error is also minished, the height tacking RMSE has been declined from 0.53 to 0.25, which is half less than before, and the velocity tacking RMSE has been declined from 0.24 to 0.085.

Conclusion
This paper proposed a safe auto tuner with high computation efficiency. The foundation of this tuner is a reasonable black box system identification implemented on the flying machine. The ultimate aim of the tuner is to realize desired physical performance, by generating control Data Set based on the system model, the mapping from controller parameters to performance characteristics is obtained. Specifically, in order to improve the optimization accuracy and efficiency, a gradual regression and extremum seeking method is applied as the key process for the tuning algorithm. A direct application of the auto-tuning algorithm is shown in the cascade control of a self-developed laboratory quadrotor platform, followed by fight experimental evaluation in the real environment.