APP下载

Modeling and simulation of quadrotor UAV based on Simscape

2020-04-28JIJiangHANJianingMENGLifan

JI Jiang, HAN Jia-ning, MENG Li-fan

(1. School of Instrument and Electronics, North University of China, Taiyuan 030051, China;2. School of Electrical and Automation Engineering, Nanjing Normal University, Nanjing 210023, China)

Abstract: In order to speed up and simplify the design of the quadrotor unmanned aerial vehicle (UAV) and carry out experimental simulation and verification of relevant control algorithms, this paper analyzed the system dynamics model of the mechanical structure and flight principle of the quadrotor aircraft, and used the Newton-Euler method to derive the non-linear dynamic equations. Aiming at improving the modeling accuracy and system integrity of the quadrotor, the physical system modeling was combined with the CAD software and the Matlab/Simscape toolbox. The three-dimensional quadrotor solid model built by CAD software was imported into the Simscape simulation platform to construct the body and power system model of the quadrotor. Based on this, the control algorithm designed by Simulink was added to the simulation platform to facilitate the experiment verification and parameter tuning. The simulation results show that the designed aircraft can achieve hover and tracking well and meet the control performance requirements of the system.

Key words: quadrotor unmanned aerial vehicle (UAV); physical system modeling; parameter tuning; tracking

0 Introduction

Quadrotor is featured with simple structure, vertical take-off and landing (VTOL), concealment and high safety. With the reduction in the hardware cost, quadrotor is becoming more and more popular. Nowadays, quadrotor unmanned aerial vehicles (UAVs) are widely used in military and civil fields.

At present, the study on quadrotor dynamics is a hot topic. Quadrotor UAV is a typical multivariable, nonlinear, strongly-coupling underactuated system. The six-degree-of-freedom motion of a quadrotor rotor is subject to real-time control of the input power of its four motors. The quadrotor system itself has parametric uncertainties and is easy to be interfered by the external environment factors. Therefore, the construction of an accurate simulation model can greatly improve the flight performance of the aircraft and the design of complex controller. And great progress has been made in the field of quadrotor control research. For example, in some recent studies, the quadrotor dynamics was approximated as a linear system[1-3]; a standard linear controller (such as proportion integration (PI) and proportion integration differentiation (PID) controller) was designed[4-5]; a PID controller was used to set up a quadrotor fixed-point flight. At present, the simulation researches of quadrotor UAV system are mainly focused on adopting corresponding mathematical equation to build the simulation model, but such mathematical modeling method makes it difficult to accurately describe some characteristics of the research object or application environment, so it is often approximated or neglected in the modeling process, resulting in the divergence between the model and the actual situation.

Simscape from Mathworks is a multidisciplinary comprehensive modeling and simulation platform based on physical models, which can provide a variety of modular components for joint simulation in many fields such as mechanics, electronics, control and hydraulics. In this paper, a three-dimensional structure model of the quadrotor aircraft was constructed by using Simscape platform, and a cascade PID controller was designed to conduct the more accurate simulation of modeling and control system of the quadrotor aircraft.

1 Dynamic modeling analysis

Since the quadrotor UAV is a nonlinear strongly-coupling control system, the following assumptions are often made to faciliate the quadrotor modeling:

1) The quadrotor has rigid body;

2) Mass and moment of inertia are constant;

3) The geometric center is consistent with the center of gravity;

4) The aircraft body has symmetrical structure and uniform mass distribution;

5) The air drag on the body is not factored in when the aircraft is flying at low speed and altitude[6];

6) The quadrotor is only subject to gravity and propeller pull, with the gravity in the right direction along theOeZeaxis and the propeller pull in the negative direction along theObZbaxis as in Fig.1[7].

First, define the reference frame for the studied quadrotor rotor as shown in Fig.1.

Fig.1 Definition of coordinate system

The attitude of the UAV is exhibited in the following rotation transformation matrix, from the body coordinate system to the inertial coordinate system.

(1)

whereθis the pitch angle,φis the roll angle andψis the yaw angle. If the rate of angular motion isωb=[pqr]Τ, the relationship between the attitude change rate and the angular velocity of the body is represented as

(2)

The resultant forceFof UAV is subjected to gravity and lift in inertial coordinate system as

(3)

