You are on page 1of 7

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

Rapid software prototyping for real-time simulation and control of a mini-helicopter robot
CARLOS M. VLEZ S., ANDRS AGUDELO Departamento de Ciencias Bsicas Universidad EAFIT Cra. 49 No. 7 sur 50, Medelln, Antioquia COLOMBIA

Abstract: - This paper presents a rapid software prototyping environment, based on Matlab/Simulink, for realtime simulation and control of a mini-helicopter robot. The application of the environment is illustrated with a software-in-the-loop simulation example. The environment is integrated by own modules (mini-helicopter simulation model, navigation filter, multirate control, filters) and modules based on Matlab toolboxes (ground control station, linearization, parameter identification, heuristic identification). The environment is being tested over a real system, where it is intended to reduce developing time and cost, giving to developer more time to focus on mathematical and algorithmic methods. Key-Words: - Aerospace simulation, aircraft navigation, helicopter control, software-in-the loop, rapid prototyping

1 Introduction
Flight control of Unmanned Aerial Vehicles (UAV) is an area of intense development in the world [2]. The most relevant highlights of these systems are reduction of human risk, low flight and maintenance costs, and versatility. Nevertheless, it is necessary to focus on the problem of autonomy to take advantage of their capabilities, and here rapid software prototyping plays a powerful role. This paper describes a Rapid Software Prototyping Environment (RSPE) called Colibri (hummingbird in Spanish), with some differences with other similar environments where Matlab is used mainly for simulation and design purposes or without some interesting possibilities. For example, the software in [1] is focused in realtime and scheduling issues, using Matlab only for control task; it is not mentioned how the environment speeds up tasks like identification, estimation, control or virtual reality. MoSART (Modeling, Simulation, Animation, and Real-Time Control), described in [9] and [10], is an interactive Matlab-based environment which is used for analyzing, designing, visualizing, and evaluating the performance of aircraft control systems. The environment lacks of identification and state estimation modules, or process-oriented tools like code generation for real-time operating systems or a ground station for use by pilots. MultiUAV2 [11] is an environment based on Matlab for cooperative flight, but mostly using script functions programmed in C++ and limited to simulation. It has been used for developing and

testing cooperative control algorithms, implementing time-optimal trajectories. In [14], a prototype simulation and 3D visualization tool for cooperating UAVs, working semi-autonomously or manually, is described. It has useful functions and prototyping capabilities, but it is mainly oriented to simulation and visualization. Commercial aerospace applications based on Matlab are given in [24] and [25]. These examples show the validity of this kind of prototyping environments. The paper is organized as follows. Section 2 presents the main characteristics of the proposed Colibri RSPE. Section 3 introduces the key ideas of mini-helicopter modeling, explained with details in [3] and [7]. Section 3 describes the main modules of the proposed RSPE. An example, with application of previously described modules, is given in section 4. Concluding remarks and ideas for future work are provided in Section 5.

2 Rapid software prototyping


Rapid software prototyping (RSP) is the process of automatic early development of a working version (prototype) of a system used to test out certain key features of a design, demonstrate concepts or methods, and to gather early user feedback [29], [30]. An adequate RSPE must integrate different tools and must be easily reconfigurable for different tests, including software-in-the-loop (SIL), hardware-inthe-loop (HIL) and man-in-the-loop (MIL) simulation.

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

Fig.1. Interaction of Colibri environment modules For example, Matlab/Simulink [12] is a RSPE which provides a proper user interface allowing the development of simulation models and prototypes, either on machine time or in real time. Automatic code generation and integration with the target computer, where the control software runs, can be achieved in Simulink by means of Real-time Workshop Toolbox (RTW). RTW generates and executes stand-alone C code for developing and testing algorithms modeled in Simulink. It is possible interactively tune and monitor the generated code. The Matlab-based RSPE presented in this paper includes various modules (Fig. 1). Some modules were developed using Simulink (X-Cell non-linear mathematical mini-helicopter simulation model, navigation filter with an Extended Kalman Filter, multirate [6], [7], [28] and other control structures, filters), the Ground Control Station (GCS) was built with Virtual Reality Toolbox and Gauges Blockset, and other tools were adapted and may be adapted directly from Matlab (linearization, parameter identification, heuristic identification, fuzzy control, etc). A trajectory generator and a Finite State Machine for managing discrete events are being developed. The core of the software environment is the mini-helicopter simulation model, which interacts easily with other Matlab tools. All developed functions are written entirely in Simulink (which can be considered a visual programming language), without using functions and with the possibility of automatic code generation for the QNX real-time operating system [23]. Both a commercial [27] and a custom [26] target solution were used to generate and transfer code to the target machine with QNX.

