Development of Real-Time Hardware in the Loop Based MPC for Small-Scale Helicopter

The most conventional and common control methods that have been used by many researchers are the SISO controls, i.e., PI or PID control because their requirements are not highly dependent on the accuracy of the plant model. Two control approaches are proposed by Kim and Shim (2003), a multi-loop PID controller and a nonlinear model predictive control for the purpose of trajectory tracking. This strategy shows satisfactory results when applied to the Yamaha R-50. However, if large perturbations need to be compensated, or significant tracking abilities are required, this strategy may not be adequate.


Introduction
In recent years, unmanned aerial vehicles (UAVs) have been shown a rapid development equipped with intelligent flight control devices. Many advantages could be offered by UAVs, due to their widely applications (Garcia and Valavanis, 2009).
Flight control is the principle unit for UAVs to perform a full autonomous mission without or with less interference of a human pilot. Numerous types of control have been developed for small-scale helicopters including classical, intelligent and vision controls.
The most conventional and common control methods that have been used by many researchers are the SISO controls, i.e., PI or PID control because their requirements are not highly dependent on the accuracy of the plant model. Two control approaches are proposed by Kim and Shim (2003), a multi-loop PID controller and a nonlinear model predictive control for the purpose of trajectory tracking. This strategy shows satisfactory results when applied to the Yamaha R-50. However, if large perturbations need to be compensated, or significant tracking abilities are required, this strategy may not be adequate. Wenbing, et al (2007) presented a multiple-input-multiple-output (MIMO) neural network controller which has a structure of two inputs and two outputs to control a small-scale helicopter. The neural network controller is used with a simple adaptive PID configuration. The PID gains k i , k p and k d are tuned online via the training of the proposed neural networks during the flight. Srikanth, James and Gaurav (2003) combined vision with low-level control to perform the landing operation of the helicopter. The vision control navigates the commands to a lowlevel controller to achieve a robust landing. In their experiments, state initializations were set in the hover condition arbitrarily. The idea was to find the helipad, then align with it, and land on it. The low-level (roll, pitch lateral and heading) controls were implemented with a proportional controller. The altitude behaviour was implemented with a PI controller. To make altitude control easier, the PI controller was split into three: sub-hover control, velocity and sonar control.

www.intechopen.com
In Montgomery et al (1995), the control system proposed in the USC architecture is implemented as PD control loops with gains tuned by trial and error. In hovering conditions, the system is assumed linear (or linearized), thus multivariable linear control techniques such as Linear Quadratic Regulator (LQR) and H ∞ can be applied. Edgar, Hector and Carlos (2007) propose a flight control structure by combining PID, fuzzy and regulation control, using a nonlinear MIMO model for an X-Cell mini-helicopter platform.
Recently, intelligent control methods have become popular and an alternative to conventional methods. Intelligent control methods can act efficiently with nonlinear and unstable systems. In general, these methods can be categorized into three main techniques: fuzzy control, neural networks approach and genetic algorithm. Furthermore, these techniques can be combined with each other or with conventional methods to become hybrid techniques.
The genetic algorithm based on floating point representation has been modified to tune the longitudinal controller gains parameters of a two-bladed XCELL helicopter platform by Mario, G. P. (1997). First principle modelling is used to model the longitudinal behaviour of the platform. The author applied and compared the proposed design in both time and frequency domains. This algorithm shows faster convergence of the system with less computational time. Kadmiry and Driankov (2003) propose a combination of a Fuzzy Gain Scheduler (FGS) and a linguistics (Mamdani-type) controller. The authors used the FGS to control the attitude stability of the helicopter, whereas the linguistics controller was used to generate the inputs to the fuzzy controller for the given attitudes (z, roll, pitch, and yaw). The proposed controller scheme contains two loops; outer lop and inner loop. The inner loop represents the attitude controller and the outer loop deals with the translational rate variables. The controller was obtained and simulated based on a real nonlinear dynamic model of the platform. This paper addresses the control problem of the HIROBO model platform which is being developed by University of Malaya team. The details of the system hardware and data collection are presented by (Zahari, et al, 2008) and (Taha. Z, T et al, 2010), respectively. The black box Nonlinear Autoregressive Model (NARX) modelling and identification of the platform is presented by (Deboucha,. A et al, 2010). The use of this model was preferred because of its ability to handle instability and nonlinearity of complex nonlinear dynamic and unstable systems such as the helicopter. The author estimated the NARX based on collected flight data test (Taha. Z, T et al, 2010). In this paper, the obtained model by Deboucha. A, et al (2010) is used as plant model to be controlled. Due to the complementary between Model Predictive Control (MPC) and NARX, the MPC algorithm is applied to control the stability of the helicopter. MPC algorithm differs from other control strategies in: firstly, its multivariables feature and secondly the possibility of using constraints. Therefore, reasonable results are anticipated. To prove the capabilities of the latter control, it has been simulated as model in the loop using SIMULINK. Furthermore, an xpctraget rapid prototype is developed to implement and test the controller to play the role of hardware in the loop test (HIL).

