ABSTRACT Title of thesis: DEVELOPMENT OF A TEST-BED FOR CLOSED-LOOP MAV FLIGHT CONTROL Nitin Kumar Gupta, Master of Science, 2006 Thesis directed by: Professor Inderjit Chopra Department of Aerospace Engineering A novel ground based test-bed for closed loop flight control of MAVs is developed. The emphasis is on easy re-programability, measurement of internal states of the vehicle, fail-safe features, and modular design so that control algorithms can be efficiently eval- uated on a real MAV in flight. The sensors transmit data to the ground station using a wireless link. All processing is carried out on the ground station, and the final commands are up-linked back to the MAV. The control algorithm on the ground station is imple- mented in LabVIEW. A microcontroller is used on the ground station to take care of the time-critical tasks that cannot be handled by a PC. Starting with the early experiments on yaw-control, this report presents the results for the 3-DOF attitude control experiments done on an MAV using this test-bed. Three independent PID control loops are used to im- plement automation. Ziegler-Nichols method is used for tuning the PID controller gains. Simple proportional controllers in pitch and roll are shown to give good performance. The roll and pitch attitudes are maintained within ?0.1 radians by the controller. DEVELOPMENT OF A TEST-BED FOR CLOSED-LOOP MAV FLIGHT CONTROL by Nitin Kumar Gupta Thesis submitted to the Faculty of the Graduate School of the University of Maryland, College Park in partial fulfillment of the requirements for the degree of Master of Science 2006 Advisory Committee: Professor Inderjit Chopra, Chair/Advisor Professor Darryll Pines Professor Sean Humbert ACKNOWLEDGMENTS I owe my gratitude to all the people who have made this thesis possible and who have made my graduate experience one that I will cherish forever. First and foremost I would like to thank my advisor, Professor Inderjit Chopra for giving me an opportunity to work at the rotorcraft center at the University of Maryland. I am grateful to him for being patient and understanding with me on several occasions and for his support and encouragement. I would like to thank Dr. Jayant Sirohi for his suggestions and advice on various occasions during my graduate life. He has always made himself available for help and has taken great pains to go through my work and suggest improvements. I am also grateful to Joe for introducing me to several ideas, especially during the starting phase of my research. Working with him for a couple of months was a great learning experience. My colleagues at the graduate research office of the rotorcraft center have made my graduate life a most enriching experience. In particular, I would like to thank Peter who has been very closely associated with my research during the last six months and has provided invaluable help in successfully conducting the flight experiments. It would have taken me much much longer to finish, but for his help in fixing the Giant after every crash! He also provided a great help by conducting experiments to validate the complementary filter. I will always remember the lively discussions I have had with Vikram and Carlos over the last year. Their keenness to explore different subjects and re-learn things starting ii from the basic principles, has greatly inspired me. I am thankful to Vikram for his help during several experiments and theoretical derivations. John?s help as a pilot for the Giant during initial experiments is gratefully acknowledged. His love for flying things turned out to be quite contagious! I am highly indebted to Abhishek who has always been there (both at work and at home!) for guidance and help as an elder brother to me. I take this opportunity to also thank Arun, Smita, Asitav, Anne, Sandeep, Shreyas, Sudarshan, and all others at the rotorcraft center whose presence has made my graduate experience all the more lively and enjoyable. I would also like to express my gratitude to Amardip, Chinna and Milind for being such wonderful friends and house-mates. I owe my deepest thanks to my family - my mother and father who have always stood by me and encouraged me to do my best. Words cannot express the gratitude I owe them. I shall always remain indebted to them for the many sacrifices they have made to make me what I am. iii Contents Table of Contents iv List of Figures viii List of Tables xiv Nomenclature xv 1 Introduction 1 1.1 Micro Air Vehicles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 MAV Research Challenges . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Motivation and Challenge in Automation . . . . . . . . . . . . . . . . . 4 1.4 The Giant MAV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.5 Proposed Stability and Control Scheme . . . . . . . . . . . . . . . . . . 7 1.6 Overview of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2 The Hardware Components 11 2.1 Sensors and their Operation . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 Actuators and their Interface . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.1 Working of a Servo . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.2 The Standard R/C Transmitter and Receiver . . . . . . . . . . . . 18 iv 3 Preliminary One DOF Experiments 23 3.1 Yaw Control Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.1 The Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.2 Yaw Stabilization . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.1.3 Yaw Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.2 Issues Involved in Implementation of Free-Flight . . . . . . . . . . . . . 31 3.2.1 The Test Stand . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.2.2 The Avionics Package . . . . . . . . . . . . . . . . . . . . . . . 32 3.2.3 System Performance . . . . . . . . . . . . . . . . . . . . . . . . 32 3.2.4 Requirements for the MAV Control Test-bed . . . . . . . . . . . 33 4 Attitude Estimation 35 4.1 Attitude Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.1.1 Euler Angles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.1.2 Quaternions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.2 Attitude Determination using Gyroscopes . . . . . . . . . . . . . . . . . 42 4.3 Attitude Determination using Accelerometers . . . . . . . . . . . . . . . 44 4.4 Complementary Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4.4.1 The Pendulum Experiment . . . . . . . . . . . . . . . . . . . . . 45 4.4.2 Design of Complementary Filter . . . . . . . . . . . . . . . . . . 48 4.4.3 Performance of Complementary Filter . . . . . . . . . . . . . . . 52 4.5 Position Determinition using INS . . . . . . . . . . . . . . . . . . . . . . 52 4.6 IMU Aiding and Kalman Filtering . . . . . . . . . . . . . . . . . . . . . 55 5 The Ground Based Setup 58 5.1 PID Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 v 5.2 Overview of the New Test-Bed . . . . . . . . . . . . . . . . . . . . . . . 60 5.3 Subsystems of the Setup (Hardware) . . . . . . . . . . . . . . . . . . . . 62 5.3.1 The Sensors and Telemetry . . . . . . . . . . . . . . . . . . . . . 62 5.3.2 The R/C Transmitter Interface . . . . . . . . . . . . . . . . . . . 64 5.3.3 The Virtual Instrumentation on PC . . . . . . . . . . . . . . . . . 66 5.4 Organization of the Virtual Instrument (Software) . . . . . . . . . . . . . 66 5.4.1 The Receiver Module . . . . . . . . . . . . . . . . . . . . . . . . 68 5.4.2 The Processing Module . . . . . . . . . . . . . . . . . . . . . . . 70 5.4.3 The Transmitter Module . . . . . . . . . . . . . . . . . . . . . . 71 5.5 Implementation of the VI . . . . . . . . . . . . . . . . . . . . . . . . . . 72 5.5.1 Initializing the IMU . . . . . . . . . . . . . . . . . . . . . . . . 73 5.5.2 State Estimation Loop . . . . . . . . . . . . . . . . . . . . . . . 74 5.5.3 Output Loop (PID controller) . . . . . . . . . . . . . . . . . . . 74 6 Results and Discussion 76 6.1 Vibrations and Sensor Saturation . . . . . . . . . . . . . . . . . . . . . . 76 6.2 Manual Flight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 6.3 Controlled Flight Results . . . . . . . . . . . . . . . . . . . . . . . . . . 80 6.3.1 Ziegler-Nichols PID Tuning . . . . . . . . . . . . . . . . . . . . 82 6.3.2 Perturbation Response . . . . . . . . . . . . . . . . . . . . . . . 109 6.4 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 7 Conclusions and Future Work 116 7.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 7.2 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 7.3 The Future Roadmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 vi Appendices 124 A Gyroscope Drift 124 B Listing of Microcontroller Codes 130 C Implementing Digital Filters 138 D Setting up the Test-Bed 144 References 150 vii List of Figures 1.1 Fixed-wing based MAVs developed by Aerovironment . . . . . . . . . . 2 1.2 Giant rotary-wing based MAV developed at the University of Maryland . 2 1.3 MIcro COaxial Rotor (MICOR) rotary-wing based MAV (UMD) . . . . . 3 1.4 Configuration of the Giant . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.5 Subsystems involved in rotorcraft control . . . . . . . . . . . . . . . . . 7 1.6 Generic feedback control . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1 Internals of a typical gimballed inertial navigation system . . . . . . . . . 13 2.2 A typical gimballed inertial navigation system . . . . . . . . . . . . . . . 14 2.3 Internals of a typical strapdown inertial navigation system . . . . . . . . . 14 2.4 A typical strapdown inertial navigation system . . . . . . . . . . . . . . . 15 2.5 Schematic of strapdown inertial navigation system . . . . . . . . . . . . . 15 2.6 The standard servo used on R/C aircraft models . . . . . . . . . . . . . . 16 2.7 The internals of a standard servo . . . . . . . . . . . . . . . . . . . . . . 17 2.8 The PCM input signal to a servo . . . . . . . . . . . . . . . . . . . . . . 18 2.9 A typical R/C transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.10 A typical 4-channel micro R/C receiver . . . . . . . . . . . . . . . . . . 19 2.11 The motor driver circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.12 The PPM signal at the data port of an 8-channel transmitter . . . . . . . . 20 viii 2.13 The swashplate connections on a Blade-CP helicopter . . . . . . . . . . . 21 3.1 The yaw test stand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.2 The yaw control scheme . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.3 The MAG3 IMU from Memsense . . . . . . . . . . . . . . . . . . . . . . 25 3.4 The PIC 16F877A development board from CCS . . . . . . . . . . . . . 26 3.5 The hardware interfacing schematic for yaw control experiment . . . . . 26 3.6 The PD control scheme for yaw control . . . . . . . . . . . . . . . . . . 27 3.7 The yaw stabilization flowchart . . . . . . . . . . . . . . . . . . . . . . . 28 3.8 The flowchart for yaw control setup . . . . . . . . . . . . . . . . . . . . 30 3.9 The avionics package for 3 DOF onboard controller . . . . . . . . . . . . 32 4.1 Reference frames used in inertial navigation . . . . . . . . . . . . . . . . 36 4.2 The body fixed reference frame for the Giant . . . . . . . . . . . . . . . 37 4.3 The Euler angle transformations . . . . . . . . . . . . . . . . . . . . . . 38 4.4 Determining gyro bias . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.5 Pendulum Experiment Setup . . . . . . . . . . . . . . . . . . . . . . . . 46 4.6 Performance of accelerometer and gyro for attitude estimation (on axis) . 47 4.7 Performance of accelerometer and gyro for attitude estimation (off axis) . 48 4.8 The complementary filter schematic . . . . . . . . . . . . . . . . . . . . 49 4.9 Bode plot of the accelerometer filter transfer function (low pass) . . . . . 50 4.10 Bode plot of the gyroscope filter transfer function (high pass) . . . . . . . 51 4.11 Performanceofcomplementaryfilterforattitudeestimation(noaccelerom- eter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 4.12 Performance of complementary filter for attitude estimation (with ac- celerometer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 4.13 Complementary filter performance (accelerometer saturation) . . . . . . . 55 ix 4.14 Complementary filter performance (free oscillations) . . . . . . . . . . . 56 5.1 Schematic of PID control for autonomous flight of Giant . . . . . . . . . 59 5.2 Schematic of attitude control loop (inner-loop) . . . . . . . . . . . . . . . 60 5.3 Architecture of the ground based test-bed . . . . . . . . . . . . . . . . . 61 5.4 The wireless IMU from Spark Fun Electronics [35] . . . . . . . . . . . . 63 5.5 The structure of a sensor data packet . . . . . . . . . . . . . . . . . . . . 64 5.6 The interface of the transmitter with the PC . . . . . . . . . . . . . . . . 65 5.7 The flowchart for the transmitter interface code . . . . . . . . . . . . . . 67 5.8 The 3 modules of the VI and their interfaces . . . . . . . . . . . . . . . . 68 5.9 The receiver module . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.10 The definition of stick positions . . . . . . . . . . . . . . . . . . . . . . 70 5.11 The implementation of the VI . . . . . . . . . . . . . . . . . . . . . . . . 73 5.12 The output loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 6.1 IMU mounted on the Giant with foam padding . . . . . . . . . . . . . . . 77 6.2 Angular rate about body x-axis during flight (gyro saturated) . . . . . . . 77 6.3 Angular rate about body x-axis during flight (gyro not saturated) . . . . . 78 6.4 Pitch attitude estimate during manual flight . . . . . . . . . . . . . . . . 79 6.5 Longitudinal cyclic during manual flight . . . . . . . . . . . . . . . . . . 79 6.6 Comparison of computed longitudinal cyclic with actual pilot command . 80 6.7 Dual-curve in throttle to reduce sensitivity near hover RPM . . . . . . . . 81 6.8 Pitch attitude vs. time (KP? = 25,KP? = 25,KP? = 30) . . . . . . . . . . 85 6.9 Roll attitude vs. time (KP? = 25,KP? = 25,KP? = 30) . . . . . . . . . . . 85 6.10 Longitudinal cyclic vs. time (KP? = 25,KP? = 25,KP? = 30) . . . . . . . 86 6.11 Lateral cyclic vs. time (KP? = 25,KP? = 25,KP? = 30) . . . . . . . . . . 86 x 6.12 Yaw attitude vs. time (KP? = 25,KP? = 25,KP? = 30) . . . . . . . . . . . 87 6.13 Vane command vs. time (KP? = 25,KP? = 25,KP? = 30) . . . . . . . . . 87 6.14 Pitch attitude vs. time (KP? = 36,KP? = 25,KP? = 30) . . . . . . . . . . 88 6.15 Roll attitude vs. time (KP? = 36,KP? = 25,KP? = 30) . . . . . . . . . . . 89 6.16 Longitudinal cyclic vs. time (KP? = 36,KP? = 25,KP? = 30) . . . . . . . 89 6.17 Lateral cyclic vs. time (KP? = 36,KP? = 25,KP? = 30) . . . . . . . . . . 90 6.18 Vane command vs. time (KP? = 36,KP? = 25,KP? = 30) . . . . . . . . . 90 6.19 Yaw attitude vs. time (KP? = 36,KP? = 25,KP? = 30) . . . . . . . . . . . 91 6.20 Pitch attitude vs. time (KP? = 18,KP? = 130,KP? = 30) . . . . . . . . . . 92 6.21 Roll attitude vs. time (KP? = 18,KP? = 130,KP? = 30) . . . . . . . . . . 92 6.22 Pitch attitude vs. time (KP? = 18,KP? = 124,KP? = 30) . . . . . . . . . . 93 6.23 Roll attitude vs. time (KP? = 18,KP? = 124,KP? = 30) . . . . . . . . . . 93 6.24 Longitudinal cyclic vs. time (KP? = 18,KP? = 124,KP? = 30) . . . . . . 94 6.25 Lateral cyclic vs. time (KP? = 18,KP? = 124,KP? = 30) . . . . . . . . . 94 6.26 Yaw attitude vs. time (KP? = 18,KP? = 124,KP? = 30) . . . . . . . . . . 95 6.27 Vane command vs. time (KP? = 18,KP? = 124,KP? = 30) . . . . . . . . 95 6.28 Pitch attitude vs. time (KP? = 36,KP? = 62,KP? = 30) . . . . . . . . . . 96 6.29 Roll attitude vs. time (KP? = 36,KP? = 62,KP? = 30) . . . . . . . . . . . 96 6.30 Pitch attitude vs. time (KP? = 32,KP? = 62,KP? = 30) . . . . . . . . . . 97 6.31 Roll attitude vs. time (KP? = 32,KP? = 62,KP? = 30) . . . . . . . . . . . 97 6.32 Longitudinal cyclic vs. time (KP? = 32,KP? = 62,KP? = 30) . . . . . . . 98 6.33 Lateral cyclic vs. time (KP? = 32,KP? = 62,KP? = 30) . . . . . . . . . . 98 6.34 Yaw attitude vs. time (KP? = 32,KP? = 62,KP? = 30) . . . . . . . . . . . 99 6.35 Vane command vs. time (KP? = 32,KP? = 62,KP? = 30) . . . . . . . . . 99 6.36 Pitch attitude vs. time (KP? = 16,KP? = 62,KP? = 30) . . . . . . . . . . 101 xi 6.37 Roll attitude vs. time (KP? = 16,KP? = 62,KP? = 30) . . . . . . . . . . . 102 6.38 Longitudinal cyclic vs. time (KP? = 16,KP? = 62,KP? = 30) . . . . . . . 102 6.39 Lateral cyclic vs. time (KP? = 16,KP? = 62,KP? = 30) . . . . . . . . . . 103 6.40 Pitch attitude vs. time (KP? = 20,KP? = 55,KP? = 30) . . . . . . . . . . 103 6.41 Longitudinal cyclic vs. time (KP? = 20,KP? = 55,KP? = 30) . . . . . . . 104 6.42 Lateral cyclic vs. time (KP? = 20,KP? = 55,KP? = 30) . . . . . . . . . . 104 6.43 Roll attitude vs. time (KP? = 20,KP? = 55,KP? = 30) . . . . . . . . . . . 105 6.44 Pitchattitudevs. time(KP? =14.4,KI? =12.3,KP? =55.8,KI? =55.8,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 6.45 Rollattitudevs. time(KP? =14.4,KI? =12.3,KP? =55.8,KI? =55.8,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 6.46 Longitudinal cyclic vs. time (KP? = 14.4,KI? = 12.3,KP? = 55.8,KI? = 55.8,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 6.47 Lateralcyclicvs. time(KP? =14.4,KI? =12.3,KP? =55.8,KI? =55.8,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 6.48 Pitchattitudevs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . 108 6.49 Longitudinal cyclic vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . 109 6.50 Rollattitudevs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . 110 6.51 Lateralcyclicvs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . 111 6.52 Pitchattitudevs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . 111 6.53 Longitudinal cyclic vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . 112 6.54 Rollattitudevs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . 113 xii 6.55 Lateralcyclicvs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) . . . . . . . . . . . . . . . . . . . . . . . . 113 6.56 Longitudinal cyclic with perturbation at 36 sec . . . . . . . . . . . . . . 114 6.57 Pitch attitude response to longitudinal perturbation . . . . . . . . . . . . 114 7.1 Hierarchical decomposition of autonomous control [41] . . . . . . . . . . 121 D.1 Communication settings in LabVIEW . . . . . . . . . . . . . . . . . . . 147 D.2 Control settings in LabVIEW . . . . . . . . . . . . . . . . . . . . . . . . 148 xiii List of Tables 6.1 Ziegler-Nichols Tuning Method . . . . . . . . . . . . . . . . . . . . . . 82 6.2 Critical gain and period for pitch and roll . . . . . . . . . . . . . . . . . 100 6.3 Ziegler-Nichols Gains (Pitch) . . . . . . . . . . . . . . . . . . . . . . . . 100 6.4 Ziegler-Nichols Gains (Roll) . . . . . . . . . . . . . . . . . . . . . . . . 100 6.5 PID Controller Gains . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 xiv Nomenclature ?,?,? Pitch, roll and yaw attitudes, respectively (Euler angles) e0,e1,e2,e3 The four Euler parameters g Acceleration due to gravity p,q,r (Euler) body rates along x, y, and z body axes, respectively Ga(s) Transfer function for the low-pass filter (accelerometer branch) Gg(s) Transfer function for the high-pass filter (gyroscope branch) Ha(s) Accelerometer transfer function Hg(s) Gyroscope transfer function Kp Proportional gain Ki Integral gain Kd Derivative gain Kcr Critical gain KP?, K? Proportional gain for pitch axis KP?, K? Proportional gain for roll axis KP?, K? Proportional gain for yaw axis KI? Integral gain for pitch axis xv KI? Integral gain for roll axis KI? Integral gain for yaw axis KD?, Kq Derivative gain for pitch axis KD?, Kp Derivative gain for roll axis KD?, Kr Derivative gain for yaw axis Pcr Critical period Td Derivative time Ti Integral time Abbreviations A/D Analog to Digital ASCII American Standard Code for Information Interchange CCPM Cyclic Collective Pitch Mixing DOF Degree-Of-Freedom FIR Finite Impulse response GPS Global Positioning System IIR Infinite Impulse Response IMU nomenInertial Measurement Unit INS Inertial Navigation System LiPo Lithium-Polymer MAV Micro Air Vehicle MEMS Micro Electro Mechanical Sensor P Proportional control xvi PD Proportional-Derivative control PI Proportional-Integral control PID Proportional-Integral-Derivative control PCM Pulse Coded Modulation PPM Pulse Position Modulation PWM Pulse Width Modulation R/C Radio Control RPM Rotations Per Minute SISO Single Input. Single Output VI Virtual Instrument xvii Chapter 1 Introduction 1.1 Micro Air Vehicles MicroAirVehicles(MAVs)aredefinedbyDARPAassix-degree-of-freedomaerialrobots measuring less than 15 cm in length, width or height [1]. Such aircraft are expected to be small, inexpensive and expendable. These can be used for surveillance and measure- ment missions in urban environments and other situations, where larger vehicles are not practical. Their applications range from small unit battlefield surveillance, mapping out chemical/radiation spills or viral outbreaks to more routine applications such as, mon- itoring crops or wildlife distributions. With the ever-decreasing size and weight of the payload components that can include video cameras, chemical sensors, electronics, and communication devices, such applications are becoming more achievable. In the last decade, several concepts for MAVs have been developed. These can be broadly classified into fixed-wing based MAVs, like Black Widow, Hornet and Wasp [2?4] (Fig. 1.1), and rotary-wing based MAVs, like Giant [5] (Fig. 1.2) and Micor [6] (Fig. 1.3). 1 CHAPTER 1. INTRODUCTION Figure 1.1: Fixed-wing based MAVs developed by Aerovironment Figure 1.2: Giant rotary-wing based MAV developed at the University of Maryland Rotary-wing based MAVs have capabilities that may allow missions to be performed that cannot be considered for fixed-wing MAVs. In order to generate enough lift to sustain weight, the fixed-wing MAVs have to fly fairly fast. Rotary-wing based MAVs, on the other hand, can hover, and can take off and land vertically. This allows them to operate in more confined environments, such as, small indoor spaces and dense urban settings. 2 CHAPTER 1. INTRODUCTION Figure 1.3: MIcro COaxial Rotor (MICOR) rotary-wing based MAV (UMD) 1.2 MAV Research Challenges The small size requirements of MAVs generate a variety of challenges in their develop- ment, not seen in their full-scale counterparts. For the rotary-wing based MAVs, these challenges fall into two main categories: (1) improving aerodynamic efficiency or figure of merit, and (2) achieving stability and control [7]. Solutions for improving figure of merit of these vehicles are currently been developed in the form of design of rotor blades suitable for low Reynolds number flight, ducted rotors, and other novel concepts [8?11]. AsahumanpilotisnotpresentonboardtheMAVs, eitheraremotepilotoranautonomous controllerisrequiredinordertoflythesevehicle. EvenifaremotepilotcontrolstheMAV, a basic stability-augmentation system is desired to reduce pilot workload. Design of a 3 CHAPTER 1. INTRODUCTION test-bed to implement and evaluate closed-loop control during flight, and development of an attitude stabilization system using this test-bed are discussed in this thesis. 1.3 Motivation and Challenge in Automation Traditionally, the UAVs and MAVs were tele-operated by remote human-pilots. These UAVs were sometimes equipped with onboard cameras and other sensors to assist the human pilot by providing visual cues on his monitor [12]. Recently there has been much research effort to automate MAVs, which would not only eliminate the remote human pilotbutalsoallowhigherdegreeofmaneuverabilitytoaccomplishmissionswhichwould be extremely difficult, if not impossible, to fly for a remote human pilot. An important requirementofsuchautomationsystemsistoaugmentstability. Thisisexpectedtoenable untrained pilot to operate an MAV by issuing high-level commands. The smaller size and lower inertia, relative to the available thrust, of rotary-wing based MAVs makes them more maneuverable and agile than the full-scale helicopters. ThisalsomakesthecontrolandstabilizationofMAVsamorechallengingtaskthanthatof full-scale helicopters. Additional requirements like control and navigation in constrained environments, and low weight and size of the avionics package makes this problem even more involved [13]. Previous work on autonomous flight control of model helicopters has investigated outdoor flight of much larger models (5 feet rotor diameter and above) with higher payload carrying capability [14?18]. This research has resulted in successful autonomous flight of these large helicopter models. Typical payload carrying capability of MAV is around 20 grams. The design of an avionics package that is both light and 4 CHAPTER 1. INTRODUCTION provides reliable state estimation is still a challenge. 1.4 The Giant MAV We propose to use the Giant MAV (Fig. 1.4), developed at the Micro Air Vehicles Lab- oratory of University of Maryland, as the test-bed for our MAV control experiments be- cause it is representative of the dynamics of a typical hover-capable rotary-wing MAV, and still has a sufficient payload carrying capacity to lift the avionics package designed using commercial off-the-shelf components. This enables us to focus on issues related to implementation and algorithms related to flight stability and control. The Giant consists of a single fixed pitch rotor, with a set of vanes in the downwash of the rotor to provide the required anti-torque. The main rotor has a diameter of 25 cm. It is a two bladed rotor with a teetering hinge and a Bell/Hiller servo-paddle. Giant is powered by a brushless DC motor, and a 700mAh Lithium-polymer battery pack gives it an endurance of about 10 minutes. Yaw control is achieved by aerodynamic control surfaces in the vanes and lateral control is achieved by a swashplate connected to the servo-paddle. The Giant is equipped with an off-the-shelf gyro that provides automatic vane inputs in order to stabilize the vehicle in yaw. The entire system weighs 250 grams and has a payload carrying capacity of about 30 grams. The actuator configuration of the Giant is very similar to a conventional helicopter. It has four controls: the lateral and longitudinal cyclic inputs control the swashplate or the roll and pitch moments produced by the rotor; the thrust (rotor RPM) is controlled by the throttle input; the yaw input controls the angle of the vanes, thereby providing the anti- 5 CHAPTER 1. INTRODUCTION Figure 1.4: Configuration of the Giant torque to counter the rotor torque. Thus the controls have a direct effect on the Giant?s roll and pitch attitude rate, vertical velocity, and the heading rate, respectively. The pilot does not control Giant?s position and velocity directly. These are con- trolled through a chain of effects as follows. The cyclic control inputs result in control moments about the rotor hub via a tilting motion of the rotor tip-path-plane. The rotor control moments produce a fuselage rolling or pitching motion. The tilting of the tip- path-plane produces horizontal thrust components. For example, holding a constant pitch angle, the Giant will accelerate until the aerodynamic drag force balances the horizontal thrust component. In the steady state, a pitch or roll angle translates into a steady longi- tudinal or lateral velocity. Figure 1.5 shows a block diagram of the subsystems involved in the longitudinal-lateral control problem. Of course, different cross couplings also need to be compensated, such as the effect 6 CHAPTER 1. INTRODUCTION Rotr Fuselage Rotor Dynamics Angular Dynamics Translational Dynamics Gust Pilot Cycli Inputs Rotr Forces Rotr Moments Rol and Pitch Rotrcaft Atitude Rotrcaft Velocity Figure 1.5: Subsystems involved in rotorcraft control of the translation or rotational fuselage motion on the rotor and fuselage attitude dynam- ics, or the secondary effects of the controls. For example, when the Giant is pitched, the vertical thrust component will decrease, requiring an increase in the thrust magnitude to maintain altitude. This increase in thrust, however, will produce a reaction torque at the rotor shaft and thus vanes will need adjustment to provide more anti-torque. The Giant because of its relatively small size, is also quite sensitive to atmospheric disturbances that affect the rotor and fuselage dynamics. 1.5 Proposed Stability and Control Scheme WeproposetoimplementfeedbackcontrolinordertostabilizeandcontrolanMAV.Basic architecture of such a control scheme is shown in figure 1.6. 7 CHAPTER 1. INTRODUCTION - + Actuators Sensors and Filter Algorithms Control Algorithm Vehicle Dynamics Desired Stats Control omands Estimate of Curent Vehicle States Figure 1.6: Generic feedback control The sensors (attached to the vehicle) and the associated filter algorithms give us an estimate of the current states of the vehicle. These states are dictated by the control algorithm and the control objective. For 6 DOF control (3 rotational and 3 translational degrees-of-freedom) of the vehicle, the states would typically be the attitude and position ofthevehicle. Thecontrolalgorithmthenusesthisinformationtocomputethecommands for the actuators in order to stabilize and control the vehicle as desired. These actuators act on the vehicle and influence its motion. The sensors, in turn, again estimate the new values of the states, and the entire cycle is repeated. The first step in implementing this scheme is the selection of a control algorithm. This decision is based on the kind of vehicle, its dynamics, availability of its flight dy- namics model, the actuator configuration, and of course the control objective. The states required by the control algorithm will dictate the sensors and the filter algorithms to be used. The sensor selection is also constrained by payload carrying capability of the vehi- cle, onboard power available and other operational constraints (e.g., GPS cannot be used if the vehicle has to operate indoors). If no suitable sensors and filter algorithms could be 8 CHAPTER 1. INTRODUCTION found to provide the states required by the chosen control algorithm, we need to select a different control algorithm for which suitable sensors and filter algorithms exist. The control algorithms can be broadly classified into modern model-based con- trol techniques and the classical techniques. Given a highly accurate vehicle dynamics model of a vehicle, the model-based techniques, like the H-infinity control, would have significantly better performance than a classical controller, like the PID (Proportional- Integral-Derivative) control [19]. While a PID based controller is expected to achieve basic automation, it will not be optimal, and will not be able to fully utilize the available degree of maneuverability of the vehicle. As there does not exist a sufficiently accurate model for the Giant and developing such a model for any rotorcraft-based vehicle is a challenging task in itself, we opt to first implement a classical PID based control and demonstrate the working of the generic test-bed developed to enable this implementa- tion. Such a test-bed can later be used for implementing a model-based controller when required. 1.6 Overview of the Thesis This thesis presents the development of an innovative test-bed for closed loop MAV flight control experiments. The basic concepts from control theory, state estimation and an overview of hardware components used for this setup is given in Chapter 2. Chapter 3 descibes the preliminary experiments performed to develop understanding of these basic concepts. The yaw-control experiment and development of a complete onboard stabiliza- tion system are discussed in detail. The software and hardware aspects of the final test- 9 CHAPTER 1. INTRODUCTION bed developed to overcome the shortcomings of the onboard stabilization system form the subject of Chapter 4. The results of the 3-DOF hover control experiment are discussed in Chapter 5. Chapter 6 presents the conclusions and recommendations for future work. A quick guide to setting up the test-bed for future experiments and solutions to common problems encountered are documented as an appendix to this thesis. 10 Chapter 2 The Hardware Components 2.1 Sensors and their Operation Inertial measurement unit (IMU) provides one of the most established methods for es- timating the motion (change in attitude and position) of a vehicle [20, 21]. This is a self-contained system and does not need information from external source, like GPS, to determine position. An accelerometer measures acceleration along a single axis. Its output can be inte- grated to get velocity. The second integration gives the position, or change in position. If the direction of travel is known, the current position with respect to the original position can thus be obtained. The inertial navigation system (INS) is a form of ?dead reckon- ing?, that is, it gives the present position with respect to the initial position, and it cannot directly find the absolute position in the inertial frame. Three accelerometers can be put together with orthogonal sensing directions to give a measure of displacement in the three-dimensional space. In order to maintain the ori- 11 CHAPTER 2. THE HARDWARE COMPONENTS entation of these accelerometers when the vehicle maneuvers, the accelerometers are sus- pended in a set of three gimbals which are gyro-stabilized to maintain the direction. Such an arrangement forms the ?gimballed? configuration of the inertial navigation system. The gyros, used in the gimballed inertial navigation system are of a type known as ?integrating? gyros, that is, they give output proportional to the angle through which they have been rotated (about their sensing axis). They serve as the sensing elements in the null-seeking servos. The output of each gyro drives the servo motor connected to the appropriate gimbal, thus keeping the gimbal in a constant orientation in inertial space. The gimbals are a set of three rings, each with a pair of bearings, initially at right angles (fig. 2.1). Each gimbal also consists of a motor, built around one of the bearings, and at the other end a synchro (an electromagnetic angle-measuring device) [22]. The innermost gimbal always maintains its orientation in inertial space, irrespective of how the vehicle maneuvers. The synchro on the innermost gimbal thus measures the azimuth (heading), the synchro on the middle gimbal measures the pitch, and the one on the outer gimbal measures roll. The innermost gimbal provides a ?stable platform? which holds the gyros and the accelerometers. The entire system is called a ?gimballed platform?. Figure 2.2 shows the Marconi FIN1000 inertial platform, which is used in virtually all the RAF?s combat air- craft and many others world-wide. Such systems can measure vehicle?s position, velocity, acceleration, attitude, and heading. Over the last 30 years, the gimballed inertial naviga- tion technology has fully matured and very reliable and accurate IMUs are available. The gimballed arrangement is mechanically very complex. It contains delicate sliprings, the motors dissipate power; mechanical resonances are unavoidable. Due to 12 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.1: Internals of a typical gimballed inertial navigation system high part count, these are too heavy and bulky to be carried by MAVs. Research in the direction of simplifying the complexity of these systems lead to the development of ?strapdown? systems. These do away with the gimbal altogether and the gyros and accelerometers are mounted on the platform directly. The gyros are used to measure the rotations in space instead of null-seeking sensors. Using the gyro informa- tion, thesystemknowswhichdirectiontheaccelerometeraxisispointinginatanyinstant. Thus, the mechanical gimbals are replaced by a ?mathematical gimbal set? (fig. 2.3, 2.4). Realizationofsuchasystembecamepossibleduetorecentadvancesinlightweight, powerful and cheap digital computers (or microcontrollers), and MEMS (Micro Electro- Mechanical Sensor) technology. A software solution is used to keep track of the orien- tation of the IMU (and vehicle) and transform the measurements from the body frame to the navigational frame. This method overcomes the problems encountered with the gimbaled system, and most importantly reduces the size, cost, power consumption, and complexity of the system. The strapdown INS measures the orientation of a vehicle by 13 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.2: A typical gimballed inertial navigation system Figure 2.3: Internals of a typical strapdown inertial navigation system 14 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.4: A typical strapdown inertial navigation system Rate Gyros Acelrometrs Orientation Integration Inital Orientation Transform to Localy-Levl Navigation Frame Subtract g From Vertical Acelration Velocity Integration Positon Integration Inital Velocity Inital Positon , xyz ! ,!"# vPositon of the vehicle Atitude of the vehicle Figure 2.5: Schematic of strapdown inertial navigation system integrating the angular rates from three orthogonal angular rate sensing gyroscopes (rate gyros) strapped down to the frame of the vehicle. To get position, 3 accelerometers, also affixed to the orthogonal axes of the moving body, measure the total acceleration vector of the body relative to the inertial space. This acceleration vector can be converted from the body coordinates to inertial coordinates using the known instantaneous orientation of the body determined by the gyros. Position is then obtained by subtracting the effect of gravity from the measured acceleration and then performing double integration starting from a known initial position (fig. 2.5). 15 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.6: The standard servo used on R/C aircraft models 2.2 Actuators and their Interface The actuators used on the Giant are the standard servos used on most commercially avail- able radio-controlled (R/C) aircraft models (fig. 2.6). A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. As the coded signal changes, the angular position of the shaft changes. These servos although quite small, can generate very high torque. The servos used on the Giant are rated at 10 oz-inch. 2.2.1 Working of a Servo Aservoworksontheprincipleofnegativefeedback. Figure2.7showstheinternalpartsof a servo. Here, the current to the motor is provided by a potentiometer that is itself driven by the same motor. This potentiometer also serves as the output shaft. The motor when turned on, drives the potentiometer till the potentiometer provides no more current to the 16 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.7: The internals of a standard servo motor. A circuitry allows for changing this zero-current position of the potentiometer, based on the input signal. So, when a new position of the potentiometer (or output shaft) is desired, this zero position is altered by the circuitry (based on input signal) and the motor turns the potentiometer till this zero position is reached. The angle is determined by the duration of a pulse that is applied to the control wire. This is called Pulse Coded Modulation (PCM). The servo expects to see a pulse every 20 milliseconds (.02 seconds). The length of the pulse determines how far the motor turns. A 1.5 ms pulse, for example, will make the motor turn to the 90-degree position (often called the neutral position). If the pulse is shorter than 1.5 ms, then the motor will turn the shaft to closer to 0 degrees. If the pulse is longer than 1.5 ms, the shaft turns closer to 180 degrees (fig. 2.8). The position of a servo can therefore be theoretically updated not more than 50 times per second (20 ms for each update). This imposes a fundamental limit on the servo bandwidth besides the mechanical performance issues. 17 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.8: The PCM input signal to a servo 2.2.2 The Standard R/C Transmitter and Receiver Giant canbe flown manuallyby ahuman pilot usingthe standard radio-controltransmitter and receiver. The radio-control transmitter (fig. 2.9) converts movements of the control sticks and switches into a coded radio signal, which is transmitted by radio to the radio- control receiver (fig. 2.10) installed on Giant. The signal is received and then decoded by the micro-controller on the receiver into the servo-control signals. Giant needs a transmitter and a receiver with at least 4 channels, one each for con- trolling longitudinal cyclic, lateral cyclic, rotor RPM and yaw-control vanes. While lon- gitudinal cyclic, lateral cyclic and yaw-control vanes are directly driven by the servos (which are connected to different channels on the receiver), the rotor RPM is controlled through a motor-driver circuit (fig. 2.11), which converts the servo-control signals into high frequency PWM signals. Radio-control transmitters are usually provided with a data port. The signals being 18 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.9: A typical R/C transmitter Figure 2.10: A typical 4-channel micro R/C receiver 19 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.11: The motor driver circuit Figure 2.12: The PPM signal at the data port of an 8-channel transmitter sent by the transmitter, corresponding to the stick positions can be read on the output pin of this port. This port also has an input pin, and any desired signal can be written to this pin for transmission to the receiver. The input and output signals on this port follow a modulation very similar to the servo-control signal. The normal state of the pin is high. Each frame has a width of 20 ms and has as many inverted-pulses as the number of channels. The width of the first pulse (inverted pulse) corresponds to the position of first servo, and so on as shown in figure 2.12. This modulation is called the inverted Pulse Position Modulation (PPM) as different channels are represented by different positions of the pulses in each frame. It is important to note that although usually each stick corresponds to one servo channel (as in case of Giant), there maybe configurations where each stick movement 20 CHAPTER 2. THE HARDWARE COMPONENTS Figure 2.13: The swashplate connections on a Blade-CP helicopter may lead to changes in more than one servo channel. For example, in a typical CCPM (Cyclic/Collective Pitch Mixing) type of RC helicopter (like, Blade-CP [23]), the swash- plate is controlled by three servos (fig. 2.13). The motion of all three servos is affected even if only one of the two cyclic or collective controls is applied. Therefore, although pilot moves only one stick at a time, the width of all three pulses corresponding to swash- plate servos changes. The hardware components described in this chapter are all commercial off-the-shelf components. These enable the Giant to be flown manually by a human pilot. The next task is to use the knowledge of the protocols and internal working of these components to interface these (along with sensors) with a processing element (microcontroller or a PC) 21 CHAPTER 2. THE HARDWARE COMPONENTS in order to automate the flight of the Giant. 22 Chapter 3 Preliminary One DOF Experiments 3.1 Yaw Control Experiment As the first step, in order to explore the requirements of a stability augmentation system, a yaw stabilization experiment was conducted on the Giant. For this purpose, a test stand that allowed only one degree-of-freedom (yaw) was prepared, and the Giant was mounted on it, as shown in figure 3.1. A single degree of freedom PD (proportional-derivative) control scheme as shown in figure 3.2, in conjunction with a commercial off-the-shelf IMU, was implemented for stabilization. The yaw angle is measured and the yaw-vanes on the Giant are controlled in a way so as to maintain the same yaw attitude. 3.1.1 The Hardware After an exhaustive search, the MAG3 IMU from Memsense [24] was selected for the sensor. This IMU (fig. 3.3) has 3 gyroscopes each with a range of ?150 deg/sec, 3 23 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Giant MAV IMU Bearing allows only Yaw DOF Vice Microcontroller Figure 3.1: The yaw test stand Figure 3.2: The yaw control scheme 24 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Figure 3.3: The MAG3 IMU from Memsense accelerometers each with a range of?2g and 3 magnetometers each with a range of?1.9 gauss. All sensor outputs are available as analog voltages varying from zero to five volts. This is one of the smallest and lightest IMUs available, weighing only 5 grams and having a size of 0.7 in x 0.7 in x 0.4 in. A development board (fig. 3.4) based on Microchip PIC 16F877A microcontroller [25] was obtained from Custom Computer Services, Inc. (CCS) [26] to serve as an in- terface between the sensors and the actuators, and to carry out the control computations. 16F877A microcontroller from PIC is an 8-bit microcontroller running at 20 MHz, and has 256 bytes of EEPROM data memory. It has 2 capture/compare/PWM functions, sup- port for I2C bus and 8 channels of 10-bit Analog-to-Digital (A/D) converter. The de- velopment board from CCS gives easy access to all these input/output pins, provides an interface to easily program the microcontroller and has a potentiometer connected to one of the A/D channels. Figure 3.5 shows the interface between different hardware compo- nents. 3.1.2 Yaw Stabilization The numerical integration of yaw-rate (to get yaw angle), PD controller and servo com- mand generation are implemented on the microcontroller as shown in figure 3.6. Here the 25 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Figure 3.4: The PIC 16F877A development board from CCS Figure 3.5: The hardware interfacing schematic for yaw control experiment 26 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Figure 3.6: The PD control scheme for yaw control analog output from yaw gyro is continuously sampled. This is then added to a counter, which is initialized to zero in the beginning of the code, to give a quantity proportional to the yaw angle (determination of exact yaw angle is not important). The output angle of the vanes is computed using the value of this angle and the angular rate at that instant. A separate interrupt routine generates appropriate signal for the vane servo, based on this desired angle of vanes, once every 20 ms (as explained in section 2.2.1). It is important to use interrupt routine for this task as it is time critical. The microcontroller suspends all other tasks, once every 20 ms, and generates the servo signal. The flowchart for this is given in figure 3.7 and the code is attached as an appendix to this report. The proportional and derivative gains (K? and Kr, respectively) used for the compu- tation of output angle of vanes are experimentally determined. Here, the HighTime equa- 27 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Figure 3.7: The yaw stabilization flowchart 28 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS tion represents the PD controller. This controller continuously moves the vanes (changes the value of HighTime) so as to hold a constant yaw attitude when the main rotor is spun or its RPM changed. 3.1.3 Yaw Control The setup is later modified for yaw control (from yaw stabilization). A potentiometer provided on the CCS development board is used to command the desired yaw angle. The code is upgraded to sample the analog voltage from the potentiometer and use it for computation of the vanes angle. The interrupt routine in this case remains the same as that for the previous case. On turning the potentiometer, the vehicle is observed to follow the command and turn by the desired yaw angle. In the next step, this setup is further modified and was interfaced with an RC re- ceiver (discussed in section 2.2.2). This way the human-pilot can command the desired yaw angle remotely using the R/C transmitter. This is different from normal radio control, as in the normal case, the pilot would control the angle of the vanes, which would change the torque, and hence the yaw acceleration. By using the yaw attitude controller, he can however directly command the desired yaw angle using the knob on the R/C transmitter. The controller now continuously adjust the vanes to achieve and maintain that yaw atti- tude. The new flowchart is given in figure 3.8. This uses two interrupt routines, one to generate the servo signal and other to read the signal from the R/C receiver. The code is listed as an appendix to this report. 29 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Figure 3.8: The flowchart for yaw control setup 30 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS 3.2 Issues Involved in Implementation of Free-Flight The goal of this project is to enable controlled free-flight of the MAV, that is, the Giant should not be constrained to the yaw-stand. The electronics therefore needs to be pack- aged and mounted on the vehicle. The source of power for this electronics should also be carried on the vehicle. Once the yaw-control is demonstrated in free-flight, it would be desirable if the same setup can later be modified for additional pitch and roll control, along with yaw control. The setup used for yaw control in the previous section (section 3.1.3) had all the basic components required for the 3-DOF control; it had an appropriate sensor package (with 3 gyros, 3 accelerometers and 3 magnetometers), a microcontroller to do the computations, and it was interfaced with the RC receiver so that control com- mands can be sent to it remotely. The microcontroller used here is on a development board which is designed for ease of use and not for least weight and size. 3.2.1 The Test Stand The test stand used in the yaw control experiment allowed the use of microcontroller development board (bulky but easy to use), as only the IMU and the servos were directly mountedonthevehicle; restofthehardwarewaskeptonthetablejustbelowtheGiantand was connected to the sensors and the actuators using long wires. A wireless telemetry link was not required for this experiment as the vehicle was not free to fly. The development of the miniature onboard stabilization system to enable free-flight of the Giant is discussed in this section. 31 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS Intel Mote One communication module used for this research is the Intel iMote, shown in figure 12. The iMote consists of an ARM 7TDMI 32-bit microprocessor operating at 12 MHz, a wireless Zeevo Bluetooth radio capable of 700 Kbps on a 2.4 GHz frequency, and on-board data logging memory, and is capable of I 2 C, UART (serial), and GPIO wired communications. The entire unit weighs 6.4 grams. This particular mote was chosen for its powerful processor and high-bandwidth radio. Transceiver Module Figure 13. Transceiver Module. An additional transceiver module, seen in figure 13, has been developed to complement the Intel Mote. This module utilizes a serial-to-wireless module from Radiotronix, along with the required external com- ponents. The maximum range of this module is approximately 500 meters, but has a lower maximum bandwidth and does not include multi-node networking as advanced as the Intel Mote. For long range vehicle communication outdoors, this module is the preferential communications module. System Integration Configurations The possibilities for system integration can be seen in figure 16. The arrows in figure 15 define components that can be connected to share information. The modularity inherent in the design allows for several configurations to suit a desired level of functionality. The actuator module includes the optional capability to interface with a traditional RC receiver, should the Intel Mote bi-directional bandwidth be unnecessary. A configuration for attitude control would include the IMU daughterboard, the actuator module, and a communications board, which weighs a total of approximately 25 grams, seen in figure 14. The Actuator module can be omitted to create a 15 gram remote inertial sensing and telemetry module, seen in figure 15. IMU/Actuator/Intel Mote Combo Figure 14. IMU/Actuator Board/Comm Board Configuration. 11 of 14 American Institute of Aeronautics and Astronautics Figure 3.9: The avionics package for 3 DOF onboard controller 3.2.2 The Avionics Package An avionics package (fig. 3.9) consisting of an IMU, three PIC 18F6722 microcontrollers and a transceiver, designed by Conroy [27], is used for onboard control implementation. This package, including the IMU and all other components weighs 30 grams. It consists of 3 boards (sensor board, actuator board and the transceiver board) that can be snapped together in different configurations. 3.2.3 System Performance The autonomous yaw stabilization with pilot controlling the other degrees of freedom was successfully demonstrated on the Giant in free-flight using this setup. The 3 DOF attitude control, although based on the same basic principle as the yaw control setup, has several significant differences. The main issue is that of sufficiently accurate estimation of attitude states. The control can only be as good as the state estimation. While minor errors in estimation of yaw heading are not critical, relatively small errors in pitch and roll 32 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS estimation are not acceptable, as the vehicle would then develop large linear velocities and cease to hover. The 3 DOF system also involves the transformation of information from body to navigation frame (section 4.1). This was not required for the yaw control experiment as only one DOF was involved. We therefore need to work towards filter and transformation algorithms before a 3 DOF control can successfully be implemented. 3.2.4 Requirements for the MAV Control Test-bed The experience with the onboard avionics package helped in the evolution of a list of features required in a setup for effective development of control laws and evaluation of different algorithms. The test-bed is required to have the following basic features: ? Visibility of states; easy to debug: The main problem with the onboard avionics package is that sufficient data is not being sent back to ground. It is therefore difficult to locate the problem and to debug the system. It is required that the test- bed allows several more intermediate states (e.g., raw sensor data, filtered data, pilot inputs, servo commands generated) to be continuously monitored for faster and effective evaluation of an algorithm. ? Easy re-programability: Re-programming the different microcontrollers on the avionics package is a very time consuming job. Firstly, all the algorithms need to be programmed in PIC-C (a variant of standard C language) and then optimized for execution on a microcontroller. Secondly, a number of wires need to be con- nected from the avionics package to the computer and power supply, each time a microcontroller has to re-programmed. This makes the entire process very cumber- 33 CHAPTER 3. PRELIMINARY ONE DOF EXPERIMENTS some and significantly reduces the number of different cases that one would like to experimentally evaluate. ? Moreprocessingpower: The microcontrollers have very limited processingpower andotherresources. Theprogramsthereforeneedtobecarefullyoptimizedtomake sure they are executed as desired. Most of the times, it becomes difficult to locate if the source of error is in the algorithm itself or in the way it has been coded for the microcontroller. In order to first evaluate the algorithm, we would like to use a test-bed with much more processing power. ? Safety features: The design of onboard avionics package did not incorporate suf- ficient safety features. In case of malfunction of any electronics, there was no way to bypass the setup and take over manual control of the vehicle. This resulted in at least one major accident that led to some serious damage to Giant. It is there- fore important that the test setup for such experiments incorporates better safety features. 34 Chapter 4 Attitude Estimation In order to implement a 3 DOF attitude stabilization and control system, the primary task is to correctly determine and represent the attitude of the vehicle. The rotations in three dimensional space are not commutative. It is therefore important to be consistent with the conventions. Further, the attitude can be estimated using both the accelerometers and the gyroscopes; but both have their limitations and therefore filtering algorithms are necessary to get reliable attitude information. These issues are discussed in detail in this chapter. 4.1 Attitude Representation Inertial navigation uses several reference frames [28], which are shown in figure 4.1. We restrict our discussion to the earth fixed navigation frame and the body fixed frame. The origin of the navigation frame is located on the surface of the earth such that the Oze axis is directly towards the center of the spherical Earth. The Oxe axis points 35 CHAPTER 4. ATTITUDE ESTIMATION Figure 4.1: Reference frames used in inertial navigation towards the local north and Oye points towards the local east to form a right-hand system. The location of the origin of this coordinate is chosen so that it lies beneath the vehicle at t = 0. Such a system is useful for defining the position of the vehicle with respect to the launch point and orientation of the vehicle, and with respect to the gravity vector and local north. ThebodyaxessystemontheGiantisdefinedinaccordancewithstandardaerospace convention. The center of gravity of the Giant is the origin of this system. The Oxb axis goes out the nose of the vehicle, the Oyb axis is perpendicular to the Oxbzb plane and points towards the right side, as shown in figure 4.2. The Ozb axis is the symmetry axis and points downwards so as to form a right-hand system. Since the vehicle is axi- symmetric about Ozb axis, an orange sticker is placed on one side of the vehicle and nose is defined as being directly opposite to this orange sticker, as shown in figure 4.2. 36 CHAPTER 4. ATTITUDE ESTIMATION Figure 4.2: The body fixed reference frame for the Giant Since we do not plan to use a magnetic heading sensor for initial experiments, we need not associate the Oxe and Oye axes with north and east directions. At t = 0, the vehicle is on ground and is stationary. Hence, Ozb axis is aligned with Oze. Therefore, to simplify interpretation of results, the Oxe axis is defined to be parallel to Oxb axis at t = 0; similarly, Oye axis is defined to be parallel to Oyb at t = 0. As the sensors are strapped to the body of the vehicle, the raw data is obtained in the body frame. This needs to be converted into navigation frame in order to determine the current position and attitude with respect to the initial states in earth-fixed reference frame. There are two main methods of carrying out this transformation: (1) using Euler angles, and (2) using quaternions (Euler parameters). 37 CHAPTER 4. ATTITUDE ESTIMATION Figure 4.3: The Euler angle transformations 4.1.1 Euler Angles The orientation of a given reference frame can be related to another reference frame by three Euler angles: ?,?,?, or, the roll, pitch and yaw angles, respectively (fig. 4.2). In the present application, Euler angles give the orientation of the Giant in space with respect to the Earth. ? is called the heading or yaw angle, ? the inclination or pitch angle, and ? the roll or bank angle. The orientation change is divided into three consecutive rotations, first about the body z-axis by angle ?, then about the new body y-axis by angle ?, and finally about the newer still body z-axis by angle ?. In figure 4.3 the x,y,z are the original body axes, xprime,yprime,zprime are the new body axes after first rotation, xprimeprime,yprimeprime,zprimeprime are the new still body axes after second rotation, and xprimeprimeprime,yprimeprimeprime,zprimeprimeprime are the final body axes after third rotation. We now derive the transformation matrix for such a sequence of rotations. Before the first rotation, the body-referenced coordinates match those of the navigation frame, i.e.,vectorx0b =vectorx. For first rotation, yaw about z-axis by angle ?, the rotation matrix is given 38 CHAPTER 4. ATTITUDE ESTIMATION by. vectorx1b = ? ?? ?? ?? ? cos? sin? 0 ?sin? cos? 0 0 0 1 ? ?? ?? ?? ? vectorx0b = R(?)vectorx0b (4.1) The transformation about z-axis does not modify the z-coordinate of the point. Other axes are modified according to the basic trigonometry. Now apply the second rotation, pitch about the new y-axis by angle ?. vectorx2b = ? ?? ?? ?? ? cos? 0 ?sin? 0 1 0 sin? 0 cos? ? ?? ?? ?? ? vectorx1b = R(?)vectorx1b (4.2) Finally, rotate (roll) the system about the newest x-axis by ?: vectorx3b = ? ?? ?? ?? ? 1 0 0 0 cos? sin? 0 ?sin? cos? ? ?? ?? ?? ? vectorx2b = R(?)vectorx2b (4.3) This represents the location of the original point in the fully-transformed body-reference framevectorx3b (henceforth called justvectorxb). The equivalent transformation can be written as: vectorxb = R(?)R(?)R(?) = ? ?? ?? ?? ? cos?cos? cos?sin? ?sin? ?sin?cos?+sin?sin?cos? cos?cos?+sin?sin?sin? sin?cos? sin?sin?+sin?cos?cos? ?cos?sin?+sin?sin?cos? cos?cos? ? ?? ?? ?? ? vectorx = R(?,?,?)vectorx (4.4) All the transformation matrices including R(?,?,?) are orthonormal, i.e., their inverse is 39 CHAPTER 4. ATTITUDE ESTIMATION equal to their transpose [28]. Therefore we can get the inverse transform as: vectorx = R?1vectorxb = RTvectorxb (4.5) Similarly, a transformation matrix for angular rates can be derived. Given the angular rates in the body frame, the Euler rates can be computed using the current Euler angles as follows [28]: ? ?? ?? ?? ? ?? ?? ?? ? ?? ?? ?? ? = ? ?? ?? ?? ? 1 sin?tan? cos?tan? 0 cos? ?sin? 0 sin?cos? cos?cos? ? ?? ?? ?? ? ? ?? ?? ?? ? p q r ? ?? ?? ?? ? (4.6) The most significant drawback of Euler angle scheme is the existence of singularity when pitch angle is ? 90 degrees, since at this angle both roll and yaw have similar effects. Thus, in applications where one has to encounter high values of pitch angle, a different way of measuring orientation is required. 4.1.2 Quaternions Quaternions present a practical alternative to the Euler angles for attitude representation. These have the advantage that no singularity is encountered for any orientation. Funda- mental to this method is Euler?s theorem that body frame can be made to coincide with navigation frame by a single rotation D about a fixed axis in space making angles A, B, C 40 CHAPTER 4. ATTITUDE ESTIMATION with the navigation frame [28]. Four parameters can be defined, e0,e1,e2,e3 as follows: e0 = cos D2 (4.7) e1 = cosAsin D2 (4.8) e2 = cosBsin D2 (4.9) e3 = cosCsin D2 (4.10) It can be verified that these four parameters are constrained by: e20 +e21 +e22 +e23 = 1 (4.11) The transformation matrix in equation (4.4) can now be written as: R(?,?,?) = ? ?? ?? ?? ? e20 +e21?e22?e23 2(e1e2 +e0e3) 2(e1e3?e0e2) 2(e1e2?e0e3) e20?e21 +e22?e23 2(e2e3 +e0e1) 2(e0e2 +e1e3) 2(e2e3?e0e1) e20?e21?e22 +e23 ? ?? ?? ?? ? (4.12) The relation between Euler angles and Euler parameters can be derived as [28]: e0 = cos?2 cos?2 cos?2 +sin?2 sin?2 sin?2 (4.13) e1 = cos?2 cos?2 sin?2 ?sin?2 sin?2 cos?2 (4.14) e2 = cos?2 sin?2 cos?2 +sin?2 cos?2 sin?2 (4.15) e3 = ?cos?2 sin?2 sin?2 +sin?2 cos?2 cos?2 (4.16) 41 CHAPTER 4. ATTITUDE ESTIMATION The rate equations for the four quaternion parameters, given the present value of these parameters are [28]: ?e0 = ?12(e1p+e2q+e3r) (4.17) ?e1 = 12(e0p+e2r?e3q) (4.18) ?e2 = 12(e0q+e3p?e1r) (4.19) ?e3 = 12(e0r+e1q?e2p) (4.20) 4.2 Attitude Determination using Gyroscopes The gyroscopes are strapped to the body and they give a direct measure of angular rates in bodyframe, i.e., p, qandr. Thesebodyratesaretransformedintonavigationframe(Euler rates) using equation (4.6). For this computation step, the values of Euler angles at the previous instant are used (dead-reckoning) and the result is then numerically integrated to obtain the new Euler angles. The algorithm is initialized with zero Euler angles when the vehicle is on ground, to start with. Gyro bias, defined as the output produced by gyro at rest, leads to drift in determi- nation of orientation. Fixed bias, if uncompensated, leads to a constant rate of drift after integration. However, the startup bias can be measured before take-off and corrected. What matters then is bias stability. The typical drift performance of a ring laser gyro is about 0.001 deg/hr, which is sufficient to get accurate position within about a mile for one hour [29]. On the other hand, the recently developed very low cost and miniature Coriolis vibratory gyroscopes (CVGs) have drift rates ranging from several degrees per hour to a 42 CHAPTER 4. ATTITUDE ESTIMATION 2.107 2.104 2.103 2.102 2.101 2.100 2.099 2.098 2.097 2.106 2.105 150010005000 Time (seconds) Output (volts) 5 sec 30 1 Figure 4.4: Determining gyro bias degree per second! A gyro at rest is sampled for a period of time and the average of all the samples collected gives the bias of the gyro. An experiment to demonstrate non-constant gyro bias was conducted. The ADXRS150 gyroscope [30] from Analog Devices is used for this experiment. Figure 4.4 shows three different lines corresponding to the averages taken over 5, 15 and 30 seconds repeatedly in order to estimate bias. The gyro is sampled at a rate of 100 samples per second using a 12 bit analog-to-digital converter. The calibration factor for the gyroscope is 60 degrees per volt. This data is collected after the sensor has been on for over 2 hours so that a stable temperature has been reached. This shows that it is not possible to assign a single exact value to gyro bias as the output for zero angular rate keeps changing over the time. Any choice of gyro bias will lead to drift in the integrated 43 CHAPTER 4. ATTITUDE ESTIMATION result. Further discussion on the sources of gyro drift is included in the appendix to this report. 4.3 Attitude Determination using Accelerometers The accelerometers, strapped to the vehicle, measure the tilt by registering changes in the component of gravity along their axes. Assuming, linear accelerations are negligible compared to the acceleration due to gravity, the pitch and roll angles can be computed from the accelerometers. Using transformation equations 4.4, 4.5, we get: ax = ?gsin? (4.21) ay = gsin?cos? (4.22) az = gcos?cos? (4.23) We therefore get: ? = sin?1 ?axg (4.24) ? = tan?1 aya z (4.25) where, ax, ay and az represent the accelerations (due to gravity) measured by the three orthogonal accelerometers aligned along the body x, y and z axes, respectively, and g represents the acceleration due to gravity. Aserious drawbackofthe accelerometeris itssensitivityto vibrations. Toeliminate this, a low frequency filter is required which limits the bandwidth of the accelerometers and introduces a phase delay in the filtered result. 44 CHAPTER 4. ATTITUDE ESTIMATION 4.4 Complementary Filter We have seen that either gyroscopes or accelerometers can be used to determine atti- tude. However, each sensor has serious limitations when used alone; a gyroscope has long term divergence problem due to drift (bad for measuring low frequency rates) and an accelerometer has bandwidth problem due to low pass filter (bad for measuring high frequency rates). These limitations are demonstrated by the results of the experiments described in the next section. 4.4.1 The Pendulum Experiment A thin aluminum beam is suspended from the rotational axis of a potentiometer to form a pendulum. The potentiometer used is a contactless Hall effect based angle sensor [31]. This potentiometer gives analog output proportional to the pendulum angle within a range of ?40 degrees. The output of the potentiometer is nonlinear outside this range. The IMU discussed in section 5.3.1 is mounted on the aluminum beam 4.5. The data from the gyroscope is integrated to get the attitude. We also get attitude from the accelerometers using equation 4.24. The data from the accelerometers and gyroscopes on the IMU can now be compared with the attitude given by the potentiometer (the true angular position of pendulum). The IMU is setup with the bluetooth transmission of sensor data. The potentiometer is sampled separately at a rate of 500 Hz using a 12-bit analog-to-digital converter. All data is displayed on a chart in LabVIEW. To filter the noise, 5 potentiometer readings are read at a time and averaged. Similarly, a moving average of last 10 samples is used on 45 CHAPTER 4. ATTITUDE ESTIMATION Figure 4.5: Pendulum Experiment Setup the accelerometer data. The angle data from the gyroscopes is quite smooth because of integration; so no filtering is required for the gyroscope. In the first case, the IMU is mounted on the axis of rotation. This makes sure that the accelerometer is not subjected to any linear accelerations and it thus measures only the change in the component of gravity along its axis (hence the angular position of pendulum). The pendulum is now given a push by the hand and the data from 3 different sensors, i.e., the potentiometer, the gyroscope and the accelerometer is recorded. This is shown in figure 4.6. The accelerometer data shows a good match with the potentiometer data. The attitude from the gyroscope is seen to drift away from the true attitude (from potentiometer) with time. The IMU is placed at a distance of 14 inches away from the axis of rotation on the pendulum for the second test. The results for this test are shown in figure 4.7. When the pendulum is held at some attitude with hand, the accelerometer is seen to give correct attitude, but when in motion, it is no longer able to give correct attitude estimate. This is because now it is subject to linear acceleration along with changes in the magnitude of gravity along its axis. In fact, when the pendulum is allowed to swing freely, the ac- 46 CHAPTER 4. ATTITUDE ESTIMATION ! " # $ % &?( &)! &)( &! ( ! )( )! *+,-./0-12 3456-. /7-52 89:-4:+9,-:-; 311-6-;9,-:-; <=;9019>- Figure 4.6: Performance of accelerometer and gyro for attitude estimation (on axis) celerometer does not measure any angle. This is because the linear accelerations exactly cancel the change in the magnitude of the gravity along its axis (in the linear approxi- mation, both equal to g? in different directions; where ? is the angle of the pendulum with the vertical). The attitude from the gyroscope is again seen to drift away from the true attitude with time. The pendulum was given large oscillatory perturbations by hand towards the end of experiment (as seen towards the right end of figure 4.7). We therefore notice that the attitude form the accelerometers is way off during such situations, i.e., in the presence of high linear accelerations, or vibrations. 47 CHAPTER 4. ATTITUDE ESTIMATION ! "# "! $# $! %# %! &?# &(# &)# &$# # $# )# (# *+,-./0-12 3456-. /7-52 89:-4:+9,-:-; 311-6-;9,-:-; <=;9019>- Figure 4.7: Performance of accelerometer and gyro for attitude estimation (off axis) 4.4.2 Design of Complementary Filter The complementary filter is used to fuse the outputs of different sensors with comple- mentary noise characteristics [32]. In this case, rate gyros provide a good high frequency estimate of attitude and the accelerometers provide a good low frequency estimate, as discussed before. The best estimate of the orientation is thus obtained as the sum of the signals from two measurement branches as shown in figure 4.8. The accelerometers feed output signal into the filter Ga(s), which provide the contribution of the accelerometer branch to the low frequency estimate of attitude. The output of rate gyros is fed into the filter Gg(s), which provides the high frequency estimate of attitude. In order to have constant amplification of the entire system, the filter transfer func- 48 CHAPTER 4. ATTITUDE ESTIMATION Acelrometr Ha(s) Rate Gyro Hg(s) Filter Ga(s) Filter Gg(s) + ! ! & Estimate Plant Figure 4.8: The complementary filter schematic tions Ga(s) and Gg(s) must be chosen according to [32]: Ha(s)Ga(s)+sHg(s)Gg(s) = 1 (4.26) where, Ha(s) and Hg(s) denote transfer functions of the accelerometer and gyro respec- tively. We assume the sensors to be ideal and hence use: Ha(s) = Hg(s) = 1 (4.27) This is assumption is valid because the dynamics of sensors is much faster than that of the vehicle itself. Therefore, equation (4.26) is reduced to: Ga(s)+sGg(s) = 1 (4.28) A second order filter with a double pole is now selected: Ga(s) = 4s+1(2s+1)2 (4.29) Gg(s) = 4s(2s+1)2 (4.30) Here, the transfer function Ga(s) works as a first order low-pass filter (-20 db per decade) on the signal coming from the accelerometer (fig. 4.9). The other transfer func- tion, Gg(s) works as a second order high pass filter with respect to the orientation (-40 db per decade), on the signal from the gyroscope (fig. 4.10). 49 CHAPTER 4. ATTITUDE ESTIMATION M a g n i t u d e ( d B ) P h a s e ( d e g ) Frequency (rad/sec) Figure 4.9: Bode plot of the accelerometer filter transfer function (low pass) 50 CHAPTER 4. ATTITUDE ESTIMATION M a g n i t u d e ( d B ) P h a s e ( d e g ) Frequency (rad/sec) Figure 4.10: Bode plot of the gyroscope filter transfer function (high pass) 51 CHAPTER 4. ATTITUDE ESTIMATION 4.4.3 Performance of Complementary Filter The pendulum experiment described in section 4.4.1 is now repeated with the comple- mentary filter designed above. The results for this case are shown in figure 4.11 (no accelerometer data) and figure 4.12 (with accelerometer data). We see that although the attitudes from both the accelerometer and the gyroscope do not match very well with the true attitude (potentiometer), for some or the other region of the chart, the attitude from the complementary filter shows a very good match for all regions. It takes care of both the drift in the gyros (low frequency phenomenon) and the linear accelerations in the ac- celerometers (mostly due to vibrations, a high frequency phenomenon). Close-up views of of different regions of this plot are shown in figures 4.13, 4.14. 4.5 Position Determinition using INS Linear position determination is a much harder problem than attitude estimation. Firstly, there are accelerometer instrument errors such as bias stability, scale factor stability, non- linearity and misalignment. Inertial grade accelerometers must keep these errors to a few micro-g to get an accuracy of 1 mile/hr. Since position is obtained by double integrating acceleration, leads to a position drift error that grows quadratically in time. It is there- fore especially critical to accurately estimate and eliminate any persistent bias errors. The second critical cause of error in position measurement is error in the orientation deter- mined in the gyros. Since the INS interprets the direction of the measured acceleration according to the computed orientation of the platform, and error in this computer orienta- tion will cause it to integrate the accelerations in the wrong direction, thus deviating from 52 CHAPTER 4. ATTITUDE ESTIMATION !" #" $" %" &" ?" (" )!"" )&" " &" !"" *+,-./0-12 3456-. /7-52 89:-4:+9,-:-; <9,=6-,-4:>;?.@+6:-; A?;9019=- Figure 4.11: Performance of complementary filter for attitude estimation (no accelerom- eter) 53 CHAPTER 4. ATTITUDE ESTIMATION !" #" $" %" &" ?" (" )!"" )&" " &" !"" *+,-./0-12 3456-. /7-52 89:-4:+9,-:-; <9,=6-,-4:>;?.@+6:-; 311-6-;9,-:-; A?;9019=- Figure 4.12: Performance of complementary filter for attitude estimation (with ac- celerometer) 54 CHAPTER 4. ATTITUDE ESTIMATION !" !# !! !$ !% &?"" &(" " (" ?"" )*+,-./,01 2345,- .6,41 789,39*8+,9,: ;8+<5,+,39=:>-?*59,: 200,5,:8+,9,: @>:8/08<, Figure 4.13: Complementary filter performance (accelerometer saturation) the true course of the vehicle. More importantly, the cancellation of gravity will be per- formed imperfectly by the navigation computer. This will cause a horizontal acceleration component to be erroneously added to the navigation-frame acceleration vector. Thus, even gyros have a more critical accuracy requirement in order to get an accurate position estimate using INS. 4.6 IMU Aiding and Kalman Filtering Although figure 2.5 shows how IMU is theoretically self-sufficient for the purpose of both attitude and position determination, we now realize that practically it can only be reliably used for attitude determination (provided linear acceleration are negligible compared to 55 CHAPTER 4. ATTITUDE ESTIMATION !! !" !# !$ %& ?"& ?!& & !& ()*+,-.+/0 1234+, -5+30 678+28)7*+8+9 :7*;4+*+28<9=,>)48+9 1//+4+97*+8+9 ?=97./7;+ Figure 4.14: Complementary filter performance (free oscillations) 56 CHAPTER 4. ATTITUDE ESTIMATION acceleration due to gravity). Therefore, IMUs are normally one component of a naviga- tion system. Other systems such as GPS (used to correct for long term drift in position), a barometric system (for altitude correction), or a magnetic compass (for attitude correc- tion) compensate for the limitations of an IMU [33]. Note that most other systems have their own shortcomings which are mutually compensated for. In case of accelerometers and gyroscopes, there is a clear distinction in the fre- quency range where each gives a reliable estimate of attitude. We are therefore able to exploitthispropertyanddeviseacomplementaryfilter. Wheremanydifferentsystemsare used, the region of reliability can always not be marked as clearly in terms of frequency or magnitude. Such situations need more advanced filtering algorithms, like Kalman filter, that can optimally fuse all the available data, utilizing sensor and their noise characteris- tics [34]. 57 Chapter 5 The Ground Based Setup 5.1 PID Configuration We need to find a suitable control algorithm that can be used for autonomous flight of the Giant, and then build a test-bed for its implementation and performance evaluation. A hu- man pilot applies lateral cyclic in order to control the roll degree-of-freedom. Similarly, one applies longitudinal cyclic or vane input to control pitch or yaw degrees-of-freedom, respectively. For a full-envelope flight, it is important to consider coupling between dif- ferent axes and nonlinear dynamical effects; thus a SISO (single input, single output) PID framework is clearly not suitable. But, for a near-hover flight, roll, pitch and yaw can be treated as uncoupled and a linear SISO PID controller is expected to give satisfactory results [19]. The schematic of the PID control scheme that we plan to implement on the Giant is shown in figure 5.1. The inner attitude-control loop (higher bandwidth) forms the core of the controller anddirectlyinteractswiththevehicletoachievetherequiredattitudes. Theoutertranslation- 58 CHAPTER 5. THE GROUND BASED SETUP Helicopter/MAV Dynamics Sensors u,v,w p,q,r ref ! ,!"# pd u long lat ! Attitude Control Loop (Inner) x,y,z Translation Cotrol Lop (Outer) Desired Positon Desired Velocity + Velocity Estimate Body Rates stiate Atitude Estimate Positon stiate PID Control Figure 5.1: Schematic of PID control for autonomous flight of Giant control loop (lower bandwidth) is the secondary controller, which takes translation com- mands from the user and generates equivalent attitude commands for the inner loop (which in turn controls the vehicle). Next, we need to look for appropriate sensors to implement these two control loops. The attitude-control loop needs the sensors that can provide information regarding the 3- DOF attitude of the vehicle, and the translation-control loop additionally requires the 3-DOF position information. In the present work, we focus on the attitude control loop of the controller and discuss in detail how to obtain a good estimate of attitude of the vehicle using low cost sensors. The detailed schematic of this controller is shown in figure 5.2. 59 CHAPTER 5. THE GROUND BASED SETUP Helicopter/MAV Dynamics Sensors p q r ref ! ! ref ref q K ! ! p r K ! ped u long lat u Figure 5.2: Schematic of attitude control loop (inner-loop) 5.2 Overview of the New Test-Bed The design of the new test-bed, incorporating the features listed in section 3.2.4, is now discussed. This is a ground based setup with the main idea to do minimal work onboard and to transfer all the complex jobs to the ground station. Ground station can employ much faster processors and can help graphical monitoring of much more data than what can be done using onboard microcontrollers. The architecture for such a system is shown in figure 5.3. Here, only the sensors and the actuators are placed on the vehicle. The sensors send the raw sensed data to the ground station using a wireless transmitter. All the processing is done on ground and the final command are linked back to the vehicle using the wireless equipment. 60 CHAPTER 5. THE GROUND BASED SETUP Receiver Computer (Processing) Transmitter Receiver Sensors and Telemetry The Flying Platform Wireless Downlink Wireless Uplink The Ground Station Figure 5.3: Architecture of the ground based test-bed 61 CHAPTER 5. THE GROUND BASED SETUP One of the most important requirement for such a system is redundancy. That is, should the control system fail, the Giant should revert back to normal manual controls. The wireless links employed need to be very reliable, as any communication failure could lead to loss of computer control of flight. Since the standard R/C transmitter-receiver is known to provide very reliable communication, is inexpensive, easily available and redundancy can be easily built using it, hence it was decided to use the same for uplinking the commands from the ground station. As mentioned earlier in section 2.2.2, the input pin on the data port of the transmitter can be used to transmit data received from a source external to transmitter. The servos and the speed controller on the Giant (or any other MAV in use) are connected to the same R/C receiver as in the case of normal manual flight configuration. 5.3 Subsystems of the Setup (Hardware) This setup consists of 3 main subsystems (fig. 5.3); first, consisting of the onboard sensors and the wireless transmission of this data; second, reception of this data on ground and its processing to generate the commands for the actuators; and third, consisting of the interface with the R/C transmitter to uplink these commands to the Giant and to read pilot inputs. 5.3.1 The Sensors and Telemetry A sensor-board with Bluetooth data transmission capability was obtained from Spark Fun Electronics [35]. It consists of a MMA7260Q single IC triple axis accelerometer [36] 62 CHAPTER 5. THE GROUND BASED SETUP The 3 orthogonal ADXRS150 Gyros The MMA7260Q triple-axis accelerometer BlueSMiRF Bluetooth transceiver Figure 5.4: The wireless IMU from Spark Fun Electronics [35] from Freescale and three ADXRS150 gyroscopes [30] from Analog Devices, mounted along three orthogonal axes as shown in figure 5.4. This sensor-board weighs about 22 grams. The analog data from these six sensors is sampled by PIC16F88 microcontroller and it transmitted to ground through an onboard BlueSMiRF Bluetooth transceiver [37]. The firmware on microcontroller allows for selection of appropriate data channels to be sampled and the range for accelerometers, as described in the datasheet [38]. Six channels corresponding to sampled data from the 3 accelerometers and 3 gyroscopes are selected from the firmware menu. A range of ?2g is selected for accelerometers. The gyroscopes have a range of ?150 deg/sec. All the analog channels are sampled using a 10-bit ADC. Therefore, each sample consists of 2 bytes in the data-stream. The lower 10 bits are occupied by the sample and the upper 6 bits read as zeros. Each data packet, consisting of one sample each from all 6 channels, starts with an ?A, then has 12 bytes corresponding to readings from 6 sensors and concludes with an end byte ?Z. Therefore, 14 consecutive bytes, starting with an ?A? and ending with a ?Z?, make a packet. The 63 CHAPTER 5. THE GROUND BASED SETUP 0 00 00 0X X X X XX X XX X Head ?A? Tail ?Z? 1 sensor eading Upper Byte Lower Byte ? readings from 5 other sensors? The uper 6 bits (zero) The 10 bit sensor dat Figure 5.5: The structure of a sensor data packet structure of the packet is illustrated in figure 5.5. A data rate of about 230 packets/second is achieved using the 57.6 kbps bluetooth wireless link. A bluetooth dongle is used on the ground station PC to receive the data from the wireless IMU. 5.3.2 The R/C Transmitter Interface The generation and sampling of high frequency pulses, as required by the transmitter for communication(discussedin section2.2.2), istimecritical andcannotbedirectlydoneby a PC running a normal non-real-time operating system (e.g., MS Windows, Linux, or Mac OS). We, therefore, either need a PC with real-time operating system, or a microcontroller to interface the transmitter with a PC running a non-real-time operating system. The latter option is chosen, as it simplifies application development using LabVIEW and is also faster and cheaper to implement. The microcontroller communicates with the PC using serial port (RS232) and with the transmitter using PPM pulses (fig. 2.12), as shown in figure 5.6. 64 CHAPTER 5. THE GROUND BASED SETUP PPM Signals ?00101001? Serial Data (RS232) PC with LabVIEW MicrocontrollerTransmitter Figure 5.6: The interface of the transmitter with the PC The radio control system used has 6 channels. Therefore, each frame of PPM (dis- cussed in section 2.2.2) consists of 6 pulses corresponding to each of these channels. The system can easily be modified to use transmitters with 4, 8 or any other number of chan- nels. The transmitter is used both for sending commands to the vehicle, as well as, as an input device, i.e., to get pilot inputs through the sticks. Therefore, the microcontroller in this interface does two jobs: 1. Writing data to transmitter: The PC sends a stream of six 8-bit numbers to the microcontroller over the serial port, corresponding to the width of each of the six pulses in a PPM frame. For servos to hold position and for the effective working of the system, a new frame is required every 20 ms. The microcontroller is pro- grammed to continue to repeat the same PPM frame till data for a new frame is received from the PC. In order to synchronize, the decimal number ?255? (a byte with all 1?s) is sent by the PC before every frame. Once the microcontroller receives this synchronization byte, the next 6 bytes are read as data corresponding to the 6 channels, respectively. 2. Reading data from transmitter: The data from the transmitter is continuously 65 CHAPTER 5. THE GROUND BASED SETUP sampled and the width of each pulse in a frame is calculated by the microcontroller. This data is then sent to the PC as six 8-bit numbers over the serial port, corre- sponding to each of the six channels. A pulse of width larger than 2.5 ms marks the beginning of a new frame. For communication with PC, the microcontroller first sends a byte with all bit as 1?s (for synchronization) and then 6 bytes corresponding to the 6 channels of data, in order. Figure 5.7 shows the flowchart for the microcontroller code. The PIC-C code is included in the appendix to this report. 5.3.3 The Virtual Instrumentation on PC The Virtual Instrumentation (VI) on the PC, using the National Instrument?s LabVIEW software [39], forms the core of this experimental setup and the rest of discussion will primarily concentrate on its implementation. The sensor data is received, processed and commands for the transmitter are generated through this VI. Almost all the processing is therefore done on the ground station PC using this VI. This provides a very efficient way to make changes to the controller and conduct different experiments. 5.4 Organization of the Virtual Instrument (Software) The in-house developed VI can be divided into 3 distinct modules as discussed below. These modules communicate using a set of well-defined protocols, i.e., the type and for- mat of input to, and output from each module is defined. This allows for replacement or up-gradation of any of the module without disturbing the working of rest of the VI. Figure 66 CHAPTER 5. THE GROUND BASED SETUP Figure 5.7: The flowchart for the transmitter interface code 67 CHAPTER 5. THE GROUND BASED SETUP Receiver Module Sensor Data from Receiver Control Module Transmitter Module 3 body rates and 3 body accelerations The 4 ?stick? positions The actual servo positions required Fixed Protocol To Transmitter Figure 5.8: The 3 modules of the VI and their interfaces 5.8 shows a schematic of the interface between these modules. 5.4.1 The Receiver Module The receiver module is coded as a separate sub-VI. It reads the data from the Bluetooth receiver via serial port. The data is received as a packet of 14 bytes (discussed in section 5.3.1). The receiver module makes use of the packet delimiters, ?A? and ?Z?, to check for validity of data. If the packet does not have appropriate delimiters, it is discarded and the module waits for next valid packet. After successful validity check, the 12 middle bytes of a packet are fused together, taken 2 at a time to retrieve the 6 sensor readings of 10-bit each. The raw sensor data thus obtained is converted into meaningful physical quantities, i.e., angular body rates in radians per second and linear accelerations in gs, using the calibration data, and passed on to the processing module. The working of the receiver module is shown in figure 5.9. 68 CHAPTER 5. THE GROUND BASED SETUP Fuse 2 bytes at a time to get sensor readings Use calibration to get physical quantities Read Data from serial port Is it valid? Pass these to Processing Module Yes No Figure 5.9: The receiver module 69 CHAPTER 5. THE GROUND BASED SETUP 100 100100 1000 0 0 0 Throttle Longitudinal Cyclic (Pitch) Lateral Cyclic (Roll) Vane (Yaw) Figure 5.10: The definition of stick positions 5.4.2 The Processing Module The processing module first transforms the data received from the receiver module into the navigation frame (section 4.1). The transformed data is then used to obtain the body attitude using a complementary filter. Finally, a PID controller computes the desired stick positions, or the amount of cyclic and anti-torque, and passes on this information to the transmitter module. The value of stick positions correspond to the physical positions where the sticks of the transmitter should be in order to generate the desired output. These are normalized on a scale of 0 to 100; 0 corresponding to one extreme position of stick and 100 to the other extreme. The convention adopted is that the increase in the value of stick position should lead to increase in thrust or yaw, pitch, roll attitudes of the vehicle, as shown in figure 5.10 The stick positions discussed above may or may not have a one-to-one relation with servo channel pulse-widths, as explained in section 2.2.2. The distinction between 70 CHAPTER 5. THE GROUND BASED SETUP servo positions and stick positions is important. The idea is that the controller (or human pilot) is interested in issuing generic lateral cyclic, longitudinal cyclic, collective and anti- torque commands. The vehicle dynamics or controller design does not depend on how these commands are conveyed to the vehicle or how the servos are actually connected to the swashplate. Therefore, the processing module essentially remains the same even when different MAVs or transmitters are used. These effects are isolated in the form of transmitter module. The transmitter module takes care of the variations in the way these commands are actually implemented on a certain design of an MAV. 5.4.3 The Transmitter Module The transmitter module sub-VI converts the stick positions received from the processing module into actual commands for different servo channels and writes it to the transmitter via the microcontroller connected to the serial port (section 5.3.2). This sub-VI also reads the pilot inputs (the servo positions from the transmitter output), translates them into stick positions and communicates these back to the processing module. The transmitter is thus used both as an input and an output device. Once the transmitter is transmitting information received on the data port through the microcontroller, it (obviously) stops transmitting the stick positions directly. Very often, it is required that the pilot still control one or more channels manually, when selec- tive channel autonomy is implemented (semi-autonomous vehicle). For example, in our experiments, the throttle stick position is controlled manually by the pilot and is not au- tonomously controlled because of lack of altitude sensor. This is implemented by reading 71 CHAPTER 5. THE GROUND BASED SETUP thethrottlestickpositionfromthetransmitterandsendingthatdatabacktothetransmitter as output by the processing module. The same concept is also used for implementing the ?throttle curve?, limits on motion of the cyclic servos, and to receive attitude commands from the pilot (via the cyclic sticks) in the attitude follow mode of control. 5.5 Implementation of the VI The sensor data is received and processed (complementary filter) at a much higher sam- pling frequency (230 Hz) than the output frequency or the servo bandwidth (50 Hz). Two parallel loops are therefore used in the implementation of the VI (fig. 5.11); one for read- ing sensor data and state estimation, and the second for PID controller and RC transmitter interface. While the first loop is a ?while loop? running at the maximum possible rate, determined by the sampling rate of sensor data, the second loop is a ?timed loop? and runs once in every 20 ms as the servo update is required only at that rate. This makes sure that the processing resources are optimally utilized. These two loops are analogous to the state equation and the output equation in the state-space form of control. It is therefore appropriate to refer to the first loop as the ?state estimation loop? and to the second as the ?output loop?. The code can thus be divided into 3 sections, i.e., 1) tasks done outside both these loops for initialization, 2) the tasks done under the first loop, and 3) the tasks done under the second loop. 72 CHAPTER 5. THE GROUND BASED SETUP Initialize the IMU Send ?g? to IMU, Estimate bias State Data (Attitudes and Rates) State Estimation Loop (?while lop? at ~230Hz) Has nsr module and Compleentary filter Output Loop (?timed lop? at 20Hz) Has PID cntroler and Transmiter mdule Used only once Two parlel ops run contiuosly Figure 5.11: The implementation of the VI 5.5.1 Initializing the IMU The first task of the VI is to send the command to the IMU to start sending data. The ASCII character ?g? is sent to the IMU, as specified in the IMU datasheet [38]. The data from 6 sensors is now made available by the sensor module. The MEMS sensors are quite sensitive to temperature. It is therefore important to wait for the temperature of sensors to stabilize before bias estimation. Every time the IMU is powered on, the analog-to-digital convertors, and other electronics need some time to stabilize. The first 5000 data packets received are thus discarded. Accurate determination of gyroscope bias (the gyro output for zero angular rate) is critical, as any error in this will lead to large drift in the estimation of attitude over long time (without filtering). The bias of a gyroscope is not constant between different runs. Therefore, the bias needs to be estimated every time before the experiment. The IMU is 73 CHAPTER 5. THE GROUND BASED SETUP kept stationary and the next 5000 samples from each of the 3 gyros are averaged to get their biases. Further discussion on gyro bias is presented in the appendix to this report. 5.5.2 State Estimation Loop State estimation loop is responsible for continuously sampling the IMU, and then filtering the raw sensor data to provide the output loop with required states, viz. the roll, pitch and yaw attitudes. The sensor data is read through the sensor module (described above), and the angular rates and translational accelerations are made available in navigation frame. The angular rates are then converted into inertial frame (section 4.1) and the accelerations into roll and pitch attitudes (section 4.3). These are finally processed by the complemen- tary filter (section 4.4) to provide the attitudes. 5.5.3 Output Loop (PID controller) The output loop uses the transmitter module to read the pilot inputs (via the sticks). The attitudes and body rates are made available by the state estimation loop. The pilot inputs and attitudes are then used along with the user supplied gains to generate output based on the selected mode, as shown in figure 5.12. The 3 modes of operation are as follows: 1. Loop-back mode: In this mode all the data received through the transmitter module (pilot stick positions) is directly wired back to the transmitter module. It is useful to check if the transmitter interface is working correctly. 2. Attitude hold mode: This mode uses the gains supplied by the user to generate the cyclic and tail-rotor commands in order to keep the attitudes close to zero (PID 74 CHAPTER 5. THE GROUND BASED SETUP Angular body rates of GiantAtitude of the Giant State dat from ?state stimation lop? The mode of Operation Proprtional nd derivative gains Pilot stick inputs (throtle, desired atitude) User Inputs PID Controller and low-pass filter Transmiter Module Figure 5.12: The output loop controller). The Giant is thus expected to hover in this mode. 3. Attitude control mode: It is similar to the attitude hold mode, except that the pilot can now demand roll and pitch attitudes through the cyclic sticks on the transmitter. The controller will make the Giant follow those attitude commands. The gains can be adjusted by the user anytime during the experiment. The servos have a limited bandwidth. The frequency of the output signal should be below 5Hz for effective working of servos. A low pass filter is therefore incorporated in the output of PID controller. 75 Chapter 6 Results and Discussion 6.1 Vibrations and Sensor Saturation The IMU is mounted on the Giant as shown in figure 6.1. During the initial test flights, the vibrations were found to lead to saturation of gyroscopes aligned with the body x and y axes as shown in figure 6.2. The reliability of attitude estimation is severely affected due to saturation of sensors. The vibrations are isolated from the IMU by proving a padding between the LiPo battery and the IMU. Different blade geometries are also seen to affect the vibration level. Typical gyro data with no saturation is shown in figure 6.3 6.2 Manual Flight In order to fly the Giant with PID controller, it is first required to get an estimate of the gains required. In order to gain confidence in the system and obtain an estimate of gains required, a manual instrumented hover flight is conducted. The data from the IMU and 76 CHAPTER 6. RESULTS AND DISCUSSION LiPo Batery Foam Pading IMU Figure 6.1: IMU mounted on the Giant with foam padding Double-click here to edit text. Gyroscope (x-axis) Figure 6.2: Angular rate about body x-axis during flight (gyro saturated) 77 CHAPTER 6. RESULTS AND DISCUSSION Gyroscope (x-axis) Figure 6.3: Angular rate about body x-axis during flight (gyro not saturated) the pilot stick inputs are recorded during the flight. Figure 6.4 shows the pitch attitude as estimated by the accelerometers, gyroscopes and the complementary filter. We see that the attitude is maintained within ? 0.1 radian. The time history of pilot longitudinal cyclic inputs during this flight is shown in figure 6.5. From this data, it can be seen that the pilot effectively uses a gain of around 20% to 25% stick range per radian. It can also be seen that cyclic is applied at a maximum frequency of about 2Hz by the pilot. Based on the complementary filter data, output proportional to the attitude, with a gain of 25% stick range per radian is computed and plotted in figure 6.6. A low-pass filter is also incorporated in the output of controller so that the servos are actuated at a frequency similar to that used by a human pilot. 78 CHAPTER 6. RESULTS AND DISCUSSION Figure 6.4: Pitch attitude estimate during manual flight Figure 6.5: Longitudinal cyclic during manual flight 79 CHAPTER 6. RESULTS AND DISCUSSION Figure 6.6: Comparison of computed longitudinal cyclic with actual pilot command 6.3 Controlled Flight Results The results for the controlled hovering flight of the Giant are presented next. The roll, pitch and yaw of the vehicle are controlled by the autonomous controller. Throttle is the only input provided by the pilot. A dual slope is used on the throttle curve to reduce the sensitivity near the hovering RPM of rotor. Once the throttle exceeds 60% stick range, a slope of 0.4 is used in place of unity, to enable finer control of rotor RPM. As can been seen in figure 6.7, both the pilot-input and the controller-output match when throttle is below 60% stick range, but the controller output increases by only 40% of pilot-input beyond that. Yaw control is provided by both the onboard (off-the-shelf) gyro as well as the control system. The off-the-shelf gyro provides the basic derivative control and it is as- sisted by a proportional control implemented in LabVIEW. The off-the-shelf gyro is left 80 CHAPTER 6. RESULTS AND DISCUSSION 0 10 20 30 40 50 60 70 80 2 32 42 52 62 72 Time (sec) T h r o t l e ( % s t i c k r a n g e ) Controler Output Pilt Iput Figure 6.7: Dual-curve in throttle to reduce sensitivity near hover RPM in place, because in case the flight mode is switched to manual (or if there is a failure of autonomous control), it would not be possible to control the Giant without some level of yaw stabilization. A fixed gain of 30% stick range per radian is used for the yaw axis for all experiments. It is important to note that from the Euler-angle transformation point of view, the yaw attitude is not important as it does not affect the roll or pitch attitudes (this is not true for roll and pitch though; roll affects both pitch and yaw, and pitch affects yaw (see equation 4.6)). However, dynamics in yaw may still influence the roll and pitch motion due to the presence of coupling terms in the dynamics of the Giant. We follow the Ziegler-Nichols method of tuning the PID controller [40]. Ziegler andNicholssuggestedrulesfortuningPIDcontrollersbaseonexperimentalstepresponse or based on the value of proportional gain that results in marginal stability when only proportional control action is used. Ziegler-Nichols tuning rules give an educated guess 81 CHAPTER 6. RESULTS AND DISCUSSION Type of Controller Kp Ti Td P 0.5Kcr ? 0 PI 0.45Kcr 11.2Pcr 0 PID 0.6Kcr 0.5Pcr 0.125Pcr Table 6.1: Ziegler-Nichols Tuning Method for the gain values and provide a starting point for fine tuning, rather than give the final settings for the gains in a single shot. We use the second Ziegler-Nichols method, i.e., the one based on the value of proportional gain that results in marginal stability, for tuning the PID controller for autonomous flight of Giant [40]. 6.3.1 Ziegler-Nichols PID Tuning According to the Ziegler-Nichols second method of PID gain tuning [40], we we increase the proportional gain, Kp, upto a critical value Kcr at which the output exhibits sustained oscillations or marginal stability. Once the critical gain Kcr and the corresponding period Pcr areexperimentallydetermined, ZieglerandNicholssuggestedthatwesetthevaluesof the proportional gain Kp, integral time Ti, and derivative time Td according to the formula given in table 6.1. The resulting controller, Gc(s), in s-domain is given by: Gc(s) = Kp parenleftbigg 1+ 1T is +Tds parenrightbigg (6.1) In terms of gains, the resulting controller action (in time domain) is: Gc(t) = Kpe(t)+Ki Z t 0 e(?)d?+Kd dedt (6.2) 82 CHAPTER 6. RESULTS AND DISCUSSION where, e(t) is the error signal given by: e(t) = setpoint?measurement(t) (6.3) We therefore see that the integral gain, Ki, and derivative gain, Kd, are related to the integral time, Ti, and derivative time, Td, as follows: Ki = KpT i (6.4) Kd = KpTd (6.5) Determining Critical Gain and Critical Period As required for the Ziegler-Nichols gain tuning method, we first conduct experiments to determinethecriticalgainandthecorrespondingcriticalperiod. Asmentionedbefore, we are primarily interested in tuning the roll and pitch loops. For simplicity, the yaw gain is keptfixedforallexperiments. Thecriticalgainsforboththerollandpitchaxesisexpected to be different because of the non-symmetric servo-swashplate assembly, i.e., the two swashplate servos need to be deflected by different amounts to get equal longitudinal and lateral cyclics. We apply the Ziegler-Nichols method to this two axes system as follows. The idea is to keep the system well-tuned in one axis at a time, and marginally stable in the other. This way, the first axis will have minimal influence during determination of critical gain and period of the other axis. The same process is then repeated with the axes swapped, in order to determine the other set of critical gain and period. We first determine approximate gains for which the vehicle is stable in both axes. We then keep one gain fixed at this value and increase the other till it becomes marginally 83 CHAPTER 6. RESULTS AND DISCUSSION unstable. This value of second gain gives us a first approximation of critical gain for that axis. We now fix the second gain to half of this value and change the first gain (which was kept fixed earlier) till the vehicle again becomes marginally unstable to get approximation of critical gain for first axis. The second gain is reduced to half of critical value because accordingtotable6.1,halfofcriticalgainisexpectedtogiveawelltunedsystem. Wenow iterate till consistent results are obtained, i.e., the system becomes marginally unstable whenweusecriticalgainforoneaxisandhalfofcriticalgainfortheother. Wethusobtain critical gains for both the axes that can be used to tune the proportional (P), proportional- integral (PI) and proportional-integral-derivate (PID) controllers. From the analysis of manual flight (section 6.2), we expect the vehicle to be stable for proportional gains of around 25% stick range per radian for both roll and pitch axes. The pitch and roll attitudes during the autonomous flight for these values of gains are shown in figures 6.8 and 6.9, respectively. The corresponding control inputs are shown in figures 6.10 and 6.11, respectively. Figures 6.12 and 6.13 show the roll attitude and corresponding controller inputs, respectively. The large peaks in all these plots at T ?48 seconds corresponds ot the landing of the vehicle. The vehicle can be seen to diverge much more in yaw than roll or pitch. This is because of relatively much lower inertia in yaw. As mentioned before, for simplicity, a fixed gain was used in yaw as any errors in yaw do not affect pitch and roll estimation. We now increase the pitch gain. The system is found to reach the critical condition for a gain of 36% stick range per radian in pitch (the roll gain is kept fixed at 25% stick range per radian). The pitch and roll attitudes for this case are shown in figures 6.14 and 6.15, respectively. Although only the pitch gain was increased, the instability in pitch 84 CHAPTER 6. RESULTS AND DISCUSSION !"#$ !"#% !"#& !"#? !"#( " "#( "#? "#& "#% "#$ ( " ? " & " % " $ " ) " * " +,-./ 01.23 +4.56/ 07683 922.:.7;-. 5.7 <=7;12;>. ? ; - > : . - . @ 5 6 7 = Figure 6.8: Pitch attitude vs. time (KP? = 25,KP? = 25,KP? = 30) ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ( " ? " & " % " $ " ) " * " + , - . / 0 1 . 2 3 45,/06783 922.:.6;-.<.6 =>6;12;?. @;-?:.-.A<76> Figure 6.9: Roll attitude vs. time (KP? = 25,KP? = 25,KP? = 30) 85 CHAPTER 6. RESULTS AND DISCUSSION 4 45 46 47 48 49 50 51 52 53 10 20 30 40 50 60 70 Time (sec) L o n g i t u d i n a l C y c l i ( % s t i c k r a n g e ) Controler Output Pilt Iput Figure 6.10: Longitudinal cyclic vs. time (KP? = 25,KP? = 25,KP? = 30) 45 47 49 51 53 5 57 59 61 63 65 10 20 30 40 50 60 70 TIme (sec) L a t e r a l C y c l i ( % s t i c k r a n g e ) Controler Output Pilot Input Figure 6.11: Lateral cyclic vs. time (KP? = 25,KP? = 25,KP? = 30) 86 CHAPTER 6. RESULTS AND DISCUSSION -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 10 20 30 40 50 60 70 Time (sec) Psi (rad) Psi Figure 6.12: Yaw attitude vs. time (KP? = 25,KP? = 25,KP? = 30) 25 35 45 5 65 75 85 95 10 20 30 40 50 60 70 Time (sec) V a n e s ( % s t i c k r a n g e ) Controler Output Pilot Input Figure 6.13: Vane command vs. time (KP? = 25,KP? = 25,KP? = 30) 87 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ? % ) * ( " ( ? ( % + ,-./01.23 +4.56/07683 Figure 6.14: Pitch attitude vs. time (KP? = 36,KP? = 25,KP? = 30) is reflected also in roll due to coupling. The corresponding cyclic inputs are shown in figures 6.16 and 6.17. The vane control inputs and yaw attitude are shown in figures 6.18 and 6.19, respectively. We now reduce the proportional gain in pitch to 18% stick range per radian (half of estimated critical value) and increase the roll gain till the system becomes marginally stable. At a gain of 130% stick range per radian in roll, the system is found to be unstable as shown in figures 6.20 and 6.21. The gain is then reduced and marginal stability is found at the gain of 124% stick range per radian in roll (with 18% stick range per radian in pitch). The pitch and roll attitudes for this flight test are shown in figures 6.22 and 6.23, respectively. The longitudinal and lateral cyclics provided by the controller for same flight are shown in figures 6.24 and 6.25, respectively. The yaw attitude and the vane input provided by the controller are shown in figures 6.26 and 6.27, respectively. 88 CHAPTER 6. RESULTS AND DISCUSSION !"#$ !"#% !"#& !"#? !"#( " " # ( " # ? " # & " # % " # $ ? % ) * ( " ( ? ( % + , - . / 0 1 . 2 3 45,/06783 Figure 6.15: Roll attitude vs. time (KP? = 36,KP? = 25,KP? = 30) !" #$ #" %$ %" "$ "" &$ &" ! % & ? ($ (! (% )*+,-./,01 2345*678*49:-;<0:*0-.=-/6*0>-?945,1 ; 3 4 6 ? 3 : : , ? - @ 7 6 A 7 6 B*:36- C4 A76 Figure 6.16: Longitudinal cyclic vs. time (KP? = 36,KP? = 25,KP? = 30) 89 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # # " # # $ " $ # % ! $ & ? " ? % ? ! ( ) * + , - . + / 0 123+425, 67/58/, -9, .38/:, 42;<+0 6=;34=55+4, >?3@?3 A85=3, );@?3 Figure 6.17: Lateral cyclic vs. time (KP? = 36,KP? = 25,KP? = 30) ! " # $ # " % $ % " & $ & " " $ " " ? $ ? " # & ? ( ! $ ! # ! & )*+,- ./,01 2 3 4 , / - . 5 - / 6 * 0 7 - 8 3 4 9 , 1 : ; 4 6 8 ; < < , 8 - = > 6 ? > 6 @ * < ; 6 - A 4 ? > 6 Figure 6.18: Vane command vs. time (KP? = 36,KP? = 25,KP? = 30) 90 CHAPTER 6. RESULTS AND DISCUSSION ! " !#$% ! # !&$% & & $ % # # $ % " " ? ( ) # & # " # ? * + , - . / 0 - 1 2 30+. /4562 Figure 6.19: Yaw attitude vs. time (KP? = 36,KP? = 25,KP? = 30) The large spikes towards the end of all these plots corresponds to the touch down of the Giant. We now check if the system is marginally stable for a pitch gain of 36% stick range per radian and roll gain of 62% stick range per radian. If this is found to be marginally stable, then the estimates of critical gains for the two axes is correct, else we need to iterate. The system was found to be unstable for these gains as shown by the pitch and roll attitudes in figures 6.28 and 6.29, respectively. We now reduce the pitch gain to 32% stick rangeperradiantogetthemarginalstabilitycondition. Thepitchandrollattitudesforthis case are shown in figures 6.30 and 6.31, respectively. The longitudinal and lateral inputs for the same flight are shown in figures 6.32 and 6.33, respectively. Figures 6.34 and 6.35 show the yaw attitude and vane servo commands given by the controller, respectively. The critical gains and period are thus obtained as shown in table 6.2. 91 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ( " ( $ ? " ? $ & " )*+,- ./,01 )2,34- .5461 Figure 6.20: Pitch attitude vs. time (KP? = 18,KP? = 130,KP? = 30) !"#$ !"#% !"#& !"#? !"#( " " # ( " # ? " # & " # % " # $ ( " ( $ ? " ? $ & " ) * + , - . / , 0 1 23*- .4561 Figure 6.21: Roll attitude vs. time (KP? = 18,KP? = 130,KP? = 30) 92 CHAPTER 6. RESULTS AND DISCUSSION !"#$ !"#% !"#& !"#? !"#( " "#( "#? "#& "#% "#$ ?" ?$ &" &$ %" )*+,- ./,01 )2,34- .5461 Figure 6.22: Pitch attitude vs. time (KP? = 18,KP? = 124,KP? = 30) !"#$ !"#% !"#& !"#? !"#( " " # ( " # ? " # & " # % " # $ ? " ? $ & " & $ % " )*+,- ./,01 23*- .4561 Figure 6.23: Roll attitude vs. time (KP? = 18,KP? = 124,KP? = 30) 93 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # ! $ % & % ! % " % # % $ " & ? ( ? " ! ( ! " % ( )*+,- ./,01 2 3 4 5 * 6 7 8 * 4 9 : - ; < 0 : * 0 - . = - / 6 * 0 > - ? 9 4 5 , 1 ; 3 4 6 ? 3 : : , ? - @ 7 6 A 7 6 B * : 3 6 - C 4 A 7 6 Figure 6.24: Longitudinal cyclic vs. time (KP? = 18,KP? = 124,KP? = 30) ! " ! # ! $ ! % ! & ! ? ! ( ! ) ! * ! " ! ! #! #& $! $& %! + , - . / 0 1 . 2 3 4 5 6 . 7 5 8 / 9 : 2 8 ; 2 / 0 < / 1 6 ; 2 = / 7 5 > ? . 3 9@>67@88.7/ AB6CB6 D ; 8 @ 6 / , > C B 6 Figure 6.25: Lateral cyclic vs. time (KP? = 18,KP? = 124,KP? = 30) 94 CHAPTER 6. RESULTS AND DISCUSSION !" ! # $ % ! # $ & ! # $ ? ! # $ ( # # $ ( # $ ? # $ & # $ % " ( # ( ) * # * ) ? # +,-./ 01.23 41,/ 05673 Figure 6.26: Yaw attitude vs. time (KP? = 18,KP? = 124,KP? = 30) !" #$ #" %$ %" "$ "" &$ &" ! $ ! " # $ # " % $ ?()*+ ,-*./ 012*-+ ,3+ -4(.5+ 6127*/ 892469::*6+ ;<4=<4 > ( : 9 4 + ? 2 = < 4 Figure 6.27: Vane command vs. time (KP? = 18,KP? = 124,KP? = 30) 95 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ? $ & " & $ % " % $ ) * + , - . / , 0 1 ) 2 , 3 4 -. 5 4 6 1 Figure 6.28: Pitch attitude vs. time (KP? = 36,KP? = 62,KP? = 30) ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ? $ & " & $ % " % $ )*+,-./,01 2 3 * -. 4 5 6 1 Figure 6.29: Roll attitude vs. time (KP? = 36,KP? = 62,KP? = 30) 96 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ( " ( $ ? " ? $ & " ) * + , - . / , 0 1 )2,34- .5461 Figure 6.30: Pitch attitude vs. time (KP? = 32,KP? = 62,KP? = 30) ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ( " ( $ ? " ? $ & " ) * + , - . / , 0 1 23*- .4561 Figure 6.31: Roll attitude vs. time (KP? = 32,KP? = 62,KP? = 30) 97 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ # " % $ % " " $ " " & $ & " ? $ ? " ! $ ! " # $ ( ) * + , - . + / 0 1234)567)389, :;/9)/, -<, .5)/=, >834+0 : 2 3 5 > 2 9 9 + > , ? 6 5 @ 6 5 A ) 9 2 5 , B 3 @ 6 5 Figure 6.32: Longitudinal cyclic vs. time (KP? = 32,KP? = 62,KP? = 30) ! " ! # $ " $ # # " # # % " % # & " & # ? " (" (# )" )# !" *+,-. /0-1 2 345-647.8917:1./;.05:1<.64=>-2 8?=56?77-6. @A5BA5 C : 7 ? 5 . + = B A 5 Figure 6.33: Lateral cyclic vs. time (KP? = 32,KP? = 62,KP? = 30) 98 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " ! % # $ ! % ! & # $ & & # $ % & % $ " & " $ ? & ()* +, - . +/ 0 1.), -2340 Figure 6.34: Yaw attitude vs. time (KP? = 32,KP? = 62,KP? = 30) ! " # " $ " % " " " & " ? " ( " ) " ! * ! " # * # " $ * +,-./01.23 456.1/07/18,29/:56;.3 < = 6 8 : = > > . : /? @ 8 A @ 8 B , > = 8 /C 6 A @ 8 Figure 6.35: Vane command vs. time (KP? = 32,KP? = 62,KP? = 30) 99 CHAPTER 6. RESULTS AND DISCUSSION Axis Kcr Pcr Pitch 32 1.4 sec (from fig. 6.30) Roll 124 1.2 sec (from fig. 6.23) Table 6.2: Critical gain and period for pitch and roll Type of Controller Kp Ki Kd P 16 ? 0 PI 14.4 12.3 0 PID 19.2 27.4 3.36 Table 6.3: Ziegler-Nichols Gains (Pitch) From table 6.1, data in table 6.2 and relations given in equations 6.4 and 6.5, we get tables 6.3 and 6.4 for pitch and roll axes, respectively. Proportional Controller We nowuse gains calculated infirst rows (correspondingto proportional control) oftables 6.3 and 6.4 to implement a proportional controller. The longitudinal and lateral attitude Type of Controller Kp Ki Kd P 62 ? 0 PI 55.8 55.8 0 PID 74.4 124 11.16 Table 6.4: Ziegler-Nichols Gains (Roll) 100 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ & " & $ % " % $ ) * + , - . / , 0 1 )2,34- .5461 Figure 6.36: Pitch attitude vs. time (KP? = 16,KP? = 62,KP? = 30) results for this flight test are shown in figures 6.36 and 6.37, respectively. The corre- sponding commands given by the controller are shown in figures 6.38 and 6.39. The performance of the controller is satisfactory but it is found to slowly diverge, i.e., the vehicle is seen to fly in slowly growing horizontal circles. With some manual tweaking the performance of the controller is found to improve. This setting corresponds to a gain of 20% stick range per radian in pitch and 55% stick range per radian in roll. The longitudinal attitude and the controller inputs are shown in figures 6.40 and 6.41, respectively. Figures 6.42 and 6.43 show the lateral cyclic com- mands and the lateral attitude of the vehicle. 101 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ & " & $ % " % $ ) * + , - . / , 0 1 23*-.4561 Figure 6.37: Roll attitude vs. time (KP? = 16,KP? = 62,KP? = 30) ! " # $ # " % $ % " " $ " " & $ & " # $ # ! # % # & # ? % $ % ! % % ( ) * + , - . + / 0 1234)567)389, :;/9)/, -<, .5)/=, >834+0 : 2 3 5 > 2 9 9 + > ,? 6 5 @ 6 5 A ) 9 2 5 ,B 3 @ 6 5 Figure 6.38: Longitudinal cyclic vs. time (KP? = 16,KP? = 62,KP? = 30) 102 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # # " # # $ " $ # % " % # & " & # ?" ?# !" !# ()*+, -.+/0 123+425, 67/58/, -9, .38/:, 42;<+0 6 = ; 3 4 = 5 5 + 4 , > ? 3 @ ? 3 A 8 5 = 3 , ) ; @ ? 3 Figure 6.39: Lateral cyclic vs. time (KP? = 16,KP? = 62,KP? = 30) ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ? $ & " & $ % " % $ $ " $ $ ) * + , - . / , 0 1 )2,34- .5461 Figure 6.40: Pitch attitude vs. time (KP? = 20,KP? = 55,KP? = 30) 103 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # ! $ ! % ! ! ! & ! ? ! ( ! ) ! * & " $ & % " % & ! " ! & & " & & +,-./01.23 4567,89:,6;2<,2/0?/18,2@/A;67.3 = 5 6 8 A 5 < < . A / B 9 8 C 9 8 D , < 5 8 / E 6 C 9 8 Figure 6.41: Longitudinal cyclic vs. time (KP? = 20,KP? = 55,KP? = 30) ! " ! # # " # # $ " $ # % " & # ? " ? # ! " ! # # " # # ( ) * + , - . + / 0 123+425,67/58/,-9,.38/:,42;<+0 6=;34=55+4, >?3@?3 A 8 5 = 3 , ) ; @ ? 3 Figure 6.42: Lateral cyclic vs. time (KP? = 20,KP? = 55,KP? = 30) 104 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ? $ & " & $ % " % $ $ " $ $ ) * + , - . / , 0 1 23*-.4561 Figure 6.43: Roll attitude vs. time (KP? = 20,KP? = 55,KP? = 30) Proportional-Integral Controller Using the gains in the second rows (corresponding to PI control) of tables 6.3 and 6.4, we implement the proportional-integral controller. The longitudinal and lateral attitudes are shown in figures 6.44 and 6.45, respectively. The corresponding controller commands are shown in figures 6.46 and 6.47. It is found to give a satisfactory performance. Proportional-Integral-Derivative Controller Next, we use the gains in the third rows (corresponding to PID control) of tables 6.3 and 6.4. The longitudinal attitude and the controller commands are shown in figures 6.48, 6.49, respectively. Figures 6.50 and 6.51 show the lateral attitude and the corresponding controller commands, respectively. As can be seen from these figures, the controller needs to be tweaked in order to 105 CHAPTER 6. RESULTS AND DISCUSSION !"#$ !"#% !"#& !"#? !"#( " "#( "#? "#& "#% "#$ ( " ? " & " % " $ " ) " * " +,-./ 01.23 +4.56/ 07683 Figure 6.44: Pitch attitude vs. time (KP? = 14.4,KI? = 12.3,KP? = 55.8,KI? = 55.8,KP? = 30) improve its performance. Starting with the gains given by Ziegler-Nichols tuning method, the gains are manually tweaked and the gains in table 6.5 are found to give satisfactory performance. The longitudinal attitude and the controller commands are shown in figure 6.52 and 6.53, respectively. Figures 6.54 and 6.55 show the lateral attitude and PID controller commands, respectively. Axis Kp Ki Kd Pitch 24 30 2 Roll 60 70 3 Table 6.5: PID Controller Gains 106 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ ( " ? " & " % " $ " ) " * " +,-./01.23 4 5 , /0 6 7 8 3 Figure6.45: Rollattitudevs. time(KP? =14.4,KI? =12.3,KP? =55.8,KI? =55.8,KP? = 30) !" !# !! !$ !% &" &# &! &$ ?" #" (" !" &" $" )" * + , - . / 0 - 1 2 3456+789+5:;.<=1;+1./>.07+1?.@:56-2 < 4 5 7 @ 4 ; ; - @ .A 8 7 B 8 7 C + ; 4 7 .D 5 B 8 7 Figure 6.46: Longitudinal cyclic vs. time (KP? = 14.4,KI? = 12.3,KP? = 55.8,KI? = 55.8,KP? = 30) 107 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # # " # # $ " $ # % " & " ? " ( " ! " # " $ " % " ) * + , - . / , 0 1 2 3 4 , 5 3 6 - 7 8 0 6 9 0 - . : - / 4 9 0 ; - 5 3 < = , 1 7><45>66,5- ?@4A@4 B 9 6 > 4 - * < A @ 4 Figure 6.47: Lateral cyclic vs. time (KP? = 14.4,KI? = 12.3,KP? = 55.8,KI? = 55.8,KP? = 30) ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ " $ ( " ( $ ? " ) * + , - . / , 0 1 )2,34- .5461 Figure 6.48: Pitch attitude vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) 108 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # $ " $ # # " # # % " % # " # & " & # ? " ()*+, -.+/0 1234)567)389, :;/9)/, -<, .5)/=, >834+0 : 2 3 5 > 2 9 9 + > , ? 6 5 @ 6 5 A)925, B3@ 6 5 Figure 6.49: Longitudinal cyclic vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) 6.3.2 Perturbation Response In order to test the robustness of the proportional controller (with 25% stick range per radian gain), we perturb the system in pitch and study its response. A large pilot input is applied at about 36 seconds into the experiment as shown in figure 6.56. The variation of the pitch attitude for this input is shown in figure 6.57. From figure 6.56, we see that the controller applies a corrective action as soon as the attitude tries to diverge as a result of the perturbation. The controller is successful in stabilizing the attitude to within 0.1 radian in 3 seconds (fig. 6.57). 109 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ " $ ( " ( $ ? " ) * + , - . / , 0 1 23*-.4561 Figure6.50: Rollattitudevs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) 110 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # ! $ ! % ! ! ! & ! ? ! ( ! ) ! " * ! * ! "* "! #* + , - . / 0 1 . 2 3 456.758/9:28;2/0?.3 9 @ > 6 7 @ 8 8 . 7 / A B 6 C B 6 D;8@6/ ,> CB 6 Figure 6.51: Lateral cyclic vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) !"#$ !"#% !"#& !"#? !"#( " "#( "#? "#& "#% "#$ " $ ( " ( $ ? " )*+,- ./,01 )2,34- .5461 Figure 6.52: Pitch attitude vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) 111 CHAPTER 6. RESULTS AND DISCUSSION ! " ! # ! $ % & % ! % " % # % $ " & " ! " " ? " &? &" (? ) * + , -. / , 0 1 2345*678*49:-;<0:*0-.=-/6*0>-?945,1 ; 3 4 6 ? 3 : : , ? - @ 7 6 A 7 6 B * : 3 6 - C 4 A 7 6 Figure 6.53: Longitudinal cyclic vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) 6.4 Discussion From the results presented in this chapter, we see that three independent SISO PID loops can be used to stabilize attitude of the Giant. We get a good estimate of proportional gains bycomputingthegainsusedbyahumanpilotduringamanualtest-flight. Ziegler-Nichols method is used to tune the roll and pitch controller gains. Since roll and pitch axes of the system are coupled, an iteration-based approach has been used in order to determine their respective critical gains and periods. One axis is stabilized at a time with the best known gain setting and the gain on the other axis is changed in order to determine its critical parameters. The value of these critical parameters is used to update the best known gain setting for one axis at a time. The process is repeated till same critical gain and period 112 CHAPTER 6. RESULTS AND DISCUSSION ! " # $ ! " # % ! " # & ! " # ? ! " # ( " " # ( " # ? " # & " # % " # $ " $ ( " ( $ ? " )*+,-./,01 2 3 *-.45 6 1 Figure6.54: Rollattitudevs. time(KP? =19.2,KI? =27.4,KD? =3.36,KP? =74.4,KI? = 124,KD? = 11.16,KP? = 30) ! " # $ # " " $ " " % $ % " & $ & " ? $ ? " $ " ($ (" )$ * + , - . / 0 - 1 2 345-647.8917:1./;.05:1<.64=>-2 8 ? = 5 6 ? 7 7 - 6 . @ A 5 B A 5 C : 7 ? 5 . + = B A 5 Figure 6.55: Lateral cyclic vs. time (KP? = 19.2,KI? = 27.4,KD? = 3.36,KP? = 74.4,KI? = 124,KD? = 11.16,KP? = 30) 113 CHAPTER 6. RESULTS AND DISCUSSION 0 10 20 30 40 50 60 70 25 30 35 40 Time (sec) L o n g i t u d i n a l C y c l i ( % s t i c k r a n g e ) Controler Output Pilot Input Figure 6.56: Longitudinal cyclic with perturbation at 36 sec Pitch Attitude -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 25 30 35 40 Time (sec) Theta (rad) Accelerometer Gyroscope Complementary Figure 6.57: Pitch attitude response to longitudinal perturbation 114 CHAPTER 6. RESULTS AND DISCUSSION values are obtained for both the axes from two successive iterations. Having obtained the critical parameters for both axes, the gains for P, PI and PID controllers are computed following the Ziegler-Nichols method. Some adjustments are required to get good performance for each case. The final performance of the system is found to be very similar in all the three cases. Proportional controllers in pitch and roll are therefore found to be sufficient for implementing attitude stabilization on the Giant. This is able to maintain the attitude of the Giant within?0.1 radian in both pitch and roll. It was observed that this corresponds to the vehicle hovering over ground within a radius of about 2 meters during the one minute duration of test-flight. 115 Chapter 7 Conclusions and Future Work 7.1 Summary The preliminary experiments conducted to validate the control setup were restricted to a single degree-of-freedom motion, namely, yaw (Section 3.1). The same yaw stabilization was then implemented on the Giant in free flight with the development of the onboard stabilization system (Section 3.2). It was soon realized that a number of features were desired to enable faster and efficient development of autonomous control (Section 3.2.4). A new ground-based control setup is then developed incorporating those features (Section 5.2). With the objective of implementing attitude feedback control on Giant, an appropri- ate sensor package, along with a high bandwidth telemetry system is identified (Section 5.3.1). Gyroscopes and accelerometers are the two main sensors that can be used for sensing attitude. In parallel with the development of hardware, attitude transformation and estimation algorithms have been investigated (Chapter 4). The attitude information 116 CHAPTER 7. CONCLUSIONS AND FUTURE WORK from gyroscopes is found to drift with time (low frequency phenomenon) and the attitude from the accelerometers if found to be corrupted with high frequency noise due to vibra- tions. Complementary filter is used to fuse information from both these sources to give a reliable estimate of attitude. It has been experimentally validated and is found to give much better results instead of using either of accelerometers or gyroscopes alone (Section 4.4). The hardware and the attitude algorithms have then been used to implement 3 inde- pendent SISO PID loops, one each in pitch, roll and yaw, for attitude control. In order to get an estimate of PID gains, a modified Ziegler-Nichols method is adopted. The system is then tuned in P, PI and PID modes and the results are presented in Chapter 6. The controller response to perturbation in attitude has also been investigated. 7.2 Conclusions For efficient testing and validation of control strategies on MAVs, a ground-based system is better suited over an onboard system for the following reasons: ? Easytodebug: as the controller is programmed in LabVIEW on a PC, the standard probe and other debug tools are available to monitor its execution. The charts and graphs in LabVIEW also provides good visibility of different critical parameters of the system. ? Easy to reprogram: the controller can be modified on a PC in graphical program- ming environment of LabVIEW. This makes it much more efficient to evaluate different algorithms, instead of reprogramming an embedded device, as in the case 117 CHAPTER 7. CONCLUSIONS AND FUTURE WORK of onboard controller implementation. ? Change parameters on the fly: several parameters, like gain settings on differ- ent channels, can be changed as and when required, even during the flight of the vehicle. ? Portability of the System and Modular code: Modular design makes it easy to change transmitter-receiver or upgrade the sensor package. All such differences are captured in the different interface modules. The core of the controller remains unaffected by such changes. This makes the system portable between different vehicles with different configurations (eg., Giant and Micor). ? Selectiveautonomy: usingatwowayinterfacebetweenthetransmitterandthePC, wecanselectthenumberofchannelsthatneedtobecontrolledbythePCandbythe human pilot. For example, for autonomous hover, we use manual throttle command but the other 3 channels (cyclics and vane angle) are autonomously controlled. This feature is also helpful in implementing maximum channel limits and scale factors on different channel outputs. For example, it is quite useful to have dual-slope or exponential-curveonthethrottlechannelinordertoreducethesticksensitivitynear hover RPM. ? Manual/auto switching: this setup provides a quick way to switch between the autonomousmodeandthefullmanualmode, byflippingaswitchonthetransmitter, in case of any problem or malfunction of the controller. Other main conclusions that follow from this work are listed below: 118 CHAPTER 7. CONCLUSIONS AND FUTURE WORK ? With the availability of advanced wireless transceivers, it is now possible to have a high bandwidth (57.6 kbps) and a long range (about 200 meters) wireless link, enabling ground-based implementation of test-bed. ? A complementary filter is able to reject high frequency noise in accelerometer data and low frequency drift in gyroscope data. It thus gives a very reliable estimate of attitude for low translational-acceleration flights. ? The algorithms for transformation and filtering of raw data received from the sen- sors and generating the servo commands, with real time performance, can be im- plemented much more efficiently on a modern PC (with dual-core processor) using LabVIEW. A lot more programming effort and tweaking is required with the older generation PCs (single-core processors) in order to get a reliable real-time perfor- mance using same algorithms. ? The actuation bandwidth of the system is only limited by the servo bandwidth; i.e., the servos are updated at the maximum rate allowed by the standard servo-control protocol (50 Hz), using the microcontroller. ? Three independent SISO PID loops can be used for control and stabilization of the Giant for low-speed flight. This enables the use of simple control scheme for attitude stabilization of the Giant. ? The pitch and roll axes need different gains because of the non-symmetric servo attachment to the swashplate. 119 CHAPTER 7. CONCLUSIONS AND FUTURE WORK ? Modified Ziegler-Nichols tuning method gives good starting values for PID gains, but some adjustments are required to get good performance. ? All three, P, PI and PID controllers are found to give comparable performance for attitude stabilization. ? A suitably tuned PID (or P, or PI) controller can keep the roll and pitch attitude within ?0.1 radians. From the flight tests it was observed that the vehicle remains with a radius of about 2 meters for a one minute controlled hover-flight using only attitude feedback. ? The controller is found to stabilize the vehicle against the perturbations in attitude issued by the pilot using the transmitter stick inputs. The attitude was found to reduce from ?0.4 radians to within ?0.1 radians in 3 seconds. 7.3 The Future Roadmap As mentioned before, the goal of research in this area is to enable autonomous flight and operation of an MAV. Looking at the bigger picture, the controller for an autonomous air vehicle can be hierarchically decomposed into three different layers as shown in fig- ure 7.1 [41]. At the highest level, we have the strategic control layer, which does mis- sion planning and way-point generation. Tactical layer forms the intermediate layer and takes care of guidance and trajectory planning. At the lowest level is the reflexive layer that includes the traditional control functions like stabilization, regulation and command tracking. Development of reflexive layer needs work in two primary areas, state estima- 120 CHAPTER 7. CONCLUSIONS AND FUTURE WORK Figure 7.1: Hierarchical decomposition of autonomous control [41] tion and stabilization or command-tracking controller design. Besides these, a test-bed to implement, test and evaluate the controller needs to be developed. During the course of this project a generic test-bed for control implementation had been developed. It has so far been used to implement an attitude-feedback PID controlled reflexive layer. Following are the suggestions for future work in this area: 121 CHAPTER 7. CONCLUSIONS AND FUTURE WORK Translation Feedback Control As discussed in section 5.1, and shown in figure 5.1, the inner attitude-stabilization loop forms the core of the controller. Although the vehicle is actuated using lateral and lon- gitudinal cyclics, which correspond to attitude commands, it is not practical or intuitive to issue attitude commands to a vehicle in order to navigate it from one point to another. Thisneedstobeaugmentedwithanoutertranslation-stabilizationloopinordertodirectly be able to issue translation or position commands instead of attitude commands. The challenge in implementing the translation feedback control is to identify ap- propriate sensors that not only give reliable position information, but are also sufficiently compact, light weight and can operate in closed environments. For initial experiments, one may use a Global Positioning System (GPS) to demonstrate the basic working of the system [42]. The GPS is of limited use for MAV applications, as it does not work in closed environments (e.g., inside a building), i.e., when it is not in line of sight of at least three GPS satellites. The other techniques that have evolved over recent years include vision based sys- tems [43], such as optic flow sensors [44]. The optic flow sensors are based on visual cues that insects use to navigate. It gives an estimate of a ratio of velocity to distance from a textures surface as seen by the sensor. So, with the knowledge of distance (using some other sensor, like pressure transducer or laser ranging system), the velocity of the vehicle can be estimated, and vice-versa. 122 CHAPTER 7. CONCLUSIONS AND FUTURE WORK Model Based Control In the present work, we have implemented PID control in order to achieve some level of automation. In order to expand the flight envelope and make use of the maneuver- ing capability of the vehicle, it is important to develop a model based controller [19]. As the MAVs are small in size and have much lower inertias compared to the manned aircraft, they have quicker vehicle responses. It is therefore required to have very high bandwidth models in order to implement model based control on MAVs. A basic struc- ture of the model of the vehicle first needs to be worked out from the first principles. The different unknown parameters in this model are then identified using system identifica- tion techniques [19,45]. Once a sufficiently ?good? model has been developed, different model-based control techniques [46] can be implemented and evaluated using this test- bed. This will complete the development of the reflexive layer and then the research ef- fort can focus on development of higher layers of autonomy, i.e., the tactical and strategic layers. 123 Appendix A Gyroscope Drift A basic explanation of gyroscope drift is given in Section 4.2. In this appendix, a more detailed explanation is presented in a form of questions and answers. ? Why does the attitude reading obtained from gyroscope drift? The fundamental reason is the non-exact determination of bias. ? What is bias? The gyroscope is an analog angular rate sensor and gives a non-zero voltage for zero angular rate. This voltage is called the bias. The angular rate is given by: Rate = (Voltage?Bias)?Calibration constant (A.1) From this, we see that if bias is not correctly estimated, the ?rate? obtained will be erroneous. As previously mentioned, the gyroscope only gives us this rate informa- tion. It needs to be integrated over time to compute the angular position (attitude). 124 APPENDIX A. GYROSCOPE DRIFT The errors in the determination of rate (due to incorrect bias) lead to diverging error in attitude estimation (the drift)! ? Why is bias not correctly determined? There are two reasons for this. The first has to do with the fundamental physical issues in the operation of gyro itself, and the second has to do with the way they are interfaced and sampled. Let us first look at the second issue. Let us assume that we have a perfect gyro (with perfectly steady bias). There is still a limit to the resolution with which the bias can be determined due to unavailability of infinite-bit analog-to-digital converters! A 10-bit ADC on a 5-volt scale can only resolve 5/1024 volts, i.e., about 4 mV. The datasheet for ADXRS150 specifies the sensitivity as 12.5 mV/deg/s [30]. Therefore we can only resolve a rate of 0.32 deg/sec with this setup. An error of 0.32 deg/sec in the estimation of bias would lead to a drift of 32 deg in every 100 seconds! But the gyro is not noise-free. It is in some ways good for us as it introduces a ?dithering? effect which leads to a finer estimation of bias! ? What is dithering? Suppose the actual output of an analog sensor is 2.6 volts, and it is being sampled by a device that truncates the fractions and resolves the data only in unit?s place. This device will show a result of 2 instead of 2.6. Now if we introduce a noise in the data such that 60% of the time the result of sampling device is 3 and remaining 40% of the time it is 2, the average will turn out to 2.6! This introduction of noise 125 APPENDIX A. GYROSCOPE DRIFT to improve the estimation of a signal is called dithering. ? Why do we still have problems (after having exploited dithering)? Firstly, we only have a finite number of samples available at any point in time. Therefore, going by the above example, there is no guarantee that the data will be sampled as 3 for 60% of the time; sometimes it might show 3 for much less than 60% of the samples or sometimes more. Even if the bias was correctly determined by taking a large number of samples, the estimation of rate (and thus angle) for any subsequent instantaneous gyro reading will still be wrong (although for white noise, the angle would fluctuate around zero, if bias is perfectly determined). Secondly, the gyro is not a perfect sensor. That is, the construction of gyro and its working principle is such that the reading from the gyro is influenced by a num- ber of factors instead of just angular rate. The MEMS gyro measures the angular rates by means of Coriolis acceleration, which is measured by estimating the dis- placement of a resonating mass and its frame (due to the Coriolis effect) through capacitive sensing elements attached to the resonator [48]. The ADXRS gyro elec- tronics can resolve capacitance changes as small as 12x1021 farads (12 zeptofarads) from beam deflections as small as 0.00016 Angstroms (16 femtometers). These sub atomic displacements are meaningful as the average positions of the surfaces of the beams, even though the individual atoms on the surface are moving randomly by much more. There are about 1012 atoms on the surfaces of the capacitors, so the statistical averaging of their individual motions reduces the uncertainty by a factor of 106 (dithering effect again!). We cannot do better because of the air molecules 126 APPENDIX A. GYROSCOPE DRIFT which cause the structure to move. Although these are also averaged, their effect is far greater. The air is not removed because the device consists of a very fine film (4 micrograms) and flexures (1.7 micron wide) that are suspended over the silicon substrate and the air molecules cushion this structure, preventing it from damage due to shocks. ? How to get better attitude then? There could be two ways of getting better attitude estimate: 1. Study the nature of bias noise and devise an advanced filter to estimate that noise much more accurately [49]. This is an involved exercise in itself and limited success has been achieved to date. 2. An alternate way is to use some sort of external aiding to correct for drift in the gyro data. This is typically done using an accelerometer [32]. An accelerometer has no drift as it directly gives the attitude (no integration re- quired)bymeasuringthegravityvector(assumingthatlinearaccelerationsare small compared to gravity). Accelerometer and gyroscope have complemen- tary characteristics. Accelerometer gives a very good low frequency estimate (no drift) but has high frequency noise due to vibrations. Gyros on the other hand have a good high frequency performance (higher rates lead to larger ca- pacitance to be measured, where the air molecule effect is smaller than the Coriolis effect; also the integration used for angle computation has an effect of averaging out the signal, so that there are no jerks in the data even at high frequency) but a poor low frequency performance (drift). Therefore we use a 127 APPENDIX A. GYROSCOPE DRIFT complementary filter to fuse the data from both these sensors to get the best estimate. ? What are the other sources of gyro errors? 1. Sensor saturation: If the gyro is subjected to angular rates higher than what it can measure, it will saturate and in turn miss all the action during that time. Although the vehicle is not expected to move at rates higher than +- 150 deg/sec (rate limits for ADXRS 150), the vibrations often exceed that limit and lead to very fast loss of orientation. 2. Temperature: The gyro is known to be sensitive to temperature. In lab ex- periments no conclusive fixed temperature calibration could be established. 3. ADC warm-up: It has been observed that when the entire system is switched on, the analog-to-digital converter and other electronics take some time to stabilize. The bias computed from the first few minutes of data is significantly worse than that computed a little later. ? How do we take care of these? The ADC warm up and temperature corrections are taken care of by letting the system run for a few minutes before starting the experiment. The bias estimation should be done after this initial period. Sensor saturation (vibration isolation) is taken care of by appropriate mounting of the sensor on the vehicle. A packaging is provided to absorb high angular rate vibrations. 128 APPENDIX A. GYROSCOPE DRIFT To reiterate, gyro drift occurs because of integration. A MEMS accelerometer does not have a constant analog bias for all of the same reasons as a gyro. The only difference is that the accelerometer data does not have to be integrated to measure the angle. If velocity was measured from integrating the accelerometer, an analogous issue as gyro drift would occur. It could be called accelerometer drift. 129 Appendix B Listing of Microcontroller Codes The microcontroller codes discussed in Sections 3.1.2, 3.1.3, 5.3.2 are listed below. All these codes are written for the CCS-C cross compiler [26] for PIC microcontrollers. TheCodeforYawStabilizationExperiment(Section3.1.2) // Initialization #include <16f877.h> #fuses HS,NOLVP,NOWDT,PUT #use delay(clock=20000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) #include #include #define GREEN_LED PIN_A5 #define YELLOW_LED PIN_B4 #define RED_LED PIN_B5 #define PUSH_BUTTON PIN_A4 char state; int32 high, cycle = 12500; // The Interrupt Service Routine // to generate servo command once every 20ms #int_ccp1 void isr(){ 130 APPENDIX B. LISTING OF MICROCONTROLLER CODES if (state == 1) { output_low(PIN_C2); CCP_1 += cycle - high; } else { output_high(PIN_C2); CCP_1 += high; } if (CCP_1 > 65535) CCP_1 = 65535-CCP_1; state = 1-state; } //The Main Routine void main() { int32 angle,temp1,inc,i,val1,val2,value,temp,base=124; setup_ccp1(CCP_COMPARE_INT); // Configure CCP1 as input compare setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); state = 0; high = 730; angle = 10000; enable_interrupts(INT_CCP1); // Setup interrupt on compare enable_interrupts(GLOBAL); CCP_1 = 10; // set interrupt at 10 timer-1 ticks set_timer1(0); // initialize timer-1 // initialize ADC setup_port_a(ALL_ANALOG); setup_adc(adc_clock_internal); set_adc_channel( 1 ); while(TRUE) { value=read_adc(); // sample ADC if (value < 10) output_low(RED_LED); // warning for saturation else output_high(RED_LED); 131 APPENDIX B. LISTING OF MICROCONTROLLER CODES if (value > 240) output_low(YELLOW_LED); // warning for saturation else output_high(YELLOW_LED); inc = value-base; // compute rate angle += inc; // angle is integral of rate if (angle<5000) angle = 5000; // lower limit on angle if (angle>15000) angle = 15000; // upper limit on angle temp = 3730 - (float)angle/4 - value*4; // servo command (PD control) if (temp<630 || temp>1245) // check for servo saturation output_low(GREEN_LED); else output_high(GREEN_LED); high = temp; // final servo command delay_us(50000); }} The Code for Yaw Control Experiment (Section 3.1.3) // Initialization #include <16f877.h> #fuses HS,NOLVP,NOWDT,PUT #use delay(clock=20000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) #include #include #define GREEN_LED PIN_A5 #define YELLOW_LED PIN_B4 #define RED_LED PIN_B5 #define PUSH_BUTTON PIN_A4 char state,state_read; int32 time, rise, high, cycle = 12500; // Interrupt Service Routine 132 APPENDIX B. LISTING OF MICROCONTROLLER CODES // to generate servo command once every 20ms #int_ccp1 void isr(){ if (state == 1) { output_low(PIN_C2); CCP_1 += cycle - high; } else { output_high(PIN_C2); CCP_1 += high; } if (CCP_1 > 65535) CCP_1 = 65535-CCP_1; state = 1-state; } // Interrupt Service Routine // to read R/C receiver #int_ccp2 void isr2() { state_read = 1 - state_read; if (state_read==0) { if (CCP_2>rise) time = CCP_2-rise; else time = 65535 - rise + CCP_2; setup_ccp2(CCP_CAPTURE_RE); } else { rise = CCP_2; setup_ccp2(CCP_CAPTURE_FE); } } // The Main Routine void main() { int32 angle,temp1,inc,i,val1,val2,value,temp,base=124, neutral; setup_ccp1(CCP_COMPARE_INT); // Configure CCP1 as input compare 133 APPENDIX B. LISTING OF MICROCONTROLLER CODES setup_ccp2(CCP_CAPTURE_RE); setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); state = 0; state_read = 0; time = 0; high = 730; // default servo output angle = 10000; // Initial value of angle neutral = 0; enable_interrupts(INT_CCP1); // Setup interrupt on compare enable_interrupts(INT_CCP2); enable_interrupts(GLOBAL); CCP_1 = 10; // set interrupt for timer-1 = 10 set_timer1(0); // initialize timer-1 // Initialize ADC setup_port_a(ALL_ANALOG); setup_adc(adc_clock_internal); set_adc_channel( 1 ); while(TRUE) { value=read_adc(); // Read Gyro data if (value < 10) output_low(RED_LED); // warning for sensor saturation else output_high(RED_LED); if (value > 240) output_low(YELLOW_LED); // warning for sensor saturation else output_high(YELLOW_LED); inc = value-base; angle += inc; if (angle<5000) angle = 5000; // lower limit on angle if (angle>15000) angle = 15000; // upper limit on angle neutral = time-700; // modify input 134 APPENDIX B. LISTING OF MICROCONTROLLER CODES // compute servo command temp = 3730 + 833 - (float)angle/3 - value*4 + (float)neutral*2; if (temp<630 || temp>1245) output_low(GREEN_LED); // check for servo saturation else output_high(GREEN_LED); high = temp; // set final servo command delay_us(50000); }} The Code for R/C Transmitter Interface (Section 5.3.2) // Initialization #include <16F877.h> #fuses HS,NOLVP,NOWDT,PUT #use delay(clock=20000000) #use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7) #include #include char i=1,statew=0; // set default values for different channels (write to transmitter) unsigned int16 high[8]={700,696,712,418,690,468,676,7500}; char stater=0, pos = 0; // set default values for different channels (read from transmitter) unsigned int16 rise, time[10]={700,700,700,410,700,468,676,700,700,700}; // Interrupt Service Routine // to read transmitter data #int_ccp1 void write(){ if (statew == 1) { output_low(PIN_E1); CCP_1 += 250; //400ns low time } else { 135 APPENDIX B. LISTING OF MICROCONTROLLER CODES output_high(PIN_E1); CCP_1 += high[i]; i++; if (i==8) i=1; } if (CCP_1 > 65535) CCP_1 = 65535-CCP_1; statew = 1-statew; } // Interrupt Service Routine // to read from the transmitter #int_ccp2 void read() { stater = 1 - stater; if (stater==0) { if (CCP_2>rise) time[pos] = CCP_2-rise; else time[pos] = 65535 - rise + CCP_2; setup_ccp2(CCP_CAPTURE_RE); if (time[pos] > 1500) // sync pulse pos = 0; pos++; } else { rise = CCP_2; setup_ccp2(CCP_CAPTURE_FE); } } void main() { unsigned int16 temp; unsigned int8 output, j; setup_ccp1(CCP_COMPARE_INT); // Configure CCP1 as output compare setup_ccp2(CCP_CAPTURE_RE); // Configure CCP2 as input capture (rising) setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); enable_interrupts(INT_CCP1); // Setup interrupt on compare enable_interrupts(INT_CCP2); // Setup interrupt on input capture enable_interrupts(GLOBAL); CCP_1 = 10; 136 APPENDIX B. LISTING OF MICROCONTROLLER CODES set_timer1(0); while(TRUE) { putc(255); for(j=1;j<7;j++) // write to PC { output = (time[j]-200) >> 2; // adjust data in 1 byte putc(output); } temp = getc(); // read from PC while (temp!=255) temp = getc(); temp=getc(); high[1] = (temp<<2) + 200; // expand data to 2 bytes temp=getc(); high[2] = (temp<<2) + 200; temp=getc(); high[3] = (temp<<2) + 200; temp=getc(); high[4] = (temp<<2) + 200; temp=getc(); high[6] = (temp<<2) + 200; } } 137 Appendix C Implementing Digital Filters The raw data collected from the sensors is often corrupted by other unwanted signals, referred to as noise. It is therefore required to filter this noise in order to get meaningful information from the sensors. In most cases, such filters have to implemented on some or the other form of digital processor as software. Since the sensors are sampled at a very high rate (hundreds of readings per second) and the entire system has to react in real time, the implementation of the filters needs be to very efficient in terms of both processing time and memory usage. There are many different ways to design filters, but the most common ones have their roots in simple averaging. Digital filters can be divided into two categories based on implementation [47]: 1. Finite Impulse Response (FIR), or the filters based on convolution: The output of these filters is affected by a finite number of samples taken in the past. That is, after a certain amount of time, the old sensor data will have no influence on the output 138 APPENDIX C. IMPLEMENTING DIGITAL FILTERS of the filter. 2. Infinite Impulse Response (IIR), or the filters based on recursion: The output of these filters is affected by all the sensor data samples collected in the past. We now discuss the implementation of 3 different digital filters that are commonly used. The first two filters (generic FIR, and moving average) belong to the FIR type of filters and the last one (exponentially weighted averaging filter) is an IIR kind of digital filter. Generic FIR Filter The most generic way to design a digital filter is to convolve the input signal with the digital filter?s impulse response. In this method, each sample in the output is calculated by weighting the samples in the input using the filter kernel (impulse response or convolution coefficients), and adding them together. MATLAB?s Filter Design Toolbox [50] provides several useful functions for de- signing, simulating and analyzing digital filters. ?FDATool? command in this toolbox provides a graphical interface to design filters. Filter kernels for generic FIR filters, can also be obtained using the ?fir? MATLAB command. This MATLAB function can be called directly from a LabVIEW VI during initialization and the kernel obtained can be repeatedly used over input data to get filtered data. Although this is a powerful digital filtering technique, it needs a lot of computa- tion per output sample. This imposes a serious limitation on how fast the sensor can be sampled and thus on the bandwidth of the control system. 139 APPENDIX C. IMPLEMENTING DIGITAL FILTERS Moving Average Filter Moving average filter is one of the simplest and most commonly used filters in digital signal processing. It is very efficient as it can be implemented in a recursive form. Suppose that at any instant k, the average of the latest n samples of a data sequence, xi, is given by: ?xk = 1n k? i=k?n+1 xi (C.1) Similarly, at the previous time instant, k?1, the average of the latest n samples is: ?xk?1 = 1n k?1? i=k?n xi (C.2) Therefore, ?xk = ?xk?1 + 1n (xk?xk?n) (C.3) Here, the average at each kth instant is based on the most recent set of n values. Or, a moving window of n values is used to calculate the average of the data sequence. It can be seen that this filter only needs one division, one addition and one subtraction operation. This is always the case, irrespective of the size of the window, n; although, we need to store the value of xk?n, which may require n storage locations. Exponentially Weighted Averaging Filter In the previous filter design (moving average filter), each data point in the window is given equal importance when calculating the average. In dynamic systems, however, the 140 APPENDIX C. IMPLEMENTING DIGITAL FILTERS most current values from the sensor reflect better the sate of the plant. We now look at the implementation of a recursive infinite response filter (that uses all the sensor data from the past), that places more emphasis on the most recent data. In the most simple form, the exponentially weighted averaging filter can be repre- sented by the following equation: ?xk = ??xk?1 +(1??)xk (C.4) where, 0?? < 1 This implementation requires only one addition, 1 subtraction and two multiplica- tions. There is no need to store a window of samples as was the case with moving average filter. The filter constant, ?, dictates the degree of filtering, i.e., how strong the filtering action will be. When the filtering is strong, i.e., ?? 1, then, ?xk ? ?xk?1, or, the current measurement does nor affect the output. On the other hand when the filtering is weak, i.e., ??0, then, ?xk ?xk, or, the measurement if not even modified by the filter. Exponentially weighted averaging filter places more importance on the more recent data in an exponential manner. This is be seen by expanding equation C.4: ?xk = ??xk?1 +(1??)xk, (C.5) and, ?xk?1 = ??xk?2 +(1??)xk?1 (C.6) therefore, ?xk = ??xk?1 +(1??)xk = ?[??xk?2 +(1??)xk?1]+(1??)xk (C.7) 141 APPENDIX C. IMPLEMENTING DIGITAL FILTERS Or, ?xk = ?2?xk?2 +?(1??)xk?1 +(1??)xk (C.8) Expanding further, ?xk = ?3?xk?3 +?2(1??)xk?2 +?(1??)xk?1 +(1??)xk (C.9) From equation C.9 we see that the contribution of the older values of xi is weighted by increasing powers of ?. Since ? is less than 1, the contribution of older values of xi becomes exponentially smaller. This is in fact a very simple implementation of first-order low-pass filter. The equivalence of a exponentially weighted averaging filter and a first-order low-pass filter is shown next. Consider the Laplace transfer function of a first-order low-pass filter, with time constant ?f. The following equation relates the filtered signal, ?x(s) to the measurement, x(s): ?x(s) x(s) = 1 1+?fs (C.10) Time equivalent of equation C.10 is: ?f d?x(t)dt + ?x(t) = x(t) (C.11) Now, we discretise equation C.11 using the following approximation: d?x(t) dt ? ?xk? ?xk?1 Ts (C.12) where, Ts is the interval between each measurement, i.e., the sampling interval. Thus equation C.11 leads to: Tf ?xk? ?xk?1T s + ?xk = xk (C.13) 142 APPENDIX C. IMPLEMENTING DIGITAL FILTERS Simplification and re-arrangement gives: ?xk = parenleftbigg T f Tf +Ts parenrightbigg ?xk?1 + parenleftbigg T s Tf +Ts parenrightbigg xk (C.14) By letting, ? = parenleftBig T f Tf+Ts parenrightBig , we get: ?xk = ??xk?1 +(1??)xk (C.15) which is same as equation C.4. This is the simplest and most efficient way of implementing a first-order low-pass filter. It has been used in several places in the VI described in Chapter 5. 143 Appendix D Setting up the Test-Bed The procedure to setup the test-bed is given below: 1. Load the appropriate code (ReadWriteTrans.hex) on the microcontroller. 2. Connect the transmitter with the microcontroller and the microcontroller to the PC. 3. Power on the transmitter and the microcontroller. 4. Use ?Device Manager? under ?Control Panel? on the PC to identify the Serial Port to which the microcontroller is connected. 5. Launch ?LabVIEW? and load the ?ReadWriteTransTrial.vi? in order to test the transmitter communication. 6. Setup the correct Serial Port parameters in the VI and run it. 7. The transmitter stick positions should be correctly read by the PC/VI. If this does not work, refer to the troubleshooting section of this appendix. 144 APPENDIX D. SETTING UP THE TEST-BED 8. Close the ?ReadWriteTrans.vi? if the transmitter connection is working fine. 9. Connect the Bluetooth dongle to the PC. 10. Power on the Giant MAV (along with the onboard avionics box). 11. Use the ?IVT BlueSoleil? software on the PC to establish connection to the blue- tooth transceiver on the Giant. 12. Launch ?GiantClosedLoopControl.vi? in LabVIEW. 13. Setup the correct Serial Port parameters for the transmitter and Bluetooth commu- nication (Fig. D.1). 14. Select the ?Type of Control? and enter gain settings (Fig. D.2). 15. Select ?Need to Initialize? in order to enable initialization of the Bluetooth link. 16. Run the VI and stop it after 5 seconds. 17. Check if the LED on the avionics box (on Giant) starts to blink. The blinking indicates successful start of data transmission. 18. If the LED is not blinking refer to the section on troubleshooting. 19. Un-select the ?Need to Initialize? option on the VI and rerun it (Fig. D.1). 20. After about 10 seconds, the data from the sensors should be available on the charts of the VI. 21. Make sure that data from all channels of the avionics box and transmitter is within expected limits. 145 APPENDIX D. SETTING UP THE TEST-BED 22. Pull the trainer switch on the transmitter to go into autonomous mode and perform the experiment. 23. After the experiment, press the ?Stop? button on the VI. 24. The VI will request for the names of the files (one for sensor data and other for transmitter data) where the on-screen data is to be stored for later analysis, before terminating. Troubleshooting ? ReadWriteTransTrial.vi does not respond to transmitter stick movements This problem is usually due to some minor mistake in the setting up of the system and is usually resolved by one of the following: ? Make sure the transmitter and the microcontroller are powered on. ? Check the connecting wires between the transmitter and the microcontroller, and between the microcontroller and the PC. The wires on the microcontroller should be connected to correct I/O pins. ? Reset the microcontroller. ? Remove the USB cable from the PC and reconnect it (this way it can reinitial- ize). ? Make sure that the VI is reading from the correct Serial Port (as shown by the ?Device Manager?). 146 APPENDIX D. SETTING UP THE TEST-BED Figure D.1: Communication settings in LabVIEW 147 APPENDIX D. SETTING UP THE TEST-BED Figure D.2: Control settings in LabVIEW 148 APPENDIX D. SETTING UP THE TEST-BED ? Check the battery level of the transmitter. Recharge it, if necessary. ? BlueSoleil software fails to connect to the Bluetooth transceiver This usually happens when the onboard avionics box has already been initialized (LED is blinking) but the communication link with the PC is required to be re- established. The solution is to reset the avionics box so that first the link can be set up before it begins transmission of data. ? LED on the avionics box is not blinking after trying to initialize it The most common reason for this problem is improper link between the PC and the onboard avionics box. The solution is to reset the avionics box and re-establish link using the ?IVT BlueSoleil? software on the PC. 149 References [1] McMichael, J. M., Francis, M. S., ?Micro Air Vehicles - Towards a New Dimension in Flight,? DARPA Document, 1997. [2] Grasmeyer, J. M., and Keennon, M. T., ?Development of the Black Widow Mi- cro Air Vehicle,? AIAA Paper No. AIAA-2001-0127, Presented at the 39th AIAA Aerospace Sciences Meeting and Exhibit, Reno, NV, January, 2000. [3] Anon., Unmanned Air Vehicles Roadmap, 2002-2027, Office of the Secretary of Defence, 2002. [4] Anon., Unmanned Air Vehicles Roadmap, 2005-2030, Office of the Secretary of Defence, 2005. [5] Sirohi, J., Tishchenko, M., and Chopra, I., ?Design and Testing of A Micro-Aerial Vehicle with a Single Rotor and Turning Vanes,? American Helicopter Society 61stnd Annual Forum, Grapevine, TX, 1-3 June, 2005. [6] Bohorquez, F., Samuel, P., Sirohi, J., Pines, D., Rudd, L., and Perel, R., ?Design, Analysis and Performance of a Rotary Wing MAV,? Journal of the American Heli- copter Society, Vol. 48, No. 2, pp. 80-90, April, 2003. 150 REFERENCES [7] Young, L., and Aiken, E., ?New Concepts and Prespectives on Micro-Rotorcraft and Small Autonomous Rotary-Wing Vehicles,? AIAA-2002-2816, Presented at the 20th AIAA Applied Aerodynamics Conference, St. Louis, Missouri, June 24-26, 2002. [8] Bohorquez, F. and Pines, D., ?Rotor and Airfoil Design for Efficient Rotary Wing Micro Air Vehicles,? 61st Annual American Helicopter Society Forum, Grapevine, TX, June 2005. [9] Pereira, J., and Chopra, I., ?An Investigation of the Effects of Shroud Design Vari- ables on the Hover Performance of a Shrouded-Rotor Micro Air Vehicle,? American Helicopter Society International Specialists? Meeting on Unmanned Rotorcraft, Jan- uary, 2005. [10] Parsons, E., Sirohi, J., and Chopra, I., ?Micro Air Vehicle; Cycloidal Rotor Concept,? American Helicopter Society International Specialists? Meeting on Un- manned Rotorcraft, January, 2005. [11] Singh, B., Ramasamy, M., Chopra, I., and Leishman, J., ?Experimental Studies on Insect-Based Flapping Wings for Micro Hovering Air Vehicles,? 46th Annual AIAA uctural Dynamics and Materials Conference, Austin, TX, April 2005. [12] Newcome,L.R.,UnmannedAviation: ABriefHistoryofUnmannedAerialVehicles, AIAA, 2004. [13] Arning, R., and Sassen, S., ?Flight Control of Micro Aerial Vehicles,? AIAA Guid- ance, Navigation, and Control Conference and Exhibit, Providence, Rhode Island, Aug. 16-19, 2004. 151 REFERENCES [14] Amidi, O., Kanade, T., and Miller, J. R., ?Autonomous Helicopter Research at Carnegie Mellon Robotics In stitute,? Proceedings of the Heli Japan ?98, April, 1998. [15] Spraque, K., et. al., ?Design and Applications of an Avionics System for a Minia- ture Acrobatic Helicopter,? The 20th Digital Avionics Systems Conference, Daytona Beach, FL, Oct. 14-18, 2001 [16] Johnson, E., Schrage, D., ?The Georgia Tech Unmanned Aerial Research Vehi- cle: GTMax,? AIAA Guidance, Navigation, and Control Conference and Exhibit, Austin, Texas, Aug. 11-14, 2003. [17] Koo, T., Hoffmann, F., Shim, H., Sinopoli, B., and Sastry, S., ?Hybrid Control of an Autonomous Helicopter,? IFAC Workshop on Motion Control, Grenoble, France, Sep. 21-23, 1998. [18] Garcia-Pardo, P. J., Sukhatme, G. S., and Montgomery, J. F., ?Towards vision-based safe landing for an autonomous helicopter,? Robotics and Autonomous Systems, Vol. 38, Issue 1, January, 2002, pp. 19-29. [19] Mettler, B., Indentification Modeling and Characteristics of Miniature Rotorcraft, Springer, 1st edition, USA, Sep. 30, 2002. [20] Britting, K., Inertial Navigation Systems Analysis, Wiley Interscience, New York, 1971. [21] Broxmeyer, C., Inertial Navigation Systems, McGraw-Hill, New York, 1964. 152 REFERENCES [22] King, A. D., ?Inertial Navigation - Forty Years of Evolution,? GEC Review, Vol. 13, No. 3, 1998, pp. 140-149. [23] Anon., ?E-flite Blade CP,? http://en.wikipedia.org/wiki/E-flite Blade CP, accessed Oct. 30, 2006. [24] Anon., ?Triaxial angular rate (gyro), acceleration and magnetic field Inertial Sen- sor,? http://www.memsense.com/products/mag3.asp, accessed Oct. 30, 2006. [25] Anon., ?PIC16F877A,? http://www.microchip.com/stellent/idcplg?IdcService= SS GET PAGE&nodeId=1335&dDocName=en010242, accessed Oct. 30, 2006. [26] Anon., ?CCS, Inc. - PIC16F877A Development Kit,? http://www.ccsinfo.com/ prod- uct info.php?products id=16F877Akit, accessed Oct. 30, 2006. [27] Conroy, J. K., Samuel, P. D., and Pines, D. J., ?Development of an MAV Control and Navigation System,? AIAA-2005-7065, Infotech@Aerospace, Arlington, VA, Sep. 26-29, 2005. [28] Pamadi, B. N., Performance, Stability, Dynamics, and Control of Airplanes, 2nd edition, AIAA, Dec. 2003. [29] Barbour, N., Schmidt, G., ?Inertial Sensor Technology Trends,? IEEE Sensors Jour- nal, Vol. 1, No. 4, December, 2001, pp 332-339. [30] Anon., ?Analog Devices ADXRS150 - Angular Rate Sensor ADXRS150,? http://www.analog.com/en/prod/0,2877,ADXRS150,00.html, accessed Oct. 30, 2006. 153 REFERENCES [31] Anon., ?QP-2HC Datasheet,? http://www.midoriamerica.com/pdf/QP-2HC.pdf, ac- cessed Oct. 30, 2006. [32] Baerveldt, Albert-Jan and Klang, R., ?A Low-cost and Low-weight Attitude Esti- mation System for an Autonomous Helicopter,? IEEE International Conference on Intelligent Engineering Systems, 1997, pp. 391-395. [33] Lu, Y., Brown, A., ?Performance Test Results of an Integrated GPS/MEMS Inertial Navigation Package,? Proceedings of the ION GNSS 2004, Long Beach, California, Sep. 2004. [34] Jun, M., Roumeliotis, S. I., Sukhatme, G. S., ?State Estimation of an Autonomous Helicopter Using Kalman Filtering,? Proceedings of the 1999 IEEE/RSJ Interna- tional Conference on Intelligent Robots and Systems, Vol. 3, 1999, pp. 1346-1353. [35] Anon., ?Spark Fun Electronics,? http://www.sparkfun.com/commerce/product info .php?products id=411, accessed Oct. 30, 2006. [36] Anon., ?MMA7260Q Product Summary Page,? http://www.freescale.com/webapp/ sps/site/prod summary.jsp?code=MMA7260Q&nodeId=01126911184209, ac- cessed Oct. 30, 2006. [37] Anon., ?BlueSMiRF v1 Datasheet,? http://www.sparkfun.com/datasheets/RF/ BlueSMiRF v1.pdf, accessed Oct. 30, 2006. [38] Anon., ?IMU 6-DOF v2 Datasheet,? http://www.sparkfun.com/datasheets/Sensors/ IMU 6DOF-v21.pdf, accessed Oct. 30, 2006. 154 REFERENCES [39] Anon., ?LabVIEW - The Software That Powers Virtual Instrumentation,? http://www.ni.com/labview/, accessed Oct. 30, 2006. [40] Ogata, K., Modern Control Engineering, Prentice-Hall Inc., New Jersey, 2002. [41] Stengel, R. F., ?Toward Intelligent Flight Control,? IEEE Transactions on Systems, Man and Cybernetics, vol. 23, no. 6, 1993, pp. 1699-1717. [42] Ananda, M. P., Bernstein, H., Cunningham, K. E., Feess, W. A., and Stroud, E. G., ?Global Positioning System (GPS) Autonomous Navigation,? IEEE Position Loca- tion and Navigation Symposium, Las Vegas, NV, Mar. 20-23, 1990. [43] Amidi, O., Kanade, T., and Miller, R., ?Vision-based Autonomous Helicopter Re- search at Carnegie Mellon Robotics Insitute 1991-1997,? American Helicopter So- ciety International Conference, Japan, April, 1998. [44] Barrows, G. L., Chahl, J. S., and Srinivasan, M. V., ?Biomimetic Visual Sensing and Flight Control,? The Aeronautical Journal, Vol. 107, No. 1069, pp. 159-168, 2003. [45] Wu, H., Sun, D., Zhou, Z., ?Model Identification of a Micro Air Vehicle in Loitering Flight Based on Attitude Performance Evaluation,? IEEE Transactions on Robotics, Vol. 20, No. 4, pp. 702-712, Aug. 2004. [46] Shim, D. H., Koo, T. J., Hoffmann, F., and Sastry, S., ?A Comprehensive Study of Control Design for an Autonomous Helicopter,? 37th IEEE Conference on Decision and Control, 1998. 155 REFERENCES [47] Smith, S. W., The Scientist and Engineer?s Guide to Digital Signal Processing, Cal- ifornia Technical Pub., 1st edition, 1997. [48] Geen, J, Krakauer, D., ?New iMEMS Angular Rate-Sensing Gyro- scope,? Analog Dialogue, Vol. 37, No. 3, 2003 (available online: http://www.analog.com/library/analogdialogue/archives/37-03/gyro.pdf). [49] Xiyuan, C., ?Modeling Random Gyro Drift by Time Series Neural Networks and by Traditional Method,? IEEE Int. Conf. on Neural Networks and Signal Processing, Nanjing, China, Dec. 14-17, 2003. [50] Anon., ?The MathWorks - Filter Design toolbox,? http://www.mathworks.com/products/filterdesign/, accessed Oct. 30, 2006. 156