A normal session with Colibri RSPE includes the following stages: 1) development of a simulation model for analysis, design and simulation; 2) separation of controller, estimation, filter, transformations, and logical blocks from the plant model; 3) attach of driver blocks; 4) automatic C code generation and conversion to real-time executable code; 5) load onto target hardware; 6) connection to target; 7) monitoring and tuning of signals parameters using Simulink as a graphical user interface; 8) load of data for analysis. Providing input to the model in execution time is done with different user interface objects including special gauges (e.g. sliders), text boxes, or a joystick control (custom input) for pilot-in-the-loop tests. The target computer in the environment is a PCbased system which can be a normal desktop computer or an embedded flight computer (PC-104 form factor). Standard communication technologies as Ethernet, wireless 802.11b and UDP/IP and TCP/IP protocols, are used for both file transferring and monitoring in a laboratory setting. The minihelicopter is equipped with a wireless bridge, and an ah-hoc wireless LAN network formed with the helicopter flight computer and one or more laptop computers, which can play the role of ground or monitoring stations. Telemetry during flights requires special attention as flight tests demand an updated view of the helicopter state. A special blockset was developed to satisfy this need. The module, available through Simulink design interface, takes model parameters and sends them through network using UDP, which is a fast and efficient protocol for timesensitive purposes.

Fig.2. X-Cell 0.60 Gas Graphite helicopter Colibri RSPE has some advantages: 1) it encourages and requires active participation in the design process through a block diagram modeling

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

environment; 2) it accelerates the learning curve and simplifies the information exchange between different technological domains; 3) the prototype is equivalent to a specification document; 4) errors can be detected earlier, reducing costs and development time; 4) it increases creativity; 5) it speeds up the development cycle due to the refinement of design by rapid iteration between algorithm design and prototyping.

3 Mini-helicopter mathematical model


The mini-helicopter used in the work is an X-Cell Gas Graphite hobby helicopter (Fig. 2). The inputs and states of mini-helicopter system are given in (1) and (2).
u = [ col

lon lat

t ]

(1)
T

x = [u , v, w, p, q, r , , , , x, y, z , a1 , b1 , ]
u = ( vr wq ) g sin + X / M a v = ( pw ru ) + g cos sin + Y / M a w = ( qu pv ) + g cos cos + Z / M a p = qr ( I y I z ) / I x + L / I x q = pr ( I z I x ) / I y + M / I y r = pq ( I x I y ) / I z + N / I z
a1 = A a1 q + lon lon e e

(2)

The mini-helicopter is an eight-degree-of-freedom system: three lineal displacements (u, v, w), three angular movements (p, q, r) and two main rotor flapping angles (a1, b1). The rigid-body dynamics of such vehicles are described by the Newton-Euler equations of motion. There are two reference frames: body-fixed and earth-fixed. The differential equations describing the minihelicopter translational and rotational motion in the body-fixed reference are given in (3), where [X Y Z]T is the vector of external forces acting on the vehicle center of gravity (c.g.), [L M N]T is the vector of external moments, Ma is the helicopter mass and I is the inertial tensor. Higher-order effects are taken into account to improve the rigid-body model accuracy. These extensions are rotor dynamics, engine-drive train and actuators dynamics. The coupled rotor and stabilizer bar equations are lumped into one firstorder equation of motion. This procedure is done for both lateral and longitudinal tip-path-plane flapping. The equations are given in (4).

4 Modules of Colibri RSPE


(3)

4.1. Mini-helicopter simulation module


The simulation model was coded in Simulink using only blocks, without functions or S-functions and integrated in one Simulink file. So, the real-time code generation is straightforward and may be used in SIL, HIL or MIL simulations (section 5). This characteristic was used for validation of logical model structure by an expert pilot, using a joystick and a 3D visual interface. The parameters of the mini-helicopter model are defined in [3] and [7]. In [7], details of mini-helicopter simulation model are given. Fig. 6 shows the front-end (mask) of model.