Model description
In this section, a brief description of the NARX black box model is presented. As reported previously, the identified orientation model of a Hirobo scale helicopter is obtained by (Deboucha, .A, et al, 2010). A standard NARX discrete time nonlinear multivariable model system with m outputs and r inputs is a general parametric form for modelling Black-box nonlinear systems with one step ahead prediction, which can be described by the following formula (Zhang & Ljung, 1999).
where, [∅ θ φ] T are the orientation behaviour of the helicopter and , , , , are the swash-plate control input vector. , are the matrices of the past outputs and inputs involved in the system, respectively, is a matrix of the input delays from each input to each output. N(.) represents unknown nonlinear function, which in this case is computed by the neural network technique for estimating the nonlinearity of the system. Since the input vector to the system is from the swash-plate, the dynamics of the actuators i.e. servo positions are not included. The dynamics from actuators position to the swash-plate control inputs is assumed linear. This mapping model is presented by (Deboucha, .A, et al, 2010).
The model which is presented in LTI state space form is linearized about a specified input vector and treated in terms of stability to ensure the performance of the model.
The linearized LTI state space model of the orientation dynamics of the helicopter platform is given by: ( 2) where, is the manipulated variable (control inputs to the helicopter), is the process output which are the Euler angles and is the state vector.

Control design
The objective of the MPC in this study is to bring the helicopter to its equilibrium i.e. the hovering condition. The controller is designed in the case where the translation velocities are www.intechopen.com decaying to zeros and the Euler angles are limited with specific constraints explained in the next section. With these parameter criteria, the helicopter tries to stabilize into a hover state.
To design an MPC control, the above matrices have to be updated following the procedure below addressed in (Liuping, 2008 andJay, et.al, 1994).
By taking the difference operation in both sides of the formula (2) (3) Then by defining ∆ ∆ ∆ the updated states model would be as follows: From (2) and (5), the relation between the outputs of the system and the state variables could be deduced as It can also defined as ∆ The augmented state space model has a new state defined by where, the predicted state space model is deduced as Because is a zero matrix, the last term in the above equation can be eliminated, where, is zeros matrix and is the identity matrix.
To predict the future behaviour of the system , the current information of the plant model should be given by . Thus, the future control signals can be expressed by the following: where is the control horizon dictating the number of parameters used to capture the future control trajectory. With the given information of the model , the future state variables are predicted for number of samples as | , | ,..., | ,..., | , where | is the predicted state variable at with given current plant .
Based on the predicted state space model with the matrices ( , , ), Similarly, from the predicted output state variables (8), the predicted outputs are written as follows: All predicted variables are formulated in terms of the information on current state variable and the future control ∆ , where , , From the above formulas, the output vector is concluded as follows: ∆ To sum up, the predictive model of the helicopter's attitude is updated in order to deal with the MPC design. In the next section the optimization algorithm of the MPC is treated based on a given set point (reference model).

Control optimization
For a given set point for Euler angles at sample time within a prediction horizon , the objective of the MPC system is to bring the predicted output behaviour of the helicopter as close as possible to the set-point signals, where firstly, assuming that the set-point signals remain constant in the optimization window. This objective is then translated into a design to find the 'best' control parameter vector ∆ such that an error function between the setpoints and the predicted outputs is minimized.
Assuming the vector set-point data as , where and are the set points of roll angle, pitch angle and yaw angle, respectively. The cost function J which reflects the control objective is defined as where the first term is linked to the objective of minimizing the error between the predicted output vector and the set-point signals, while the second term concerns the consideration of ∆ when the objective function is as small as possible. is a diagonal matrix in the form that where is used as tuning parameter for the desired closed loop performance. The goal would be solely to make the error as small as possible. In the case of large the cost function is interpreted as the situation where would carefully consider how large the ∆ might be and cautiously reduce the error www.intechopen.com To find the optimal ∆ that will minimize the cost function J we have ∆ , and, ∆ ∆ ∆ From the first derivative of the cost function The required condition is ∆ From which the optimal solution for the control signal is found: where is the Hassian Matrix in the optimization.
The MPC is designed based on the above updated model and optimized cost function. One of the criteria of MPC, the constraints in both inputs and outputs has been chosen with regard to the behaviour of the vehicle during the flight test. Based on the flight test, the range outputs that guarantee the behaviour of the helicopter in hovering condition were approximately degrees while the input ranges were approximately degrees.
The second feature that has to be defined in designing an MPC is the selection of the prediction horizon and the control horizon . In this work, the chosen value is 25 and the chosen is five-control inputs horizon.
Based on these criteria and to satisfy the equation ( ∆ ), the best tuning output weights to stabilize the model were found to be the following matrix: .

