Institutionen för systemteknik Department of Electrical Engineering Examensarbete Attitude Control of a Hexarotor Examensarbete utfört i Reglerteknik vid Tekniska högskolan vid Linköpings universitet av Tobias Magnusson LiTH-ISY-EX--14/4779--SE Linköping 2014 Department of Electrical Engineering Linköpings universitet SE-581 83 Linköping, Sweden Linköpings tekniska högskola Linköpings universitet 581 83 Linköping Attitude Control of a Hexarotor Examensarbete utfört i Reglerteknik vid Tekniska högskolan vid Linköpings universitet av Tobias Magnusson LiTH-ISY-EX--14/4779--SE Handledare: Niclas Evestedt isy, Linköpings universitet Thomas Barath UAS Europe AB Examinator: Daniel Axehill isy, Linköpings universitet Linköping, 12 juni 2014 Avdelning, Institution Division, Department Datum Date Department of Automatic Control Department of Electrical Engineering SE-581 83 Linköping 2014-06-12 Språk Language Rapporttyp Report category ISBN Svenska/Swedish Licentiatavhandling ISRN Engelska/English Examensarbete C-uppsats D-uppsats — LiTH-ISY-EX--14/4779--SE Serietitel och serienummer Title of series, numbering Övrig rapport ISSN — URL för elektronisk version http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-109073 Titel Title Attitydstabilisering av en Hexakopter Författare Author Tobias Magnusson Attitude Control of a Hexarotor Sammanfattning Abstract This master’s thesis has been on modeling, identification and control of a hexarotor system. It has been carried out on behalf of UAS Europe in Linköping. A set of non-linear dynamic equations describing the motion of the hexarotor were derived. These equations were then implemented in Matlab/Simulink, which became a good simulation environment for further studies. A decentralized control system using P-PD controllers was successfully implemented in both simulation and on a hexarotor platform. The non-linear simulation model and the hexarotor platform were then identified using black box identification between virtual controls and angular rates. The result from identification of the hexarotor platform was not bad at all, but left some room for improvements. These linear models ware then used to tune the parameters of the inner PD controllers using a method called placement of dominant poles. This method worked well in simulation environment but unfortunately not as well on the real platform. Nyckelord Keywords Multirotor, Multicopter, Hexacopter, Hexarotor, Black-box identification, PID Abstract This master’s thesis has been on modeling, identification and control of a hexarotor system. It has been carried out on behalf of UAS Europe in Linköping. A set of non-linear dynamic equations describing the motion of the hexarotor were derived. These equations were then implemented in Matlab/Simulink, which became a good simulation environment for further studies. A decentralized control system using P-PD controllers was successfully implemented in both simulation and on a hexarotor platform. The non-linear simulation model and the hexarotor platform were then identified using black box identification between virtual controls and angular rates. The result from identification of the hexarotor platform was not bad at all, but left some room for improvements. These linear models ware then used to tune the parameters of the inner PD controllers using a method called placement of dominant poles. This method worked well in simulation environment but unfortunately not as well on the real platform. iii Acknowledgments At first, I would like to thank UAS Europe for giving me the opportunity of doing my master’s thesis. My colleagues Thomas, Thom and Patrik have not only been a very nice company during my days at the office but also helped me a lot with the project. Without them, I would not have been able to get the hexarotor flying. I also want to thank my examiner, Daniel, and my supervisor at isy, Niclas, for being supportive and helpful whenever needed. My biggest thanks is to my parents. Without your unconditional support through out my entire life I would not even be close to where I am today. You have always been there and have given me every opportunity to become the person I am today. You have always answered my questions about big and small, lived through my never ceasing curiosity and inspired me to never stop learning. Then I would like to give a big and special thanks to my partner Hedvig. When my thesis work was ever going slow or not going at all you were there to comfort me and cheer me up. And lastly, to all my fellow students during my five fantastic year at Linköping University I would like to say thank you! You have made my time as a student to the best five years years of my life. I hope I will meet you all again! Linköping, June 2013 Tobias Magnusson v Contents Notation 1 Introduction 1.1 Background . . . . . 1.2 Problem formulation 1.3 Previous works . . . . 1.4 Thesis outline . . . . xi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1 2 3 2 Hexarotor 2.1 Basic movement . . . . . . . . . . . 2.1.1 Throttle . . . . . . . . . . . 2.1.2 Roll . . . . . . . . . . . . . . 2.1.3 Pitch . . . . . . . . . . . . . 2.1.4 Yaw . . . . . . . . . . . . . . 2.2 Control loop . . . . . . . . . . . . . 2.3 Hardware . . . . . . . . . . . . . . . 2.3.1 Autopilot Easy Pilot 3.0 . . 2.3.2 Propulsion system . . . . . . 2.3.3 RC transmitter and receiver 2.3.4 Sensors and filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5 6 6 7 7 8 8 8 8 9 9 3 System Modeling 3.1 Frames of reference . . . . . . . . . . . . . 3.2 Kinematics . . . . . . . . . . . . . . . . . . 3.3 Dynamics . . . . . . . . . . . . . . . . . . . 3.3.1 Translational dynamics . . . . . . . 3.3.2 Rotational dynamics . . . . . . . . 3.4 Applied forces and torques . . . . . . . . . 3.4.1 Gravity . . . . . . . . . . . . . . . . 3.4.2 Thrust and torque from propellers 3.4.3 Gyroscopic effects from propellers 3.4.4 Air friction . . . . . . . . . . . . . . 3.5 Thruster model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 11 12 14 14 14 15 16 16 18 18 18 . . . . . . . . . . . . . . . . . . . . . . . . vii . . . . Contents viii 3.5.1 Propeller model . . . . 3.5.2 Electrical motor model 3.6 Final model . . . . . . . . . . . 3.6.1 System input . . . . . . 3.6.2 Total system model . . 3.7 Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 19 20 20 20 21 4 Control design 4.1 Choice of control design . . . . . 4.2 Control techniques . . . . . . . . 4.2.1 Decentralization . . . . . . 4.2.2 Cascade structure . . . . . 4.2.3 The general pid controller 4.3 Implemented control . . . . . . . 4.3.1 Roll . . . . . . . . . . . . . 4.3.2 Pitch . . . . . . . . . . . . 4.3.3 Yaw . . . . . . . . . . . . . 4.3.4 Throttle . . . . . . . . . . 4.3.5 Scaling and rotor mapping 4.4 Flight performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 25 26 26 26 27 28 28 29 30 30 30 32 5 Identification 5.1 Identification of a multirotor system . . . . . 5.2 Black box identification in a closed loop . . . 5.2.1 Choice of input signal . . . . . . . . . 5.2.2 Applying the input signal . . . . . . . 5.3 Concept evaluation in simulation . . . . . . . 5.3.1 Experiment set up and data processing 5.3.2 Roll axis identification experiment . . 5.3.3 Pitch axis identification experiment . . 5.3.4 Yaw axis identification experiment . . 5.3.5 Validation data . . . . . . . . . . . . . 5.3.6 Choosing model structure . . . . . . . 5.3.7 Identification of roll dynamics model . 5.3.8 Identification of pitch dynamics model 5.3.9 Identification of yaw dynamic model . 5.3.10 Evaluation . . . . . . . . . . . . . . . . 5.4 Data acquired from real flight . . . . . . . . . 5.4.1 Roll axis identification experiment . . 5.4.2 Pitch axis identification experiment . . 5.4.3 Yaw axis identification experiment . . 5.5 Models identified from flight data . . . . . . . 5.5.1 Roll dynamic model . . . . . . . . . . 5.5.2 Pitch dynamic model . . . . . . . . . . 5.5.3 Yaw dynamic model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 35 36 36 37 40 40 41 42 42 44 45 45 46 48 49 49 50 52 54 56 56 59 61 Contents 6 Controller Tuning 6.1 Placement of dominant poles . . . . 6.2 Tuning in simulation . . . . . . . . . 6.2.1 Quick and reactive response . 6.2.2 Smooth and damped response 6.3 Tuning of real platform . . . . . . . . 6.3.1 Roll rate controller . . . . . . 6.3.2 Pitch rate controller . . . . . . 6.3.3 Yaw rate controller . . . . . . 6.3.4 Flight test . . . . . . . . . . . ix . . . . . . . . . 65 65 67 68 70 71 72 75 76 77 7 Conclusions and further work 7.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Further work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 79 79 A Blade flapping 83 B Residual analysis 85 C Basic control theory 87 Bibliography 89 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Notation xii Notation Notation in modeling Symbol η θ ξ ρ τi φ ψ ω Ω aR aT g l m p q r rP s·,c·,t· u v w x, y, z {xE , yE , zE } {xB , yB , zB } Meaning Vector describing the attitude of the body frame relative the earth frame, also called Euler angles using Tait-Bryan formalism Pitch angle, i.e. rotation of B 1 around yB1 Vector describing the body frame’s position in the earth frame Air density Reaction torque from rotor i Roll angle, i.e. rotation of B around xB Yaw angle, i.e. rotation of B 2 around zB2 Vector representing body angular rates Angular velocity of the propeller and motor Rotational air friction coefficient Linear air friction coefficient Gravitational acceleration Length of air frame arm, i.e. distance between center of gravity and propeller Mass of the hexarotor Body angular rate around xB -axis (forward direction of the body) Body angular rate around yB -axis (right direction of the body) Body angular rate around zB -axis (down direction of the body) Propeller radius sin( · ), cos( · ), tan( · ) Forward speed of the hexarotor Sideway speed of the hexarotor Downward speed of the hexarotor The elements of the ξ-vector Base vectors of the earth frame Base vectors of the body fixed frame Notation xiii Notation in modeling (cont...) Symbol B CT CQ E F Fw FA FR I J JP ,zz Jxx Jyy Jzz Kt Kv M Mp Mq Mq MA MG MR Qi RA RL Ti V Vin Meaning Body fixed frame of reference Propeller thrust constant Propeller torque constnat Earth frame, used as inertial frame of reference Sum of all external forces on the hexarotor Total thrust produced by propellers Aerodynamic force produced by propellers Force caused by air friction Current of the DC-motor Inertia matrix expressed in the body frame The moment of inertia of the propeller and motor around the propeller shaft The hexarotor body’s moment of inertia around xB axis The hexarotor body’s moment of inertia around yB axis The hexarotor body’s moment of inertia around zB axis DC-motor torque constant DC-motor speed constant Sum of all external torques on the hexarotor Torque around xB axis produced by differential propeller thrust Torque around yB axis produced by differential propeller thrust Torque around zB axis produced by differential reaction torque Aerodynamic torque produced by propellers Gyroscopic torque caused by the rotation of the rotors Torque caused by air friction Aerodynamic torque from propeller i Relation between ω and time derivative of η Rotation matrix from earth frame to body frame Thrust produced by propeller i Vector representing linear velocity of the hexarotor in the body frame Input voltage to the DC-motor Notation xiv Notation in controller Symbol δi θC θ̂ θ̇ D µ φC φ̂ φ̇D ψ̇ C p̂ q̂ r̂ ui KD KI KP Ts TC Up Uq Ur Uw Meaning Duty cycle of a PWM-signal Pilot commanded pitch Estimate pitch angle Desired pitch rate Derivative filter coefficient in time discrete PIDcontroller Pilot commanded roll Estimate roll angle Desired roll rate Pilot commanded yaw rate Estimated roll rate Estimated pitch rate Estimated yaw rate Virtual control signal to rotor i Derivative parameter of a PID-controller Integral parameter of a PID-controller Proportional parameter of a PID-controller Sample time Pilot commanded throttle Virtual roll control Virtual pitch control Virtual yaw rate control Virtual throttle control Abbreviations and Acronyms Acronym ahrs arx armax cpu dc esc gps imu pid psd pwm rc uav vtol Description Attitude and heading reference system Auto-regression extra input Auto-regressive moving average extra input Central processing unit Direct current Electronic speed controller Global positing system Inertial measurement unit Proportional, integral, differential (regulator) Power spectral density Pulse width modulation Radio controller Unmanned aerial vehicle Vertical take-off and landing 1 Introduction 1.1 Background The use and development of small unmanned aerial vehicles (uavs) have increased significantly over the last few decades. uavs can be used in several field and applications. People in possession of large grounds, such as farmers and forest owners, can use uavs to remotely inspect their properties. Rescue organisations like the coast guard can send uavs to search for capsized boats. Being able to replace human pilots with autonomous aerial vehicles is obviously a tremendous advantage. The vertical take-off and landing (vtol) uavs are in particular interest because of their ability to take off and land in a limited area and hover above targets. Such air crafts make for excellent camera platforms when producing films and television. UAS Europe AB is a company in Linköping specialized in development of uavs. Today their autopilot SkyView EasyPilot has the capability of flying fixed wing aircrafts autonomously. UAS wishes to integrate support for vtol uavs in the autopilot and in particular multirotor vtol uavs. The specific multirotor platform which will be used during this project is a hexarotor, i.e. a small helicopter with six vertical rotors. 1.2 Problem formulation The goal of this master’s thesis is to control the attitude of a hexarotor platform. The final field of application of the product will most likely be surveillance and reconnaissance missions, implying flying at low speed following way points. Also, 1 1 2 Introduction the final controller should be applicable to other multirotor platforms than the one used in this project, why the controller should be as model-independent and easily tuned as possible, without losing too much of the flight performance. To obtain understanding of the system and to be able to evaluate different control strategies a non-linear physical model will be derived and implemented in matlab/Simulink. To synthesis and tune the controller the platform will be identified using decoupled black box models. But to be able to perform the flight experiments a novice control system is needed. This will be a simple pid-controller based upon previous works and then tested in the simulation environment. The goals of the master’s thesis are • Derive and implement a non-linear physical model of a multirotor • Develop and implement simple pid controllers for the attitudes • Identify decoupled models of the angular rate dynamics • Synthesize and tune attitude controller from identified models 1.3 Previous works Understanding the non-linear and unstable dynamics of a multirotor system is the core in most previous works. The basics of the model, the rotation and translation of a rigid body can be found in every paper regarding modeling and control of multirotor platforms. Identification of different parameters is a time consuming and in many cases expensive processes. Works of [Elsamanty et al., 2013] show that even though it is possible, it demands a lot of equipment and multiple experiments. The parameters will still only be valid for hovering, since recreating the condition during forward flight is very difficult. The work load may very well correspond to a master thesis of its own, why another solution must be found. One approach that could prove useful is the one used in [Barsk, 2012, Beltramini et al., 2011]. There the authors try to identify linear decoupled models with data collected from flight experiments. The controllers are then designed using these models. Control of a multirotor platform is a widely explored field in previous work. Lots of different model dependent control strategies have been proposed, such as backstepping [Sanca et al., 2010, Arellano-Muro et al., 2013], linear quadratic [Bouabdallah et al., 2004, Rinaldi et al., 2013], feedback linearization [Mokhtari et al., 2006] and model predictive control [Alexis et al., 2011, Abdolhosseini et al., 2013, Barsk, 2012]. However, the final controller should be model-independent and easily tuned. pid controllers is a well-tried concept and may very well prove enough to stabilize the 1.4 Thesis outline 3 hexarotor. Earlier work, such as [Alaimo et al., 2014, Bouabdallah et al., 2004, Rinaldi et al., 2013], shows that pid controller can be a suitable choice of control strategy. An interesting approach is used by [Elbir et al., 2013] where they identify several linear models from flight data and then tune the pid controllers using these identified models. 1.4 Thesis outline The outline of this thesis is as follows: • Chapter 2 explains the basic about the flying platform used. If the reader is completely unfamiliar with multirotors, he or she should start by reading this chapter. • Chapter 3 deals with the physical modeling of the hexarotor. From Newton and Euler’s law of motion a complete set of differential equations describing the motion of the system are derived. The chapter also briefly describes how the model was implemented in matlab/Simulink. • Chapter 4 describes the initial novice controller and its key concepts and how it was implemented in both simulation environment and on the autopilot. • Chapter 5 contains the experiment design, data collection and system identification performed and then presents the identified models. • Chapter 6 deals with the synthesis and tuning of the control system and the evaluation of the flight performance after the tuning. • Chapter 7 sums up this thesis with conclusions and some discussions of the results. 2 Hexarotor The multirotor platform used in this thesis is a hexarotor. It consists of six arms all connected symmetrically to the central hub. At the end of each arm a propeller driven by an electric motor is attached. All the propellers have fixed pitch blades, meaning that propellers can not be tilted (The movement of the classic helicopter is controlled by pitching the main propeller). The electronics used for communication and control are placed on the central hub together with the battery. 2.1 Basic movement The only way of controlling the hexarotor is through its propellers. Each propeller produces an upward thrust by pressing air downwards. Since the source of the thrust is located outside the center of gravity, differential thrust can be used to rotate the vehicle. The rotation of the rotors (motors and propellers) also produce a reaction torque opposite of the direction of the rotation. Since half of the propellers are spinning in one direction, the net torque when all rotors have equal speed is zero. The are four basic movements: throttle, roll, pitch and yaw. These control signals, in this thesis denoted virtual control signals, are mapped to different ways of changing the propeller speed. The speed of every individual rotor is the sum of the four control signals’ contribution to that particular rotor. Linear movement, i.e. fly the hexarotor along the ground, is controlled through the roll and pitch angle. That is, to move forward (in some sense) the hexarotor is tilted downwards. This will produce an acceleration in the forward direction. 5 2 6 2.1.1 Hexarotor Throttle The main control of the hexarotor is the throttle. It is used to control the hexarotor’s movement in the body fixed vertical direction. Since the propellers are fixed pitched, the direction of the throttle is fixed. The biggest part of the throttle is used to counter act gravity. When increasing (decreasing) the throttle, the hexarotor will travel upwards (downwards). If the hexarotor is tilted, part of the thrust will move the hexarotor in the tilted direction. Figure 2.1: Throttle is produced by increasing (decreasing) the speed of all rotors equally much. 2.1.2 Roll The roll command is used to rotate the hexarotor around its forward-axis. Rolling is performed by increasing (decreasing) the thrust produced by the propellers on the right side of the hexarotor while decreasing (increasing) the thrust produced by the propellers on left side of the hexarotor. The total thrust will thus remain unchanged and the command leads only to a rotation. Figure 2.2: Roll movement is produced by increasing (decreasing) the speed of rotors on right side while decreasing (increasing) the left side rotors’ speed equally much. 2.1 Basic movement 2.1.3 7 Pitch The pitch command is used to rotate the hexarotor around its right-axis. Pitching is performed by increasing (decreasing) the thrust produced by the propellers on the front of the hexarotor while decreasing (increasing) the thrust produced by the propellers on the rear of the hexarotor. The total thrust will thus remain unchanged and the command leads only to a rotation. Figure 2.3: Pitch movement is produced by increasing (decreasing) the rear rotors’ speed while decreasing (increasing) the front rotors’ speed. 2.1.4 Yaw The yaw command is used to rotate the hexarotor around its vertical axis. Yawing is performed by increasing (decreasing) the thrust produced by the propellers rotating clockwise while decreasing (increasing) the thrust produced by the propellers rotating counter-clockwise. The total thrust will thus remain unchanged and the command leads only to a rotation. Figure 2.4: Yaw movement is produced by increasing (decreasing) the speed of the rotors rotating clockwise while decreasing (increasing) the rotors rotating counter clockwise. 2 8 2.2 Hexarotor Control loop The control system on the hexarotor is divided into an inner and an outer loop. The inner loop controls the attitude and height while the outer loop controls the position. The position is controlled by sending reference values to the inner controller. The outer loop could either be a pilot with a radio controller flying in stabilized mode or a control system running on board. The task of the outer loop could either be to maintain a hover position or following way points from a navigation system. Navigation system Outer controller Attitude, altitude Inner controller Hexarotor Position Figure 2.5: A brief overview of the different blocks in the control chain 2.3 Hardware The core of the hardware is the autopilot Easy Pilot developed by UAS Europe AB. It contains two central processing units (cpus) responsible for control, communication and sensor data processing. A bunch of sensors are used such as an inertial measurement unit (imu), a barometer and a gps-receiver. The system can receive flight commands through a radio controller (rc) or through a ground station control. The autopilot is also capable of sending back flight data to the ground station. A map of the different hardware components is seen in Figure 2.6. 2.3.1 Autopilot Easy Pilot 3.0 The flight board used is the Autopilot Easy Pilot 3.0 developed by UAS Europe AB. Its core are the two central processing units. The main cpu is responsible for communication and controlling the air vehicle. The secondary cpu collects data from sensors and filters that data. The board also contains a modem for communication with a ground station. 2.3.2 Propulsion system Each propulsion system consists of an electronic speed controller (esc), a brushless electronic motor and a propeller. The propellers used are 11 inch slow flight 2.3 Hardware IMU 9 Magnetmetometer Barometer AHRS GPS Main CPU Motor ESC Motor ESC Motor ESC Motor ESC Motor ESC SBUS-Receiver ESC Modem Motor Figure 2.6: An overview of the different hardware components used on the platform. propellers. They are driven by NTM Prop Drives Series 28-30A 800kv brushless motors. They are capable of rotating up to 18400 rpm without any load. A brushless motor cannot be driven directly by a pwm signal. It is instead controlled by an esc, the one used in this project is a Turnigy Plush 25A. The esc receives a pwm signal from the flight board and controls the motors by rapidly turning on and off the current to the different poles in the motor. 2.3.3 RC transmitter and receiver The transmitter is the radio controller Futaba T7C. It is used to control the hexarotor by sending reference values for roll, pitch, yaw and throttle. The operator can then control the hexarotor through its control system, in a mode called stabilized flight. The receiver for the radio controller is a Futaba R6203SB. It transfers the received commands through a serial bus to the autopilot. 2.3.4 Sensors and filter To keep track of the attitude, heading and position of the hexarotor an array of sensors together with a software filter is needed. On the autopilot board all the needed sensors are integrated except for the external gps-receiver. On the secondary cpu a filter used to estimate heading and attitude of the hexarotor is running. A compilation of the states, sensors and data processing can be seen in 2 10 Hexarotor Table 2.1. The sensors used to estimate the angular velocity of the body are gyroscopes, one for each body axis. The gyro signals are low pass filtered before sent to the control loop. To estimate the attitude of the hexarotor the gyroscopes are used together with accelerometers. The estimation is made by a complementary filter. The attitude is estimated by integrating the angular velocities from the gyroscope. Since all gyros have a small drift the accelerometers are used to compensate for that drift. The estimation of heading of the body is made in a similar manner, but instead of accelerometer data a magnetometer is used. The estimation of position, that is longitude and latitude, is made by the gps. The gps can also estimate altitude and direction of velocity. Since a hexarotor can fly in any direction (not just forward, compared to a fixed wing aircraft) the flight direction does not have be equal to the body heading. Finally, the two barometers measure static pressure and dynamic pressure respectively. From these measurement the altitude and change of altitude can be found as well as air speed. State Sensors used Processing Body angular velocities Attitude (roll and pitch) Body heading (yaw) Latitude and longitude Flight direction Flight speed Altitude Altitude change Gyroscope Gyroscope, accelerometer Gyroscope, magnetometer gps gps gps Barometer Barometer Low pass filtering Complementary filter Complementary filter Low pass filtering - Table 2.1: How the different states are obtained and estimated 3 System Modeling 3.1 Frames of reference Let E = {xE , yE , zE } be an inertial frame with origin on the surface of the earth. As convenient when describing aircraft motion, the earth fixed frame is a north-eastdown-system (NED-system) with xE pointing to the north, yE pointing to the east and zE pointing downwards [Cook, 2007]. Also, introduce B = {xB , yB , zB } as a body fixed frame with origin at the hexarotor’s center of gravity. xB is equivalent with the forward direction of the hexarotor, yB with right and zB with down. This choice of body fixed frame has the advantage that the inertia tensor is time-invariant and that the body symmetry will simplify the equations. φ yE xE xB θ ξ ψ zE zB yB Figure 3.1: The two frames of reference and their relation 11 3 12 3.2 System Modeling Kinematics The body fixed frame’s position in the earth fixed frame can be described by the vector ξ = [ x y z ]T and its orientation, attitude and heading, by the vector η = [ φ θ ψ ]T . The angles used to represent the orientation are defined using Tait-Bryan formalism. This type of formalism differs from proper Euler angles by using three different axes when forming the rotation [Bishop, 2007]. Within aerospace literature this representation is often referred to as Euler angles, which may cause some confusion. The adopted order of rotation is commonly used when describing aircraft motion [Cook, 2007, Merzouki et al., 2012]. To bring the body fixed frame into coincidence with the earth fixed frame the following rotations are considered: • First, rotate the body-fixed frame about the xB -axis by the roll angle φ, resulting in a new frame of reference called B 1 . • Then, rotate the new frame B 1 about the new axis yB1 by the pitch angle θ, resulting in a new frame of reference called B 2 . • Lastly, rotate the new frame B 2 about the new axis zB2 (which coincide with zE ) by the yaw angle ψ, resulting in a new frame aligned with the earth fixed frame. In order to transform any linear quantity from earth frame to body frame rotation matrices are used. In order to simplify the notation sin( · ) and cos( · ) are abbreviated s · and c · respectively. The relation between B and B 1 after the rolling can be described by xB 1 y 0 B = zB 0 0 cφ −sφ 0 xB1 sφ yB1 1 cφ zB (3.1) where the rotation matrix is denoted R(x, φ). In similar manner, after the pitching B 1 is related to B 2 via 1 xB cθ 1 yB = 0 1 −sθ zB 0 1 0 sθ xB2 0 yB2 2 cθ zB (3.2) with the rotation matrix R(y, θ). After the final yawing B 2 and E are related by 2 xB cψ 2 yB = −sψ 2 0 zB sψ cψ 0 0 xE 0 yE 1 zE (3.3) 3.2 Kinematics 13 using the rotation matrix R(z, ψ). The total rotational matrix, to transform any quantity from earth frame to body frame, is obtained by multiplying R(x, φ), R(y, θ) and R(z, ψ). That yields cθcψ xB yB = sφsθcψ − cφsψ zB cφsθcψ + sφsψ cθsψ sφsθsψ + cφcψ cφsθsψ − sφcψ −sθ xE sφcθ yE cφcθ zE (3.4) and the total rotational matrix is denoted RL . This matrix is sometimes referred to as the direction cosine matrix. One convenient feature of RL is that its inverse T is equal to the transpose, that is R−1 L = RL , since RL ∈ SO(3) [Siciliano and Khatib, 2008]. This is useful when transforming quantities in the body fixed frame to the earth fixed frame. Denote the linear velocity of the hexarotor expressed in the body fixed frame V = [ u v w ]T . Then the second time derivative of the position ξ is ξ = RTL V ξ̇ (3.5) In order to relate the change of attitude with the body angular velocities the different steps of the rotation have to be considered [Sidi, 1997]. First, denote the body angular velocities ω = [ p q r ]T , where p is rotation around the xB -axis, q is rotation around the yB axis and r is rotation around the zB -axis. The first rotation applied to the earth fixed frame, the yawing, is subject to three successive angular transformation: rotation around zE , yB1 and xB . The second rotation, the pitching is subject to two successive angular transformation: rotation around yB1 and xB . Lastly, the rolling is only subject to one attitude transformation: rotation around xB . That gives the relation φ̇ 0 0 p q = R(x, φ)R(y, θ)R(z, ψ) 0 + R(x, φ)R(y, θ) θ̇ + R(x, φ) 0 r ψ̇ 0 0 0 −sθ φ̇ 1 = 0 cφ sφcθ θ̇ 0 −sφ cφcθ ψ̇ (3.6) where the final transformation matrix is denoted RA . Then the time derivate of the hexarotor’s attitude η is η̇ = R−1 A ω and with t · short for tan( · ) the inverse can be written 1 sφtθ cφtθ −1 cφ −sφ RA = 0 sφ cφ 0 cθ cθ (3.7) (3.8) 3 14 3.3 System Modeling Dynamics To begin with, the general equations of linear and angular motion of a rigid body must be derived. To do this, Newton-Euler formalism is used. In order to distinguish between quantities expressed in different frames of reference, the following notation is used: • A quantity expressed in the inertial earth frame is denoted X E • A quantity expressed in the body fixed frame is denoted X B • A quantity already defined in a frame of reference, e.g. ω , will not have the notation above. 3.3.1 Translational dynamics In the earth fixed inertial frame, Newton’s second law can be applied [Taylor, 2005], giving F E = mξ̈ = maa E (3.9) aE where the time derivate is with respect to the inertial frame and is the acceleration of the body fixed frame expressed in the inertial frame, m is the mass of the body which is constant and F E is the sum of all external forces applied to the body expressed in the inertial frame. However, it would be convenient to express the dynamics in the body fixed frame. By using the rotational matrix from equation (3.5) a change of basis can be obtained and the expression becomes ! V dV B B RLF = mRLa = mRL (3.10) dt E where the time derivate is still with respect to the inertial frame and V is the velocity of the body fixed frame expressed in the body fixed frame. Computing that derivative is rather cumbersome, but using a well-known relation, sometimes called the transport theorem, yields ! ! V dV +ω ×V (3.11) FB = m dt B Let the time derivative with respect to the body fixed frame be denoted by a dot, then the final equation of the translational dynamics expressed in the body fixed frame is F B = mV̇ + ω × mV V 3.3.2 (3.12) Rotational dynamics Again starting in the inertial frame, Euler’s second axiom is M E = L̇ E (3.13) where the time derivative is with respect to the inertial frame, L E is the angular momentum of the body expressed in the earth frame and M E is the sum of all 3.4 Applied forces and torques 15 external torques applied to the body expressed in the earth frame. The quantities can be expressed in the body fixed frame by applying the rotational matrix for angular velocities from equation (3.7), giving ! ω dJω B B RAM = RAL̇ = RA (3.14) dt E ω and J is the inertia matrix expressed in the body frame. Differenwhere L = Jω tiating J with respect to the earth frame is rather difficult since it will be timedependent. Instead, using the transport theorem again, the expression becomes ! ω dJω ω MB = + ω × Jω (3.15) dt B Since the choice of body fixed frame ensured that the inertia matrix is time invariant, the final equation is ω M B = J ω̇ + ω × Jω 3.4 (3.16) Applied forces and torques The relations in equation (3.12) and (3.16) are general equations of motion for a rigid body. Now, it is time to apply them to the hexarotor system by finding the different components of the external forces F and torques M . This will be done in similar manner as [Bresciani, 2008, Pounds et al., 2010]. The forces and torques acting on the hexacopter are gravity, air friction aerodynamic forces and torques produced by the propellers and the gyroscopic effects from the rotation of the propellers. The torque caused by the angular acceleration of the propeller has been neglected. All quantities are expressed in the body fixed frame unless anything else is stated. T6 T1 T5 Tk , Ωk Qk Tj , Qj T2 T4 mg T3 Ωj (a) Thrust, reaction torque and direction of rotor rotation (b) Thrusts and gravity applied to the rigid body Figure 3.2: Forces and torques produced by rotors. k = 2,4,6 and j = 1,3,5 3 16 3.4.1 System Modeling Gravity First off is the gravity which is the only force or torque which is naturally expressed in the earth frame. The gravitational force is acting on the hexacopter’s center of gravity according to Euler’s first axiom and is directed along the zE -axis. In the body fixed frame the contribution of the gravitional force F B G is 0 sθ 0 sφcθ = R FB = mg (3.17) L G mg cφcθ where g is the acceleration due to gravity. 3.4.2 Thrust and torque from propellers The second contribution is the thrust produced by the aerodynamics of the propellers and reaction torque from the rotation of the rotors. Figure 3.2 shows where the forces are applied on the air frame. The sum of the thrust from the different propellers is total lift force and is always directed along the negative zB -axis. If the thrust from propeller i is denoted Ti , then the lift force Fw is Fw = T1 + T2 + T3 + T4 + T5 + T6 (3.18) Since the sources of thrust, i.e. the propellers, are not located in the center of gravity, they will create torques around the different axes of rotation. With some basic geometry seen in Figure 3.3, it’s easy to find the produced torque. Around the xB -axis the torque Mp from propeller thrust is l l l l Mp = − T1 − lT2 − T3 + T4 + lT5 + T6 2 2 2 2 where l is the length of each arm. Around the yB -axis the torque Mq is √ √ √ √ 3l 3l 3l 3l T1 − T3 − T4 + T Mq = 2 2 2 2 6 (3.19) (3.20) The torque around the zB -axis is a result of Newton’s third law. When the DCmotor accelerates and keeps the propeller rotating, it exerts a torque on the propeller shaft. The motor will be subject to an equally sized torque in opposite direction from the propeller shaft. Since the motor is mounted to the airframe, the torque will propagate to the airframe. This torque is often called reaction torque. If the reaction torque from propeller i is called τi the total torque around the zB -axis denoted Mr is Mr = −τ1 + τ2 − τ3 + τ4 − τ5 + τ6 (3.21) The reaction torque is produced by two different sources. When the motors and propellers accelerate, they will exert a torque on the air frame. Also, pressing the propeller through the air creates friction. This friction is called aerodynamic 3.4 Applied forces and torques 17 xB 30◦ l 60◦ yB Figure 3.3: The geometry of the hexarotor seen from above torque. The contribution from accelerating the propeller is neglected since its duration will be very quick, and thus the reaction torque will be equal to the aerodynamic torque. The thrust and aerodynamic torque produced by a propeller can be related to the rotational speed of the propeller blades. A simplified relation of the thrust generation model used in [Bouabdallah, 2007] is used for now. If the rotational speed of propeller i is denoted Ωi , then the generated thrust Ti is Ti = kT Ω2i (3.22) where kT is a propeller specific constant explained more thoroughly later. In the same way, the aerodynamic torque Qi of propeller i becomes Qi = kQ Ω2i (3.23) where kQ is a propeller specific constant. Now, the total torque M A from the aerodynamic effects of the propeller can be written l − kT Ω2 − lΩ2 − l kT Ω2 + l kT Ω2 + lΩ2 + l kT Ω2 2 1 2 3 5 6 4 2 2 2 √ √ √ √ 3l 3l 3l 3l 2 2 2 2 (3.24) M A = k Ω − k Ω − k Ω + k Ω T T T T 1 3 6 4 2 2 2 2 −kQ Ω21 + kQ Ω22 − kQ Ω23 + kQ Ω24 − kQ Ω25 + kQ Ω26 and the total force F A becomes 0 0 F A = −kT (Ω21 + Ω22 + Ω23 + Ω24 + Ω25 + Ω26 ) (3.25) 3 18 3.4.3 System Modeling Gyroscopic effects from propellers A propeller is a mass which rotates both around the propeller shaft, but since it is connected to the airframe, it will follow the rotations of the airframe. If the rotation around the shaft is the spin and the rotation of the airframe is the precession, the gyroscopic torque produced by the propeller can be found. The spin quantity is already defined as Ωi and the precession vector as ω. The gyroscopic torque M Gi from propeller i is 0 0 M Gi = ω × JP (3.26) (−1)i Ωi where JP is the inertia matrix of the propeller around the propeller axis and the factor (−1)i comes from the fact that the propellers rotate in opposite directions. Using the fact that the inertia matrix is a diagonal matrix the expression can be simplified to i 0 qJP ,zz (−1) Ωi = −pJP ,zz (−1)i Ωi 0 M Gi = ω × (3.27) i JP ,zz (−1) Ωi 0 Summing up all propellers, the total gyroscopic torque M G is qJP ,zz (−Ω1 + Ω2 − Ω3 + Ω4 − Ω5 + Ω6 ) −pJ M G = P ,zz (−Ω1 + Ω2 − Ω3 + Ω4 − Ω5 + Ω6 ) 0 3.4.4 (3.28) Air friction The air frames movement through the air will cause friction. Because of the shape of the air frame, the air friction is assumed to be low and a simple model is sufficient. The model of the air friction is given by F R = −AT · V M R = −AR · ω (3.29) (3.30) where AT and AR are diagonal matrices with diagonal elements aT and aR respectively. 3.5 Thruster model The thruster model can be separated into two subsystems: the propeller and the electric motor. The propeller converts rotational speed into thrust and the electrical motor converts voltage into rotational speed. This part of the modeling is quite often neglected, but can have a big impact of the performance. The most important part is the time delay of the propulsion system which is the time between the pwm-signal is calculated and the propeller reaching the desired speed. 3.5 Thruster model 3.5.1 19 Propeller model A proper, accurate propeller model includes but is not limited to studying of momentum theory, blade element theory, relative airflow, blade flapping and the bending and twisting of the propeller blades as in works of [Khan and Nahon, 2013]. It is a quite complicated subject, and much of the result comes out as empirical data. A basic propeller model, as found in [Pounds et al., 2010], states that the generated thrust T is T = CT ρrP4 πΩ2 (3.31) where ρ is the air density, rP is the propeller radius and CT is the thrust coefficient of the propeller. Similarly, the aerodynamic torque Q can be expressed as Q = CQ ρrP5 πΩ2 (3.32) where CQ is the propeller torque constant. Modeling CT and CQ is the complicated part of the propeller model and is mostly done empirically. The constants will depend on the geometry of the propeller as well as the direction the propeller is traveling in. An extended model of a propeller taking theses factors into account can be found in [Khan and Nahon, 2013]. 3.5.2 Electrical motor model The electrical motors used on the platform are rather complex to model in detail. The esc receives a pwm-signal which it decodes to a desired rotor speed. The motor contains permanent magnets. To make the magnets rotate, a magnetic field is moved around the housing of the motor. The magnets are trying to follow that magnetic field, and a rotation is created. The speed of this rotation depends on how fast the magnetic field is moved around which is made by turning on and off the poles in the housing. The interesting part of the dynamics of the rotor is the time constant and the pwm to rotor speed relation. Because of that, a pwm to voltage mapping and a classic model of a dc-motor is considered sufficient for the purpose of this thesis. The pwm to voltage mapping is described in Chapter 3.7. A second order dc-motor model is found in [Ljung and Glad, 1999]. By assuming that the inductance and the friction caused by the moving parts of the motor are zero the model becomes a first order model which is considered enough. The model is defined by Vin − Kv Ω R Kt τ Ω̇ = +I− IP IP τ=Q I= (3.33a) (3.33b) (3.33c) where I is the current, Vin is the voltage input, Kv and Kt are speed and torque constants, Ω is the motor speed, τ is the reaction torque and Q is the aerodynamic torque. 3 20 3.6 System Modeling Final model Combining the first derivative of the position equation (3.5), the first derivative of the orientation equation (3.7), the translational dynamics equation (3.12), the rotational dynamics equation (3.16), and the external forces equations (3.17), (3.24), (3.25) and (3.28) the final model becomes ξ̇ = RTL V (3.34a) B B B ω × mV V + FG + FA + FR mV̇ = −ω (3.34b) B (3.34d) η̇ = RTA ω B B ω × Jω ω + MA + MG + MR J ω̇ = −ω 3.6.1 (3.34c) System input The input to the system can be chosen as several physical quantities. To fulfill the requirement of platform independence, or at least make the model as modular as possible, one can choose the system input as total aerodynamic force and torque produced by the propellers and the gyroscopic torque as a disturbance. To extend the model, the rotational speed of the propellers can be chosen as input to the system. Then the model can include a complex relation between rotational speed of the propellers and generated trust and reaction torque. Going even further, one can include the electrical motors in the model. These are controlled by the pwm-input to the esc, and then the duty cycle of the pwm-signals could be the input signal. In this model, the rotational speed of the propellers will be chosen as input. To simplify notation, these will be mapped to the virtual input signals by Fw = kT (Ω21 + Ω22 + Ω23 + Ω24 + Ω25 + Ω26 ) l l l l Mp = − kT Ω21 − lkT Ω22 − kT Ω23 + kT Ω24 + lkT Ω25 + kT Ω26 2 2 2 2 √ √ √ √ 3l 3l 3l 3l Mq = k Ω2 − k Ω2 − k Ω2 + k Ω2 2 T 1 2 T 3 2 T 4 2 T 6 Mr = −kQ Ω21 + kQ Ω22 − kQ Ω23 + kQ Ω24 − kQ Ω25 + kQ Ω26 WG = (−Ω1 + Ω2 − Ω3 + Ω4 − Ω5 + Ω6 ) (3.35a) (3.35b) (3.35c) (3.35d) (3.35e) where Fw corresponds to the third component of aerodynamic force FA from the propellers defined by equation (3.25) and Mp , Mq and Mr to the components in the aerodynamic torques MA defined by equation (3.24) and where WG is the input to the disturbance caused by gyroscopic torques. 3.6.2 Total system model For convenience, the system model is written in component form where the inputs have been included ẋ = cθcψu + (sφsθcψ − cφsψ)v + (cφsθcψ + sφsψ)w (3.36a) 3.7 Simulator 21 ẏ = cθsψu + (sφsθsψ + cφcψ)v + (cφsθsψ − sφcψ)w ż = −sθu + sφcθv + cφcθw a u̇ = rv − qw + sθg − T u m a v̇ = pw − ru + sφcθg − T v m 1 a ẇ = qu − pv + cφcθg − Fw − T w m m φ̇ = p + sφtθq + cφtθr θ̇ = cφq − sφr sφ cφ ψ̇ = q+ r cθ cθ Jyy − Jzz 1 ṗ = qr + M + Jxx Jxx p J − Jxx 1 q̇ = zz rp + M − Jyy Jyy q Jxx − Jyy 1 ṙ = pq + M − Jzz Jzz r 3.7 (3.36b) (3.36c) (3.36d) (3.36e) (3.36f) (3.36g) (3.36h) (3.36i) JP ,zz qWG − Jxx JP ,zz pWG − Jyy aR p Jxx aR q Jyy aR r Jzz (3.36j) (3.36k) (3.36l) Simulator The model derived earlier was implemented in matlab/Simulink. The aim was to make it modular, easily upgradeable and modifiable in terms of number of propellers and configuration. This led to a Simulink model divided into several subsystems. The subsystem containing the thruster could easily be altered to a quadcopter or octacopter by just changing a variable in the configuration file. The dynamic model is implemented in several subsystems according to Figure 3.4. The core is an arbitrary rigid body which is subject to external forces and torque. The rigid body contains information about its mass and moment of inertia. The output from the rigid body is velocity, acceleration, angular acceleration and angular speed according to equations (3.34b) and (3.34d). The external forces are gravity, air friction and aerodynamic thrust and torque as in equations (3.34b) and (3.34d). Gravity and air friction are implemented straight forward. To transform gravity into body coordinates, the function block needs the angles of the hexarotor. The aerodynamic thrust and torque are implemented in a more complex block which is seen in Figure 3.5. The input signal to the thruster is the duty cycle of the PWM-signal. This is mapped to a voltage according to [Khan and Nahon, 2013], that is Vin = P (δ) = 4.99 · 10−9 δ3 − 2.66 · 10−5 δ2 + 4.93 · 10−2 δ − 27.33δ (3.37) The DC-motor is an implementation of equation (3.33) which takes a voltage Vin 3 22 η System Modeling FG g Gravity V AT Air friction FR FA δi MG MA + F J, m AR ω ω̇ + M Rigid body Thrusters ω V V̇ MR Air friction Figure 3.4: A block diagram showing how the dynamic equations are implemented in Simulink. A rigid body translate the external forces generated by gravity, air friction and the thrusters into translational and rotational movement. and aerodynamic torque Qi as inputs and produces an angular velocity Ωi and a reaction torque τi . The propeller block is an implementation of equations (3.31) and (3.32). From the angular speed of the motor it produces thrust and reaction torque. It contains information about the propeller: thrust and torque constants CT and CQ , air density ρ and propeller radius r. The gyroscopic block realizes equation (3.27), converting angular speed of the rotor and body angular rate of the hexarotor to gyroscopic torque MGi . Only one thruster block is implemented. Instead of making six equal blocks, the thruster block has vectors as inputs and outputs. Every element in the vector represents a thruster. This makes it possible to simulate not just hexarotors, but δ Qi CT , CQ , ρ, r Ti Ω P (δ) Vin Kt , Kv ,JP ,zz , R τi PWM-to-voltage DC-motor FA Propeller ω JP ,zz Gyroscopic MGi l MG MA Geometry Figure 3.5: A block diagram of a thruster implemented in Simulink. 3.7 Simulator 23 a multirotor with an arbitrary number of rotors. In order to make the system as arbitrary as possible with respect to number of rotors, the geometry block had to be implemented. This block maps the thrust and torques produced by the arbitrary number of propellers to net forces and torque exerting on the hexarotor. It contains information about length of the arms, propeller rotation direction and the geometry seen in Figure 3.3, i.e. the position of the thruster with respect to the body-fixed frame. The numerical parameters used in the simulation are a mixture of previous, similar projects and measurements of the the real platform. In Table 3.1 all parameters used in the simulator can be found. Name Description Numerical value Source m l Ixx Mass of platform Length of arm Moment of inertia around xaxis Moment of inertia around yaxis Moment of inertia around zaxis Propeller thrust constant Propeller torque constant Propeller radius Motor constant Motor constant Motor resistance Motor and propeller inertia around propeller shaft Translational air friction constant Rotational air friction constant Air density Acceleration of gravity 2.1 kg 0.32 m 3.8 · 10−3 kgm2 Measurement Measurement [Sanca et al., 2010] 3.8 · 10−3 kgm2 [Sanca et al., 2010] 7.1 · 10−3 kgm2 [Sanca et al., 2010] 0.01458 1.037 · 10−3 0.14 m 4.19 · 10−3 Vs/rad 4.19 · 10−3 Nm/A 1Ω 4.3 · 10−5 kgm2 [Sanca et al., 2010] [Sanca et al., 2010] Measurement [Sanca et al., 2010] [Sanca et al., 2010] [Sanca et al., 2010] [Sanca et al., 2010] 4.8 · 10−2 Ns/m [Sanca et al., 2010] 6.4 · 10−4 Ns/m [Sanca et al., 2010] 1.20 kg/m3 9.81 m/s2 [Nordling, 2006] [Nordling, 2006] Iyy Izz CT CQ r Kv Kt R IP ,zz aT aT ρ g Table 3.1: The numerical values of the parameters used in simulation 4 Control design The hexarotor is a very unstable system and not possible to control without a proper control system. In order to perform identification experiments a control system was implemented both in simulation and on the real platform. The initial control system used a decentralized approach with cascade P-PD controllers for each axis with empirically chosen parameters. The input commands to the control loops were sent by a test pilot with a radio controller when flying the real platform. 4.1 Choice of control design In previous works several different control design are proposed to control multirotor systems. Model depended controller such as ackstepping [Sanca et al., 2010, Arellano-Muro et al., 2013], linear quadratic [Bouabdallah et al., 2004, Rinaldi et al., 2013], feedback linearization [Mokhtari et al., 2006] and model predictive control [Alexis et al., 2011, Abdolhosseini et al., 2013, Barsk, 2012] are popular in literature regarding control of multirotor systems. However, most of the result from those works are from simulations. pid controllers are a well tried concept, even among multirotors. [Alaimo et al., 2014, Bouabdallah et al., 2004, Rinaldi et al., 2013] have all successfully implemented such controllers. Since the final users of the autopilot should be able to understand and tune the controllers without a degree in master of science, UAS Europe prefers pid controllers. 25 4 26 4.2 Control design Control techniques The initial control system used three different concepts: decentralization, cascading and pid. The result was three different P-PD controllers, all easily tuned and implemented that together were capable of controlling the hexarotor. 4.2.1 Decentralization A common approach when controlling the attitude of a multirotor system is to neglect the effects from the cross couplings and design one SISO-controller for every control signal, that is roll, pitch and yaw. The cross couplings will however exist. The gyroscopic effects from the rotors are estimated to be small since the inertia of a rotor is very small. But the gyroscopic effects from the rotating airframe may be in the same size as the control signal when the angular rates are big. Although, previous works have shown that treating the cross couplings as a disturbance is sufficient for controlling a multirotor. This strategy can be found in works of [Bouabdallah, 2007, Bresciani, 2008] among others and has been successfully implemented in the commercial autopilot ArduCopter. [ArduPilot.com, 2012]. In Figure 4.1 a simple block diagram shows the concept of a decentralized control on a hexarotor. One control loop for every axis, roll, pitch and yaw, was used together with a throttle mapping. Roll Control Roll, roll rate Pitch Control Pitch, pitch rate Hexarotor Pilot commands Throttle mapping Yaw Control Yaw, yaw rate Figure 4.1: The three different loops controlling the hexarotor together with a throttle mapping. 4.2.2 Cascade structure A cascade structure is often used when the dynamics of a system is of varying speed. The inner loop controls the fast dynamics of the angular rate while the outer controller works with the slower angle dynamics. This is a control design 4.2 Control techniques 27 which in literature is referred to as a PD2 controller and which has been successfully implemented in the ArduCopter project. Angle control Desired angular rate Angle Angular rate control Angular rate Hexarotor Virtual control Pilot commands A block diagram of a cascade control structure can be found in Figure 4.2. The pilot command is transformed into a desired angular rate by comparing it to the current angle of the hexarotor. The desired angular rate is the reference signal to the inner, faster controller. This controller produces the virtual control signal. Figure 4.2: The cascade structure of the control loops handling attitude. The critical part is the inner controller which controls the angular rate. This is where the stability of the hexarotor is ensured. Once able to control the angular rates, controlling the angles is just a matter of setting the angular rate. The outer controller will then be more of a design choice, the hexarotor can easily be made more or less aggressive. 4.2.3 The general PID controller Both the angle and angular rate controller is initially implemented using pid techniques. pid controllers are very popular, easily implemented and can be tuned by common users. The ideal pid controller can be found in [Glad and Ljung, 2006] and is defined by Zt u(t) = KP e(t) + KI e(τ)dτ + KD t0 de(t) dt (4.1) where e(t) is the error between reference signal and measured value. A perfect derivation is never possible in practice and the transfer function of the controller becomes F(s) = KP + KI s K 1 + KD = KP + I + KD s µs + 1 s KD µ + 1 s (4.2) where µ is a design parameter. The implemented controller is a discrete time controller so the pid controller has to be discretized. Using Euler backward, the 4 28 Control design derivative can be approximated as s = T1 (1 − z −1 ), where Ts is the sample time, s which yields the discrete time transfer function F[z] = KP + KI 1 Ts + KD −1 1−z KD µ + Ts 1−z −1 (4.3) To implement the derivative part as a discrete time system, the transfer function for the derivative is written as a recurrence relation d[k] = = 1 KD µ + Ts 1−z −1 e[k] = KD µz −1 (1 − z −1 ) 1 − z −1 e[k] = d[k] + e[k] KD µ + Ts KD µ + Ts KD µ(1 − z −1 ) + Ts KD µ 1 d[k − 1] + (e[k] − e[k − 1]) KD µ + Ts KD µ + Ts (4.4) where d[k] is the derivative part of the output, which also is described in [Enqvist et al., 2010]. A discrete time PD controller would then be u[k] = KP e[k] + KD d[k], 4.3 d[k] = KD µ 1 d[k − 1] + (e[k] − e[k − 1]) KD µ + Ts KD µ + Ts (4.5) Implemented control The controllers were implemented on the autopilot and tuned empirically. The control loop ran at approximately 60 Hz. Figure 4.3 shows a block diagram describing the different control loops, mapping and scaling. 4.3.1 Roll The roll controller used a cascade structure including an outer P controller and an inner PD controller. The outer controller is described by φ̇D [k] = Pφ (φC [k] − φ̂[k]) (4.6) where the output φ̇D is the desired roll rate, φC is the roll command from the pilot and φ̂ is the estimated roll angle. The inner controller is described by Up [k] = KP e[k] + KD d[k], d[k] = KD µ 1 d[k − 1] + (e[k] − e[k − 1]) KD µ + Ts KD µ + Ts (4.7) Implemented control 29 TC θC P φ̇D θ̇ D ψ̇ C + p̂ PD + q̂ PD + r̂ PD Up Uq Ur ++ Scaling δ1,2,...,6 + θ̂ P Uw u1,2,...,6 φC + φ̂ Mapping Mapping 4.3 Hexarotor Figure 4.3: A block diagram of the control loops running together with throttle mapping, virtual control to control signal mapping and hardware scaling. where e[k] = φ̇D [k] − p̂[k], p̂ is the measured roll rate and Up is the virtual roll control. Here, the assumption that p ≈ φ̇, since the roll angle φ and the pitch angle θ always will be small, was made. Both the input to the outer loop, the commanded roll angle, and the input to the inner loop, the desired roll rate, as well as the output Up from the cascade loop was limited. The limit was lower than the physical limit of the propulsion system and was made to avoid far too aggressive commands. 4.3.2 Pitch The pitch controller is implemented in the exact same manner as the roll control. The outer controller is described by θ̇ D [k] = Pθ (θ C [k] − θ̂[k]) (4.8) where the output θ̇ D is the desired pitch rate, θ C is the pitch command from the pilot and θ̂ is the estimated pitch angle. The inner controller is described by Uq [k] = KP e[k] + KD d[k], d[k] = KD µ 1 d[k − 1] + (e[k] − e[k − 1]) KD µ + Ts KD µ + Ts (4.9) where e[k] = θ̇ D [k] − q̂[k], q̂ is the measured pitch rate and Uq is the virtual pitch control. Here, the assumption that q ≈ θ̇ was made. Both the input to the outer loop, the commanded pitch angle, and the input to 4 30 Control design the inner loop, the desired pitch rate, as well as the output Uq from the cascade loop was limited. The limit was lower than the physical limit of the propulsion system and was made to avoid far too aggressive commands. 4.3.3 Yaw The yaw loop is implemented with only the inner PD controller and the pilot is thus able to control the yaw rate directly. The yaw control is described by Ur [k] = KP e[k] + KD d[k], d[k] = KD µ 1 d[k − 1] + (e[k] − e[k − 1]) KD µ + Ts KD µ + Ts (4.10) where e[k] = ψ̇ C [k] − r̂[k], ψ̇ C is yaw rate command from the pilot, r̂ is the measured yaw rate and Ur is the virtual yaw control. Here, the assumption that r ≈ ψ̇ has been made. The input to the controller, the commanded roll rate, and the output Ur from the controller, was limited. The limit was lower than the physical limit of the propulsion system and was made to avoid far too aggressive commands. 4.3.4 Throttle The throttle was mapped from pilot command to virtual throttle control with the relation Uw = c1 (e c2 (R C −R min )/Rmax − 1) − Ulim (4.11) where Uw is the virtual throttle control limited between ±Ulim , RC is the throttle command from the pilot limited between Rmin and Rmax . The exponential mapping makes the pilot’s throttle adjustment smoother at low throttle speed. To make sure the mapping is from [Rmin , Rmax ] to [−Ulim , Ulim ] c2 is only tunable parameter. c1 is calculated by c1 = Rmax + Umax e c2 ∗(Rmax −Rmin )/Rmax − 1 (4.12) With this implementation the pilot was able to control the roll and pitch angle, the yaw rate and throttle which is a common set up for hobby multirotor systems. 4.3.5 Scaling and rotor mapping The four virtual control signals had to be mapped and scaled to actual pwm signals to the rotors. This was done in two steps. First, with the help of equations (3.35b) and (3.35c) the applied roll and pitch moment could be written 4.3 Implemented control 31 α Mp − 2 = √ M 3α q 2 −α 0 − α2 − √ 3α 2 α 2 √ − 23α α 0 2 Ω1 2 α Ω2 2 Ω23 2 √ 3α Ω4 Ω2 2 5 2 Ω6 (4.13) where α = lkT . The mapping was calculated by inverting the relation above, using a psedo inverse. Since kT is an unknown, model dependent parameter of the propeller dynamics, α was simply set to 1. Thus, the motor mix was calculated using only the geometry of the arms of the hexarotor. This gave the mixing relation √ 3/6 u1 −1/6 u −1/3 2 √0 U p u3 = −1/6 −√3/6 u 4 1/6 − 3/6 U q u5 1/3 √ 0 u6 1/6 3/6 (4.14) where ui are the rotor signals which later will be mapped to a PWM duty cycle and Up and Uq are the virtual roll and pitch control respectively. To simplify even further, the mixing relation was normalized, which gave √ 3/2 u1 −1/2 u −1 2 √0 U u3 −1/2 −√3/2 p = u4 1/2 − 3/2 Uq u5 1 √ 0 u6 1/2 3/2 (4.15) The virtual yaw control was mapped by adding a column to the matrix above which contains the sign of the propeller direction. This was then added to the virtual throttle control and so the final rotor mapping was √ 3/2 −1 1 u1 −1/2 u −1 U 1 p 1 2 √0 u3 −1/2 −√3/2 −1 1 = u4 1/2 − 3/2 1 Uq + 1 Uw u5 1 1 0 −1 √ Ur 1 u6 1/2 3/2 1 (4.16) 4 32 Control design This mapping had no other physical meaning than the geometry of the arms. In practice, the virtual yaw control will have much less impact than the roll and pitch virtual controls. This will however be solved by setting the control parameters accordingly, moving the tuning to one place in the control chain. The rotor signals ui were finally mapped linearly from the interval [−100, 100] to the duty cycles of the pwm signals, δi which were in the interval of [1000, 2000]. 4.4 Flight performance The P-PD controllers were tuned empirically according to Table 4.1. Controller KP KD Input limit Roll angle Pitch angle Roll rate Pitch rate Yaw rate 4 4 10 10 60 20 20 120 25 degrees 25 degrees 100 degrees/s 100 degrees/s 100 degrees/s Table 4.1: The empirically found parameters to the two P controllers and three PD controllers used The hexarotor performed rather well in some aspects. The pilot was not able to flip the hexarotor thanks to the limit of the commanded angle and angular rate. The trade off between attitude stabilization and yaw rate control felt comfortable according the test pilot. However, two problems were discovered during the flight test. The first problem is perhaps a bit more simple. By looking at the first few seconds of a response to a pitch rate command in Figure 4.4, it is quite obvious that the pitch rate response was rather oscillatory. This is due to both the nature of the hexarotor and a minor flaw in the control design. The flaw in the control design is that the controller differentiate the control error. This will cause aggressive responses to pilot commands. Also, the derivative filter seems to filter out much of the response from the D-part of the controller. This could have been solved by tuning the parameter µ more properly. The nature of the hexarotor is both a time delay in the propulsion system and the fact that the system is sort of an integrator. The second problem can clearly be seen in both Figure 4.4 and 4.5. The hexarotor never reaches the commanded pitch angle. At first glance, one might think this due to the absence of an integral part in the controller. This is however not the entire truth. Surely, the pitch angle never reaches the desired angle. But after the first peak, the hexarotor slowly rotates back toward zero angle. This can also be seen in Figure 4.4 where the the pitch rate first reaches about 40 degrees/s, but 4.4 Flight performance 33 Pitch rate [degrees/s] 60 40 20 0 −20 −40 148 150 152 154 Time [s] 156 158 Figure 4.4: The response of a pitch rate command. The dashed line is the desired pitch rate set by the outer controller and the solid line is the pitch rate. The pitch rate response is quite oscillatory which is caused by the nature of the hexarotor, the time delay in the propulsion system and the fact the controller differentiate the control error instead of just the measurement. then stays below 10 degrees/s even though the desired pitch rate is around 40 degrees/s. An integral part would improve the steady state error, but probably cause even more oscillations. To propose a solution to the problem, a better understanding of what is causing the error is needed. The problem looks to be within the pitch rate loop. The outer loop is obviously trying to increasing the pitch rate, but the hexarotor only response the first time. The difference between the two time instances (around 151 seconds and from 152 seconds in Figure 4.4) is that the hexarotor is standing still at first, but then starts to accelerate because of the pitch command. Unfortunately, no measurements of the velocity were acquired. A look at the virtual pitch control during the pitch command in Figure 4.6 shows that the hexarotor does not respond equally to the command depending on when the command is given. At 151 the virtual pitch command only has to reach 5 to rotate the hexarotor. Then, when the hexarotor has gained speed, not even a virtual pitch command of 10 is able to rotate the hexarotor. This problem is also investigated in [Hoffmann et al., 2007]. Here the authors shows that when the velocity increases a restoring moment is created which brings the hexarotor back to zero angle. This restoring moment is caused by a phenomenon known as blade flapping and is discused further in appendix A. 4 34 Control design Pitch angle [degrees] 20 15 10 5 0 148 150 154 152 Time [s] 156 158 Figure 4.5: The response of a pitch command. The dashed line is commanded pitch angle set by the pilot and the solid line is the pitch angle. The controller is not strong enough to drive the system up to the desired angle. After a while, the hexarotor is even starting to rotate back toward zero angle. Virtual pitch control 15 10 5 0 −5 −10 148 150 152 154 Time [s] 156 158 Figure 4.6: The virtual pitch control during the pitch command. The first peak gave an immediate pitch response, but when the hexarotor had gain speed, not even a pitch command twice the size could rotate the hexarotor. 5 Identification Identifying a multirotor platform could roughly be carried out in two different ways. The most tested approach in previous work is identification of the physical parameters. However, in this thesis a black box identification between virtual control input and angular rates was preferred. The flight experiments as well as system identification from obtained data was first tested and evaluated in simulation before conducted on the real platform. 5.1 Identification of a multirotor system Roughly there are two different approaches to identify a multirotor system, facing different kinds of problems. The most common approach in previous work is to identify the physical parameters such as moment of inertia and the relation between propeller thrust and angular speed of the propeller. However, such an approach is quite time consuming and expensive in the sense that a lot of equipment is needed. Since the autopilot will be used to control various kinds of multirotor platforms, these experiments has to be repeated whenever changing payload, using another propulsion system or modifying the system in other ways. The other approach is to do a black box identification between virtual control input and angular rate. This has been tried in another project by [Barsk, 2012]. Although it is model dependent, once performed on one system it can easily be repeated on other systems. The main drawback is that to perform the needed flight experiments to acquire identification data, the multirotor has to have a working controller because of the unstable nature of the multirotor system. That means that the input signal will not be the one actually controlling the multirotor, but a reference signal to the control system or an overlay on the controller output. 35 5 36 Identification The biggest issue of this approach is that the identified system will be under influence of feedback. Both the angle and the angular rate will be estimated and then used by the controller. But trying to fly a multirotor not using feedback is an extremely difficult task, even for the most experienced pilot. 5.2 Black box identification in a closed loop The identification will be performed using a black box structure, i.e. no previous knowledge of the system will be used. The biggest issue is that the data collection must be done using feedback, or otherwise the system would be uncontrollable. The approach used is called direct approach in [Ljung and Glad, 1999]. Then the system is excited using a reference signal to the controller but only the actual input and the output is measured. Identification performed on a closed loop may incur additional difficulties compared to performed on an open loop. 5.2.1 Choice of input signal The choice of input signal is very important when identifying a system. First off, the frequency range of the input signal has to be considered. The system dynamics will only be accurate in the frequency range where the input signal has high power spectral density. Thus, the dynamics of interest in the model has do be in the input signal. Finding the frequency range of interest can be found by performing a step experiment and then finding the rise time. Though in the case of a multirotor system, a step experiment is very tricky to perform since the system is unstable. The final choice of frequency range will be based upon previous works. From this it is concluded that the input signal should contain frequencies from 0.1 Hz up to 5 Hz in order to excite the most important dynamics. The next step is to choose the actual input signal. The input signal must satisfy several demands. The hexarotor must be maintained near hovering state at all time to minimize the effects from non-linearities. Also, when tilting the hexarotor it will start drifting. To keep it close to the starting point the input signal should be symmetrical around zero. Furthermore, the input of choice should be easily produced by a pilot through a radio controller. In their work [Beltramini et al., 2011] are trying three different input signals to identify a multirotor system using a gray box. According to their simulations, an optimal multisine input yields the most accurate parameter identification, while an optimal piece wise constant input and a frequency sweep provides acceptable results. In [Tischler, 2006] the author provides lots of useful ideas which are applicable in the practical case. There, the recommended input signal is a frequency sweep (chirp) with an exponential frequency increase. The input signal used in the identification experiments in this thesis was the exponential frequency sweep. It fulfills all the above requirements and was considered the easiest one to generate by the test pilot. The frequency sweep starts 5.2 Black box identification in a closed loop 37 with a full period of the lowest frequency and then exponentially increases the frequency. In figure 5.1 the first 100 seconds of a frequency sweep is seen as well as the power spectral density (psd) estimate. This particular frequency sweep was designed to contain frequencies between 0.1 Hz and 5 Hz. The psd shows that the signal contains the desired frequencies up to 5 Hz. 2 0 −2 0 20 40 Time [s] 60 80 100 Power [dB] (a) The time history of a frequency sweep showing the first 100 seconds 0 −20 −40 0 2 4 6 Frequency [Hz] 8 10 (b) The psd of the frequency sweep input Figure 5.1: A computer generated frequency sweep with exponentially increasing frequency. The frequency range is 0.1 Hz to 5 Hz and the amplitude is normalized. Gaussian noise with standard deviation of 10% of the amplitude has been added. This signal contains information in the desired frequency range and should be a good choice of input signal. 5.2.2 Applying the input signal In addition to the choice of input signal there are other factors to consider. The cross coupling of the system is regarded low. During the identification phase the system is therefor treated as a decoupled system. The input signal will be applied for one of the axes at time, while the controllers for the other axes will try to keep the hexarotor still. Since the identification will be carried out on a closed loop system, there are two different ways of applying the input to the hexarotor. The first way is to apply the input as a desired angle to the controllers which can be seen in Figure 5.2. The disadvantage of this strategy is obviously that the controllers will modify the input signal before applying them to the hexarotor. The benefit is that the risk of crashing is lower and the maximum angle is constrained by the nature of the controller. 5 38 Input + Error - Virtual Control Controller Identification Hexarotor Measurement Figure 5.2: A schematic drawing of how the input is applied in the first way, as a reference to the controllers. The second way is to overlay the input on the controller output which is seen in Figure 5.3. The controllers works in the same manner as in the first case with the difference that they receive a zero reference. The controllers will counter act the input signal and try to bring the hexarotor back to hover state. By adjusting down the gain in the controllers this should provide stability as well as less impact from the controllers. Input 0 + Error - Controller + + Virtual Control Hexarotor Measurement Figure 5.3: A schematic drawing of how the input is applied in the second way, as an overlay on the controller output while the controller is receiving a zero reference input. To find out which approach that is most promising in practice, some simulation experiments were performed. In Figure 5.4 the psd of the actual inputs, i.e. the the virtual control signals, to the system are compared using the two different approaches. The desired frequency content seen in Figure 5.1b were equally preserved when applied as a reference to the controllers, as seen in Figure 5.4a, as when mixed with the controller output, as seen in Figure 5.4b. Clearly both approaches had the downside that the lower frequencies of the input were filtered out. A second way of comparing the different cases is by looking at the squared coherence estimate between frequency sweep input and the virtual control. This is done by plotting 2 (f ) Pxy (5.1) Cxy (f ) = Pxx (f )Pyy (f ) where Pxx is the psd of the frequency sweep input, Pyy the psd of the virtual control and Pxy is the cross psd between the two. Cxy is close to 1 when the two signals are strongly correlated. In Figure 5.5 it is seen that not much differed between the two ways of applying the input signal. Also in this comparison it is seen that the lower frequencies of the inputs were disturbed by the controller. Black box identification in a closed loop Power [dB] 5.2 20 0 −20 −40 0 2 4 6 Frequency [Hz] 39 8 10 Power [dB] (a) The psd of the virtual control when the input is the desired angle 20 0 −20 −40 0 2 4 6 Frequency [Hz] 8 10 (b) The psd of the virtual control when the input is mixed with the controller output Magnitude Figure 5.4: A comparison of the psd of the two different ways of applying the input signal in simulation. The effects on the energy content seems very similar, the lower frequencies were filtered out by the controller but the higher frequencies were well preserved. 1 0.5 0 0 2 4 6 Frequency [Hz] 8 10 Magnitude (a) Coherence between frequency sweep input and virtual control when input applied as a reference to the controllers 1 0.5 0 0 2 4 6 Frequency [Hz] 8 10 (b) Coherence between frequency sweep input and virtual control when input mixed with controller output Figure 5.5: A comparison of the squared coherence function between frequency sweep input and virtual control in simulation. The function is close to 1 at the frequencies where the input and output are strongly correlated. In both cases, the frequencies below 1 Hz are not strongly correlated. 5 40 Identification Both ways were almost identical in producing data for identification. The chosen approach of applying the input signal was as a desired angle since this should give the pilot better control of the hexarotor during the frequency sweeps. 5.3 Concept evaluation in simulation To evaluate the concept of collecting flight data and identify a black box model, everything was first tested in simulation. Here it could be investigated that the chosen experiment design produced the data required to make good models of the hexarotor system. It would also give some knowledge of what the models should look like when identifying the real platform. 5.3.1 Experiment set up and data processing For the roll and pitch identification experiment in simulation a frequency sweep input was used, with a frequency range from 0.1 Hz to 5 Hz, a maximum amplitude of 15 degrees and a time duration of 300 seconds. Gaussian noise with a variance of 10% of the amplitude was added. The yaw axis dynamics differs from the roll and pitch dynamic. The reaction torque used for yaw rotation is much weaker than the corresponding for roll and pitch. Also, the moment of inertia is higher around the yaw axis. Thus, the yaw dynamics should be in a lower frequency range. The maximum frequency was therefore chosen to 2 Hz. The signal was used as an angle reference for the controller during the roll and pitch axis experiment and as an angular rate reference during the pitch axis experiment. The acquired data was the virtual input and the measured angular rate. The experiment was conducted for every axis, that is once for roll, pitch and yaw. An overview of the setup of the experiment design can be read in Table 5.1. Axis Input type Frequency range Amplitude Input applied Roll Pitch Yaw Chirp Chirp Chirp 0.1 Hz - 5 Hz 0.1 Hz - 5 Hz 0.1 Hz - 2 Hz 15 degrees 15 degrees 15 degrees/s Roll reference Pitch reference Yaw rate reference Table 5.1: A survey of the identification experiments performed in simulation The sampling rate was set to 50 Hz which was the estimated sampling rate of the real platform. A rule of thumb states that the sampling rate should be ten times the bandwidth of the system. Since the system most likely would not contain any interesting dynamics above 5 Hz this sample rate was considered enough. The acquired data was filtered to remove content in the frequency range of no interest during the identification. The signal had been filtered by a tenth order 5.3 Concept evaluation in simulation 41 butterworth filter with cut off frequency 5 Hz for roll and pitch dynamics identification and 2 Hz for yaw dynamics identification. The filter was applied by using the matlab command filtfilt instead of filter to avoid phase lag. 5.3.2 Roll axis identification experiment Roll [degrees] In Figure 5.6 a time history of the angles of the hexarotor during the roll axis identification experiments can be seen. The roll angle was kept within approximately 15 degrees. At higher frequencies it is clear that the hexarotor could not keep up with the desired angle. The pitch was however kept small while the yaw angle did not vary too much. This indicates that the system could be treated as a decoupled system since the impact from pitch and yaw movement should be small. 20 0 −20 0 50 100 150 Time [s] 200 250 300 20 0 −20 0 100 200 Time [s] 300 (b) The pitch angle during the roll axis identification experiment Yaw [degrees] Pitch [degrees] (a) The roll angle during the roll axis identification experiment 50 0 −50 0 100 200 Time [s] 300 (c) The yaw angle during the roll axis identification experiment Figure 5.6: A time history plot of the angles of the hexarotor during the roll axis identification experiment in simulation. The roll angle was kept within the desired limit. When the frequency of the chirp increased the hexarotor system could not keep up. The pitch angle was kept close to zero by the pitch controller and yaw angle did not vary too much thanks to the yaw rate controller. The frequency content of the acquired data, the virtual input and the roll rate, is seen in Figure 5.7. The psd estimate has been smoothed to improve readability. As previously seen the input suffered from loss of content in the lower frequencies due to the impact of the controller. Also, the low pass filtered data, which later will be used for identification, is shown in the plot. 5 42 20 0 −20 −40 −60 Identification 0 −50 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual roll control 0 5 10 Frequency [Hz] 15 (b) Frequency content of the measured roll rate Figure 5.7: The frequency content of the acquired data from the roll axis identification experiment. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. The lower frequencies are filtered out in the input signal, as expected. 5.3.3 Pitch axis identification experiment The result from the pitch axis identification experiment was almost identical to the roll axis result. This was unsurprisingly since the same input was used and the only different between roll and pitch movement is that a different propeller mappings are used. The pitch angle was varied within the desired angle limit. The roll angle was kept close to zero while the yaw angle did not vary too fast. The frequency content seen in the psd estimate was unsurprisingly very similar to the psd estimated from the roll axis identification experiment. Because of the almost identical result, no further plots are presented. 5.3.4 Yaw axis identification experiment The yaw axis identification experiment was conducted a bit differently, as previously explained. In Figure 5.8 a time history of the angles of the hexarotor during the yaw axis identification experiments can be seen. The roll and pitch angles were kept small which ensured low cross coupling effects. The yaw angle did not have to be kept around a specific work point to ensure near hover state and did not have to be limited. The yaw rotation movement was as seen in Figure 5.8 not as reactive as the roll and pitch movement. The frequency content of the acquired data, the virtual yaw rate input and the yaw rate, is seen in Figure 5.9. The frequency content was evenly distributed among the frequencies of interest. At the lower frequencies there were even more frequency content than before. This was probably because only one controller was active. The data should be suitable for identification of the yaw dynamics. Concept evaluation in simulation Yaw [degrees] 5.3 43 40 20 0 0 50 100 Time [s] 150 20 0 −20 0 50 100 Time [s] 150 (b) The roll angle during the yaw axis identification experiment Pitch [degrees] Roll [degrees] (a) The yaw angle during the yaw axis identification experiment 20 0 −20 0 50 100 Time [s] 150 (c) The yaw pitch during the yaw axis identification experiment 20 0 −20 −40 −60 Power [dB] Power [dB] Figure 5.8: A time history plot of the angles of the hexarotor during yaw axis identification experiment in simulation. The roll and pitch angle were kept small. The yaw angle did not have to be contained within a certain interval. At the higher frequencies of the chirp, the hexarotor was barely moving. This could certainly be a limitation when conducting this experiment on the real platform. 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual yaw control 0 −50 0 5 10 Frequency [Hz] 15 (b) Frequency content of the measured yaw rate Figure 5.9: The frequency content of the acquired data from the yaw axis identification experiment. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. The frequency content of the virtual yaw control is evenly distributed, even at the lower frequencies. This can be because only one controller is active, compared to two in the previous experiments. 5 44 5.3.5 Identification Validation data As always when doing system identification a different data set for validation is needed for cross validation. To obtain a usable data set from simulation, another input signal than the frequency sweep is applied. The chosen input is a two sided doublet as recommended in [Tischler, 2006]. It was applied to the system just as in previous experiments. 2 0 −2 0 5 10 Time [s] 15 (a) The two sided doublet input Angle [degrees] In Figure 5.10 a time history of a two sided doublet input as well as the angle of the hexarotor when this input was applied is seen. The other angles were limited by the controller as seen in previous experiments. The hexarotor is maintained around hover state and the angle is limited. The frequency content of the virtual input and the measured angular rate can be seen in Figure 5.11. The frequency content in this signal seems to be slightly lower than the chirp. 20 0 −20 0 5 10 Time [s] 15 (b) The angle of the hexarotor during the input 20 0 −20 −40 −60 Power [dB] Power [dB] Figure 5.10: The two sided doublet input applied as a reference to the controllers and the angle of the hexarotor during the generation of validation data. The other angles were kept small by the controllers. 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual control 0 −50 0 5 10 Frequency [Hz] 15 (b) Frequency content of measured angular rate. Figure 5.11: The frequency content of the acquired data from one of the validation experiments. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. 5.3 Concept evaluation in simulation 5.3.6 45 Choosing model structure Choosing the best model structure is mostly a trial and error process. During this phase of the system identification all model structures available and considered reasonable, that is arx, armax, Box-Jenkins and process models, were tested and evaluated. It became quite clear that most often the more complex model structures armax and Box-Jenkins did not perform better than arx or process models. Therefore they are not discussed through this part of the report. 5.3.7 Identification of roll dynamics model The best ARX model found was a second order with two zeros which gave a fit of 94% using the validation data set and a parameter uncertainty in the order of 10−6 . A higher model order did not improve the fit. When prediciting the output five steps ahead, it gave a fit of 94%. Roll rate [degrees/s] The process model fitted to the validation data also gave a fit of 94% using the validation data set while having a parameter uncertainty in the order of 10−2 . The process model did not improve if a zero or a time delay was introduced. The output from the models compared to the measured output can be seen in Figure 5.12. 50 0 −50 −100 0 5 10 15 25 20 Time [s] 30 35 40 Figure 5.12: A comparison between the simulated output from the roll dynamics models and the measured output. The measured output is the blue line, the output from the ARX model is the green line and the output from the process model is the red line. Both models can predict the output very well. A common way of validating a model is by looking at its residuals which is explained in appendix B. In the residual plot of the models in 5.13 it is clear that both models passed the cross correlation test, but failed the whiteness test. Since the measurement noise was feedback through the controller, it was quite obvious that the models would fail this test. Increasing the model order of the ARX model did not improve the results either. The discrete time ARX model had its two real poles close to z = 1, making it close to unstable. Its real valued zero was located near z = −1 and its effects are hard to analyze since the real system is continuous time, as stated in [Glad and Ljung, 5 46 Identification Autocorrelation of residuals for output y1 1 0 −1 −20 0.2 −15 −10 −5 0 5 10 15 20 Cross corr for input u1 and output y1 resids 0 −0.2 −20 −15 −10 −5 0 Samples 5 10 15 20 Figure 5.13: A plot of the roll dynamics model residulas. The green line is the ARX model and red line is the process model. Both models pass the cross correlation test but fails the whiteness test. The bad results on the autocorrelation may be due to that the system is under influence of feedback. 1997]. The continuous time process model had one real valued fast pole and one real valued pole close to the imaginary axis and no zeros. The final choice of model was the ARX model. Both models produced similar results and were very alike. The ARX model contained zeros and will be a better robustness test for the tuning synthesis later on since tuning a system with zeros obviously is harder than tuning one without. The transfer function of the identified ARX model is φ[k] = 0.001688z −1 + 0.001627z −2 1 Up [k] + e[k] (5.2) 1 − 1.917z −1 + 0.9175z −2 1 − 1.917z −1 + 0.9175z −2 where e[k] is white, Gaussian noise with variance 2.3612 · 10−6 . The model is made continuous by the matlab command d2c using zero order hold, which gives the transfer function G(s) = 5.3.8 0.0003662s + 8.649 s2 + 4.303s + 0.6024 (5.3) Identification of pitch dynamics model Since the pitch dynamics is almost identical to the roll dynamics, at least theoretically, the same kind of models as for the roll dynamics, were tested. Unsurprisingly both models gave an equally good fit as the roll dynamics models. The ARX model fitted the validation data with 95%, just as the process model. The parameter uncertainty were in the same order as for the roll dynamics model, that is, 10−6 for the ARX model and 10−2 for the process model. 5.3 Concept evaluation in simulation 47 Pitch rate [degrees/s] The simulated output from the models can be found i Figure 5.14. The analyse of the model residual plots, seen in Figure 5.15 yielded the same conclusions as for the roll dynamics just as its placement of poles and zeros. When simulated with a five step predication horizon the ARX model had a fit of 94% and the process model of 95%. 50 0 −50 −100 0 5 10 15 25 20 Time [s] 30 35 40 Figure 5.14: A comparison between the simulated output from the pitch dynamic models and the measured output. The measured output is the blue line, the output from the ARX model is the green line and the output from the process model is the red line. Both models can predict the output very well. Autocorrelation of residuals for output y1 1 0 −1 −20 0.2 −15 −10 −5 0 5 10 15 20 Cross corr for input u1 and output y1 resids 0 −0.2 −20 −15 −10 −5 0 Samples 5 10 15 20 Figure 5.15: A plot of the pitch dynamic model residulas. The green line is the ARX model and red line is the process model. Both models pass the cross correlation test but fails the whiteness test. The bad results on the autocorrelation may be due to that the system is under influence of feedback. The final choice of model is once again the ARX model. The transfer function of 5 48 Identification the identified ARX model is φ[k] = 0.001687z −1 + 0.00163z −2 1 Up [k] + e[k] 1 − 1.917z −1 + 0.9175z −2 1 − 1.917z −1 + 0.9175z −2 (5.4) where e[k] is white, Gaussian noise with variance 2.3612 · 10−6 . The model is made continuous by the matlab command d2c using zero order hold, which gives the transfer function G(s) = 5.3.9 0.0003662s + 8.649 s2 + 4.303s + 0.6024 (5.5) Identification of yaw dynamic model The yaw dynamics identification experiment was conducted a bit differently, as described earlier. Still though, the identification was just as accurate as the roll and pitch dynamics models respectively. The arx model had a fit of 95% while having a parameter uncertainty in the order of 10−6 . The process model also had a fit of 95% and a parameter uncertainty in the order of 10−2 . When simulated with a five step prediction horision the arx model had a fit of 98% and the process model a fit of 94%. Pitch rate [degrees/s] The simulated output from the models compared with the measured output can be seen in Figure 5.16. Since only one feedback was used, there was some expectation of improving the model residuals. In Figure 5.17 it can be seen that they look very similar to previous residual plots. 20 0 −20 0 5 10 15 20 25 Time [s] 30 35 40 Figure 5.16: A comparison between the simulated output from the yaw dynamic models and the measured output. The measured output is the blue line, the output from the arx model is the green line and the output from the process model is the red line. Both models can predict the output very well. The arx model has similar placement of its poles compared to previous models. Its zero is located on the real axis between the poles and the origin. As mentioned before, a zero in the z-domain is hard to analyse when the model is a sampled version of a continuous time system. The final choice of model is once again the arx model. The transfer function of 5.4 Data acquired from real flight 49 Autocorrelation of residuals for output y1 1 0 −1 −20 0.5 −15 −10 −5 0 5 10 15 20 Cross corr for input u1 and output y1 resids 0 −0.5 −20 −15 −10 −5 0 Samples 5 10 15 20 Figure 5.17: A plot of the yaw dynamic model residulas. The green line is the arx model and red line is the process model. Both models pass the cross correlation test but fails the whiteness test. The bad results on the autocorrelation may be due to that the system is under influence of feedback. the identified arx model is 0.0001333z −1 − 0.2573 · 10−5 z −2 1 Up [k] + e[k] 1 − 1.94z −1 + 0.9402z −2 1 − 1.94z −1 + 0.9402z −2 (5.6) where e[k] is white, Gaussian noise with variance 2.3612 · 10−6 . The model is made continuous by the matlab command d2c using zero order hold, which gives the transfer function φ[k] = G(s) = 5.3.10 0.004117s + 0.273 + 3.081s + 0.6985 s2 (5.7) Evaluation From the results above, it seems obvious that the system can be identified well. The critical part is producing good estimation and validation data. The quality of the data will depend on how well the pilot manages to produce the frequency sweeps used in simulation. Most likely a higher model will be needed since the response of the real hexarotor will be more non-linear than the simulation model used. Although, there are hopes of being able to identify the real system as a black box model. 5.4 Data acquired from real flight The identification experiments with the real platform was performed indoor to minimize disturbances from wind. The test pilot executed several frequency 5 50 Identification sweeps for roll, pitch and yaw respectively. The amplitude was limited by the controller to 25 degrees. The data was sampled at the highest rate the system could manage which was at approximately 60 Hz. Several attempts were made and the best data sets were picked out. The two sided doublets used in simulation did not provide good validation data. Perhaps this was because they were not long or many enough. Nevertheless, they did not contain the frequency content required. Instead a frequency sweep had to be used as validation data, alas the amount of estimation data was reduced. The data was detrended and then low pass filtered at 5 Hz using the non-casual variant of the matlab command idfilt. 5.4.1 Roll axis identification experiment Roll [degrees] In Figure 5.18 the attitude of the hexarotor during a roll experiment is seen. The sweeps have varying frequency, but as seen it was hard producing a perfect frequency sweep. The pitch angle is maintained within an acceptable limit and the yaw angle does not change too fast. The biggest variations in pitch angle can be because the pilot accidently moved the pitch stick while producing roll movements. 20 0 −20 285 290 295 300 305 310 Time [s] 315 320 325 330 10 0 −10 290 300 310 320 330 Time [s] (b) The pitch angle during a roll axis identification experiment Yaw [degrees] Pitch [degrees] (a) The roll angle during a roll axis identification experiment 20 0 −20 290 300 310 320 330 Time [s] (c) The yaw angle during a roll axis identification experiment Figure 5.18: A time history plot of the angles of the hexarotor during a roll axis identification experiment. This data was used as model estimation data. The roll angle was kept within the desired limit. The pitch angle was not kept very small at all time, but was within an acceptable limit. The yaw angle did not change to fast. This data should be suitable for identifying the roll dynamics. 5.4 Data acquired from real flight 51 20 0 −20 −40 Power [dB] Power [dB] The frequency content is plotted in Figure 5.19. Compared to the simulations the input did not contain much energy above 2.5 Hz. Probably this was because the controller filtered out the high frequency content or that the propulsion system was slower than in the simulation model. On the other hand, the content among the lower frequencies seemed even better than in simulation. 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual roll control 0 −20 −40 −60 −80 0 5 10 Frequency [Hz] 15 (b) Frequency content of the measured roll rate Figure 5.19: The frequency content of the acquired data from the roll axis identification experiment. This data was used as estimation data. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. Not much energy content is seen above 2.5 Hz which is because the controller filtered out that content. As a consequence, the model will only cover frequencies up to that frequency. Roll [degrees] A set of validation data was also obtained which can be seen in Figure 5.20. The validation data looked a lot like the estimation data set, and may give an over confidence in model performance. Its frequency content is visible in Figure 5.21. Here it can be seen that the lower frequency content was quite low. 20 0 −20 130 135 140 Time [s] 145 150 Figure 5.20: A time history plot of the roll angle during a frequency sweep. This data was used as validation data for the roll model. 5 20 0 −20 −40 Power [dB] Power [dB] 52 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual roll control 0 −20 −40 −60 −80 0 Identification 5 10 Frequency [Hz] 15 (b) Frequency content of the measured roll rate Figure 5.21: The frequency content of the acquired data from the roll axis identification experiment. This data was used as validation data. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. Not much content is seen above 2.5 Hz 5.4.2 Pitch axis identification experiment Figure 5.23 shows the attitude of the hexarotor during the pitch axis experiment. Several frequency sweeps were performed. The roll angle was not kept small at all time, but within an acceptable limit. By the looks of the angle plots, the pilot seems to have made corrections of the pitch between the sweeps. The strange look of the yaw axis may be due to corrections from the pilot and gyro drift. 20 0 −20 −40 Power [dB] Power [dB] The look of the frequency content in Figure 5.22 is similar to the roll experiment. The higher frequencies are filtered out by the controller and thus the model will only be valid up to about 2.5 Hz. 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual control 0 −20 −40 −60 −80 0 5 10 Frequency [Hz] 15 (b) Frequency content of the measured roll rate Figure 5.22: The frequency content of the acquired data from the pitch axis identification experiment. This data was used as model estimation data. The solid lines are the unfiltered signals and the dotted line has been low pass filtered with cut off frequency 5 Hz. Data acquired from real flight Pitch [degrees] 5.4 53 20 0 −20 340 350 360 370 380 Time [s] 390 400 20 Yaw [degrees] Roll [degrees] (a) The pitch angle during a pitch axis identification experiment 0 −20 340 360 380 Time [s] 400 (b) The roll angle during a pitch axis identification experiment 50 0 −50 340 360 380 Time [s] 400 (c) The yaw angle during a pitch axis identification experiment Figure 5.23: A time history plot of the angles of the hexarotor during a pitch axis identification experiment. This data was used as model estimation data. The pitch angle was kept within the desired limit. The roll angle was not kept small at all time, but was probably corrected by the pilot between the sweeps. The yaw angle did not change to fast, but seemed to have a drift in the filter. Pitch [degrees] A validation data set was obtained in the same manner as for roll and can be seen in Figure 5.24. This sweep was performed rather well by the pilot. Once again, the frequency content, found in Figure 5.25, is high among the lower frequencies but decreases after 2.5 Hz. 20 0 −20 105 110 115 Time [s] 120 125 130 Figure 5.24: A time history plot of the pitch angle during a pitch frequency sweep. This data was used as validation data for the pitch model. 5 20 0 −20 −40 Power [dB] Power [dB] 54 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual pitch control 0 −20 −40 −60 −80 0 Identification 5 10 Frequency [Hz] 15 (b) Frequency content of the measured pitch rate Figure 5.25: The frequency content of the acquired data from the pitch axis identification experiment. This data was used as model validation data. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. 5.4.3 Yaw axis identification experiment 40 20 0 −20 −40 Power [dB] Power [dB] In the plot of the psd in Figure 5.26 it is seen that the frequency content is similar to what was seen in the simulations. 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual yaw control 0 −20 −40 −60 −80 0 5 10 Frequency [Hz] 15 (b) Frequency content of the measured yaw rate Figure 5.26: The frequency content of the acquired data from a yaw axis identification experiment. This data was used as model validation data.The solid lines are the unfiltered signals and the dotted line has been low pass filtered with cut off frequency 5 Hz. Performing frequency sweeps for the yaw axis was a bit more difficult compared to roll and pitch since the hexarotor is not as reactive in this direction. The attitude of the hexarotor during the sweep is seen in Figure 5.27. The roll and pitch angle were kept small and the yaw angle is varied with increased frequency. It is however clear that the cross coupling from yaw command to roll and pitch rate is quite strong. The change of rotor speed when rotating in yaw is much bigger than for pitch and roll which may be the cause. A small offset in the pitch and roll angle is seen, but if this was due to a bias 5.4 Data acquired from real flight 55 Yaw [degrees] in the attitude filter or was the actual case during the experiment is not known. The bias is only around 3 degrees, and did perhaps not affect the hexarotor very much. 100 0 −100 510 515 520 525 Time [s] 530 10 Pitch [degrees] Roll [degrees] (a) The yaw angle during a yaw axis identification experiment 0 −10 510 520 530 Time [s] (b) The roll angle during a yaw axis identification experiment 10 0 −10 510 520 530 Time [s] (c) The pitch angle during a yaw axis identification experiment Figure 5.27: A time history plot of the angles of the hexarotor during a yaw axis identification experiment. This data was used as model estimation data. The yaw angle is varied with increasing frequency. The roll and pitch angles are clearly affected by the yaw movement but the controllers are keeping them small. Yaw [degrees] The validation data set is similar to the estimation data set. The attitude of the hexarotor can be seen in Figure 5.28 and the frequency content in 5.29. 100 0 −100 220 225 230 Time [s] 235 240 Figure 5.28: A time history plot of the yaw angle of the hexarotor during a yaw frequency sweep. This data was used as yaw model validation data. The yaw angled is varied while the pitch and roll angle are kept small. 5 40 20 0 −20 −40 Power [dB] Power [dB] 56 0 5 10 Frequency [Hz] 15 (a) Frequency content of the virtual yaw control 0 −20 −40 −60 −80 0 Identification 5 10 Frequency [Hz] 15 (b) Frequency content of the measured yaw rate Figure 5.29: The frequency content of the acquired data from a yaw axis identification experiment. This data was used as model validation data. The solid lines are the unfiltered signals and the dotted lines have been low pass filtered with cut off frequency 5 Hz. 5.5 5.5.1 Models identified from flight data Roll dynamic model Four different models at the lowest model order possible were found. These were a third order arx model, a third order armax model a process model with a time delay and a process model with a time delay and a zero. The four chosen models all fitted the validation data better than 43% as seen in Table 5.2. Model Validation data fit arx armax Process model with delay Process model with delay and zero 47% 47% 43% 63% Table 5.2: How well the models fitted the validation data The model which had the best fit was the process model with a zero. However, when looking at its zeros and poles there were obvious problems. One of its poles was extremely far to the left. This could also be seen by looking at the parameter values of the model. The largest one was in the order of 108 and the smallest one in the order of 10−11 . That would most likely cause numerical problems later and the model was discarded. Looking at the plot in Figure 5.30 of simulated output, all models managed to recreate the validation data quite well at the higher frequencies. At the lower frequencies the fit was far worse, which was predicted by looking at the frequency content of the estimation data. The models were also tested for five step ahead prediction. The fit from the result 5.5 Models identified from flight data 57 Roll rate [degrees/s] 200 100 0 −100 −200 0 5 10 Time [s] 15 20 Figure 5.30: A comparison between the simulated output from the roll dynamic models and the measured output. The measured output is the black line, the arx model is the blue line, the armax model is the magenta line and the process model is the green line. The model fits well during the high frequency parts of the validation signal, but worse otherwise. is found in Table 5.3. The arx and armax models performed really well and managed to predict the output at same level as in simulation, around 94%. Model Validation data fit arx armax Process model with delay 93% 94% 43% Table 5.3: How well the models fitted the validation data when predicting the output five steps ahead The residual plots looked similar to the ones from the simulation. All models failed the whiteness test which is due to the feedback in the system. According to [Ljung and Glad, 2004] feedback in the system also leads to correlation for negative samples. In Figure 5.31 the residuals of the models have been plotted. The arx, armax models along with the process model without zero passes the test and seemed to have capture enough of the system dynamics. The discrete time arx and armax having a similar model order, they also had similar placement of the poles and zeros. The zero was located very near the origin. Their poles were located near the unit circle, two complex on the inside and one real on the outside. This made the models both unstable and oscillatory which reflects the behaviour of the real system well. The continuous time process model had its two complex poles quite near the imaginary axis, making that 5 58 Identification Autocorrelation of residuals for output y1 1 0 −1 −20 −15 −10 −5 0 5 10 15 20 Cross corr for input u1 and output y1 resids 1 0 −1 −20 −15 −10 −5 0 Samples 5 10 15 20 Figure 5.31: A plot of the roll dynamic models residuals. The arx model is the blue line, the armax model is the magenta line and the process model is the green line. The arx and armax models pass the cross correlation test when considering that the correlation for negative samples are affected by the feedback. All models fail the whiteness test which is due to the feedback. system prone to oscillate. As predicted, none of the models managed to capture the dynamics of the lower frequencies, which is due to lack of good estimation data in that frequency range. The process model with a zero is not chosen because of the big variations in the size of the parameters. The arx and armax models performed equally well and therefore the armax is discarded. The final choice of model is the arx model, defined by 0.0002181−1 1 Up [k]+ e[k] −1 −2 −3 −1 1 − 2.891z + 2.82z − 0.9299z 1 − 2.891z + 2.82z −2 − 0.9299z −3 (5.8) where e[k] is white, Gaussian noise with variance 4.1132 · 10−6 . The model was made continuous by the matlab command d2c using zero order hold, which gave the transfer function φ[k] = G(s) = 0.004469s2 + 0.812s + 49.02 s3 + 4.362s2 + 147.1s − 147.2 (5.9) 5.5 Models identified from flight data 5.5.2 59 Pitch dynamic model The pitch dynamic model should be very alike the roll dynamic model. The same model structures were tested together with an additional forth order arx and armax models since a higher model order improved the fit. Again, the process model with a zero had big variations in the size of the parameter values and was therefore discarded. The model fit to the validation data can be found in Table 5.4. The armax models did not fit better than the arx models and were rejected. Model Validation data fit Third order arx Third order armax Forth order arx Forth order armax Process model with delay 45% 44% 53% 52% 43% Table 5.4: How well the models fitted the validation data The simulated output together with the measured validation output can be seen in Figure 5.32. It can be seen that the models still had problems when the input frequency is low, but performed well at the higher frequencies. Pitch rate [degrees/s] 200 100 0 −100 −200 0 5 15 10 20 25 Time [s] Figure 5.32: A comparison between the simulated output from the pitch dynamic models and the measured output. The measured output is the black line, the third order arx model is the blue line, the process model is the green line and the forth order arx model is the red line. The models fit well during the high frequency parts of the validation signal, but worse otherwise. The arx and armax models was able to predict the output five steps ahead very well which is seen in Table 5.5. Even though the models would not be used to 5 60 Identification predict the output, this is still a good measure of model quality. The process model was, as seen in the Table 5.5, not very good at predicting the output. Model Validation data fit Third order arx Third order armax Forth order arx Forth order armax Process model with delay 93% 93% 96% 97% 45% Table 5.5: How well the models fitted the validation data when predicting the output five steps ahead In the plot of the model residuals in Figure 5.33 it is seen that none of the models passed either the whiteness test nor the cross correlation test. When the model order was increased there were no signs of improvement either. Autocorrelation of residuals for output y1 1 0 −1 −20 −15 −10 −5 0 5 10 15 20 Cross corr for input u1 and output y1 resids 1 0 −1 −20 −15 −10 −5 0 Samples 5 10 15 20 Figure 5.33: A plot of the pitch dynamic models residuals. The third order arx model is the blue line, the process model is the green line and the forth order arx model is the red line. All models fails both the whiteness and cross correlation test. The process model along with the third order arx model had poles and zeros like as the roll dynamic model. The forth order arx model had four complex poles, all inside but close to the unit circle. All models reflect the oscillatory nature of the hexarotor. 5.5 Models identified from flight data 61 The improvement of the forth order arx model compared to the third order was not sufficient to motivate a more complex model. Also, the roll dynamic could be modelled by a third order arx model and since the pitch dynamic should be almost identical, the third order arx model was chosen here as well. The model is defined by 1 0.0002608−1 Up [k]+ e[k] −2 −3 −1 + 2.777z − 0.9076z 1 − 2.87z + 2.777z −2 − 0.9076z −3 (5.10) where e[k] is white, Gaussian noise with variance 5.3713 · 10−6 . The model was made continuous by the matlab command d2c using zero order hold, which gave the transfer function φ[k] = 1 − 2.87z −1 G(s) = 5.5.3 0.0053742 + 0.9805s + 59.31 s3 + 5.819s2 + 144s − 127 (5.11) Yaw dynamic model Four different models were tested. The armax models were rejected since they had shown any improvements compared to the more simple arx model. The models tested were a second order arx, a third order arx, a process model with a delay and a process model with delay and zero. The fit of the models using the validation data can be seen in Table 5.6. The process model with a zero did not have the numerical issues this time, but had a worse fit to the validation data compared to the process model without a zero. Therefore it could be discarded early. Model Validation data fit Second order arx Third order arx Process model with delay Process model with delay and zero 64% 75% 70% 68% Table 5.6: How well the models fitted the validation data As seen in the plot of the simulated output in Figure 5.34 the validation data did not contain much low frequency content. This leads to an over confidence in the identified model. If the validation would have contained more low frequnecy sweeps, the fitting would probably be worse than now. But on the other hand, the yaw dynamics should be easier to identify with linear models than the roll and pitch dynamics because of the nature of yaw rotation. The models were also tested in predicting the output five steps ahead. As before, the arx models managed to predict the output almost exactly while the process model had som issues. The results can be found in Table 5.7. The residuals of the models were investigated. The second order arx model passes the cross correlation test while the others fail. Just as before, none of the 5 62 Identification Yaw rate [degrees/s] 100 50 0 −50 −100 0 5 15 10 20 25 Time [s] Figure 5.34: A comparison between the simulated output from the yaw dynamic models and the measured output. The measured output is the black line, the second order arx model is the blue line, the third order arx model is the red line, the process model without zero is the green line and the process model with zero is cyan line. The model fits well during the high frequency parts of the validation signal, but worse otherwise. Model Validation data fit Second order arx Third order arx Process model with delay 92% 96% 70% Table 5.7: How well the models fitted the validation data when predicting the output five steps ahead models pass the whiteness test. The two poles of the continuous time process model are both real. One of them is quite far to the left in the s-plane. This tells nothing of the oscillations one might expect. The two arx models have similar pole placement as previous models. All poles are inside the unit circle, but complex and near the unit circle. 5.5 Models identified from flight data 63 Autocorrelation of residuals for output y1 1 0.5 0 −0.5 −20 −15 −10 −5 0 5 10 15 20 Cross corr for input u1 and output y1 resids 1 0 −1 −20 −15 −10 −5 0 Samples 5 10 15 20 Figure 5.35: A plot of the yaw dynamic models residuals. The second order arx model is the blue line, the third order arx model is the red line and the process model is the green line. The second order arx model passes the cross correlation test. 6 Controller Tuning When linear models of the system had been identified, an analytical tuning method was tried. The method formed the closed loop through placing dominant poles by setting the right pid parameters. This meant that an integral part in the inner PD controller had to be introduced in the control design. In theory and simulation the method worked well, but when tested on the real platform it failed. 6.1 Placement of dominant poles The technique used to tune the P-PD controller is placement of dominant poles, introduced in [Persson and Åström, 1993] and well described in [Zhiping, 2007]. The desired performance of the closed loop is express by a pair of conjugate poles, λ1,2 = −α ± β. (6.1) The characteristics of a step response from a system containing two complex conjugate poles is presented in C. To ensure that the system is dominated by those poles all other poles of the closed loop must lie to left of the line s = −mα where m usually is between 3 and 5. In addition to that there can be no zeros nearby. The problem is then reduced to finding the pid parameters which guarantee that λ1,2 are the dominant poles. This problem is solved by expressing KI and KD in terms of KP and then using a root-locus of the closed loop to find an appropriate value of KP . In Figure 6.1 the placement of the dominant poles and the desired area of the other poles can be seen in the s-plane. The identified system can in general terms be expressed by G(s) = N (s) −Td s e D(s) 65 (6.2) 6 66 Controller Tuning Im ρ1 −mα Re ρ2 Figure 6.1: The desired placement of the poles in closed loop. λ1 and λ2 are the dominant poles. All other poles should lie in the area left to the line s = −mα. where N (s) is the numerator polynomial, D(s) is the denominator polynomial and Td the time delay of the system. The transfer function of a perfect pid controller is K F(s) = KP + I + KD s s The closed loop system will have the transfer function Gc (s) = F(s)G(s) 1 + F(s)G(s) (6.3) from reference signal to output. The solutions to the characteristic equation of the closed loop, i.e. the denominator put to zero, are the placements of the poles of the closed loop. To begin with, this is used to find an expression for KD by substituting λ1 = −α + β into 1 + F(s)G(s) = 0, which yields −1 ⇐⇒ G(λ1 ) −α + β KI −1 ⇐⇒ KP + + KD (−α + β) = KP + KI 2 + KD (−α + β) = −α + β G(λ1 ) α + β2 (6.4) 1 + F(λ1 )G(λ1 ) = 0 ⇐⇒ F(λ1 ) = Since this is a complex equation, the real and imaginary parts can be solved separately. By solving for KI and KD in terms of KP it is obtained that " # " # α2 + β2 1 −1 1 −1 2 2 KI = KP − (α + β )Γ1 , Γ1 = < + = (6.5a) 2α 2α G(λ1 ) 2β G(λ1 ) " # " # 1 1 −1 1 −1 KD = K P + Γ2 , Γ2 = − < + = (6.5b) 2α 2α G(λ1 ) 2β G(λ1 ) It can easily be shown that the poles of the closed loop are the solutions to the characteristic equation 1 + F(s)G(s) = 0. With the expressions for KI and KD , the 6.2 Tuning in simulation 67 characteristic equation becomes ! ! α2 + β2 N (s)e−Td s 1 K KP − (α 2 + β 2 )Γ1 + P + Γ2 s = 2α s 2α D(s) ! 2αs + α 2 + β 2 + s2 N (s)e−Td s (α 2 + β 2 )Γ1 N (s)e−Td s N (s) =1− + sΓ2 + KP = s D(s) D(s) 2αs D(s) ! 2αs + α 2 + β 2 + s2 N (s)e−Td s sD(s) − (α 2 + β 2 )Γ1 N (s) + s2 Γ2 N (s)e−Td s = +KP sD(s) 2αs D(s) | {z } 0 = 1 + Kp + (∗) (6.6) Dividing all terms with (∗) gives KP 0=1+ 1 + KP ! 2αs + α 2 + β 2 + s2 N (s)e−Td s 2αs D(s) sD(s) − (α 2 + β 2 )Γ1 N (s)e−Td s + s2 Γ2 N (s)e−Td s sD(s) (2αs + α 2 + β 2 + s2 )N (s)e−Td s ⇐⇒ 2αsD(s) − 2α(α 2 + β 2 )Γ1 N (s)e−Td s + 2αs2 Γ2 N (s)e−Td s which can be analysed using a root-locus. 6.2 = ⇐⇒ 1 + KP G̃(s) = 0 (6.7) Tuning in simulation Before using root-locus to determine KP , the desired step response had to be designed. This was a trade off between rise time, overshoot and reasonable parameter values. To demonstrate the method, two different pole placements were chosen. One prioritising a quick, reactive response and one a smooth, well damped response. The system used in the synthesis is the identified roll model, defined by equation (5.2). The pitch model is almost the same as the roll model. The yaw model looks like the roll model too and thus it is sufficient to evaluate only tuning of the roll model. When the parameters had been calculated they were used in the simulation. There were several things which could be tested. The tuning synthesis was made with a continuous time pid-controller using a perfect derivative, while the controllers in the simulation environment were discrete time with a filtered approximation of a derivative. Will the parameters still be valid? And how would the controllers react to measurement noise? 6 68 6.2.1 Controller Tuning Quick and reactive response Choosing λ1,2 = −2 ± 4 gives in theory a system with rise time 0.345 seconds and an overshoot at 20.8%. Plugging λ and the identified roll model from equation (5.3) into equation (6.7) and then using the matlab function rlocus to plot the pole placement for different KP , yielded the plot found in Figure 6.2. There it is seen that a KP > 5.02 is needed to push the other poles left of the line s = −αm with m = 3. Imaginary 5 KP = 3.64 0 −5 −8 −6 −4 −2 Real 0 2 4 Figure 6.2: The root locus plot of poles of the closed loop using a quick and reactive controller. The two poles which we want to dominate the closed loop are not affected by the choice of KP . To push the third left of the line s = −6 KP has to be 5.05 or greater. Using that KP in equations (6.5a) and (6.5b) gives the pid controller F(s) = 5.02 + 13.89 + 0.66s. s (6.8) and the closed loop transfer function Gc (s) = 0.0002443s3 + 5.771s2 + 43.67s + 1.2 s3 + 10.07s2 + 44.027s + 121.2 (6.9) A pole zero plot of Gc (s) shows that the zeros are not very near the dominant poles, but actually between the dominant poles and the line s = αm. Hopefully the dominant pole would still be dominant enough to form the desired step response. A Bode plot of the roll rate system showed that the phase margin of the system was 55 degrees and the amplitude margin was infinite. That was considered good enough since the main focus was to form the step response of the closed loop. The parameters were then tried in simulation. At first, no measurement noise 6.2 Tuning in simulation 69 Roll rate [degrees/s] was used to show the theoretical performance of the closed loop. A 20 degrees step in roll rate reference was tried. The tracking performance of the controller can be seen in Figure 6.3. The overshoot was slightly larger than desired, 21.5% while the rise time was only 0.08 seconds. 20 15 10 5 0 9.5 10 10.5 Time [s] 11 11.5 Figure 6.3: The step response from the quick and reactive roll rate controller in simulation with measurement noise turned off. The rise time is very small, about 0.08 seconds, while the overshoot is 21.5%. When measurement noise was added the performance was still good. In Figure 6.4 it is seen that the overshoot increased, but the rise time was still small. Roll rate [degrees/s] 25 20 15 10 5 0 9.5 10 10.5 Time [s] 11 11.5 Figure 6.4: The step response from the quick and reactive roll rate controller in simulation using measurement noise. 6 70 6.2.2 Controller Tuning Smooth and damped response The poles were now chosen to λ1,2 = −2 ± 2 which should give a rise time of 0.76 seconds and an overshoot at 4.3%. The root locus, found in Figure 6.5, were once again used to find KP . This time, KP were determined to 3.64. Imaginary 4 2 KP = 3.64 0 −2 −4 −8 −6 −4 −2 Real 0 2 4 Figure 6.5: The root locus plot of the poles in the closed loop using a smooth and damped controller. The two poles chosen earlier are not affected by the choice of KP . To push the third pole left of the line s = −6, KP has to be 3.64 or greater. This choice of KP gave the controller F(s) = 3.64 + 5.57 + 0.66s. s (6.10) and the closed loop transfer function Gc (s) = 0.0002443s3 + 5.718s2 + 31.48s + 48.16 s3 + 10.02s2 + 32.08s + 48.16 (6.11) A bode plot of the roll rate system showed the phase margin were 74 degrees while the amplitude margin When this controller was used in simulation, without measurement noise, it produced a step response which can be seen in Figure 6.6. It had an overshoot of 9% and a rise time of 0.08 seconds. The overshoot was lower but the rise time was still very fast. Using measurement noise, the controller produced a step response as seen in Figure 6.7. It had the same rise time but a bigger overshoot. The measurement noise was quite obviously having a rather big impact on the performance. Still though, the behavior of the hexarotor with the tuned controller looked acceptable. The parameters designed for the continuous time controller worked also with the discrete time controller. This tuning method was ready to be tested on the real platform. 6.3 Tuning of real platform 71 Roll rate [degrees/s] 20 15 10 5 0 9.5 10 10.5 Time [s] 11 11.5 Figure 6.6: The step response from the smooth and damped roll rate controller in simulation with measurement noise turned off. The rise time is very small, about 0.08 seconds, while the overshoot is 9%. Roll rate [degrees/s] 25 20 15 10 5 0 9.5 10 10.5 Time [s] 11 11.5 Figure 6.7: The step response from the smooth and damped roll rate controller in simulation using measurement noise. 6.3 Tuning of real platform The tuning of the pid-controllers were made using the same method as tested in simulation. The transfer functions used were the models previously identified. The poles were placed to form a good step response and bode plot of the closed loop, which was an iterative process. The dominant poles were disturbed by nearby zeros which affected the performance. The method used did not handle those zeros at all. When the step response and bode plot looked alright, the 6 72 Controller Tuning performance was tested on the real platform. 6.3.1 Roll rate controller Phase (deg) Magnitude (dB) The model used was the identified arx-model, defined by equation (5.9). The bode plot of the model can be found in Figure 6.8. As seen, the system had a poor phase curve originating from the unstable pole. 0 −50 −100 −150 −90 −180 −270 10−2 10−1 101 100 102 Frequency (rad/s) 103 104 Figure 6.8: A bode plot of the roll model. The phase curve was near -180 degrees at low frequencies, which made the system unstable initially. Forming the closed loop of roll rate controller proved to be quite hard. The model used to tune the parameters was more complex and challenging than the one used in the concept evaluation in simulation. The choice of dominant pole was made by looking at the shape of the step response and the nyquist curve. In other words it was an iterative process. The choice of dominant poles were λ1,2 = −0.7 ± 0.2 (6.12) which, in theory, should give slow step response with rise time 4.35 seconds and no overshoot. These Figures might sound bad, but the poles were chosen to form the step response of the actual closed loop. This will soon become clear. To improve results, the value of m was modified. A bigger m means that the dominant poles will be more dominant with the cost of bigger pid parameters. m = 12 proved to be good trade off. The model and the dominant poles were inserted into equation (6.7) which was then analysed using root-locus. The plot of the root-locus is found in Figure 6.9. 6.3 Tuning of real platform 73 To push the other poles behind the line s = −12 · 0.7 a KP value of 33.47 or greater was needed. 40 KP = 33.47 30 Imaginary 20 10 0 −10 −20 −30 −40 −10 −5 0 Real 5 10 Figure 6.9: The root-locus plot of the poles of the closed loop using the controller defined by the dominant poles λ1,2 = −0.7±0.2. The KP value needed to push all other poles left to the line s = −12 · 0.7 was 33.47. With this choice of KP the pid-controller became F(s) = 33.47s + 11.53 + 18.73s s (6.13) which gave the transfer function of the closed loop Gc (s) = 0.07725s4 + 14.17s3 + 872.5s2 + 1522s + 521.6 s4 + 18.2s3 + 1008s2 + 1387s + 521.6 (6.14) The location of the poles and zeros of Gc can be found in Figure 6.10. In the plot where the dominant poles have been zoomed, it is clear that two zeros are near the dominant poles. This was a downside of the tuning method, since the designed step response would be affected by the zeros but nothing in the method stated how to handle those zeros. To find the stability margins of the system the nyquist curve of the system is plotted in Figure 6.11. There it can be seen the phase margin is 37 degrees while 6 74 0.5 Imaginary axis Imaginary axis 100 0 −100 −100 Controller Tuning 0 Real axis (a) All poles and zeros 100 0 −0.5 −2 −1 Real axis 0 (b) Zoomed in at dominant poles Figure 6.10: A pole-zero plot of the closed roll loop. The dominant poles are affected by the nearby zeros. the gain margin is -20.9 dB. A negative gain margin means that if the loop gain is lowered too much, the system will become unstable. Imaginary Axis 5 0 −5 −10 −15 −15 −10 0 −5 Real Axis 5 10 Figure 6.11: The nyquist curve of the roll rate system. The phase margin is 37 degrees while the gain margin is -20.9 dB. If the loop gain is lowered too much, the closed loop will lose its stability. At last, the step response of the closed loop have been plotted in Figure 6.12. The rise time was only 0.04 seconds. This is not very realistic and the model had obviously not captured the time delay that should be present in the propulsion system. The overshoot was 26% at its biggest. The zeros had a relativly big impact on the step respons and made it far more oscillative. 6.3 Tuning of real platform 75 1.5 1 0.5 0 0 2 1 3 4 5 Time [s] Figure 6.12: The step response of the closed loop. The rise time was only 0.04 seconds, which obviously was extremely unrealistic. The overshoot was 26%. 6.3.2 Pitch rate controller Then the pitch dynamic loop was to be tuned. The identified system, defined by equation (5.11) was used. Its bode plot was almost identical with the bode plot the roll dynamic and thus it will not be presented here. The dominant poles were chosen to λ1,2 = −0.7 ± 0.2 (6.15) which were exactly the same as for the roll controller. Using root-locus again, a KP value of 24.99 was needed to push the other poles left to the line s = −0.7 · 12. This was slightly lower than for the roll control. This gave the pid-controller F(s) = 24.99 + 8.63 + 13.88s s (6.16) and the closed loop equation Gc (s) = 0.0694s4 + 12.79s3 + 788.9s2 + 1387s + 476.4 s4 + 18.2s3 + 922.9s2 + 1267s + 476.4 (6.17) The closed loop had its poles and zeros placed almost identical as the closed roll loop. Once again, this was as expected. The nyquist curve of the pitch rate system showed that the phase margin and gain margin were almost the same as the corresponding ones for the roll rate loop. The step response had similar look to the step response of the closed roll loop. The overshoot was 23 % and the rise time was only 0.04 seconds. Once again, the rise time is obviously not realistic and the identification phase was not able to model that properly. 6 76 6.3.3 Controller Tuning Yaw rate controller Phase (deg) Magnitude (dB) The yaw rate controller was quite a challenge to tune. In Figure 6.13 the bode plot of the yaw dynamics model is shown. The system was not unstable and thus its bode plot looked rather good. 0 −50 −100 −150 0 −90 −180 −270 10−2 10−1 102 100 101 Frequency (rad/s) 103 104 Figure 6.13: The bode plot of the yaw dynamics model. Thanks to the low gain of the system, the gain margin was high at all time. The poles were chosen to λ1,2 = −1.3 ± 0.8 and m was set to 2. Using root-locus as before, KP was found to be 77.07. This gave the PID-controller F(s) = 77.07 + 75.30 + 21.02s s (6.18) and the closed loop Gc (s) = 0.04259s4 + 7.866s3 + 490.4s2 + 1357s + 1305 s4 + 13.1s3 + 755.6s2 + 1474s + 1305 (6.19) The integral term of the controller was very big and would probably cause problems with integral windup. To control the yaw rate properly an integral term was really not needed. Although, to form the closed loop it was needed. When the parameters later were tested on the real platform, the integral part had to be lowered and even removed since the control system otherwise would prioritize the yaw loop too much over pitch and roll. A look at the zeros and poles of the closed loop in the s-plane in Figure 6.14 showed that once again there were zeros near the dominant poles. Plotting the nyquist curve showed that the phase margin was 37 degrees and that the gain margin was infinite. A final look at the step response of the closed loop in Figure 6.15 the rise time again was far to quick to be realistic. The overshoot was very small, about 4%. 6.3 Tuning of real platform 77 Overall, the step response is very oscillative beacuse of the zeros near the dominant poles. 2 Imaginary axis Imaginary axis 100 0 −100 −100 0 Real axis 100 (a) All poles and zeros 0 −2 −2 −1 Real axis 0 (b) Zoomed in at dominant poles Figure 6.14: A plot of the poles and zeros of the closed yaw loop. In the zoomed plot it is obvious that the zeros were too close to the dominant poles. 1.5 1 0.5 0 0 1 2 3 4 5 Time [s] Figure 6.15: The step response of the closed yaw loop. The rise time was only 0.06 seconds, while the settling time was 3.1 seconds. The overshoot was only 4 %. 6.3.4 Flight test The parameters found in the design process were then used in the control loop on the real platform. Since the initial control system on the hexarotor did not have an integral part, one was added to the existing PD-controller. However, with the new parameters the hexarotor had become impossible to fly. It reacted extremely oscillatory and aggressive. When the integral part was removed it was still not able to fly properly. 7 Conclusions and further work 7.1 Conclusions The model implemented could fairly well simulate the behavior of a hexarotor system during hoover flight. A control system using decentralized P-PD controllers was a good choice since it managed to stabilize the hexarotor’s attitude. It was easily implemented and tuned and should work on all kinds of multirotor systems. The black-box identification of the attitude dynamics showed promising results. The frequency sweep used was a wisely chosen input signal. The hexarotor managed to stay airborne and it stayed near hover flight during the entire sweep. With more and better data, the identified models could have been really good. The method for tuning the parameters, placement of dominant pole, was successful in simulation but did not work on the real platform. The most reasonable explanation is the fact the identified models were not good enough. In simulation however, the step response of the system could be shaped in a desirable way. 7.2 Further work A better physical model of the propulsion systems should be developed to make the simulation model more realistic. One easy thing could be to include time delay in the motors, which should give a better understanding of the robustness limitations. The identification experiments should be repeated, with focus on the lower frequencies. By using a lower amplitude on the sweeps, the risk of leaving the hover 79 80 7 Conclusions and further work flight should be minimized. The control design could be improved by using gain scheduling to compensate for the restoring moment discussed earlier. Also the derivative part of the controller could be improved by better tuning the filter parameter and using a set point weight of zero, which means that only the measurement will be differentiated. Appendix A Blade flapping The propeller model used in thesis assumes rigid propellers, but in reality they are far from rigid which is why this effect was unaccounted for in the controller design. α T Tlon hr Center of gravity Air speed Figure A.1: Longitudinal motion will cause the propeller blades to flap. This in turn tilts the thrust vector which produced a restoring moment. In short, blade flapping is caused when the propeller translates through the air. The difference between propeller speed and air speed, that is the effective velocity, will be greater at the side of the advancing blade. A bigger effective velocity means more lift force on that side of the propeller. This will cause the blades to flap up and down once per revolution which tilts the thrust vector away from the flight direction. In figure A.1 a sketch of the effect can be seen. The tilting of the 83 A 84 Blade flapping thrust vector causes a longitudinal force, which is equal to Tlon = sin(α)T (A.1) where the tilt angle α depends on the amount of blade flapping. The blade flapping can be said to be depended on the longitudinal speed of the hexarotor (i.e. the air speed), the rotor speed and the stiffness of the blades. The attachment point of the propeller is above center of gravity causes the longitudinal force to create a restoring moment, calculated by Mr = Tlon hr (A.2) where hr is the distance vertical distance between the propeller and the center of gravity of the hexarotor. B Residual analysis The analysis of a model’s residuals, that is its prediction errors, is a good way of evaluating if the chosen model structure is able to capture all dynamic excited by the input signal according to [Ljung and Glad, 2004]. If y(t) is the measured output from the system and ŷ(t|θ̂N ) is the predicted output from the identified model described by the parameter vector θ̂N (N is number of samples in the estimation data), then the prediction error is naturally defined by ε(t) = ε(t, θ̂N ) = y(t) − ŷ(t|θ̂N ) (B.1) N 1 X ε(t + τ)u(t), N (B.2) Ideally, the prediction error should be independent of the input signal u(t). If vital part of system dynamics is missing in the model, the model will not be able to predict the output correctly and the prediction errors will not be independent of the input signal. By creating the covariance function between the input and the prediction errors, that is, R̂εu (τ) = t=1 |τ| ≤ M If the prediction error really is independent of the input, then R̂εu (τ) is normally distributed for big N with mean zero and variance according to Pr = ∞ 1 X Rε (k)Ru (k) N (B.3) k=−∞ where Rε (k) and Ru (k) are the covariance functions of ε and u respectively. To √ find out if R̂εu (τ) can be considered small enough one usually compares it to ±3 Pr . If R̂εu (τ) is outside these lines for some τ, it may be an indication that 85 B 86 Residual analysis ε(t + τ0 ) and u(t) are dependent for this particular τ0 . If an arx-model is used then one should consider including u(t − τ0 ) in the model. If this τ0 < 0 it is not an indication of an incomplete model structure, but rather a sign of that the data has been collected during feedback. One more way of investigate if the disturbance model is sufficient is by looking at the autocorrelation of the residuals. Ideally, the residuals should be mutually independent. This is tested by looking at R̂εε = N 1 X ε(t)ε(t + τ) N (B.4) t=1 This test is sometimes referred to as a whiteness test since the residuals should behave as white noise. C Basic control theory A second order system can be represented by G(s) = ω02 (C.1) s2 + 2ζω0 s + ω02 with ζ < 1 when the poles are complex conjugates. ζ is said to the relative damping of the system, while ω0 is a time scaling. The poles of this system are p (C.2) s = ω0 −ζ ± 1 − ζ 2 With the representation used earlier in thesis, that is the poles are ρ1,2 = −α ± β (C.3) p it is easily seen that α = ω0 ζ and β = ω0 1 − ζ 2 . The inverse relation is given by q α 1 =q ω0 = α 2 + β 2 , ζ = p (C.4) β 2 α2 + β2 1+ α From this it cat be concluded that the distance from origo to the poles is the time scaling, while the relation between α and β is the relative damping. The relation between α and β can also be interpreted as an angle, φ. This is because 1 cos(arctan(x)) = √ 1 + x2 (C.5) and by setting arctan(β/α) = arctan(φ) it is obtained that ζ = cos(φ) 87 (C.6) C 88 Basic control theory The angle and the distance can be drawn in the complex plane, as done in figure C.1. Im ω β 0 φ α Re Figure C.1: The poles and their relation to φ and ω0 The step response from this system is p e−ζω0 t y(t) = 1 − p sin(ω0 1 − ζ 2 t + φ), 1 − ζ2 cos φ = ζ (C.7) From this equation it can directly be seen that the frequency of the oscillation frequency of the step response is in fact β and that the exponential damping is α. From equations (C.4) and (C.7) it can be concluded that the characteristics of the step response is affected according to C.1. Parameter Interpretation Effect by increase of parameter |α| |β| arctan(β/α) p α2 + β2 Exponential damping Oscillation frequency Relative damping Time scaling Faster settling time, lower overshoot Faster rise time, bigger overshoot Faster rise time, bigger overshoot Faster rise time, overshoot constant Table C.1: How changing the poles affects the characteristics of the step response From this it can be said that a large β compared to α gives more oscillations and the magnitude of both α and β corresponds to the speed of the system. Bibliography M. Abdolhosseini, Y.M. Zhang, and C.A. Rabbath. An efficient model predictive control scheme for an unmanned quadrotor helicopter. Journal of Intelligent & Robotic Systems, 70(1-4):27–38, 2013. ISSN 0921-0296. doi: 10.1007/s10846-012-9724-3. Cited on pages 2 and 25. A. Alaimo, V. Artale, C. Milazzo, and A. Ricciardello. Pid controller applied to hexacopter flight. Journal of Intelligent & Robotic Systems, 73(1-4):261–270, 2014. ISSN 0921-0296. doi: 10.1007/s10846-013-9947-y. Cited on pages 3 and 25. K. Alexis, G. Nikolakopoulos, and A. Tzes. Switching model predictive attitude control for a quadrotor helicopter subject to atmospheric disturbances. Control Engineering Practice, 19(10):1195 – 1207, 2011. ISSN 0967-0661. doi: http: //dx.doi.org/10.1016/j.conengprac.2011.06.010. Cited on pages 2 and 25. ArduPilot.com. Arducopter wiki: Attitude pid, 2012. URL https://code. google.com/p/arducopter/wiki/AC2_attitude_PID. Accessed: 201404-11. Cited on page 26. C.A. Arellano-Muro, L.F. Luque-Vega, B. Castillo-Toledo, and A.G. Loukianov. Backstepping control with sliding mode estimation for a hexacopter. In Electrical Engineering, Computing Science and Automatic Control (CCE), 2013 10th International Conference on, pages 31–36, Sept 2013. doi: 10.1109/ICEEE. 2013.6676026. Cited on pages 2 and 25. K-J. Barsk. Model predictive control of a tricopter. Master’s thesis, Linköping University, Automatic Control, The Institute of Technology, 2012. Cited on pages 2, 25, and 35. F. Beltramini, M. Bergamasco, and M. Lovera. Experiment design for mimo model identification, with application to rotorcraft dynamics. In World Congress, volume 18, pages 14392–14397, 2011. Cited on pages 2 and 36. R.H. Bishop. Mechatronic Systems, Sensors, and Actuators: Fundamentals and Modeling. The Mechatronics Handbook, Second Edition. Taylor & Francis, 89 90 Bibliography 2007. ISBN 9781420009002. URL http://books.google.se/books?id= 3UGQsi6VamwC. Cited on page 12. S. Bouabdallah. Design and Control of Quadrotors with Application to Autonomous Flying. PhD thesis, École polytechnique fédérale de Lausanne, 2007. URL http://infoscience.epfl.ch/record/95939/files/ EPFL_TH3727.pdf. Cited on pages 17 and 26. S. Bouabdallah, A. Noth, and R. Siegwart. Pid vs lq control techniques applied to an indoor micro quadrotor. In Intelligent Robots and Systems, 2004. (IROS 2004). Proceedings. 2004 IEEE/RSJ International Conference on, volume 3, pages 2451–2456, Sept 2004. doi: 10.1109/IROS.2004.1389776. Cited on pages 2, 3, and 25. T. Bresciani. Modeling, identification and control of a quadrotor helicopter. Master’s thesis, Lund University, oct 2008. Cited on pages 15 and 26. M.V. Cook. Flight Dynamics Principles. Butterworth-Heinemann, 2nd edition, 2007. ISBN 0080550363. Cited on pages 11 and 12. O. Elbir, A.U. Batmaz, and C. Kasnakoglu. Improving quadrotor 3-axes stabilization results using empirical results and system identification. In Control Conference (ASCC), 2013 9th Asian, pages 1–5, June 2013. doi: 10.1109/ASCC. 2013.6606281. Cited on page 3. M. Elsamanty, A. Khalifa, M. Fanni, A. Ramadan, and A. Abo-Ismail. Methodology for identifying quadrotor parameters, attitude estimation and control. In Advanced Intelligent Mechatronics (AIM), 2013 IEEE/ASME International Conference on, pages 1343–1348, July 2013. doi: 10.1109/AIM.2013.6584281. Cited on page 2. M. Enqvist, T. Glad, S. Gunnarsson, and J. Löfberg. Industriell reglerteknik, kurskompendium, 2010. Cited on page 28. T. Glad and L. Ljung. Reglerteori, Flervariabla och Olinjära metoder. Studentlitteratur AB, 2:5 edition, 1997. ISBN 978-91-44-03003-6. Cited on page 45. T. Glad and L. Ljung. Reglerteknik, Grundläggande teori. Studentlitteratur AB, 4:7 edition, 2006. ISBN 978-91-44-02275-8. Cited on page 27. Gabriel M. Hoffmann, Haomiao Huang, Steven L. Wasl, and Er Claire J. Tomlin. Quadrotor helicopter flight dynamics and control: Theory and experiment. In In Proc. of the AIAA Guidance, Navigation, and Control Conference, 2007. Cited on page 33. W. Khan and M. Nahon. Toward an accurate physics-based uav thruster model. Mechatronics, IEEE/ASME Transactions on, 18(4):1269–1279, Aug 2013. ISSN 1083-4435. doi: 10.1109/TMECH.2013.2264105. Cited on pages 19 and 21. L. Ljung and T. Glad. System Identification: Theory for the user. Prentice Hall, 2 edition, 1999. ISBN 0136566952. Cited on pages 19 and 36. Bibliography 91 L. Ljung and T. Glad. Modellbygge och Simulering. Studentlitteratur AB, 2:5 edition, 2004. ISBN 978-91-44-02443-1. Cited on pages 57 and 85. R. Merzouki, A.K. Samantaray, P.M. Pathak, and B.O. Bouamama. Intelligent Mechatronic Systems: Modeling, Control and Diagnosis. SpringerLink : Bücher. Springer, 2nd edition, 2012. ISBN 9781447146285. URL http: //books.google.se/books?id=k81ECeMxyk8C. Cited on page 12. A. Mokhtari, N. K. M’Sirdi, K Meghriche, and A Belaidi. Feedback linearization and linear observer for a quadrotor unmanned aerial vehicle. Advanced Robotics, 20(1):71 – 91, 2006. ISSN 01691864. Cited on pages 2 and 25. C. Nordling. Physics Handbook. Studentlitteratur AB, 8:4 edition, 2006. ISBN 978-91-44-04453-8. Cited on page 23. P. Persson and K.J. Åström. Dominant pole design - a unified view of {PID} controller tuning. Control Engineering Practice, 1(6):1082, 1993. ISSN 0967-0661. doi: http://dx.doi.org/10.1016/0967-0661(93) 90080-B. URL http://www.sciencedirect.com/science/article/ pii/096706619390080B. Cited on page 65. P. Pounds, R. Mahony, and P. Corke. Modelling and control of a large quadrotor robot. Control Engineering Practice, 18(7):691 – 699, 2010. ISSN 09670661. doi: http://dx.doi.org/10.1016/j.conengprac.2010.02.008. Special Issue on Aerial Robotics. Cited on pages 15 and 19. F. Rinaldi, A. Gargioli, and F. Quagliotti. Pid and lq regulation of a multirotor attitude: Mathematical modelling, simulations and experimental results. Journal of Intelligent & Robotic Systems, 73(1-4):33–50, 2013. ISSN 0921-0296. doi: 10.1007/s10846-013-9911-x. Cited on pages 2, 3, and 25. A.S. Sanca, P.J. Alsina, and J. de Jesus F Cerqueira. Dynamic modeling with nonlinear inputs and backstepping control for a hexarotor micro-aerial vehicle. In Robotics Symposium and Intelligent Robotic Meeting (LARS), 2010 Latin American, pages 36–42, Oct 2010. doi: 10.1109/LARS.2010.14. Cited on pages 2, 23, and 25. B. Siciliano and O. Khatib. Springer Handbook of Robotics. Gale virtual reference library. Springer, 2008. ISBN 9783540239574. URL http://books.google. se/books?id=Xpgi5gSuBxsC. Cited on page 13. M.J. Sidi. Spacecraft Dynamics and Control: A Practical Engineering Approach. Cambridge Aerospace Series. Cambridge University Press, 1997. ISBN 9780521787802. URL http://books.google.se/books?id= xQpZJMtDehQC. Cited on page 13. J.R. Taylor. Classical Mechanics. University Science Books, 2005. ISBN 9781891389221. URL http://books.google.se/books?id= P1kCtNr-pJsC. Cited on page 14. 92 Bibliography M.B. Tischler. Aircraft and Rotorcraft System Identification. Engineering Methods with Flight-Test Examples. AIAA education series. Reston, VA : American Institute of Aeronautics and Astronautics, 2006. ISBN 1563478374. Cited on pages 36 and 44. Z. Zhiping. Stabilizability and dominant pole placement by pid controllers. Master’s thesis, National University of Singapore, 2007. Cited on page 65. Upphovsrätt Detta dokument hålls tillgängligt på Internet — eller dess framtida ersättare — under 25 år från publiceringsdatum under förutsättning att inga extraordinära omständigheter uppstår. Tillgång till dokumentet innebär tillstånd för var och en att läsa, ladda ner, skriva ut enstaka kopior för enskilt bruk och att använda det oförändrat för ickekommersiell forskning och för undervisning. Överföring av upphovsrätten vid en senare tidpunkt kan inte upphäva detta tillstånd. All annan användning av dokumentet kräver upphovsmannens medgivande. För att garantera äktheten, säkerheten och tillgängligheten finns det lösningar av teknisk och administrativ art. Upphovsmannens ideella rätt innefattar rätt att bli nämnd som upphovsman i den omfattning som god sed kräver vid användning av dokumentet på ovan beskrivna sätt samt skydd mot att dokumentet ändras eller presenteras i sådan form eller i sådant sammanhang som är kränkande för upphovsmannens litterära eller konstnärliga anseende eller egenart. För ytterligare information om Linköping University Electronic Press se förlagets hemsida http://www.ep.liu.se/ Copyright The publishers will keep this document online on the Internet — or its possible replacement — for a period of 25 years from the date of publication barring exceptional circumstances. The online availability of the document implies a permanent permission for anyone to read, to download, to print out single copies for his/her own use and to use it unchanged for any non-commercial research and educational purpose. Subsequent transfers of copyright cannot revoke this permission. All other uses of the document are conditional on the consent of the copyright owner. The publisher has taken technical and administrative measures to assure authenticity, security and accessibility. According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected against infringement. For additional information about the Linköping University Electronic Press and its procedures for publication and for assurance of document integrity, please refer to its www home page: http://www.ep.liu.se/ © Tobias Magnusson

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement