Rapid Control Prototyping and PIL Co-Simulation of a Quadrotor UAV Based on NI myRIO-1900 Board

In this paper, a new Computer Aided Design (CAD) methodology for the Processor-In-the-Loop (PIL) cosimulation and Rapid Control Prototyping (RCP) of a Quadrotor Vertical Take-Off and Landing (VTOL) type of Unmanned Arial Vehicle (UAV) is proposed and successfully implemented around an embedded NI myRIO-1900 target and a host PC. The developed software (SW) and hardware (HW) prototyping platform is based on the Control Design and Simulation (CDSim) module of LabVIEW environment and an established Network Streams data communication protocol. A dynamical model of the Quadrotor UAV, which incorporates the dynamics of vertical and landing flights and aerodynamic forces, is obtained using the Newton-Euler formalism. PID and Model Predictive Control (MPC) approaches are chosen as examples for experiment prototyping. These control laws, as well as the dynamical model of the Quad, are implemented and deployed as separate LabVIEW Virtual Instruments (VI) on the myRIO-1900 target and the host PC, respectively. Several demonstrative cosimulation results, obtained for a 3D LabVIEW emulator of the Quadrotor, are presented and discussed in order to improve the effectiveness of the proposed Model Based Design (MBD) prototyping methodology Keywords—Quadrotor UAV; modeling; Computer Aided Design; Model Based Design; Rapid Control Prototyping; PIL cosimulation; LabVIEW/CDSim; NI myRIO-1900; PID and MPC approaches


INTRODUCTION
The Unmanned Aerial Vehicles (UAV), particularly the Quadrotors ones [1]- [5], are flying robots without pilot which are able to conduct missions in autonomous or halfautonomous modes, also in hostile and disturbed environments.Among the tasks to be conducted with these robots are found military acknowledgment, monitoring missions and specially civilian missions such as the inspection of dams, border monitoring, the prevention of forest fires and so on [6].This explains the interest shown by many researchers to study the flight dynamics and the advanced control laws real-world implementation of these kinds of vehicles.
The Quadrotor is a very promising concept of UAV aircrafts.It is a VTOL vehicle equipped with four rotors that are independently controlled [3].The movement of such UAV results from changes in the speed of these rotors.The front and rear motors rotate counter-clockwise, while the left and right motors rotate clockwise.During its flight, a Quadrotor is subjected to external forces like the gusts of wind, gravity, viscous friction and others such as the thrust of rotors and body and propellers drag forces.Moments generated by gyroscopic effects of motors are also noted [1,3].So, this mechanical structure and the nonlinear and coupled flight dynamics increase the complexity of the Quadrotor.The problem of its flight control and prototyping, i.e. the dynamics stabilization and path tracking, becomes challenging and allowed to be a popular topic in the field of robotics research.Control laws must be designed to work in a real-world scenario and over different flight conditions.Among many control approaches proposed for the dynamics stabilization and path tracking of Quadrotors, we note mainly the PID and Linear Quadratic [7]- [10], Sliding Mode (SMC) [11]- [13], backstepping [14], neural network [15] and Model Predictive (MPC) [16]- [19] control methods.
From the real-world practical point of view, such flight control algorithms must be verified and well prototyped before their definitive implementation on the Quadrotor.Sophisticated and embedded SW/HW solutions for this design stage are usually needed and a powerful platform for achieving both the rapid prototyping and final real-world implementation is very required.This problem can be efficiently handled thanks to the MDB and CAD concepts, especially with the related Processor-In-the-Loop (PIL) and/or Hardware-In-the-Loop (HIL) co-simulation methods.In this framework, the recent increased processing power of the Reconfigurable Inputs and Outputs (RIO) targets of the National Instruments (NI) Company, particularly the embedded myRIO-1900 devices [20], makes these platforms well suited to perform the advanced processing tasks required by complex and hard applications such as the rapid control prototyping, the HIL cosimulation and the final real-world implementation of various flight embedded controllers for QTW UAVs.Based on its suitable architecture and powerful onboard devices such as the three-axis accelerometer, analog IO extensions and Wi-Fi module, the myRIO-1900 target is a promised embedded solution for both prototyping and final real-world implementation platform of various and sophisticated flight controllers of aerial robots.Its associated LabVIEW Real-Time (RT) software tool takes also advantage of deterministic execution and the highest degree of reliability.So, this paper deals with the design and development of a new MBD solution www.ijacsa.thesai.orgfor the PIL co-simulation and rapid control prototyping of a Quadrotor.Such a CAD methodology is built and successfully implemented around an embedded NI myRIO-1900 platform and a host PC.The software implementation is based on the Control Design and Simulation (CDSim) module of LabVIEW environment [21,22] and a set-up Network Streams-based data communication protocol.Both PID and MPC approaches are investigated as experiment examples in order to validate the proposed PIL co-simulation solution.
The remainder of this paper is organized as follows.Section 2 deals with the modeling of the Quadrotor for the vertical and landing flight dynamics using the Newton-Euler formalism.In Section 3, the developed NI myRIO-1900 based platform for the PIL co-simulation and control rapid prototyping of the rotorcraft is presented.All related software and hardware tools of such a CAD prototyping methodology are described.Section 4 is dedicated to the implementation and hardware co-simulation of the PID and MPC approaches, chosen as experiment examples for the Quadrotor attitude and altitude control prototyping.Several demonstrative results as well as our own developed LabVIEW graphical interfaces for rapid flight control prototyping are presented and discussed.Finally, concluding remarks end the paper in Section 5. II.