(21)
While, the best input weights were found to be To validate the previously designed controller that stabilizes the helicopter, the designed MPC is implemented into the same hardware described in the previous section. Using xpctarget software in SIMULINK, the model (in Fig 1) have been developed and deployed into the target PC (PC-104). The model contains the IMU sensor software, the MPC, and the corresponding C/T blocks for both capturing and generating PWM signals. The IMU DATA RECEIVE software reads the behaviour of the helicopter (angular position, acceleration...etc) and sends these data to the controller. The MPC generates the required swash-plate angles as well the pedal control by setting the corresponding servo positions. The relationship between the swash plate which has 120 0 layout and the servo position is given by the transformation matrix from as described by (Deboucha et al, 2010):

Fig. 1. Simulink Block Diagram model of the MPC implementation
The servos' positions are controlled through a set of PWM signals as described by (Deboucha et al, 2011). The pedal control has no effect on the swash-plate layout. Thus, its PWM signal is determined from the servo position. The corresponding C/T blocks (QUARTZ MM) in the SIMILINK model set the frequency of the PWM signals, which is 50 Hz. To capture the actual PWM signals, the QUARTZ PWM capturing block is used for each generated signal from the MPC. The saturation blocks are used to limit the duty cycle if any over-range of its values.

Experimental setup
A part of this work is to implement the above Simulink model to the target PC-104. Fig.2 presents the overall experimental prototype setup. The IMU sensor was mounted on the

Simulation results
To test the designed MPC, a simulation of the helicopter performance under different setpoints is studied. The step response of the helicopter with the introduction of the disturbance in the roll angle is presented in Fig.3. The amplitudes of the roll, pitch and yaw angles are 12, 10 and 13 degrees, respectively. At 5 seconds, a disturbance with amplitude of 5 degrees is introduced. It can be seen that the controller damps down the amplitude of the angle to 13.3 out of 17 degrees in approximately 5 seconds. The effect of the disturbance on the other states is less and it would appear that there is a small steady state error in the yaw angle after 5 seconds of simulation.
The designed MPC has also been tested to track a square wave with a variety of amplitudes for Euler angles. The performance of the controller is good for all the utilized amplitudes, as illustrated in Figures 4, 5 and 6.

Experiment results
This section presents the implementation of developed hardware in the loop system. Two experiments were conducted in this work. The first is conducted where the flight test data were used as reference model and disabling the role of the IMU. Figures 4, 5 and 6 present the generated inputs by the real time MPC to the system to follow the reference model compared with the given inputs system during the flight test. From Fig 1, the collected PWM signals are collected as duty cycle; therefore it has to be transferred to the corresponding angles for each actuator. Instead of activating the IMU software, the feedback to the MPC is the reference model itself. It is noticeable that the generated inputs by the MPC do not follow closely the actual inputs used for modelling task. This is because the MPC is designed based on linearized model of the platform.
As preliminary step to investigate a real autonomous flight, a second experiment is carried out where the IMU software is enabled (fig1) to test its functioning and also to assess how the MPC is sensitive with disturbances. To achieve these criterions, the reference model is settled to zero and the nose of the helicopter is shaken slightly with small variation, the position of actuators change in order to bring back the system into the still condition i.e. the MPC gives the action to the system.

Conclusion
In this paper, a MIMO model predictive control (MPC) system is implemented into hardware in the loop based xpc-target rapid-prototype system to guarantee the equilibrium of the helicopter platform. The MIMO MPC design was carried out using an experimentally estimated model of the Helicopter. The performance of the controller is tested in simulation and hardware in the loop using different set-point scenarios. Simulation results showed that the controller can efficiently stabilize the system under all the introduced disturbances. A real time controller based on xpc-target rapid prototype is developed to implement the proposed controller. The ground results proved that the proposed real time MPC can sufficiently stabilize the system in hovering conditions.