(4)

Taking the cross-shaped layout as an example, the torque produced by the propeller is present as

(5)

wherelis the distance between the centroid of the UAV and the generator rotor shaft,Miis reactive torque. When the rotor rotates, torqueMgis generated due to the gyro effect as

(6)

whereωi=[0 0 (-1)i+1Ωi]Ωi(i=1,2,3,4) is the speed of the four rotors,Iris the moment of inertia of the rotor module. The gyro effect is zero when the body is in static state. The external torque received by the UAV can be defined as

(7)

Given the assumption that the mass center of the UAV is located in the center of the body, the body inertia matrixIof the UAV is expressed as

(8)

whereIx,IyandIzare the moment of inertia in the corresponding axis respectively. According to Euler equation of rigid body motion, the rotation moment equilibrium equation of rigid body in body coordinate system can be obtained as

(9)

From Eqs.(7) and (9), it is easy to get the following expression

(10)

2 Modeling of quadrotor UAV based on Simscape

In the development process of a big project where different teams work together, teams conduct the development in turn. Using Simscape can quickly create and emulate physical system models in a Simulink environment, helping to develop control systems and test system-level performance. The physical modeling is based on the structure of the system itself, and the physical models are stacked to build the model. There is no need to establish a dynamic model of the system through mathematical derivation, which accelerates and simplifies the modeling process of the dynamic system to a great extent (for example, the quadrotor design simplifies the modeling process of the motor, propeller propulsion system, etc.). The three-dimensional model drawn by CAD software automatically generates the physical model of mechanical system. In addition, when the design changes, the possibility of introducing errors is greatly reduced compared with the traditional mathematical modeling and derivation.

Taking the DJI F450 quadrotor UAV model drawn by Solidworks software as an example, it is shown in Fig.2.

Fig.2 CAD model introduction

By converting the model to an XML-formatted document and introducing the Simscape multibody physical modeling tool, the resultant model has the same physical properties (including size, position, moment of inertia) as the model in CAD. This is a very convenient way to build a project, which can facilitate the modeling and simulation analysis of the system straightforward and skip the calculation of the relevant information and parameters (such as quality, size, moment of inertia, etc.).

The environment model of the UAV is established by taking the world coordinate system as the reference coordinate system, defining the physical properties of the UVA (i.e. the gravity that the UAV bears), and simulating the physical ground, obstacles, as well as starting and ending points. The position, attitude angle and angular velocity of the UAV can be detected by adding six degrees of freedom (DOF) of quadrotor UAV based on 6-DOF hinge unit in the environment. The environment model is set up as shown in Fig.3.

Quadrotor motion requires the rotation of the propeller to provide lift, so the propeller lift module is defined as shown in Fig.4.

Fig.3 UAV environment model

Fig.4 Lift module

The motors provide input control of the quadrotor motion. As shown in Fig.5, the model includes signal-voltage module, voltage pulse-width modulation (PWM) module, H-bridge module and direct current (DC) motor module. Four electronic speed controllers (ESCs) adjust speed of the four motors according to the input PWM signal. The signal-voltage module converts the input signal into a voltage. The voltage-PWM module produces a PWM signal, and it is input as a voltage to determine the working period of the PWM signal driving the motor. The H-bridge module rotates the two motors clockwise, while the other two motors counter-clockwise.

Fig.5 Motor mode

3 Analysis and design of controller

Attitude control is the core of UAV system control and the premise of position control, and the control results directly affect the whole flight quality. In this paper, a cascade PID control system is adopted, with attitude angle control as the outer loop of the system and attitude angular velocity control as the inner loop of the system, so as to design the corresponding cascade controller. At the same time, the adoption of the throttle control makes the UAV reach the desired height. There is no coupling relationship between altitude control and yaw angle, and a channel control can be formed independently. The height control is based on simple proportional and derivative (PD). As shown in Fig.6, the four control channels of UAV pitch, roll, yaw and throttle are allocated according to the corresponding relationship. By inputting the desired attitude angle and height, the PWM signal is output to control the motors.

Fig.6 Throttle and attitude controller

The position controller is based on PID as shown in Fig.7. The desired pitch angle is obtained from the position difference withXaxis, and the desired roll angle is obtained from the position difference withYaxis.