4col u uw o 2 k 3 mr Rmr 1 (4) + 2 e w ww 16 mr sign mr + k 8 mr + amr mr mr Rmr b1 1 4col v vw b1 = p + 2k o + e e 3 mr Rmr + Blat e lat

4.2 Inertial navigation module


It is not realistic to assume that all output vehicle variables can be measured. Even if it were possible, there are measurement errors and noise that could be minimized using data from different sensors (navigation aids), such as GPS, barometer, sonar, magnetometer, accelerometers and gyros [22] (the last two are integrated into an Inertial Measurement Unit - IMU). An Extended Kalman Filter (EKF) is an optimal predictor-corrector estimator for Gaussian disturbances, which uses the knowledge of kinematical models, measurement errors, sensor models, and initial condition information to estimate position, velocity and attitude of a vehicle (its state). The estimated state is a combination of a predicted

(col, lon, lat, r, t): control inputs (main rotor collective, longitudinal cyclic, lateral cyclic, tail rotor collective and throttle) (u, v, w): vehicle velocities in body axes (p, q, r): vehicle angular rates in body axes (, , ): Euler angles (roll, pitch, yaw) (x, y, z): vehicle position in navigation axes (a1, b1): longitudinal and lateral main rotor flapping angles : main rotor angular speed

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

state and a correction using measurement data. Fig. 3 shows the respective equations and algorithm. The EKF was implemented in the environment using only Simulink blocks (Fig. 4 and 5), which makes possible the automatic code generation.

Fig.6. PID control with state estimation Fig.6 shows the simulation of PID controllers with a decoupled configuration and state estimation of Fig. 4 and 5. The PID controllers use position and velocity errors separately, which improve closed-loop behavior. Governor controller and wind gust are modeled.

Fig.3. Extended Kalman Filter algorithm

Fig.4. Implementation of EKF in Simulink

Fig.7. Multirate control In Fig.7, a multirate control, using the Multirate Control Toolbox [28], is applied to mini-helicopter supposing different input and output sampling rates. A single-rate state feedback control u = -KX is obtained for a linearized model around a hover operating point (obtaining with the PID controller) and then is translated into a multirate control using the multirate modeling method exposed in [7]. The linearization is performed using tools available with Matlab.

Fig.5. Application of EKF to state estimation

4.3 Control module


Some control methods (Fig. 6, 7) have been tested with the mini-helicopter simulation model. The first one was a PID control with anti-windup and bumpless transfer considerations. This heuristic method is used to obtain control input values in different operational points (e.g., hover or cruise) and as an initial control which helps to compare other model-based methods. Inaccuracies in parameters and initial conditions are introduced. Other implemented controllers: fuzzy, state feedback and multirate. Hereafter, novel control methods can be applied.

4.4 Model linearization module


Linear control design from a complex non-linear mini-helicopter model is not a trivial problem. Usually, approximated or theoretical models are used and tuned around a selected operational point. In the environment, linearization is accomplished easily using Matlab tools (Table 1) and the mini-helicopter simulation model, excluding subsystem models such as actuator, quaternion and fuel dynamics.

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

The linearized model was also obtained theoretically from mathematical equations and compared with models from other references [4], [13]; this process helped in the validation process of simulation model and to estimate different model parameters from experimental data. Table 1. Matlab linearization code
% x_op = [u v w p q r roll pitch yaw x y z a1 b1 Omega] x_op = [0 0 0 0 0 0 0.0795 0 0 0 0 -60 0 0.00769 167]; % u_op = [d_col d_lon d_lat d_ped throttle] u_op = [0.6123 0 0.0191 0.4273 0.5283]; [A,B,C,D] = linmod('colibri_linearization_model', x_op, u_op);

4.5 Ground Control Station module


The Ground control station was developed completely in Matlab/Simulink and may be configured according to a specific test; for example, the GCS is different for identification, experimental tests or supervision tasks. It is not a single program, but the integration of several elements: gauges, virtual reality model, time plots, maps, etc (Fig. 8). In this sense, laptop is the station and can be composed taking advantage of several Matlab tools. This is an interesting concept, because designers usually think about a ground station as a single program.

