Quadrotor Flight Control Computer Part 2: Dynamics Simulation, PD Tuning, and Ground Tests
This is the second part of my B.S. thesis at Seoul National University, Design of Quadrotor UAV Flight Control Computer and Control System (December 2014, advisor: Youdan Kim; mentor: Yongjun Seo). Part 1 covered the flight control computer (FCC) hardware. This part covers the quadrotor dynamics simulation, the controller, and the tests on the real quadrotor.
Quadrotor dynamics modeling and controller simulation
Before designing the quadrotor controller on the flight control computer, it is necessary to see how the quadrotor model responds to motor inputs through dynamics modeling and simulation, and to design the controller from that. This is done by simulating the quadrotor dynamics and giving it virtual control inputs. I used MathWorks Simulink for the quadrotor dynamics simulation, and the dynamics equations followed the references [2, 3]. In the microcontroller simulation in Part 1, I generated the signals that correspond to the quadrotor’s motor outputs. The Simulink dynamics simulation receives them and shows how the quadrotor responds to the motor outputs. The two simulations communicate through a virtual serial port, which exchanges data between them.
The Simulink model has three main parts: serial communication, the motor system model, and the quadrotor six-degree-of-freedom model. The serial communication part receives and processes the serial data sent from Proteus 8. The motor system part calculates the thrust and torque from the motor speed, which it receives from the serial communication part. The six-degree-of-freedom dynamics part takes the thrust and moments calculated in the body frame and calculates the velocity, Euler angles, and other states with respect to the ground frame. Since the quadrotor airframe had not been selected yet, I set the physical properties and parameters at reasonable values to observe the trends. Because the properties were chosen arbitrarily, the motor speed used in the calculation has no exact physical meaning. I only adjusted the properties so that the quadrotor hovers when all four motors are given 50.
Building the quadrotor and mounting the flight control computer
I mounted the flight control computer on a quadrotor. The airframe and its specifications are as follows.
| Item | Specification |
|---|---|
| Weight | 614 g (without electronics) |
| Width | 585 mm |
| Motor bolt holes | 16/19/25 mm |
| Layout | X or + landing gear setup |
| Motors | 28-XX or 35-XX brushless outrunner × 4 |
| ESCs | 18–30 A brushless ESC × 4 |
| Propellers | 8×4 to 10×4.7 × 4 (2 standard, 2 reverse rotation) |
| Battery | 2200–3000 mAh 11.1 V LiPo |
| Radio | 4-channel transmitter and receiver |
Table 1. Specification of the quadrotor.
The quadrotor with the flight control computer developed in this study is shown below. To prevent accidents while designing the controller, I built a stand that holds the quadrotor on the ground so the controller can be designed there. The bottom of the quadrotor is fixed to the stand with a ball joint, so it has only roll, pitch, and yaw freedom. On the stand, the quadrotor can move between −30° and +30° in roll and pitch, and through the full range of −180° to +180° in yaw.
The controller blocks programmed on the flight control computer are shown below. Because the controller was built from blocks in Simulink, it could be loaded onto the flight control computer easily, following the earlier steps.
I tuned the controller with the quadrotor carrying the developed flight control computer. A PD controller was used, one each for roll, pitch, and yaw, and suitable gains were found by trial and error. First, with the D gain set to 0, I raised the P gain to find a suitable value: the P gain at which the quadrotor oscillates with a constant period. Then I raised the D gain from 0 little by little until the system was damped. The PD gains found this way for roll and pitch are shown below.
I tuned yaw in the same way, after roll and pitch were stable. The PD gains for yaw were set as shown below.
Simulation results
Open-loop response
The following results come from giving the microcontroller transmitter inputs that set two of the four motors to a speed of 60 and the other two to 55, and running the dynamics model on the motor signals received in Simulink. The transmitter inputs were PWM step inputs with duty ratios of 60 and 55, applied to the general-purpose input pins of the microcontroller at the start of the simulation, and they reached the Simulink model through serial communication as step inputs of the same size.
In the simulation, the pitch angle decreased from 0 to 3 seconds, and at the same time a displacement in the positive x direction appeared. This matches the empirical fact that when the output of the two motors opposite the nose is increased symmetrically, the quadrotor tilts toward the nose and moves forward. Around 3 seconds, however, the pitch angle reached $-\pi/2$ and the vehicle quickly became unstable. At the same time a large displacement in the positive z direction appeared, which means the quadrotor was moving in the direction of gravity: it could not control its attitude and was falling. A controller is therefore needed for attitude control.
PID controller in simulation
To stabilize the attitude of the dynamics model above, I designed a simple PID controller that controls roll and pitch separately [4]. The controller block and the PID gains are shown below.
In an ideal quadrotor model, roll and pitch have the same transfer function. A step input of $\pi/8$ on the roll angle showed that the controller works well on the developed dynamics model.
A flight simulator with a game controller
The simulator above ran the quadrotor dynamics in MATLAB Simulink with step inputs as the control inputs, and I looked at the transient response to them. For more intuitive controller tuning, however, it is necessary to see how the quadrotor responds to arbitrary inputs from a real user.
So instead of step inputs, I set up a way to take user inputs in real time from a game controller, similar to flying a real quadrotor. I also used Simulink Animation Blocks to show the attitude and thrust of the quadrotor visually. The game controller was an InterLink ELITE, connected to the PC as shown below.
As shown above, the 3D model of the quadrotor changed with the game controller input. The top images show the change in thrust with the throttle stick, and the bottom images show the change in roll with the aileron input. Once the physical properties of the commercial quadrotor are measured and suitable control parameters are chosen, a more intuitive quadrotor simulation should be possible.
The Simulink model of the simulator is shown below. It has three main parts: a virtual transmitter block that uses the game controller, a controller block that takes the control inputs from the transmitter and the attitude feedback, and a quadrotor plant block that calculates the attitude from the control inputs. I added the virtual transmitter block and the 3D animation block to the simulator I had built before.
The transmitter block converts the game controller signals to values between 0 and 1. The signals changed linearly with the joystick input, so I normalized them by their maximum and minimum values.
The 3D animation block takes the attitude and thrust from the quadrotor plant and shows them visually.
Testing the flight control computer
After mounting the flight control computer on the quadrotor and finishing the controller tuning, I applied a step input to the quadrotor. Before the step input, the propeller thrust control kept the pitch angle of the quadrotor at 0. The step input was applied at about 9 seconds, and the pitch angle changed in response.
After the step input, the quadrotor did not recover its attitude and stayed at +30°. The derivative term of the PD controller overreacted to the sudden change of the step input and drove the motors too hard, so the quadrotor moved quickly and hit the angle limit of the stand. This needs further work, and a stand with a wider angle range should solve it. The step from +30° back to 0° converged to 0 without steady-state error.
Conclusion and future work
I built a flight control computer and a controller for a quadrotor and mounted them on a quadrotor to check the performance of the flight control computer. The flight control computer and the controller controlled the attitude of the quadrotor stably. The response to the unit step input was somewhat unstable, which can be fixed by modifying the controller blocks. Because the controller on this flight control computer is designed directly in Simulink, various advanced control methods can be applied easily, and future work will study and apply them. I will also take the quadrotor off the stand and look at its response in real flight tests.
In addition, I plan to measure the physical properties and parameters used in the simulation through system identification of the frame, motors, and propellers, and to improve the dynamics model with them. This will make it possible to predict the performance of a controller before designing it on the flight control computer.
References
- 1. Lee, I. (2010). AVR ATmega128 Microcontroller: From Basics to Device Control (with the WinAVR compiler). Seoul: Hongneung Science. (in Korean)
- 2. Stevens, B. L., & Lewis, F. L. (2003). Aircraft Control and Simulation (Vol. 2). New York: Wiley.
- 3. Sanca, A. S., Alsina, P. J., & Cerqueira, J. de J. F. (2008). Dynamic modelling of a quadrotor aerial vehicle with nonlinear inputs. In Robotic Symposium, 2008. LARS'08. IEEE Latin American (pp. 143–148).
- 4. Junior, J. C. V., De Paula, J. C., Leandro, G. V., & Bonfim, M. C. (2013). Stability control of a quad-rotor using a PID controller. Brazilian Journal of Instrumentation and Control, 1, 15–20.