Fig.7 Horizontal position controller

4 Simulation experiment

A UAV simulation module is built using Matlab/Simulink, as shown in Fig.8.

The simulation module of UAV mainly includes position controller, throttle, balance controller, motor, dynamic controller and quadrotor dynamics.

Fig.8 UAV simulation module

The main parameters of the UAV are shown in Table 1.

Table 1 Parameters of UAV

A fixed-point flight simulation experiment is carried out, and the target position is set as [1 1 1]T, its initial position is [0 0 0]Τ, the initial angular velocity is [0 0 0]Τ, the initial Euler angle is [0 0 0]Τ, and the initial linear velocity is [0 0 0]Τ. By continuously adjusting the PID parameters, the aircraft is controlled to fly from the original point to the target position and hover stably.

The response curves of Matlab/Simulink simulation platform are shown in Figs.9-10. The position response curve is shown in Fig.9 (response curve of absolute-value output inZaxis direction position is taken to facilitate observation and comparison), and the Euler angle response curve is shown in Fig.10.

Fig.9 Response curve of dynamic modeling position

Fig.10 Response curve of dynamic modeling Euler angle

As shown in Fig.11, a simple animation simulation can also be performed in Simscape, where UAVs can reach the specified location quickly.

Fig.11 Dynamic modeling animation simulation

5 Simulation results and analysis

In Simscape, a controller is designed to stabilize flight and track the device. The controller sets the target position and distributes the output of the throttle, roll, pitch and yaw channels to obtain the control signals of the four motors, and the motor model converts the control signal to the motor speed. Each controller consists of a proportional unit, an integrating unit and a differential unit. The PID module available in the Simulink is used, because each PID module is related to the PID tuner and can specify the required response time and the desired transient behaviour. PID parameter adjustment is obtained by setting parameters directly in the PID module[8-9]and using trial and error method. The parameters of PID controller are adjusted by PID regulator, and the linearized dynamic model of quadrotor UAV is obtained.

There is a motor model for the quadrotor UAV, so the UAV model is a nonlinear model and cannot be linearized directly. That’s why a new model is defined to match the nonlinear physical model. In the new model, the PID module is adjusted; the input and output data are attained through simulation without noise and filtering compared with the actual input and output data[10]; the step signal parameters are set; and the response curve is obtained by simulation. In the simulation process, the output of PID controller is taken as the input of the controlled object, and the input of PID controller is taken as the output of the controlled object. As shown in Fig.12, the model is linearized into a second-order system with zero by identification. The response curve of line 1 is directly obtained by simulation data, and the response curve of line 2 is linearized by PID regulator.

Fig.12 Linearization model of PID regulator

PID parameters are automatically adjusted and matched,and after the automatic adjustment, the matching degree is as high as 99.99%. The resultant response curve almost overlaps, as shown in Fig.13.

The animation results are obtained by simulation to verify the adjustment effect of the control regulator intuitively. And taking the response curve in Simulatoin Data Inspector as a reference, the satisfactory response effect can be obtained through repeated debugging.

In addition, the effect of PID regulator is verified by the comparison between the step response curve of the regulator’s linearization model and that of the regulator’s nonlinear physical model. As shown in Fig.14, the linearized model has a high matching degree with the nonlinear physical model, and the error of response curve is less than ±0.02 m. This adjustment process greatly simplifies the adjustment of PID parameters.

Fig.13 Automatic matching response curve

Fig.14 Response curve error of linear model and nonlinear model

The response curve of the target position of [1 1 1]Tis also obtained by parameter adjustment. The position response curve based on Simscape Multibody modeling is shown in Fig.15, and the Euler angle response curve is shown in Fig.16. Both can reach the target position in a short period of time, with similarly stable attitude effect.

Fig.15 Response curve of physical modeling position

Fig.16 Response curve of physical modeling Euler angle

6 Conclusion

In this paper, a dynamics model of UAV was established by physical modeling and mathematical derivation. Through the comparison of modeling process, it is found that the whole modeling process is simplified by using Simscape Multibody. The physical model is more compatible with the real UAV, and there is no need to make some assumptions to simplify the physical model like mathematical derivation modeling. The PID parameters adjusted in the simulation model can be directly applied to UAV, further reducing the difficulty of hardware parameter adjustment.