Recent Innovations in Mechatronics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/riim.2016.1-2/7. Aspects Regarding Fly Control of Quadcopter Endrowednes Kuantama Engineering Doctoral School University of Oradea 1 Universităţii St., Oradea, Romania endrowedne[email protected]m Ioan Tarca1, Radu Tarca2, Dan Craciun3 Mechatronics Department University of Oradea 1 Universităţii St., Oradea, Romania
[email protected],
[email protected],
[email protected] Abstract—Quadcopter is one of Unmanned Aerial Vehicle (UAV) which has two pairs of identical fixed pitched rotor propellers. It can fly autonomously based on pre-programmed flight or manually controlled by a remote, and every movement achieved by varying the speed of each rotor independently. The orientation of quadcopter axes relative to a reference line and its direction of motion are known as attitude. Fly control factors are affected by attitude determination which can be calculated from 3 possible angles using combined measurement. Gyroscope and accelerometer are primary sensors to control quadcopter attitude, but magnetometer sensor and GPS also used to enhance the stability during flight. This paper will focus on details of function and mathematical formula of every factor regarding fly control and comparative data of 2 types of orientation sensor used in this system. Keywords—quadcopter; attitude; gyroscope; fly control; orientation sensor I. INTRODUCTION Quadcopter is classified as Unmanned Aerial Vehicle which is lifted by 4 rotors, as its name suggest. Its movement can be directed by controlling the angular speed of each rotor. The rotors are connected with the propellers, and the each pair of opposed similar propeller are rotating in the same direction (two clockwise and two counterclockwise). The most important aspects needed to be considered when designing quadcopter are related to its flight stability: what factors are affecting it and how they influence the stability. Main topics regarding quadcopters are related to their attitude; mathematical formulas and flight control aim to control their attitude. Attitude is a position of the body (inertial frame) or the orientation of quadcopter axes relative to a reference line and its direction of motion. Quadcopter attitude can be measured using MEMS (Micro Electro Mechanical System) sensor. This sensor cannot accomplish same accuracy as Kalman filter or complementary fusion algorithms which are used to provide more accurate and reliable information in the MEMS attitude determination systems [1]. Sensor system is a fundamental part of UAV, including quadcopter, having their role in calculating accurate attitude by measuring three angles, using combined measurements such as the gyroscope/gyro rate, accelerometer and magnetometer [2]. These sensors measure three-axis angular rates, three-axis apparent acceleration, and Earth’s magnetic field with respect to the quadcopter’s body frame. In order to achieve the best evaluation of attitude angles from these sensors, it is essential to fuse these measurements in a seamless manner while considering the difference between each sensor’s signal specifications. It is possible to use a rate gyro to obtain attitudes, by integrating the rigid body's kinematic equations, while accelerometers provide gravity direction. With high quality gyroscope and appropriate initial values, these assessments can be very accurate over long periods of time. On the other hand, accelerometers signals present direct values of tilt angles [3]. When quadcopter shifts from one position to the other, the wing on respective side will slant slightly in the moving direction as seen on Fig.1. The resulted angle is an important factor in determining the quadcopter stability. Each movement’s angle has to be continuously monitored by the orientation sensor until the stability is achieved. With the flight control sensors' help, quadcopter will adjust its position accordingly, even in the case of natural disturbances or propeller airflow. These aspects reveal the importance of quadcopter flight control. Fig. 1. Illustration of attitude quadcopter movement II. ATTITUDE PARAMETERIZATION AND REPRESENTATION Proper estimation of attitude angles and position of quadcopter are the most important factor in flight control navigation. Determination of flight attitude also involves the computation of quadcopter’s pitch angle, roll angle, and heading angle. Both pitch angle and roll angle can be computed by measuring accelerations and body rates from accelerometers and rate gyros, while heading angle can be measured by calculating the magnetic heading. Having known the acceleration on three axes (pitch, roll, and yaw rate information), the pitch and roll angles can also be determined either by computing the gravitational acceleration components
Recent Innovations in Mechatronics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/riim.2016.1-2/7. on the body axes, or by using the Euler quaternion method. The latter method, however, provides low noise contents and fast response to changes in the input signals, but tends to drift with time due to gyro bias errors [4]. The absolute linear position of the quadcopter is defined in the inertial frame x, y, z axes with Euler (£). The attitude is defined in the inertial frame with three Euler angles: Pitch angle (θ) determines the rotation of the quadcopter around the y-axis, while Roll angle (ɸ) around the x-axis and Yaw angle (ψ) around z-axis. Using concept of kinematic moving frame, quadcopter movement from initial position to desired position can be calculated as seen on Fig. 2. Fig. 2. Illustration of quadcopter orientation The Euler formula (1) can be used to calculate the rotation of the quadcopter frame throughout each axis as well as the matrix multiplication result of Rroll, Rpitch, Ryaw: (1) Where symbol ‘s’ represent sine and ‘c’ represent cosine. To get the desired quadcopter movement (based on each movement angle), the angular movement of every rotor must generate appropriate thrust. The thrust movement in (2) is produced by each rotor through the torque applied by rotor which driven by electronic speed controllers. The rotor speed is ωi and the lift constant of quadcopter is b that depends on the air density around propeller. (2) Fly control, especially the attitude measurement sensor, holds an essential part to monitor every attitude and orientation of quadcopter in order for it to fly stable even through disturbance. III. QUADCOPTER FLY CONTROL MEASUREMENT In terms of quadcopter attitude, orientation and movement position have to be monitored continuously using orientation measurement such as accelerometer and gyroscope sensor. Accelerometer is used to measure acceleration from quadcopter movement, whereas gyroscope is used to measure the angular rate as seen in diagram block on Fig. 3. Magnetometer and GPS as position sensors are used to improve the accuracy of rotation and position of quadcopter. By using these sensors, one can precisely evaluate quadcopter speed, position and orientation and help stabilizing quadcopter movement. Fig. 3. Quadcopter flight control unit Accelerometer and gyroscope as orientation sensors are called strap down system in which the inertial sensors are directly attached to the vehicle frame. These sensors function as the full dynamic motion of the vehicle. The relationship between the body-fixed frame and the navigational frame must be maintained computationally on board. A. Quadcopter attitude estimation based on Accelerometer Acceleration is the rate of velocity change with time or the rate of change of distance with squared time. To determine specific acceleration, an accelerometer is used. As a measure sensor, accelerometer can calculate the difference between vehicle’s acceleration and gravity acceleration. To be able to determine three-dimensional acceleration vector, acceleration can be calculated based on Newton’s second law of motion which relates force (F), mass (m), and acceleration (a). Accelerometer is going to be used in inertial navigation; therefore, acceleration with respect to the inertial frame is needed. The output of accelerometer is measurement of the difference between the actual vehicle acceleration (a) and the gravitational acceleration (g) (3) In (3), F is the specific force. It is necessary to know the magnitude and orientation of the gravity vector g with respect to the accelerometer input axis in order to compute the acceleration components from the accelerometer outputs. The output of acceleration on a rigid body is therefore given by (4). (4) Where am is the measured acceleration and Fg is the force due to gravity and Ft is the external force. One can use (4) to calculate the gravitational effect when the external forces equals to zero. It is assumed that the axes of the accelerometer are aligned with the body-frame axes and that the accelerometer has been properly calibrated to remove misalignment errors and cross-axis sensitivity. Y X ψ X X Y Z Z Z Gyroscope Accelerometer Acceleration (m/s2) Angular Rate (rad/s) Navigation Algorithm Attitude (rad) Velocity (m/s) Position (m) Magnetometer & GPS Z’ (c) Pitch movement ψ Y’ X’ (a) Yaw movement Y’ ϕ ϕ Z’ X’ θ θ (b) Roll movement Y )FF( m 1 agtm )ga(F 2 i .bT cccsscssscsc cssssccsccss ssccc Rt
Recent Innovations in Mechatronics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/riim.2016.1-2/7. In the three axis accelerometer, (ax, ay, az) represent the acceleration measured in the body frame axes. In the inertial frame, the force of gravity is in z-axis. Using (4) and the force of gravity, the acceleration in the body frames is given by (5). (5) The symbol Ri represent the rotation matrix from the inertial to the body-fixed reference frame, which come from calculation between Pitch and Roll (Rx, Ry), as in (1). Since the accelerations in stable flight regimes are usually small compared to the gravity acceleration, neglecting the linear acceleration is a classical assumption [5]. Normalizing the vector of acceleration measurements facilitates to express the roll and pitch angles as (6). (6) Where ϕ is the roll angle and θ is the pitch angle relative to the ground. Quadcopters are different from ground vehicles because of the thrust required to keep them airborne. The accelerometers in strap down systems measure the resultant of gravitational and other accelerations acting on the body to which the sensors are attached. The idea of this method is to regard the accelerometers as inclinometers, which provide an absolute reference of the attitude by relating the body orientation to the gravity vector. It is assumed that the body is not moving or is moving at constant speed, so that the acceleration due to the earth’s rotation is negligible and the gravity is the only source of acceleration, also known as Coriolis acceleration [6]. The accelerometers can provide very accurate measurements of attitude, but the accelerometerbased attitude is sensitive to external acceleration and vibration. B. Quadcopter attitude estimation based on gyroscope Gyroscope is the angular rate sensor which is used to measure the rate of rotation around the sensor axis in quadcopter. Theoretically, when integrating the signal from the gyroscope, one can acquire the angular change over a period of time. In Fig. 2 can be seen the illustration of quadcopter’s orientation and position, the reference frame X, Y, and Z is aligned with the principal (main) axis of the body. In strap down systems, gyroscopes measure the angular rates of three axes of the body with respect to the inertial coordinate frame. With these measurements of angular rates in body coordinates, the attitude of the quadcopter can be derived by integrating the rigid body kinematic equations, starting from a known initial attitude at a given point in time. The attitude of a body with respect to the inertial coordinate frame is defined by Euler formula. Examination of small changes in each Euler angle and the effects on the angular vector are based on kinematic moving frames theorem. The continuous time nonlinear rigid body kinematic equation in state space representation is shown in (7) and (8). (7) (8) Where p, q, r are the angular rates measured by gyroscopes in the body coordinate frame. Using this equation, the measurement result from gyro sensor will be compared with desired attitude of quadcopter. C. Quadcopter attitude estimation based on magnetometer Magnetometers are commonly used to measure Earth’s local magnetic field vector thus determine the direction in which magnetic north lies. A 3 axis magnetometer can measure magnetic field intensity in 3 dimensions. These points are referred to as the magnetic poles. Magnetic field lines vary both in strength and direction about the face of the earth. The direction and strength of the earth’s magnetic field (H) can be represented by the three axis values Hx, Hy, and Hz. The Hx and Hy information can be used to determine compass headings in reference to the magnetic poles. The attitude is estimated by two successive quaternion rotations. The first rotation is the one between magnetic field vector measured by the magnetometer in its reference system and the earth’s magnetic field vector estimated by a model. The second rotation is by subtracting the centripetal acceleration from the acceleration measured by the accelerometer [8]. The magnetometer-based attitude determination is widely used for spacecraft as well as quadcopter [9]. In quadcopter, these methods are based on the quaternions attitude representation. The information about roll and pitch angle can be extracted from gravity points which head to the local vertical down direction. The magnetometer is used to measure quadcopter’s magnetic field intensity in 3 dimensions. The declination (δ) and inclination (Ƞ) are modeled and provided by the World Magnetic Model (WMM) of the National Geophysical Data Center (NGDC). From this model, the magnetic vector, which is expressed in local navigation frame, can be known. In addition, the yaw, pitch, and roll angle is determined by the magnetometer measurements. The gravity vector of the earth is always pointing to a local vertical down direction. In contrast, the direction of the magnetic vector of the earth varies with position on the earth. In yaw movement, the direction of the magnetic vector is expressed by the declination and inclination of the local navigation frame in Fig. 4. coscosgcossingsing a a a z y x coscos cossinsin R; g 0 0 R a a a ii z y x coscossecsin0 cossincos0 sin01 r q p 0 0 0 0 R0 0 RR r q p xyx r q p seccossecsin0 sincos0 tancostansin1
Recent Innovations in Mechatronics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/riim.2016.1-2/7. Fig. 4. Magnetic vector of the earth on local navigation frame The magnetometer-based yaw angle in quadcopter is determined with the Earth’s magnetic field. Horizontal direction of the Earth’s magnetic field is pointing toward the magnetic north of the Earth. Magnetic north is deviated from true north. Its deviation is referred as a declination angle and varies with its position on the Earth. The yaw angle determination from the magnetometer measurement is conducted as shown in (9) and (10): (9) (10) Where Hb is the magnetometer measurement vector in body frame and δ is the declination angle of the earth’s magnetic field. The angle ψ can be calculated using the equation above based on illustration in Fig. 4. Obviously, the error of roll and pitch angle affects the accuracy of the determined yaw angle. Therefore, the magnetometer-based yaw aiding method should be applied with a valid roll and pitch angle information. Example for magnetic roll angle determination can be seen in Fig. 5. Fig. 5. Magnetic roll angle determination The heading-down plane and the X, Y, and Z plane are identical, and H represents the projected magnetic vector on this plane. Angle ȠT can be calculated by transforming the magnetic vector from the magnetic field model to the headingdown frame. Angle λ is determined by the magnetometer measurements, which are transformed from the body frame to the X’, Y’, and Z’ frame. Likewise, the roll angle can be determined by subtracting ȠT from λ. This process is given by (11): (11) The accuracy of magnetic vector is limited to about 1o in root mean square by the modeling resolution, variation about time and external disturbances [10]. The magnetic field is easily disturbed by the environment, thus the magnetometer-based attitude method should be applied with an appropriate calibration and disturbance detection. The λ and ȠT angle can be calculated using trigonometry or kinematic moving frame theorem. D. GPS-based attitude GPS holds an important role in attitude estimation because of its long-term accuracy in reading quadcopter’s position and velocity. Large errors in low-cost inertial sensors can be counterbalanced by data updates acquired from GPS. For small scaled rotary-wing aircraft, an attitude estimation method using the velocity measurements with single antenna GPS was proposed; the time lag of the estimated attitude was compensated with the help of measurements from gyroscopes by using the complementary filter [11]. A GPS receiver calculates its position by using a method called Trilateration which is shown in Fig. 5. Many trilateration algorithms have been proposed to determine location accurately. GPS receiver calculates the position, velocity and time based on the data from the GPS Satellite. Fig. 6. Trilateration The 3D multi-lateration uses the following standard equations: (12) Where, (13) From this theory of trilateration, the synthesized attitude is called the pseudo-attitude. It consists of an equivalent roll angle about the velocity vector of the quadcopter, an equivalent pitch angle defined as the horizontal flight path angle and an equivalent yaw angle defined as the vertical flight path angle. Standard equation usage and quaternion for quadcopter are two of the most popular approaches which are used to calculate pseudo attitude. The quaternion and Euler angles are both common representations of the attitude. The quaternion, which represents a rotation about a specific axis, is defined in terms of four parameters in a column vector as seen in (14). (14) One essential constraint of the quaternion in the application is that its norm should be equal to unity. The quaternion units from q1 to q3 are called the vector part of the quaternion, while H δ Ƞ X Y ϕ ȠT H λ Y Z Z’ Y’ GPS receiver (X, Y, Z) D1 D4 D3 D2 (X1, Y1, Z1) (X2, Y2, Z2) (X3, Y3, Z3) (X4, Y4, Z4) X kqjqiqq 310 = ).Z Z2(Z + ).YY - 2(Y + X1).X - 2(X = ).Z Z2(Z + ).YY - 2(Y + X1).X - 2(X = ).Z Z2(Z + ).YY - 2(Y + X1).X - 2(X 14144 13133 12122 )Z-(Z-)Y-(Y-)X-(X - )D - (D )Z-(Z-)Y-(Y-)X-(X - )D - (D )Z-(Z-)Y-(Y-)X-(X - )D - (D 2 4 2 1 2 4 2 1 2 4 2 1 2 4 2 1 2 3 2 1 2 3 2 1 2 3 2 1 2 3 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2 2 2 1 b H cossin0 sincos0 001 cos0sin 010 sin0cos H x y H H arctan
Recent Innovations in Mechatronics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/riim.2016.1-2/7. q0 is the scalar part. The inputs are the angular rates measured by the gyroscopes and the velocity with respect to ground in North-East-Down direction coordinates acquired from the GPS receiver, and the outputs are the estimated roll angle, pitch angle, and yaw angle, computed from the quaternion estimated to the Euler angles can be derived by using: [12] (15) IV. ATTITUDE AND ORIENTATION SENSOR The orientation sensors compared in this research are the GP9 and UM7 sensor. They use their own attitude estimation in conjunction with the onboard accelerometers, in order to measure changes in velocity. These velocity estimates are then compared to velocities reported by the GPS and pressure sensors. Since attitude inaccuracy is a major source of velocity measurement error, it is possible to measure attitude by comparing the accelerometer-based velocity with GPS-based velocity. In Table 1 detail information of GP9 and UM7 AHRS electronic system can be seen. TABLE I. COMPARISON BETWEEN TWO ATTITUDE SENSOR Comparison GP9 UM7 Power consumption < 150mA at 5.0V during GPS seek. < 100mA at 5.0V with GPS lock 50mA at 5.0V Operating temperature -40C to +85C -40 to +85 C Communication 3.3V TTL UART 3.3V TTL UART, SPI bus Rate of measures orientation, velocity, and position 500 Hz 500 Hz Static pitch/roll accuracy +/- 2 degree +/- 2 degree Dynamic pitch/roll accuracy +/- 1 degree +/- 4 degree Static yaw accuracy +/- 5 degree +/- 5 degree Dynamic yaw accuracy +/- 1 degree +/- 8 degree Resolution < 0.01 degrees 0.01 degree Data output rate 0 to 255 Hz, selectable data 0 Hz to 255 Hz (binary packets) 1 Hz to 100 Hz (NMEA packets) It can be concluded that GP9 has higher level of sensitivity for dynamic movement with less power consumption. Data output are in the form of acceleration, angular rates, magnetic field, barometric pressure, GPS altitude, position, velocity, attitude (quaternion, Euler Angle). Both sensor and processing yield excellent gyro bias stability over temperature. Adjustable lowpass filter and Kalman filter settings provide customizable performance for various applications. States and sensor data synchronized to GPS position and velocity using optional external GPS module allows for alignment calibration and third-order bias and scale factor temperature compensation for accelerometers, gyros, and magnetometer. Magnetometer soft and hard-iron calibration can be performed through the serial interface software. V. CONCLUSION Flight control plays an indispensable role in managing quadcopter flight stability. Gyroscope and accelerometer are just enough to monitor quadcopter’s position and movement orientation, but to counter the error factor and outside disturbance, additional sensors such as magnetometer and GPS are needed. While gyroscope compares the angle between the initial position and the desired position, magnetometer compares each initial and altered angle with earth magnetic field in order to get the changes in angle. With this data, the result from gyro and magnetic sensor can be compared to get better reading. GPS has accurate reading on quadcopter positioning and movement. Sensor orientation GP9 has higher precision on attitude changes reading, compared to UM7. ACKNOWLEDGMENT This work has been funded under the LEADERS - Erasmus Mundus Grant (agreement number 2014-0855/001-001) by European Commission, through the Education, Audiovisual and Culture Executive Agency, in the Action Plan 2 for the years 2014-2018. REFERENCES [1] Shiau, J. K., & Wang, I. C. (2013). Unscented Kalman Filtering for Attitude Determination using MEMS Sensors. Journal of Applied Science and Engineering Vol.16 No.2, 165-176. [2] M.G.Earl, & D'Andrea. (n.d.). Real Time Attitude Estimation Techniques applied to a For Rotor Helicopter. IEEE Conference on Decision and Control Vol.4 (pp. 3956-3961). Alantis-Bahamas: IEEE. [3] Sanca, A., Ferreira, J., & Javier, P. (2012). Real Time Attitude Estimation Scheme for Hexarotor Micro Aerial Vehicle. ABCM Symposium Series in Mechatronics Vol.5, (p. 1160). [4] Zhao, W., & Go, T. H. (2014). Quadcopter Fromation Flight Control Combining MPC and Robust Feedback Linearization. Elsevier, 13351355. [5] P. Martin, E. S. (2010). The True Role of Accelerometer feedback in Quadrotor Control. Robotics and Automation (ICRA) (pp. 1623-1629). IEEE. [6] Ying-Chih Lai, S.-S. J. (2011). Attitude Estimation Based On Fusion Of Gyroscopes And Single Antenna Gps For Small Uavs Under The Influence Of Vibration. Springer, 67-77. [7] Hector Garcıa de Marina, F. E. (2010). Adaptive UAV Attitude Estimation Employing Unscented Kalman Filter, FOAM and Low-Cost MEMS Sensors. Sensors, 9566-9585. [8] Eduardo M belo, R. B. (2013). Attitude Estimation Using Mems IMU And Magnetometer Data with Pi Filter. International Congress of Mechanical Engineering 22nd (pp. 4234-4242). Brasil: ABCM. [9] Gebre_Egziabher D, E. G. (2008). MAV Attitude Determination by Vector Matching. IEEE Trans Aerosp Electron Syst., 1012-1028. [10] Maus S, M. S. (2010). The US/UK World Magnetic Model for 20102015. NOAA Technical Report NESDIS/NGDC. [11] Tenn HK, J. S. (2009). Pitch and Roll Attitude Estimation of a Smallscaled helicopter using single antenna GPS with Gyroscope. GPS Solutions, 209-220. [12] Beard, D. B. (2004). Real-Time Attitude and Position Estimation for Small UAVs Using Low-Cost Sensors. AIAA 3rd (pp. 1-9). Chicago, Illinois: American Institute of Aeronautics and Astronautics. )qq(21 )qqqq(2 tan ))qqqq(2(sin )qq(21 )qqqq(2 tan 2 3 2 2 3021 1 2031 1 2 2 2 1 1032 1