Fig.9. Trajectories of estimated parameters using a heuristic identification method Mini-helicopter simulation model in blocks allows the application of different parametric and heuristic identification methods, in open and closed loop. It is possible to estimate some parameters indirectly, comparing a good theoretical linear model with an experimental one, or directly with the simulation model, using heuristic methods (like evolutionary computation and optimization) and closed-loop data (e.g., with a PID control) with persistent excited reference signals, applying the Matlab Parameter Estimation Toolbox (Fig. 9). So, the non-linear identified model and the simulation model are the same. This is a really interesting approach, because any indirect computation such as linearization [4] is unnecessary. Moreover, it is important to take in account that closed-loop identification with parametric methods (least squares, prediction error, etc) is inexact due to negative effects of feedback, which generates a bias in the estimation.

4 Software-in-the-loop simulation
Fig.8. Ground control station (GCS) for supervision of an autonomous mini-helicopter robot The Colibri RSPE is applied here in a SIL context, as SIL simulation requires almost all Colibri modules. Fig.10 shows a typical SIL configuration with three computers. PC2 and PC3 are actual systems. The mini-helicopter is changed for its simulation model running in real-time. In a pilot-in-the-loop simulation, PC2 is changed for a joystick interface. Fig.11 shows Simulink configuration for RTW compiling; SM_control (PID controllers in Fig. 6) and SS_Helicopter subsystems are compiled, while SC_Console (setpoint and plot blocks together with virtual reality blocks) is the GCS. Parametric and heuristic identification (Fig. 9), and state feedback, PID, fuzzy and multirate control (using linearization) were applied.

4.6 System identification module


It is important in the flight control development process to use experimental data, additional to pilot simulation tests, to refine simulation model and, at the same time, obtain a more accurate and reliable mathematical model for control design. There exist methods like MOSCA and CIFER that point in that direction [4], [18], [19]. The interaction between both models (theoretical and estimated) helps to identification of some system parameters, without using wind tunnels [20], [21].

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

accurate and intuitive mathematical model for simulation and control design. Acknowledgment: This work was supported by Colciencias (Colombian Institute for Development of Science and Technology) under code 1216-14-14884. The authors would like to express thanks to students of Mathematical Engineering of Eafit University by their constant support to the project. References: [1] Henzinger T.A., Kirsch C.M., Sanvido M.A.A., Pree W., From Control Models to Real-Time Code Using Giotto, IEEE Control System Magazine, No.1, 2003, pp. 50-64 [2] Ollero A., Merino L., Control and perception techniques for aerial robotics, Annual Reviews in Control, Vol. 28, 2004, pp. 167178 [3] Gavrilets V., Autonomous Aerobatic Maneuvering of Miniature Helicopters, Ph.D. Thesis, Massachusetts Institute of Technology, 2003 [4] Mettler B., Identification Modeling and Characteristics of Miniature Rotorcraft, Kluwer Academic Publishers, 2003 [5] Snchez E., Becerra H.M., Vlez C.M., Combining fuzzy and PID control for an unmanned helicopter, North American Fuzzy Information Processing Society Annual Conference, 2005, pp. 235-240 [6] Vlez C.M., Salt J., Control Multifrecuencia en Tiempo Real Utilizando Herramientas CACSD, Revista Iberoamericana de Automtica e Informtica Industrial (RIAI), Vol. 1, No. 3, 2004, pp. 43-52 [7] Vlez C.M., Agudelo A., Multirate control of an unmanned aerial vehicle, WSEAS Transactions on Circuits and Systems, Vol. 4, No.11, 2005, pp. 1628-1634 [8] Colibri, http://www.control-systems.net/colibri/ [9] Rodriguez, A.A., Tae-Young K., Chen-I L., Metzger R.P.A, A tool for analyzing, designing, and visualizing multivariable aircraft control systems, Proceedings of American Control Conference, Vol. 1, 1999, pp. 237-241 [10] Rodrguez A.A., Metzger R.P., Cifdaloz O., Dhirasakdanon T. , Description of a Modeling, Simulation, Animation, and Real-Time Control (MoSART) Environment for a Class of Electromechanical Systems, IEEE Transactions on Education, Vol. 48, No. 3, 2005, pp. 359-374 [11] Rasmussen S.J., Mitchell J.W., Chandler P.R., Schumacher C.J., Smith A.L., Introduction to the MultiUAV2 simulation and its application to cooperative control research, Proceedings of

Fig.10. Software-in-the-loop simulation architecture

Fig.11. Software-in-the-loop simulation blocks in Matlab/Simulink

