PID controllers for Roll, Pitch, and Yaw are designed and error .... design and implementation of the Ch. The Roll ....
Modeling, Simulation and Implementation of a Quadrotor Farshid Jafari Harandi, Harandi Vahid Khorani, orani, and Alireza Mohammad Shahri
Abstract—In this paper design and implementation of a Quadrotor flying robot named ‘Charotor’ is presented. Based on a developed dynamic amic model in MATLAB Simulink, three PID controllers for Roll, Pitch, and Yaw are designed by trial and error procedures. These PID controllers are simulated and implemented in the real Quadrotor. To validate the simulation and experimental results the pitch ch PID controller performance is examined whilee a disturbance is inserted to the Quadrotor.
eal implementation, Keywords: Quadrotor rotorcraft, Real dynamic modeling, MATLAB model, PID controller. I. INTRODUCTION
F
LYING machines are one of the most complex systems in case of design and control. Development of autonomous flight control for such machines has always been into researchers` center of attention. In smaller-size smaller applications, Vertical Take Off and Landing, VTOL, can provide more flexibility in autonomous flight compared to Conventional Take Off and Landing, CTOL. A Quadrotor flying machine as a VTOL machine uses less number of complex mechanical parts compared to a simple tail rotor helicopter, simplifying its design procedure. Quadrotor concept is not new in flying machines. machines One of the very first VTOL machines was a real-size size Quadrotor built by Frenchman Etienne Oehmichen in 1924 flying for 360 meters [1]. In recent years, Quadrotors became in researchers focus as a reliable platform for Unmanned Air Vehicles, UAVs. One of the earliest examples of such projects is Mesicopter, a micro scale Quadrotor at the scale of a tip of a finger developed in Stanford University starting on 1998[2]. In this project feasibility of a small autonomous flying robot is investigated and technologies and scaling limits are explored. A swarm of Mesicopters Mesicopter are intended to be used for atmosphere exploration. However, most of the researchers keep their focus on modelss with rotor to rotor size of 0.4 to 1 meter. OS4 by S. Bouabdallah et. al. is developed as a PhD thesis in EPFL university [3]. In this thesis dynamic d modeling is used and non-linear linear control techniques are applied on both the model and the actual robot built. Detailed information
Farshid Jafari Harandi is a Master of Science ience student in Mechatronics program at ECE department of Azad University of Qazvin, Qazvin, Iran (email:
[email protected]). Vahid Khorani is a Master of Science ience student in Mechatronics program at ECE department of Azad University of Qazvin, Qazvin, Iran (e-mail:
[email protected]). Alireza Mohammad Shahri, PhD, is ann assistant professor at Electrical Engineering department of Iran University of Science and Technology, IUST, Tehran, Iran (e-mail:
[email protected]).
are presented in order to elaborate the design procedure and highlight main concerns in building a Quadrotor and importance of component selection. selection STARMAC project from Stanford University exports the use of GPS and Microstrain [4] IMUs on a group of Quadrotors flying as multiagent flying robots [5].. In another project by Erdinç Erdi Altug et. al. trajectory control of a Quadrotor with the aid of two cameras for position feedback, feed one pan/tilt/zoom camera on a ground station and another pan/tilt camera onboard is presented [6]. In his work Backstepping controller and feedback linearizing are used in simulation and on the actual robot. The developed flying robot ‘Charotor’ in this paper which is shown hown in figure 1 can hover and follow the commands given to its remote control.. In order to control the Charotor an IMU including a three dimensional accelerometer and three gyroscopes are applied as feedback sensors for the Roll, Pitch, and Yaw PID controllers. Xbee wireless communication moduless with 1 KM ran range are used on-board to communicate with the ground PC station for real-time telemetry. Flight light control results and attitude estimation presented here are all gathered with the aid of this communication possibility.
Fig. 1. Charotor, the developed develo Quadrotor
There are a few challenges behind the design process of a Quadrotor. uadrotor. This paper addresses practical issues in the design process, modeling, and controller design for such a robot. The dynamic model of the Quadrotor which is developed in MATLAB Simulink is presented in the following section. Section III is dedicated to the simulation process while in section IV some practical issues in the design and implementation of the Charotor Ch are addressed. The Roll, Pitch, and Yaw PID controllers design and its implementation results are addressed in section V and VI.
Finally the paper is concluded in section VII. II. DYNAMIC MODELING In the process of designing a controller for a system it is of vital importance to develop a model for that system so the behavior of the system can be experimented artificially. In flying machines, and Quadrotors in this case, modeling can save time and money. A free fall from 10 meters high due to a control failure can impose permanent damage on the frame, propellers, or motors on a real machine. Modeling of a helicopter is not an easy task. As John Watkinson puts it "A helicopter is a collection of vibrations held together by differential equations". The first step of making a model is to model the dynamics of a Quadrotor [7]. By using E-frame for earth fixed frame and B-frame for body fixed frame the two frames which are used in dynamic modeling can be presented as figure 2 [8].
Fig. 2. Body Frame and Earth Frame
A. Kinematics Here dynamic modeling of a Quadrotor is studied. Equation below describes the kinematics of a generic 6-DOF rigid body [8]: (1)
Where and are the generalized velocity vectors with respect to E-frame and B-frame respectively and is the generalized matrix. is composed of 4 sub-matrices: 0
(2)
0
Where and are the rotation and transfer matrices defined as: (3) 1 0 0 /
/
) +, * -" #$% ' ' $% $%( ) + * , ) ." / #' '( +, * > (5) 56 8) 0 12 34 37 +9 122 122 56 8) 3 1: 04 1 07 1 +
:: :: 4 1 03 < + ; 1;; = Where !, - and . are axes of the E-frame and 7 is the propellers’ speed vector and +, is the vertical force and +9 , + and += are the torques generated by propellers. +, 7,9 799 7 9 7=9 9 9 +9 79 7= 9 9 > (6) + 7, 7
9 9 9 9 +, 7, 79 7 7= 7 7, 79 7 7= expressed as [8]:
(4)
Where , and represent Euler angles (Roll, Pitch, and Yaw respectively). B. Kinetics A new frame named H-frame which is a hybrid frame composed of E-frame and B-frame is used for the kinetic equations. By using kinematic equations and Newton-Euler formulation, the kinetic equations in H-frame can be
!" #$% $% ' $% '(
Where 7? for % 1,2,3,4 indicate the propellers` speed. Combination of BLDC motors and Electronic Speed Controllers on the real Quadrotor are estimated and modeled using DC motor equations: K E KF < 9 KF (7) 7? 7? 7? 56 56 56 ? Where ? for % 1,2,3,4 indicates the motor input voltages. List of the values used as model parameters are listed in TABLE I. By selecting parameters similar to the real Quadrotor it has been tried to make a realistic model. TABLE I PARAMETERS OF THE MODELED QUADROTOR Symbol
Quantity
b
trust factor
d
drag factor
m
122 1:: 1;; l 56 OP
OT
mass of the Quadrotor body moment of inertia around the x-axis body moment of inertia around the y-axis body moment of inertia around the z-axis distance between the center of the Quadrotor and the center of a propeller total rotational moment of inertia around the propeller (motor) axis electric motor constant mechanic motor constant
R
motor resistance
g
acceleration due to gravity
value
11 10GH #I 9 (
1.1 10GH #I* 9 ( 1.3 #K/(
8.1 10G #I* 9 ( 8.1 10G #I* 9 (
14.2 10G #I* 9 ( 0.27 #*(
7.33 10GN #I* 9 ( 6.3 10G #R 4S< G, ( 6.3 10G #I * UG, ( 0.6 #7(
9.81 #* G9 (
III. SIMULATION In this section results of simulations done on the dynamic model introduced in section II are presented. Implementation of the model is done in MATLAB Simulink. Wind is modeled as a Gaussian distributed force by zero means value which is applied to Quadrotor in the direction of each axis. The wind variations by height are not accounted for in this simulation. Figure 3 illustrates block diagram of the PID controller used.
Fig. 3. Block diagram of the PD controller used
For testing the model two tests are done. First, a disturbance on pitch axis is simulated and second, a trajectory is given to the Quadrotor to follow.
bring the pitch angle back to zero. In this process rear motor and front motor’s output will change to compensate this disturbance. In figure 4 the rear motor control effort is shown. Speed of this motor is increased to compensate the increase in the angle where left and right motors` control efforts remain unchanged. B. Trajectory tracking Controller of the Quadrotor in trajectory control uses position and attitude of the robot as feed-back parameters to follow the given path. Apart from attitude controller, three PD controllers are also used for position control in X, Y, and Z axes. A given trajectory is used for simulating the behavior of the Quadrotor in path tracking. The given path, shown in figure 5, is similar to circumference of a rectangle where at the end there is a 1 meter height increase with the robot continuing its way to the center of the rectangle afterwards. Figure 5 represents the reference path and robot’s performance.
A. Hovering control Hovering control of the Quadrotor uses attitude displacement of the robot as feed-back parameters. Attitude is controlled by three separate PD controllers to guarantee hovering of the robot in the Pitch, Roll, and Yaw axis.
Fig. 5. Refrence and results of a 3-D trajectory given to the simulated Quadrotor
In this trajectory Quadrotor must move by a fixed speed of 1 */ on the whole path without stopping at any point of the given path.
Fig. 4. An initial force of 2 (N.m) applied to the Pitch angle of the simulated model (top) and the corresponding motor control effort output (bottom)
Effects of 2 #I. *( disturbance applied on the pitch angle is studied. As results in show figure 4, Pitch angle changes to 1.5° and it takes 2 seconds for the Pitch PD controller to
Fig. 6. results of the same trajectory as in figure 4 shown for Pitch, Roll, and Yaw angles and the trajectory itself in 2-D view
As figure 6 shows, simulated Quadrotor performs required Roll and Pitch changes to move forward, turn, and follow the given trajectory with satisfactory results. To prevent position divergence Pitch and Roll angles are kept around zero by the PD controller. IV. BUILDING THE QUADROTOR Building a flying machine, it is of outmost importance to select the best possible components which match each other to provide the best possible performance. These parts can be generally divided into mechanical and electrical components. A. Mechanical components Body is made out of Fiber Carbon, one of the lightest and strongest materials, reinforced by Balsa wooden dowels. Carbon fiber has greater strength to weight ratio compared to Aluminum or Plastic. Tractor and Pusher APC 10x4.7 propellers are selected as the strongest and most balanced propellers available commercially. These propellers are carefully made out of glass-filled nylon and can survive crashes. Four KDA20-22L BLDC motors with 924 RPM/V spin the propellers. These motors provide high efficiency at low-price. B. Electrical components Set of an MMA7260Q (a 3-axis accelerometer) and 3 x LISY300AL gyros is used for pose estimation. In selection of sensors, availability was the key factor while there were better sensors to be used with higher resolution, bandwidth, and resonant frequency like ADXL335 accelerometer and IDG500/ISZ500 Gyros. An Arduino Duemlianove board [9] which uses an Atmel AVR at 16MHz is used as the controller linking the input sensors to the motors driven by Turnigy Plush 25A BLDC drivers. Remote commands are received by a 6-Channel RC remote control as standard PPM signals. Bidirectional data transfer and telemetry is made possible with the aid of an onboard 60mW Digi Xbee communication module and another module at the ground station. C. Pose estimation Robot's attitude is determined using the sensor outputs fed to a second order complementary filter [10]. This filter accepts gyroscopic sensors as inputs and compensates their drift with the angle read from the accelerometer. This filter maintains good performance with minimum processing usage. Therefore it can run in real-time on an 8-bit microcontroller. Figure 7 shows the performance of this filter while the real Quadrotor is tilted around its Pitch axis from -40 to +40 degrees.
Fig. 7. Output of the second order complementary filter (A) with a rotation around pitch from -40 to +40 calculated based on input sensors (B)
D. Controller software Controller board software is composed of periodic tasks executing at certain intervals while interrupts are exported to minimize processor time needed on reading inputs. Main loop, shown in diagram 1, utilizes 70% of processor time. Serial telemetry
Read remote control
10/200Hz
10 Hz
Update motor speeds
Read input sensors 500 Hz
500 Hz
PID Controllers
Atitude estimation
500 Hz
500 Hz
Dia. 1. Main loop on the Quadrotor controller software
V. CONTROLLER DESIGN A. PID controller Simple discrete PID controllers for each axis of the robot are used for attitude control. As shown in Figure 8 each controller accepts target position and current position as inputs and outputs the corresponding axis command.
Fig. 8. Separate discrete PID controllers for each axis
The motor output for each axis is later calculated using the output given from the corresponding controller and the received throttle signal from the remote control as below: Y4'%Z''4 [4'8\ '88]'**S%< – -S_]'**S%< \S4Z''4 [4'8\ `$[]'**S%< – -S_]'**S%< $/[Z''4 [4'8\ – '88]'**S%< -S_]'**S%< a\bZ''4 [4'8\ '88]'**S%< -S_]'**S%