A. System description and aerodynamic forces
The studied Quadrotor is detailed with their body-frame e e e respectively, as shown in Fig. 1.Let denote by m the total mass of the Quadrotor, g the acceleration of the gravity and l the distance from the center of each rotor to the Center of Gravity (COG).The orientation of the Quadrotor is given by the rotation matrix where     . cos .c  and     .sin .s  . 1 sin tan cos tan 0 cos sin 0 sin sec cos sec where e  and B  are linear velocities of the mass center expressed in the earth-frame and body-frame, respectively.
Each motor of the Quadrotor produces the force i F which is proportional to the square of the angular speed.The trust force generated by the i th rotor of Quadrotor is given by: where  is the air density, r and  are the radius and the section of the propeller respectively, T C is the aerodynamic thrust coefficient.
The aerodynamic drag torque, caused by the drag force at the propeller of the i th rotor and opposed the motor torque, is defined as follows: where D C is the aerodynamic drag coefficient.
The pitch torque is a function of the difference ( 3 the roll torque is proportional to the term ( 4 2 FF  ) and the yaw one is the sum of all reactions torques generated by the four rotors and due to the shaft acceleration and propeller drag.All these pitching, rolling and yawing torques are defined respectively as follows: where  is a proportional coefficient.
Two gyroscopic effects torques, due to the motion of the propellers and the Quadrotor body, are additively provided.These moments are given respectively by: where  is the vector of angular velocities in the fixed earth-frame and The Quadrotor is controlled by independently varying the speed of the four rotors.Hence, these control inputs are defined as follows: where 1,2,3,4  are the angular speeds of the four rotors, respectively.
From Eq. ( 12), it can be observed that the input 1 u denotes the total thrust force on the Quadrotor body in the z-axis, the inputs 2 u and 3 u represent the roll and pitch torques, respectively.The input 4 u represents a yawing torque.

B. Modeling with Newton-Euler Formalism
While using the Newton-Euler formalism for modeling, the Newton's laws lead to the following motion equations of the Quadrotor: Substituting the position vector and the forces expressions into the Eq. ( 13), we have the following translational dynamics of the Quadrotor: From the second part of Eq. ( 13), and while substituting each moment by its expression, we deduce the following rotational dynamics of the rotorcraft: According to the above established Eq. ( 14) and Eq. ( 15

PROPOSED CAD METHODOLOGY FOR RAPID CONTROL PROTOTYPING
A. Rapid control prototyping platform An advanced MBD platform for control algorithms verification and prototyping must make easy the practical implementation with the same used hardware target and software tools.In this paper, the hardware setup of the proposed MBD methodology for rapid prototyping and PIL co-simulation of QTW UAVs is depicted in Fig. 2. www.ijacsa.thesai.orgThe developed SW/HW solution is based mainly on the use of an embedded myRIO-1900 platform from National Instruments Company.Well-suitable for complex processing and real-time computing, this NI portable and RIO target is associated to a host PC with LabVIEW CDSim, myRIO 2015 and Robotics environments.After prototyping phase, the myRIO-1900 device operates autonomously to execute a LabVIEW control project which is deployed on its RT dualcore processor.Thanks to its powerful tools, LabVIEW software environment simplifies construction and prototyping of designed control systems and provides the ability to implement a variety of control algorithms.

B. NI my RIO-1900 board based implementation
The main component of the proposed PIL platform for rapid prototyping of the QTW vehicle is the embedded and reconfigurable NI myRIO-1900 board, depicted in Fig. 3. Featuring the NI industry-standard reconfigurable I/O technology, this hardware target is the enclosed version of myRIO platforms which presents three I/O connectors, wireless capabilities and a dual-core ARM RT Cortex-A9 processor with 667 MHz frequency speed [20].The NI myRIO-1900 platform is also equipped with 256 MB of nonvolatile memory and 512 MB of DDR3 RAM memory.Running a real-time OS as well as a customizable FPGA circuit with the Xilinx SoC Zynq-710 architecture, this embedded target provides differential and single-ended (referenced 0-5V and ±10V) 10 Analog Inputs (AI) and 6 Analog Outputs (AO), 40 general-purpose Digital I/O lines (DIO), with 3.3V output, 3.3 V/5 V-compatible, audio, and power output in a compact embedded device.
The NI myRIO-1900 platform contains an onboard threeaxis accelerometer with a range of ±8g, a resolution of 12 bits and a sample rate of 800 S/s.This integrated device samples each axis continuously and updates a readable register with the result and remains very suitable for the UAV control prototyping and implementation framework.Connected to a host computer over USB and wireless 802.11b, g, n possibilities [20], the myRIO-1900 is equipped with a box Wi-Fi module which can be used for remote control of such UAV aircrafts.Adaptable for LabVIEW programming level and thanks to its onboard devices (PWM, SPI, I2C, encoder, etc.), its reduced physical dimensions and low weight, the myRIO-1900 provides an affordable tool that helps to design and prototype advanced flight control algorithms and real-world design projects of UAV guidance.When integrated with others NI built-in tools, such as LabVIEW MathScript RT module, the CDSim module performs textual mathematics and algorithm design in LabVIEW using the *.m file based syntax.Furthermore, the usability of LabVIEW CDSim module can be also expanded with LabVIEW System Identification toolkit to find empirical models from real plant stimulus-response information, with LabVIEW PID and Fuzzy Logic toolkit for design and tuning various PID and fuzzy control structures, and with LabVIEW Statechart module for event-based control prototyping [21].Once the control algorithms are designed, it is easy to deploy www.ijacsa.thesai.orgdynamic systems to real-time hardware targets without the need to generate code by using the LabVIEW Real-Time and LabVIEW FPGA modules.The LabVIEW myRIO toolkit can be instead used while working with NI myRIO platforms as shown in Fig. 5.

HARDWARE IMPLEMENTATION AND CO-SIMULATIO RESULTS
In order to show the effectiveness of the proposed PIL cosimulation methodology, PID and MPC approaches are investigated for prototyping tests.For the discrete-time control laws implementation, a sampling time equal to 0.01 sec is used.The physical parameters of Table I are used for controller's synthesis and PIL co-simulation stages.The setpoints for the attitude and position dynamics control are applied by external potentiometers connected to the appropriate analog inputs of the myRIO-1900 board.A. PID control prototyping A typical structure of PID controller, given by Eq. ( 16), is used for the stabilization of the altitude and attitude dynamics of the QTW [23]: The error signal   et is used to generate the proportional, integral and derivative actions of the designed controller.The empirical Ziegler-Nichols based method is firstly adopted to compute the values of the PID parameters [23].Then, such parameters can be tuned further thanks to the developed PIL co-simulation interface.Four PID control laws, for each altitude z , roll , pitch  and yaw  dynamics, will then generated as control inputs for the Quadrotor according to Eq. ( 12).
For the PIL and HIL applications, communication between VIs and exchange data between them is always a critical part of a LabVIEW RT project.Such applications typically function as "data servers" and operate with the principle of the LabVIEW Server/Client architecture [22].In such architecture, a host PC acts as a data "Server" in order to provide information to the myRIO NI-1900 platform as the "Client".For such a communication protocol building and management, different data communication mechanisms, such as Network-Published Shared Variables, Raw Ethernet (TCP/UDP) and Network Streams have been proposed [22].
In our PIL co-simulation case, we need sending measures of Quadrotor states from the host PC VI and receive such data in the controller VI, deployed on the myRIO target, to provide in turn control signals and setpoints to the Quadrotor.Thus, we choose the Network Streams approach that best meets our mentioned needs.For setting-up a network stream for the proposed PIL solution, the LabVIEW diagrams of Fig. 6 and Fig. 7 are implemented on the host PC (Quadrotor model) and myRIO deployed embedded target (PID controller), respectively.We develop later the LabVIEW diagram for the MPC approach.Two control & simulation loops from the LabVIEW CDSim module are used to build separately the Quadrotor and control algorithms models.Each model can be then implemented inside these given loops.
The implemented LabVIEW front panels for the PID controller prototyping and the dynamic model of the Quadrotor are shown in Fig. 8 and Fig. 9, respectively.Such implementations are made separately on two VIs which are physically deployed on the host PC and the embedded myRIO-1900 platform, respectively.This proposed HW/SW solution leads to the hardware co-simulation results of Fig. 10 and Fig. 11 for the attitude and altitude dynamics control prototyping, respectively.These demonstrative curves show the effectiveness of such an advanced PIL solution based on the embedded NI myRIO-1900 platform.
Later, we give in Fig. 17   At every sampling time and for a specified prediction and control horizons, the MPC controller, designed and implemented on the LabVIEW/CDSim environment, attempts to minimize the following cost function [24,25,21]:   In Eq. ( 17),    16 for the position and attitude control prototyping, respectively.In order to show the controlled flight behavior of the co-simulated Quadrotor, a 3D prototype is built and animated under LabVIEW environment as depicted in Fig. 17.It can be observed that such a 3D prototype behaves properly in realtime according to the variation of the control setpoint inputs.This result improves further the effectiveness and the validity of our proposed HW/SW co-simulation solution.www.ijacsa.thesai.org

CONCLUSION
In this paper, a new CAD methodology for PIL cosimulation is proposed and successfully implemented for the rapid flight control prototyping of a Quadrotor UAV.The proposed SW/HW solution is based on an embedded NI myRIO-1900 platform and a host PC equipped with the LabVIEW/CDSim graphical programming environment.An efficient set-up Network Streams data communication protocol is further established for such MBD platform.The nonlinear dynamic model of the Quadrotor as well as those of PID and MPC algorithms are implemented and deployed on two separate VIs within a LabVIEW RT myRIO project thanks to the developed and given LabVIEW patterns for the host PC and deployed embedded target parts.All hardware cosimulation results, obtained for a built 3D prototype of the studied rotorcraft, show the effectiveness of our proposed myRIO-based prototyping platform.These results improve further the low cost and simplicity of the future real-world implementation of the prototyped control laws while using the same embedded NI myRIO-1900 platform.

Fig. 1 .
Fig. 1.Mechanical structure of the Quadrotor rotorcraft is the inertia matrix of the Quadrotor, r J denotes the z-axis inertia of the propellers rotors.
air drag force which resists to the Quadrotor motion,       is the overall residual rotor angular velocity.III.

Fig. 3 .
Fig. 3. Embedded NI myRIO-1900 Board C. LabVIEW CDSim and myRIO software tools The LabVIEW CDSim, as a sophisticated LabVIEW addon from NI Company [21], leads to identify and simulate online and offline dynamic systems, analyze open-loop model behavior, design closed-loop controllers and estimators, and deploy digital control systems implementation on NI hardware platforms.As depicted in Fig. 4, the CDSim tool provides various libraries for control design and simulation of dynamic systems.
some flight illustrations in the 3D frame, obtained for the MPC based control prototyping of the emulated Quadrotor rotorcraft.www.ijacsa.thesai.org

Fig. 8 .
Fig. 8. LabVIEW Front Panel for the rapid PID control prototyping: VI deployed on the myRIO-1900 target

Fig. 10 .
Fig. 10.PID prototyping results for the Quadrotor attitude are the predicted plant output, the output setpoint profile and the predicted increment of change in control action, respectively.The terms T matrices.Minimizing the cost function (17) is usually subject to the operational constraints on the control action, its rate of change and plant output signals[21].To create an MPC controller under the LabVIEW/CDSim environment, the CD Create MPC Controller VI of Fig.12is used.This VI bases the MPC controller on a state-space model of the controlled plant.The prediction and control horizons must be provided in the MPC Controller Parameters input of the CD Create MPC Controller VI.These predictive control parameters, as shown in Fig.1, are fixed for the duration of the execution of the controller.MPC State Estimator Parameters of this VI specifies the parameters of the state estimator that the MPC Controller uses to estimate the states of the plant.

Fig. 12 .
Fig. 12. LabVIEW CD Create MPC Controller VIFurthermore, the created MPC controller is now implemented either in the co-simulation, or in a real-world scenario, while using the CD Implement MPC Controller VI of Fig.13within a timed or simulation loops.

Fig. 13 .
Fig. 13.LabVIEW CD Implement MPC Controller VI After the MPC algorithm implementation for the studied Quadrotor, we give in Fig. 14 the developed LabVIEW diagram for the rapid MPC prototyping.The demonstrative cosimulation results are depicted in Fig.15and Fig.16for the position and attitude control prototyping, respectively.In order to show the controlled flight behavior of the co-simulated Quadrotor, a 3D prototype is built and animated under LabVIEW environment as depicted in Fig.17.It can be observed that such a 3D prototype behaves properly in realtime according to the variation of the control setpoint inputs.This result improves further the effectiveness and the validity of our proposed HW/SW co-simulation solution.

Fig. 14 .
Fig. 14.LabVIEW diagram for the Network Streams "Client" based implementation of the MPC algorithm model