5 Conclusions
The rapid software prototyping environment allows the analysis, design and rapid prototyping development of real-time control for an X-Cell minihelicopter, in an intuitive and efficient way, with reduction of programming, debugging and understanding time of the system and problem by researchers and students. With the environment, it is possible to test new methods (control, monitoring, signal processing, estimation, identification, etc) in an easy and flexible manner. The environment integrates general tools based on Matlab toolboxes, with the possibility of adding new functions according to new requirements. Up to date, successful tests have been done with avionics and software in flight, but other tests are necessary to validate and exploit all possibilities of whole software environment. The future work will be focused on control design interfaces, discrete event modeling, real applications, and multirate control possibilities and benefits. Parameter estimation using mini-helicopter Simulink model has a great potential if it is used together with tools as genetic algorithms or evolutionary computation, due to advantages that implies an

Proceedings of the 10th WSEAS International Conference on SYSTEMS, Vouliagmeni, Athens, Greece, July 10-12, 2006 (pp289-295)

American Control Conference, Vol. 7, 2005, pp. 4490-4501 [12] Matlab and Simulink, Mathworks, http://www.mathworks.com [13] Padfield G.D., Helicopter flight dynamics: the theory and application of flying qualities and simulation modeling, AIAA, 1996. [14] Castillo M., Alvis W., Castillo C., Modeling and visualization of multiple autonomous heterogeneous vehicles, IEEE International Conference on Systems, Man and Cybernetics, Vol. 3, 2005, pp. 2001-2007 [15] McDuffie J.H., Using the architecture description language MetaH for designing and prototyping an embedded reconfigurable sliding mode flight controller, Proceedings of Digital Avionics Systems Conference, Vol. 2, 2002, pp. 8B1-1 - 8B1-17 [16] Tudor N., Adams M., Clayton P., O'Halloran C., Auto-coding/auto-proving flight control softwar, Digital Avionics Systems Conference, Vol. 2, 2004, pp. 6.E.4 - 61-11 [17] Hongru L., Zhensheng F., Hongqiang G., Jianhui C., Flying control system simulation modeling using Simulink, Proceedings of the 4th World Congress on Intelligent Control and Automation, Vol. 1, 2002, pp. 147-150 [18] Tischler M.B., Cauffman M.G., FrequencyResponse Method for Rotorcraft System Identification: Flight Applications to BO-105 Coupled Fuselage/Rotor Dynamics, Journal of the American Helicopter Society, Vol. 37, No. 3, 1992, pp. 3-17 [19] Cevita M., Messner W.C., Kanade T. Modeling of small-scale helicopters with integrated first-principles and systemidentification techniques, Proceedings of the 58th Forum of the American Helicopter Society, 2002, pp. 2505-2516 [20] Hamel P.G., Jategaonkar R.V., Evolution of flight vehicle system identification, Journal of Aircraft, Vol. 33, No. 1, 1996, pp. 9-28 [21] Hamel P.G., Kaletka J., Advances in rotorcraft system identification, Progress in Aerospace Sciences, Vol. 33, 1997, pp. 259-284 [22] Rogers R.M., Applied mathematics in integrated navigation systems, AIAA Education Series, 2000 [23] QNX, http://www.qnx.com/ [24] Bell Helicopter Develops First-Ever Commercial Tiltrotor Using The MathWorks Tools and Model-Based Design, Vertical Magazine, April 2006, Available on-line: http://www.verticalmag.com

[25] Lockheed Martin Aeronautics and The MathWorks Achieve Milestone With Successful F-35 JSF Flight Simulator Test, Mathworks Press Room, January 2004. Available on-line:: http://www.mathworks.com [26] Martin R.F.K, Designing a Real-Time PUMA Controller Using Simulink and QNX, Available on-line: http://www-users.cs.umn.edu/~martin [27] RT-Lab, http://www.opal-rt.com/ [28] Vlez C.M., Multirate Control Toolbox, Available on-line: http://www.mathworks.com [29] Pollini L., Innocenti M., A Synthetic Environment for Dynamic Systems Control and Distributed Simulation, IEEE Control System Magazine, Vol. 20, No. 2, 2000, pp. 49-61 [30] Luqi L., Steigerwald R., Rapid software prototyping, Proceedings of International Conference on System Sciences, Vol. 2, 1992, pp. 470-479

You might also like