Transcript
  • LOW COST FRAMEWORK FOR PARAMETERIDENTIFICATION OF UNMANNED AERIAL

    VEHICLES

    By

    Ahmad Adel Ahmad Metwalli Khattab

    A Thesis Submitted to theFaculty of Engineeringat Cairo University

    in Partial Fulfillment of theRequirements for the Degree of

    MASTER OF SCIENCEin

    Aerospace Engineering

    FACULTY OF ENGINEERING, CAIRO UNIVERSITYGIZA, EGYPT

    2015

  • LOW COST FRAMEWORK FOR PARAMETERIDENTIFICATION OF UNMANNED AERIAL

    VEHICLES

    By

    Ahmad Adel Ahmad Metwalli Khattab

    A Thesis Submitted to theFaculty of Engineeringat Cairo University

    in Partial Fulfillment of theRequirements for the Degree of

    MASTER OF SCIENCEin

    Aerospace Engineering

    Under the Supervision of

    Prof.Dr. Ayman Hamdy Kassem Prof.Dr. Gamal Mahmoud Sayed ElbayoumiProfessor of flight dynamics and control Professor of flight dynamics and control

    Aerospace Engineering Department Aerospace Engineering Department

    Faculty of Engineering, Cairo University Faculty of Engineering,Cairo university

    FACULTY OF ENGINEERING, CAIRO UNIVERSITYGIZA, EGYPT

    2015

  • LOW COST FRAMEWORK FOR PARAMETERIDENTIFICATION OF UNMANNED AERIAL

    VEHICLES

    By

    Ahmad Adel Ahmad Metwalli Khattab

    A Thesis Submitted to theFaculty of Engineeringat Cairo University

    in Partial Fulfillment of theRequirements for the Degree of

    MASTER OF SCIENCEin

    Aerospace Engineering

    Approved by the Examining Committee:

    Prof.Dr. Ayman Hamdy Kassem, Thesis Main Advisor

    Prof.Dr. Gamal Mahmoud Sayed Elbayoumi, Thesis Co Advisor

    Prof.Dr. Mohamed Nader Mohamed Abuelfoutouh, Internal Examiner

    Prof.Dr.Omar Al-Farouk Abd El-hameid , External ExaminerMilitary Technical College

    FACULTY OF ENGINEERING, CAIRO UNIVERSITYGIZA, EGYPT

    2015

  • Engineers Name: Ahmad Adel Ahmad Metwalli KhattabDate of Birth: 1/10/1989Nationality: EgyptianE-mail: [email protected]: 00201020549948Address: 239L Hadaek AlahramRegistration Date: 1/10/2011Awarding Date: / /2015Degree: Master of ScienceDepartment: Aerospace Engineering

    Supervisors:Prof.Dr. Ayman Hamdy KassemProf.Dr. Gamal Mahmoud Sayed Elbayoumi

    Examiners:Prof.Dr. Ayman Hamdy Kassem (Thesis main advisor)Prof.Dr. Gamal Mahmoud Sayed Elbayoumi (Thesis Co Advisor)Prof.Dr. Mohamed Nader Mohamed Abuelfoutouh (Internal examiner)Prof.Dr.Omar Al-Farouk Abd El-hameid (External examiner)Military Technical College

    Title of Thesis:

    LOW COST FRAMEWORK FOR PARAMETER IDENTIFICATION OFUNMANNED AERIAL VEHICLES

    Key Words:

    Unmanned Aerial Vehicles;Parameter identification; Autopilot; Hopfield;Recuurent neural network

    Summary:In this thesis a framework was designed and tested to identify the parametersof a unmanned aerial vehicles.The framework was designed to be low in costand to be accessible to be modified and customized. Tests were done on twosmall remotely piloted RC models. Oine Parameter identification was doneusing Hopfield neural network.

  • AcknowledgementsThanks to Allah for all his gifts to me.I want to thank my supervisors for guiding me

    through the work. I would like to say thank you to my parents for their support to methrough all my life.I would like to thank my wife for her support to me. I would like tothank all ASTL people for their help to me through my thesis work especially: Eng.OsamaSaied, Eng.Mohaned Draz , Eng.Mustafa Moharm .Thanks to all students I worked withthrough their graduation projects for their accumulated work that increased the knowledgeand transfered it through years. I also would like to thank all my undergraduate professorsin Aerospace Engineering Department, Cairo University.

    i

  • DedicationTo My family .... To My grand father Haj. Ahmad Khattab

    ii

  • Contents

    Acknowledgements i

    Dedication ii

    List of Figures v

    List of Tables vii

    List of Symbols and Abbreviations viii

    Abstract 1

    1 Introduction 2

    2 Literature Review 52.1 Parameter Identification Techniques . . . . . . . . . . . . . . . . . . . . 52.2 Work achieved in Aerospace department . . . . . . . . . . . . . . . . . . 8

    3 Parameter Identification 113.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2 Artificial neural network . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    3.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.2 Hopfield neural network . . . . . . . . . . . . . . . . . . . . . . 12

    3.2.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 123.2.2.2 Parameter Estimation Problem . . . . . . . . . . . . . 14

    3.2.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    4 Data Gathering Module 224.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.2 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    4.2.1 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.2.2 Microcontroller shield . . . . . . . . . . . . . . . . . . . . . . . 244.2.3 Servo Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.2.4 Servos and potentiometer Sets . . . . . . . . . . . . . . . . . . . 264.2.5 Potentiometers . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.2.6 IMU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.2.7 Pressure Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2.8 Velocity sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2.9 Wireless module . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    iii

  • 4.2.10 GPS module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2.11 Alpha-Beta sensor . . . . . . . . . . . . . . . . . . . . . . . . . 284.2.12 Batteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.2.13 RC Transmitter and receiver . . . . . . . . . . . . . . . . . . . . 31

    4.3 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.3.1 Arduino Mega Software . . . . . . . . . . . . . . . . . . . . . . 314.3.2 Monitoring Software . . . . . . . . . . . . . . . . . . . . . . . . 324.3.3 Parameter Identification Software . . . . . . . . . . . . . . . . . 33

    5 Test flights and Results 355.1 KADET LT-40 RC model Test Flight . . . . . . . . . . . . . . . . . . . . 35

    5.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.1.2 PI of Longitudinal Dynamics . . . . . . . . . . . . . . . . . . . . 365.1.3 PI of Lateral Dynamics . . . . . . . . . . . . . . . . . . . . . . . 405.1.4 Test Summary and recommendation . . . . . . . . . . . . . . . . 42

    5.2 Low Super Trainer RC model . . . . . . . . . . . . . . . . . . . . . . . . 435.2.1 Modifications for Test 2 . . . . . . . . . . . . . . . . . . . . . . . 435.2.2 Flight test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485.2.3 Longitudinal Dynamics Identification . . . . . . . . . . . . . . . 485.2.4 Lateral Dynamics Identification . . . . . . . . . . . . . . . . . . 50

    6 Conclusion and Future Work 536.1 The Future suggested work . . . . . . . . . . . . . . . . . . . . . . . . . 53

    6.1.1 Parameter Identification . . . . . . . . . . . . . . . . . . . . . . . 536.1.1.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . 536.1.1.2 Software . . . . . . . . . . . . . . . . . . . . . . . . . 53

    6.1.2 Autopilot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    References 55

    Appendix A Hopfield neural network matlab code 56

    Appendix B ArduImu V3 Codes 66

    Appendix C Arduino Mega code 69

    Appendix D Simulink GCS 80

    iv

  • List of Figures

    1.1 Autopilot Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    2.1 Simplified block diagram of the estimation procedure[6] . . . . . . . . . 52.2 A sample of the used method for PI . . . . . . . . . . . . . . . . . . . . . 10

    3.1 An artificial neuron as used in a Hopfield network . . . . . . . . . . . . . 133.2 An artificial neuron as used in a Hopfield network with added sigmoid

    function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3 Example for Discrete image recognition using Hopfield Neural Network . 143.4 Flow chart for Hopfield Neural Network PI . . . . . . . . . . . . . . . . 163.5 Real,measured and Predicted data for states and states rate . . . . . . . . 183.6 Real,measured and Predicted data for a sample state . . . . . . . . . . . . 193.7 True and estimated parameters . . . . . . . . . . . . . . . . . . . . . . . 203.8 Error in parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    4.1 Block Diagram for the whole system processes . . . . . . . . . . . . . . 234.2 Data gathering Module Hardware . . . . . . . . . . . . . . . . . . . . . . 244.3 Arduino mega 2650 microcontroller . . . . . . . . . . . . . . . . . . . . 244.4 Arduino Customized shield . . . . . . . . . . . . . . . . . . . . . . . . . 254.5 Servo Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.6 Servos Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.7 Potentiometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.8 Arduimu V3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.9 BMP085 Module GY-65 Pressure Sensor . . . . . . . . . . . . . . . . . . 274.10 Velocity Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.11 Xbee pro 52B wireless module . . . . . . . . . . . . . . . . . . . . . . . 274.12 GPS Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.13 First Design (Not used because of middle flow from motor propeller) . . . 284.14 Air data fin drown by Solid Works . . . . . . . . . . . . . . . . . . . . . 294.15 CNC manufacturing of Air data fin . . . . . . . . . . . . . . . . . . . . . 294.16 Air data fin for Side Slip angle . . . . . . . . . . . . . . . . . . . . . . . 304.17 Air data fin for angle of attack . . . . . . . . . . . . . . . . . . . . . . . 304.18 The total AOA and Side slip sensors attached to the wing tip . . . . . . . 314.19 Flow Chart of Arduino Software . . . . . . . . . . . . . . . . . . . . . . 324.20 Monitoring Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.21 Simulink GCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.22 Flow Chart of Simulink GCS . . . . . . . . . . . . . . . . . . . . . . . . 334.23 Flow chart for Hopfield Neural Network PI . . . . . . . . . . . . . . . . 34

    v

  • 5.1 The Flight Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.2 Ready to Fly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365.3 Captured photo from the flight test . . . . . . . . . . . . . . . . . . . . . 365.4 Longitudinal States (Measured and estimated).The yellow line is the ele-

    vator signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.5 Longitudinal States (Measured and estimated) when using elevator and

    change in elevator as inputs.The yellow line is the elevator signal . . . . . 395.6 Estimated Pole map of the Longitudinal dynamics . . . . . . . . . . . . 405.7 Lateral States (Measured and estimated).The last line is the aileron signal 415.8 Estimated Pole Map of the Lateral dynamics . . . . . . . . . . . . . . . 425.9 Low Super Trainer RC model . . . . . . . . . . . . . . . . . . . . . . . 435.10 Replacing the engine with an electric motor . . . . . . . . . . . . . . . . 445.11 The fin of the old sensor and the smaller one of the new sensor . . . . . . 455.12 The black potentiometer and the golden Encoder . . . . . . . . . . . . . 455.13 The modified Air data system . . . . . . . . . . . . . . . . . . . . . . . . 465.14 The Air data systems setup for both aircrfats . . . . . . . . . . . . . . . 465.15 The Air data systems of both two aircrfats . . . . . . . . . . . . . . . . . 475.16 The two sets of the new Air data system . . . . . . . . . . . . . . . . . . 475.17 The two velocity sensors data during the flight . . . . . . . . . . . . . . 485.18 The two beta sensors data during the flight . . . . . . . . . . . . . . . . . 485.19 Doublet elevator input . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.20 Measured and Estimated Longitudinal States . . . . . . . . . . . . . . . 505.21 Longitudinal Pole Map . . . . . . . . . . . . . . . . . . . . . . . . . . . 505.22 Lateral States , Last line for Aileron . . . . . . . . . . . . . . . . . . . . 515.23 Lateral Pole Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    6.1 Suggested Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

    vi

  • List of Tables

    3.1 Estimated elements of A and B matrices . . . . . . . . . . . . . . . . . . 173.2 Results of different combinations of data Sampling frequency and the type

    of the input signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    5.1 KADET LT-40 RC model Specifications . . . . . . . . . . . . . . . . . . 355.2 Low Super trainer RC model Specifications . . . . . . . . . . . . . . . . 44

    vii

  • List of Symbols and Abbreviations

    A Dynamics Matrix in State space model

    B Control Matrix in State space model

    u input vector for the state space model

    x States of the dynamical system

    r Aircraft angular velocity, z body axis (yaw rate), deg/sec

    t Time, sec

    u Velocity along body fixed x-axis, m/sec

    v Velocity along body fixed y-axis, m/sec

    w Velocity along body fixed z-axis, m/sec

    B Bias Vector

    W Weighting matrix

    E Error

    Angle of attack, deg

    Angle of sideslip, deg

    Control surface deflection, deg

    Roll Euler angle, deg

    Pitch Euler angle, deg

    Yaw Euler angle, deg

    f sigmoid function

    ax Acceleration in x-direction, m/sec2

    az Acceleration in z-direction, m/sec2

    g Acceleration due to gravity, m/sec2

    k Discrete time index

    m Aircraft mass,kg

    p Aircraft angular velocity, x body axis (roll rate), deg/sec

    q Aircraft angular velocity, y body axis (pitch rate), deg/sec

    viii

  • ANN Artificial Neural Network

    AOA Angle of attack

    AS CD Aerodynamic stability and control derivatives

    AS T L Aeronatical and Space technology laboratory, Cairo University

    DGM Data gathering Module

    GCS Ground control station

    HNN Hopfield Neural Network

    IMU Inertial measurment unit

    NN Neural Network

    PCB Printed circuit board

    PI Parameter Identification

    RNN Recurrent Neural Network

    S NR Signal to noise ratio

    ix

  • AbstractThe rst step in the autopilot design phase is the estimation of the aerodynamic stability

    and control derivatives. Parameter identication (PI) from ight data is one of the main andaccurate methods for nding aerodynamic stability and control derivatives especially forsmall and unconventional aircrafts.

    In this work, we are going to introduce an off-line PI system (software and hardware)using a per-collected data from a remotely piloted RC model. The thesis is divided intotwo main parts: 1) Flight segment: including data collection sensors and telemetry. 2)Ground segment: including telemetry and parameters identication software.

    KADET LT-40 RC model aircraft was rst used as a test case and the aerodynamic stabilityand control derivatives estimated by our proposed system led to an estimated responsewhich was in a good match with the measured one with an error about 7%. Again usinganother RC model Low Super Trainer RC model and after some modications to the dataGathering system and sensors a better results was obtained the error was less than 1.5%for longitudinal dynamics and 4% for lateral dynamics.

    1

  • Chapter 1: IntroductionIn conventional autopilot Design, Parameter identification (PI) is a very essential phase inaircraft mathematical modeling. By means of real flight tests, Data of input and outputsignals of the aircraft could be collected for a post processing task to identify the aerody-namic stability and control derivatives of the aircraft.

    The Linear state space model of the aircraft consists of two matrices, The dynamicsand control matrices. By identifying these two matrices, it is possible to build a linearmathematical model of the aircraft. Data are collected using a customized data gatheringmodule designed for this purpose.The module consists of calibrated sensors and a micro-controller to collect and send data to the ground control station to be saved for the sakeof PI in the post processing phase. The PI is done using Hopfield neural network HNNwith 24 neurons for longitudinal dynamics and another 24 neurons for the lateral dynamics.

    In the following section main autopilot steps will be introduced to find where the thesiswork locate in the overall autopilot design steps. Starting from lower part in figure 1.1 it ispossible to find the main steps of autopilot design.

    Figure 1.1: Autopilot Sequences

    Starting from uncalibrated sensors and by adding a data acquisition tool for filtrationand calibration we have now a sensor module. Connecting between the sensor module anda microcontroller and saving the data for post processing is the DGM. Using the readingsthe next step is to use it for parameter identification.

    By PI it is possible to build the appropriate mathematical model of the system. By

    2

  • adding the control algorithm such as altitude hold and heading autopilot it is possible toconvert unstable aircraft into a stable one by control or to make a stable aircraft morestable in the stability control phase.

    In stability control phase it is possible to say that all required change in aircraft states isequal zero i.e. you need to hold altitude at certain value or speed at constant cruise speedor Euler angles to be all zero or little changes to maintain altitude and heading. Now wecan call that aircraft can draw a point i.e it will not fall, it will not stall and it will sustainin the sky and avoid any disturbances like a standing baby who cannot till now move.

    Now we convert to the phase of guidance to move the baby where the aircraft is re-quired to move from one point to another from certain longitude and latitude value toanother one.By adding a mission requirements to the stability control we reach the finalpoint in autopilot design.Ground control station GCS is modified and become more com-plicated from a step to another.

    In the thesis work, we will reach only the step of PI - the oine PI phase. Thework required to build a data gathering module DGM . DGM contains calibrated sensorsconnected with a microcontroller to sense and save all aircraft data during flight i.e. inputand output signals for example elevator signal and pitch angle.

    This data could be used for various applications. One may use them for PI anotherone could use them for an autopilot circuit. In the present work test flights were made on aremotely piloted RC models and a good flight sample was chosen to be used in the PI phase.

    The tests were done for two RC models:KADET LT-40 and Low super trainer. TheKADET had the first tests and some modifications on the whole system was suggestedand taken into consideration in the Low super trainer test flights. Results showed that theapproach was successful with a very appealing results and open the way for future work inon line parameter identification and the stability control autopilot design based on oineparameter identification results.

    In chapter 3, the Hopfield neural network for PI is introduced describing the problem ofPI then the branch in neural network where Hopfield is located then how to use HNN inPI. The main proof of the method was introduced in Raol and others see [6] but for a twostates system with 2x2 A matrix and 2x1 B matrix. A general code for any nxn A andnxm B matrices will be introduced where n for states and m for inputs of the system. Ageneral flow chart for the method will be introduced. To validate the method, a systemwith a know state space model will be used. Input signal will applied to the system toget its states responses. A noise signals will be applied to the states and input signals.The noisy signals will be taken as input to the HNN code to get the original A,B matricesof the system. A comparison with the original and estimated systems will be introducedwhich will show an appealing results to be used further with the real flight data.

    In Chapter 4, The data gathering module(DGM) will be introduced. The various compo-nents of the system will be shown and describing specifications and limitation of each

    3

  • sensor.Then A full flow chart of the system will be introduced showing onboard compo-ments and ground control station(GCS) components. The varoius software used will beintroduced including the onboard software and GCS software and the PI software. Thefull detailed software codes are introduced in the appendices.

    In chapter 5, The flight tests will be introduced showing the specifications of each aircraftused in flight then the flight data and cautions. The results of the first flight was introducedand discussed to show the recommendation and cautions to be taken into concentration inthe second test flight. The recommended modification will be done and introduced in thischapter. The second test flight will show a better performance and results.

    In chapter 6, Conclusions and recommendation for future work will be introduced anddiscussed.

    4

  • Chapter 2: Literature Review2.1 Parameter Identification TechniquesParameter Identification is a wide research subject and when relating to aircraft systems, itallows us to obtain a mathematical model of an aircraft from real flight data. These datacould get us the aerodynamic properties of an aircraft even this aircraft is in the designedflight condition or not, even the flight was a stable flight or unstable and even the geometryof the aircraft was changed through a crash or added external payloads or weights. Windtunnel experiments can be validated through real flight data and the real flights are morereliable and accurate than the restricted wind tunnels. Flight simulation for pilot trainingcould be enhanced when the simulation is close to the real flight actions and this could begrantee with the results of parameter identification techniques.

    The problem of parameter estimation is based on minimization of some criterion (ofestimation error) and this criterion itself can serve as one of the means to establish theadequacy of the identified model. Figure 2.1shows the simple approach to parameter

    Figure 2.1: Simplified block diagram of the estimation procedure[6]

    identification. Given the z measurements of a system which is the real state response to aninput but with added noise.Input signal is applied to the aircraft and the states are thenmeasured taking into consideration that the measured states responses may have an addednoise. On the other hand, an initial model of the system is assumed and the input signal isapplied to it to get the model response which will not be equal the measured one. So theoptimization criteria is introduced and iteration occurred till reaching an accepted outputerror. The optimization criteria is the main difference between the various PI methods. Wehave to take into consideration that the least output error is not the sufficient condition forachieving good estimate so expanded versions are introduced to get the sufficient criteria.

    5

  • Lots of methods were used for the problem of PI. One of them is The maximum likelihood-output error method. This method has a batch iterative procedure.This mean that in oneshot all the measurements are used and parameter corrections are obtained. Hence a newparameters are calculated and iteration occurred and so on .

    The output error method has two limitations:i) it can handle only measurement noise not the process noise.ii) Divergence may occur for unstable systems

    Using Kalam Filter could help in solving the process noise. This leads to a new methodcalled the filter error method.In this method, the output states are filtered before applyingthe cost function. This makes the method more complex and computationally intensive.The filter error method can compete with the extended Kalman filter, which can handleprocess as well as measurement noises and also estimate parameters as additional states.One major advantage of Kalman filter/extended Kalman filter is that it is a recursivetechnique and very suitable for on-line real-time applications. For the latter application, afactorization filter might be very promising. One major drawback of Kalman filter is thefilter tuning, for which the adaptive approaches need to be used.

    The second limitation of the output error method for unstable systems can be overcome byusing the so-called stabilized output error methods, which use measured states.This stabilizes the estimation process.Alternatively, the extended Kalman filter or theextended factorization filter can be used, since it has some implicit stability property in thefiltering equation. The filter error method can be efficiently used for unstable/augmentedsystems.

    Since the output error method is an iterative process, all the predicted measurementsare available and the measurement covariance matrix R can be computed in each iteration.The extended Kalman filter for parameter estimation could pose some problems sincethe covariance matrix part for the states and the parameters would be of quite differentmagnitudes. Another major limitation of the Kalman filter type approach is that it cannotdetermine the model error, although it can get good state estimates. The latter part isachieved by process noise tuning. This limitation can be overcome by using the modelerror estimation method.

    The approach provides estimation of the model error, i.e., model discrepancy with respectto time. However, it cannot handle process noise. In this sense, the model error estimationcan compete with the output error method, and additionally, it can be a recursive method.However, it requires tuning like the Kalman filter. The model discrepancy needs to befitted with another model, the parameters of which can be estimated using recursive leastsquares method.

    Another approach, which parallels the model error estimation, is the estimation beforemodeling approach. This approach has two steps:i) the extended Kalman filter to estimate states (and scale factors and bias related parame-ters);ii) a regression method to estimate the parameters of the state model or related model.

    6

  • The modelerror estimation also has two steps:i) state estimation and discrepancy estimation using the invariant embedding method.ii) a regression method to estimate the parameters from the discrepancy time-history.Both the estimation before modelling and the model error estimation can be used forparameter estimation of a nonlinear system. The output error method and the filter errormethod can be used for nonlinear problems.

    The feed forward neural network based approach somewhat parallels the two-step method-ologies, but it is quite distinct from these: it first predicts the measurements and thenthe trained network is used repeatedly to obtain differential states/measurements. Theparameters are determined by Delta method and averaging.

    The recurrent neural network based approach looks quite distinct from many approaches,but a closer look reveals that the equation error method and the output error method basedformulations can be solved using the recurrent neural network based structures. In fact,the equation error method and the output error method can be so formulated withoutinvoking recurrent neural network theory and still will look as if they are based on certainvariants of the recurrent neural networks. This revealing observation is important frompractical application of the recurrent neural networks for parameter estimation, especiallyfor on-line/real-time implementation using adaptive circuits/VLSI, etc. Of course, oneneeds to address the problem of convergence of the recurrent neural network solutions totrue parameters. Interestingly, the parameter estimation procedure using recurrent neuralnetwork differs from that based on the feed forward neural network. In the recurrentneural network, the so-called weights (weighting matrix W) are pre-computed using thecorrelation like expressions between x, x,u, etc. The integration of a certain expression,which depends on the sigmoid nonlinearity, weight matrix and bias vector and someinitial guesstimate of the states of the recurrent neural network, results into the new statesof the network. These states are the estimated parameters (of the intended state-spacemodel). This quite contrasts with the procedure of estimation using the feed forwardneural network. In feed forward neural networks, the weights of the network are not theparameters of direct interest. In recurrent neural network also, the weights are not ofdirect interest, although they are precomputed and not updated as in feed forward neuralnetworks. In both the methods, we do not get to know more about the statistical propertiesof the estimates and their errors. Further theoretical work needs to be done in this direction.

    The genetic algorithms provide yet another alternative method that is based on directcost function minimization and not on the gradient of the cost function. This is veryuseful for types of problems where the gradient could be ill-defined. However, the ge-netic algorithms need several iterations for convergence and stopping rules are needed.One limitation is that we cannot get parameter uncertainties, since they are related tosecond order gradients. In that case, some mixed approach can be used, i.e., after theconvergence, the second order gradients can be evaluated. Parameter estimation workusing the artificial neural networks and the genetic algorithms is in an evolving state. Newresults on convergence, uniqueness, robustness and parameter error-covariance need to beexplored. Perhaps, such results could be obtained by using the existing analytical resultsof estimation and statistical theories. Theoretical limit theorems are needed to obtain more

    7

  • confidence in these approaches. The parameter estimation for inherently unstable/aug-mented system can be handled with several methods but certain precautions are needed.The existing methods need certain modifications or extensions, the ramifications of whichare straightforward to appreciate. On-line/real-time approaches are interesting extensionsof some of the off-line methods. Useful approaches are:i) factorisation-Kalman filtering algorithm.ii) recurrent neural network.iii) frequency domain methods.

    2.2 Work achieved in Aerospace departmentThrough the last four years, various approaches to the autopilot design were made. In2011, work started to get uncalibrated sensors and after then be filtered and calibrated.The sensors varied from a very cheap one with low accuracy to the very expensive one.Thetwo approaches where canceled, the expensive one for budget and the lower one for lowaccuracy.Then in the same year another approach was chosen to use a full autopilot andupload a customized control gains for a flying wing UAV previously calculated. Micropilotautopilot was chosen for the task, the autopilot wasnt easy to deal with like other opensource autopilots like ArduPilot. The autopilot had a problem in wireless module andthe warranty period was finished before the start of the project. The autopilot stoppedworking after a while and the customer services told us that we have to send it to themto be fixed and return back all on our charge.In 2012 atrial to use ArduPilot shows thatArduPilot is easier and extremely cheaper than MicroPilot with appealing results forstudent projects.ArduPilot board like Micropilot board wasnt easy to replace a fault partor to add a custom sensors. In 2013 we began to purchase the ArduPilot inner componentsseparately i.e microcontroller and sensors.Work started to build our own autopilot circuitbased on Arduino mega microcontroller and Arduimu sensor. In 2014, a first DGM wasbuilt to be used for PI.In the same year a stability control autopilot was built based on thisDGM and displacement autopilot was successfully done.In 2015 we did the oine PI forboth longitudinal and lateral aircraft dynamics using the customized DGM with a GCSbased on Simulink.

    For the Control Algorithms, In 2011 we built a Linear and nonlinear simulation ofthe aircraft using Matlab and Simulink, then Designing a Linear PID control for thealtitude hold autopilot.Verification of the gains on the nonlinear simulation was done anditerated till getting a better nonlinear response of the altitude hold autopilot. The parameteridentification was done based on Roskam aerodynamic stability and control derivativesbook using a Matlab code. In 2013,another project modified the code to be generally usedfor any dimensions of a conventional aircraft. The code was used to design PID controllerfor altitude hold of Bixler RC model. The gains were very near to the documented gainsof Bixler used in ArduPilot autopilot but not so good in the lateral gains.Now Roskamcalculated parameters was successful for longitudinal dynamics but not sure for the lateralones. Aircraft aerodynamic stability and control derivatives ASCD change from a flightcondition to another.ASCD changes if a destruction or a modification occurred to anypart of the aircraft.New aircrafts need to define its ASCD using real experiments. Usingequation of motion to find the dynamics equations of an aircraft may be a difficult workand also need to be verified. All these difficulties are solved using real flight tests designed

    8

  • to do PI for aircrafts. A lot of work was done for PI based on real flights either usingoine PI or online PI. Doning a survey on oine PI, It was found that output error methodwas the most famous used method.Studies shows that using NN for off-line PI is moreaccurate than the output error method which is the most used technique for oine PI(see(J.R. Raol, G. Girija and J. Singh, 2004)) [6]. In online PI Neural network is a very famoustechnique.So a better track for a long term PI work is to use Neural network for oineand then do modifications to neural network to be used for online. So in this study we aremainly interested in studying the oine PI using NN.

    9

  • Figure 2.2: A sample of the used method for PI

    10

  • Chapter 3: Parameter Identification3.1 IntroductionFor our major of study, parameter identification techniques are used to estimate aerody-namic and stability derivatives of the aircraft. Given these derivatives we could build amodel that describes the dynamics of the aircraft. A lot of methods were generated to dothis job. Roskam built a good method to obtain parameters via experimental tests. Eventhis method is more accepted for large aircrafts and depends on the calculated geometryand properties of the aircraft. Parameter identification PI using real flight data is the mostreliable technique to measure the aircraft parameters where mathematical model of theaircraft is not needed as you treat with the real body.Also changing in aircraft geometryor flight condition through flight is not a problem where you could deal with the realbody problem specially for on-line PI. There are two techniques of PI using real flightdata: on-line and off-line . On-line estimation algorithms estimate the parameters of amodel when new data is available during the operation of the model. In contrast, if youfirst collect all the input/output data and then estimate the model parameters, you performoff-line estimation. Parameter values estimated using on-line estimation can vary withtime, but parameters estimated using off-line estimation do not.In this way, off-line trainingis not restricted by the on-board computers computation power and the approximation canbe highly accurate.Traditional methods include recursive least-squares and the Kalmanfilter for parameter estimation (Ljung, 1999). Newer alternative methods include HopfieldNeural Networks (HNNs) for parameter estimation (see, for example, (Atencia, Joya, &Sandoval, 2004; Hu & Balakrishnan, 2005)). Neural networks are used mainly for on-linePI.The off-line learning cannot take the advantage of a neural networks learning ability toadapt to the changing aircraft dynamics during the flight. The on-line learning methoduses the real-time flight data obtained for training and has much higher requirements foron-board hardware and software implementation. However, this method has the ability tolearn the changing aircraft dynamics and give the controller some level of intelligence.The on-line NNs learning speed and accuracy is limited by the natural frequency of thesystem, the on-board computation power and available resources. This study benefits isto learn NN for off-line PI so it may be easy using it when trying the on-line parameterestimation. Also the onborad computer is restricted to be the lowest cost.Studies showsthat using NN for off-line PI is more accurate than the output error method which is themost used technique for oine PI(see (J.R. Raol, G. Girija and J. Singh, 2004))[6].So inthis study we are mainly interested in studying the oine PI using NN.

    3.2 Artificial neural network

    3.2.1 IntroductionArtificial neural network ANN is a try to get a mathematical model for the human brain.The human brain is consisting of a very large number of neurons. The artificial neuronreceives one or more inputs (representing the one or more dendrites) and sums them toproduce an output (representing a biological neurons axon). Usually the sums of each

    11

  • node are weighted, and the sum is passed through a non-linear function known as anactivation function. The activation functions usually have a sigmoid shape. Modeling ofa system using artificial neural networks has recently become popular with applicationto signal processing, pattern recognition, system identification and control. Estimationof parameters using empirical data plays a crucial role in modeling and identification ofdynamic systems. Often equation error and output error methods are used for parameterestimation of dynamic systems. These are generally batch iterative procedures where a setof data is processed to compute the gradient of a cost function and estimation error. Theestimation of parameters is then refined using an iterative procedure based on the improvedestimates of error and its gradients. Such methods can be termed as batch iterative. Theartificial neural networks provide new/alternative paradigms to handle the problem ofparameter estimation with potential application to on-line estimation. Especially recurrentneural networks are easily amenable to such possibilities due to their special structure-feedforward neural networks with feedback feature. In order to obtain fast solutions, a systemof parallel computers can be used. This will require the parallelization of the conventionalparameter estimation algorithms. Since artificial neural networks have massively parallelprocessing capacity, they can be adapted to parameter estimation problems for on-lineapplications. In particular, the recurrent neural networks can be considered as moresuitable for the problem of parameter estimation of linear dynamical systems, as comparedwith perhaps feed forward neural networks. The recurrent neural networks are dynamicneural networks, and hence amenable to explicit parameter estimation in state-spacemodels. One of the architectures of RNN is the Hopfield neural network HNN. In thefollowing section HNN will be introduced to be used for PI.

    3.2.2 Hopfield neural network3.2.2.1 Introduction

    One of the milestones for the current renaissance in the field of neural networks was theassociative model proposed by Hopfield at the beginning of the 1980s. Hopfields approachillustrates the way theoretical physicists like to think about ensembles of computing units.No synchronization is required, each unit behaving as a kind of elementary system incomplex interaction with the rest of the ensemble. Hopfield neural network HNN couldbe successively used for the problem of PI. First we have to introduce HNN as a generalneural network. For Human neural network,lets have an example.a man recognizes photosby both eyes. For a sick eye, the brain tries to depend on the better eye more than the otherone hence sends more blood to the better one.And perceptrons between eyes and the brainbecome weaker in the sick one. It looks like brain take more weighting to the healthy eyeand less weighting to the sick one. Doctors advice to treat the sick eye because it now isgoing to become weaker and weaker because the brain tries to neglect it time by time.Thisweightings is what we try to do when trying to descibe what happens mathematically.A simple way to show that as in figure 3.1. So to get the right output, it is a must firstto know the right values of weights and this is called learning. Then After getting theappropriate weights and applying the input signals you could get the output and this iscalled validation. Assume a discrete problem where it is required to recognize the Ccharacter when writing it in a 4*3 pixels as shown in figure 3.3a. When writing the Ccharacter as in figure 3.3b, The solid pixels are represented as 1 and the unsolid as -1 as in

    12

  • Figure 3.1: An artificial neuron as used in a Hopfield network

    figure 3.3c.From Hopfield Neural Network the weights are obtined between each pixeland the other pixels as shown a sample of the weights in figure 3.3d and by the languageof neural network pixels are now neurons where:

    wi j = xi x j (3.1)where i and j are the neuron index and x is the value of the neuron 1 or -1 . By obtainingthese weights, learning step has now ended. Now the validation where the pixels are let forsome one to write the C character on them as seen in figure 3.3e. What has been writtenis transfeered into 1 and -1 as in figure 3.3f. The neural network now try to change thepixels 1 and -1 values till reach a learned character which here is only the C character. Toupdate a neuron value hopfiled uses the following rule:

    xi = sign(n

    j=1

    i jx j) (3.2)

    This equation is proofed that it will never diverge [6]. The values of the neurons will movetowards the nearest shape to the C character. So it may reach the C character or it willnot go worse. So the sign apperaed in equation 3.2 shows an added block to HNN shownin figure 3.1 which is added after the summation rectangualr block which in general forcontinuous system will not be a sign but generally will be a sigmoid function where thesign is a special case in it as shown in figure 3.2.

    Figure 3.2: An artificial neuron as used in a Hopfield network with added sigmoid function

    13

  • This was a roughly description to what happen in Hopfiled neural network.

    (a) 4*3 Pixels (b) C character (c) A subfigure (d) Sample of the weights

    (e) A subfigure (f) A subfigure

    Figure 3.3: Example for Discrete image recognition using Hopfield Neural Network

    3.2.2.2 Parameter Estimation Problem

    The Proof was given in Raol and others[6] and the main theory was revised from its mainpaper[7] . Consider the state space representation of a dynamical system

    x = Ax + Bu (3.3)

    The aim is to solve for A,B the system parameter matrices knowing x, x and u. Herex is (n1) state vector, u = u(t) is the control input (scalar), A = [ai j] is nn matrix andB = [bi] is n1 vector. The parameters ai j (elements of A) and bi (elements of B) to beestimated are denoted by np1 vector where:

    = [a11,a12....aln,a21,a22...a2n..an1,an2...ann,b1,b2...bn] (3.4)

    where np is the number of parameters to be estimated i.e. (n2 + n). Next we describethe dynamics of HNN as

    =

    nj=1

    i ji + bi (3.5)

    Our problem is to define the Weighting matrix W, the bias vector b, choose the sigmoidfunction f and its coefficients then use these information to get the change in the parametersi.e. then get the new parameter values as new = old + t .

    Given e(k) as the equation error where e = xAxBu we can define the cost functionas:

    E() =12

    nk=1

    eT (k)e(k) =12

    nk=1

    (xAxBu)T (xAxBu) (3.6)

    14

  • Also we haveE =

    12

    i

    j

    i ji j

    i

    bii (3.7)

    as the energy landscape of the recurrent neural network.Now from optimization theory bydifferentiating the cost function w.r.t we have

    t= E

    = 1

    2(n

    k=1 eT (k)e(k))

    (3.8)

    Since as a parameter vector contains the elements of A and B, we can obtain expressionsE/A and E/B for A and B vectors.

    EA

    =

    nk=1

    (xAxBu)(x)T = A

    xxT + B

    uxT

    xxT (3.9a)

    EB

    =

    nk=1

    (xAxBu)(u) = A

    xu + B

    u2

    xu (3.9b)

    By expanding the elements of the above matrices we could get E/ai j and E/bi j . Forexample

    Ea11

    = a11

    x21 + a12

    x1x2.........+ b1

    x1u......

    x1x1 (3.10)

    Again by differentiating the energy equation w.r.t we have

    Ei

    = n

    j=1

    i jibi (3.11)

    By comparing equations 3.10 and 3.11 we could find the elements of both the weightingmatrix W and the bias vector b. Now Since i = f () then = f 1(i) then

    i =( f 1(i))

    i (3.12)

    So we could define the change in parameters as

    i =1

    ( f1(i))

    i =1

    ( f1(i))

    nj=1

    i ji + bi (3.13)

    And by choosing a suitable sigmoid function we could get . Assuming

    f (i) = (1 ei1 + ei

    ) (3.14)

    then

    i =(22i )

    2

    nj=1

    i ji + bi (3.15)

    15

  • Finally to get the new parameters vector we have

    i(k + 1) = i(k) + t (3.16)

    i(k + 1) = i(k) +t(22i )

    2

    nj=1

    i ji + bi (3.17)

    Figure 3.4: Flow chart for Hopfield Neural Network PI

    3.2.3 ResultsA Matlab code was built depending on the previous illustrations. A set of data wasgenerated from a given linear state space model.The model has four states and one inputsignal with 20 parameters. The estimation was carried out using noise free data and againwith additive noise(SNR=10). The tuning parameters and were kept at 0.001 and 200respectively.Sampling time was set at .00025 sec. It was noted that RNN took around200,000 iterations before the convergence of estimated parameters to true values for thefree noise signal and about 900,000 iterations for the noisy signal. Table 3.1 shows theestimated parameters for the two data sets.Error was shown as only the difference betweenthe real and estimated value.

    16

  • Table 3.1: Estimated elements of A and B matrices

    True Values Estimated Error Estimated Erroriter 200000 900000

    SNR SNR=inf SNR=10-0.045 -0.045003671 3.6707E-06 -0.027277008 -0.017722992-0.036 -0.036021552 2.15516E-05 0.173624619 -0.209624619

    0 0.00038355 -0.00038355 -12.22945959 12.22945959-30 -30.00003794 3.79433E-05 -26.46613445 -3.533865551

    -0.369 -0.369084965 8.49649E-05 -0.075466871 -0.293533129-2.02 -2.020498759 0.000498759 -0.184922364 -1.835077636

    1 1.008898544 -0.008898544 0.567241605 0.4327583950 -0.000878168 0.000878168 2.034148622 -2.034148622

    0.0019 0.000911806 0.000988194 -0.010721288 0.012621288-0.0396 -0.045400063 0.005800063 0.010295163 -0.049895163-20.948 -20.84433291 -0.103667093 -16.91628511 -4.031714892

    0 -0.010214947 0.010214947 0.375789166 -0.3757891660 0.000588044 -0.000588044 0.002145217 -0.0021452170 0.003451917 -0.003451917 0.018468908 -0.0184689081 0.938412706 0.061587294 0.963367259 0.0366327410 0.006077832 -0.006077832 0.040599949 -0.040599949

    0.56 0.560001413 -1.41341E-06 -0.969877568 1.529877568-0.8 -0.79996698 -3.30197E-05 -0.536048355 -0.263951645-0.5 -0.499613434 -0.000386566 -0.478945969 -0.021054031-0.7 -0.700228534 0.000228534 -0.653822901 -0.046177099

    Error -0.04314389 1.467580966

    Estimated data for both data cases are shown in figures 3.6, 3.7 and 3.8 . Figure 3.6shows the real and estimated states and change in states. Figure 3.7 shows the true A and Bmatrices elements and the estimated parameters. Figure 3.8 shows the error in parameterswith iterations.

    A study [6] was shown that using an input with 3211 signal will excite the long andshort period in the aircarft. Also using a sampling frequency when collecting data 0.01Hz will be better in PI problem [10]. In the following table four situations will be studiedshowing the impact of sampling frequency and the type of signal on HNN PI problem.

    Table 3.2: Results of different combinations of data Sampling frequency and the type ofthe input signal

    100 HZ 20 HZ Comment

    3211 inputError= 0.0359 %

    Time = 63.485 secError= 0.2744 %Time = 64.72 sec

    Long period ObtianedShort Period Obtained

    Pulse inputfor 2 sec.

    Error= 0.0199 %Time = 64.94 sec

    Error= 0.1912 %Time = 65.214 sec

    Long Period (Not Obtained)Short Period Obtained

    Doublet Input0.5 Hz

    Error= 0.0362 %Time = 66.538 sec

    Error= 0.3053 %Time = 68.0966 sec

    Long Period (Not Obtained)Short Period Obtained

    17

  • (a) S NR =

    (b) S NR = 10

    Figure 3.5: Real,measured and Predicted data for states and states rate

    18

  • (a) S NR =

    (b) S NR = 10

    Figure 3.6: Real,measured and Predicted data for a sample state

    19

  • (a) S NR =

    (b) S NR = 10

    Figure 3.7: True and estimated parameters

    20

  • (a) S NR =

    (b) S NR = 10

    Figure 3.8: Error in parameters

    21

  • Chapter 4: Data Gathering Module4.1 IntroductionAutopilot is the brain of an aircraft. It is responsible of all orders given to the aircraft.Itcollects data, processes it and finally makes the decision. The whole autopilot systemcontains from its hardware elements ,the software saved on it and the ground controlstation GCS. Autopilot hardware circuit contain all the elements required to make theproper sensing to the aircraft and its situation like altitude, attitude,velocity, surroundingatmosphere and so on and so far. Autopilot software transfer all the sensors data to theautopilot processor.Autopilot software analyses the data in the processor unit then makethe decision and send it to the aircraft actuators.For now we are just using the autopilot as adata gathering module.So data is just collected and stored with no resulting control action.In the following sections a brief description will be presented about the hardware circuitcomponents, specifications and limits then a description to the data gathering modulesoftware and GCS software .

    4.2 HardwareThe DGM designed and tested in ASTL was of total weight about 250 gm and externaldimensions about 9x3x5 cm.The parts chosing crietrai was to get the best parts in thelocal market.Most of parts were getting from Ram and future electronics, see[2],[3] . It isconsisting of 3 PCBs the first main one contains the microcontroller and the sensors andthe second one is a servo set PCB to connect between servos and the main PCB.The lastone conects between analog inputs (potentiometers and velocity sensors) and the mainboard. The work done at west Virginia university was very helpful during the choosing andtesting of sensors.Dr Brad seanor did his PhD at 2002[10] and then he was of supervisorsof Dr YuGu during Dr Yu Gu PhD in 2004[5] and Eng. Amanda K. McGrail during herMsc. in 2012 [8].

    22

  • Figure 4.1: Block Diagram for the whole system processes

    23

  • Figure 4.2: Data gathering Module Hardware

    4.2.1 MicrocontrollerAs shown in figure, the used microcontroller was Arduino Mega 2560 16 MHz, 256KB RAM. It collects data from various sensors and sends it to the computer via serialcommunication or through wireless via wireless module. It is responsible on controlcommands. The board also connects between the remote controller and the servos for thepurpose of manual flights. Its limitations come from the low processor and the low RAMcapacity.

    Figure 4.3: Arduino mega 2650 microcontroller

    4.2.2 Microcontroller shieldThe Arduino shield is a two layer PCB. This customized shield was used to connect themicrocontroller with the various sensors.

    24

  • (a) Front Layer (b) Back Layer

    (c) Implementation - Lower Layer

    (d) Implementation - Fixed with Arduino

    Figure 4.4: Arduino Customized shield

    4.2.3 Servo MotorsThe used servo motor was the Standard High-Torque BB Servo Futaba S3010. Its speed is0.20 sec/60 @ 4.8V

    Figure 4.5: Servo Motor

    25

  • 4.2.4 Servos and potentiometer SetsThis is a customized PCB to connect the servos to the main Arduino shield. This board isgood for longer servos distributions and to simplify the main Arduino shield. There aretwo boards of this kind one for servos and the other one for potentiometers

    (a) Implementation (b) PCB Layout

    Figure 4.6: Servos Set

    4.2.5 PotentiometersPotentiometers are used to measure the control surfaces deflections. The output is used tobe stored as the input signals. Input signals are used for parameter identification purposesas will be shown later.

    Figure 4.7: Potentiometer

    4.2.6 IMUAs shown in figure, the used IMU was Arduimu V3. It is responsible for measuring theEuler angles , and , the Euler angles rates p, q and r and the accelerations ax, ay andaz. Specifications of this Arduimu comes from the motion processing unit used insideit which is MPU-6000. MPU-6000 comes integrated with a 3-axis MEMS gyroscope, a3-axis MEMS accelerometer and a 3-axis magnetometer. The used ranges are 500 /sec forgyroscope and 4g for the accelerometer, see [12].

    Figure 4.8: Arduimu V3

    26

  • 4.2.7 Pressure SensorThe used atmospheric pressure sensor was BMP085 Module GY-65.The sensor has arange of 30:110KPa ( altitude 9000:-500m) with a resolution ratio of 6 Pa (0.5 meter) inlow power mode and 3 Pa (0.25 meter) in high linear mode. The response time equals 7.5ms, see [11].

    Figure 4.9: BMP085 Module GY-65 Pressure Sensor

    4.2.8 Velocity sensorThe MPXV7002DP series piezoresistive transducer is a monolithic silicon pressure sensorwith a pressure range of 2 kPa and 2.5 % typical error and 6.25% maximum error over+10C to +60C.

    Figure 4.10: Velocity Sensor

    4.2.9 Wireless moduleThe uses wireless module was Xbee PRO 52B.It is responsible for data transmissionbetween autopilot and the ground station. It has an outdoor line-of-sight at about 1500m.

    Figure 4.11: Xbee pro 52B wireless module

    4.2.10 GPS moduleCJMCU-108-H is a UBLOX GPS with 5 Hz update rate and -148 dBm acquisitionsensitivity (cold start), -162 dBm tracking sensitivity. The error in location is about 1.5 m.

    27

  • Figure 4.12: GPS Module

    4.2.11 Alpha-Beta sensorAir-data sensor is an alpha beta probe used for measuring the angle of attack and side slipangle.The sensor was difficult to be obtained from the market for small aircrafts and theavailable one was very expensive. So the sensor had to be built.The design of the fens wastaken from the Open Air Data Computer project through the web site[4]. The obtainedfens was capable of measuring the AOA when the velocity reaches about 14 m/sec. andthe alpha and beta fens were collected in one set. So a modification on the design weredone.First a 1.8 scaled fens was built to get readings at a velocity about 7 m/sec.Secondthe fens were separated one at the right wing tip and the other one at the left wing tip.Thisallow a better weight distribution and to be away from the propeller flow at the middle ofthe aircraft. A 3D model for the whole sensor was built then manufactured in the ASTL.After the first test flight the system was modified as shown in the flight test chapter later.

    Figure 4.13: First Design (Not used because of middle flow from motor propeller)

    28

  • Figure 4.14: Air data fin drown by Solid Works

    Figure 4.15: CNC manufacturing of Air data fin

    29

  • Figure 4.16: Air data fin for Side Slip angle

    Figure 4.17: Air data fin for angle of attack

    30

  • Figure 4.18: The total AOA and Side slip sensors attached to the wing tip

    4.2.12 BatteriesThe Power source of the Arduino mega and the servos was separated then collected atonly one ground. The Arduino used a battery of 7.4 volts with 2500 mhA which has avery good capacity that could sustain for a very good time without needing recharging.The servos are using the standard Ni-Cd 4.8 volt batteries.

    4.2.13 RC Transmitter and receiverA Futaba RC Remote was used for manual control of the servos. It sends signals to thereceiver. The receiver is connected to Arduino. Finally Arduino sends signals to servos.

    4.3 Software

    4.3.1 Arduino Mega SoftwareSensors Signals to Microcontroller Software is used to transfer data from sensors tothe Arduino microcontroller. The software is based on Arduino programming program.The software collects about 27 readings from various sensors. The data gained couldbe used for parameter identification and for control purposes The output data are inASCII format. Through signal monitor data could be seen sending row by row. Each

    31

  • row contains all the sensors readings as follow: RLL:0.07,PCH:0.08,YAW:0.33,altitude:-0.50,velocity:0.00,elev:-683,ail:-713,rdr:-713,alpha:-737,beta:-690,AN0:0.13,AN1:-0.62,AN2:0.22,AN3:17.78, AN4:-0.08,AN5:8190.33,lat:0.00,lon:0.00,gpsalt:17.00 , gpsgc0.00,gpsgs0.00, fix:0,numsat:0,elevs:0,ails:0, ruds:0,throts:0. RC receiver is connected to Ar-duino mega through its digital ports. So Arduino could collect the RC remote signal tostore it then sends it to the servos through the PWM ports.The main code for Arduimu wasgiven from its website [12] and then modifications was done on the code as in AppendixC to get the right angles and some website were very helpful in that, see[1].

    Figure 4.19: Flow Chart of Arduino Software

    4.3.2 Monitoring SoftwareMonitoring software is used to plot the various received data from the autopilot in realtime. This software could also save the data for after-processing. Saved data could beused for analyzing the recorded flight and for off line parameter estimation purposes. Thesoftware was built in Simulink environment. The autopilot sends data in ASCII formatthen the monitoring software convert it to decimal. The software is connected to Googleearth program. Google earth receives the GPS data from the Simulink program to plot theaircraft location using longitude and latitude readings , see Appendix D.

    (a) the whole program(b) ASCII to deci-mal Block

    Figure 4.20: Monitoring Software

    32

  • Figure 4.21: Simulink GCS

    Figure 4.22: Flow Chart of Simulink GCS

    4.3.3 Parameter Identification SoftwareParameter identification software is a generated Matlab code. The inputs to the code arethe measured data received from the autopilot for the sensors signals and control surfacesdeflections signals. The code is based on Hopfield neural network as will be discussedlater. The outputs from the code are the A, B matrices of the linear state space model forlongitudinal and lateral aircraft dynamics. The whole software is shown in Appendix A.

    33

  • Figure 4.23: Flow chart for Hopfield Neural Network PI

    34

  • Chapter 5: Test flights and Results5.1 KADET LT-40 RC model Test Flight

    5.1.1 IntroductionThe used aircraft specifications are shown in table 5.1. The test flight was performed at9:00 am and the Airflow was quiet and suitable for the test. The test flight was performedfor about 5 min. as shown in the map in the red path.Through the flight the data werecollected and stored into the GCS.Post processing was performed

    Figure 5.1: The Flight Path

    Table 5.1: KADET LT-40 RC model Specifications

    Wing Span 1778 mmWing Area 58.1 dmLength 1447 mmFlying Weight 2490 - 2720gWing Loading 43 - 47 g/mEngine 2-Stroke .46 cu. in. (7.5 cc)

    35

  • Figure 5.2: Ready to Fly

    Figure 5.3: Captured photo from the flight test

    5.1.2 PI of Longitudinal DynamicsFor the linearized longitudinal equation of motion we have

    uq

    = Auq

    + Bu (5.1)Our aim now is to do the following:1- Collect all the available data from the state space vector, its derivative and the inputvector i.e (u, , q, ,u,,q, ,u).2- Estimate the data that was not capable to be measured.3- Identify the A and B matrices.

    36

  • The unavailable data that cannot be measured were the angular acceleration term q andthe angle of attack rate (AOA) .For q the angular rate q was differentiated to get q andthis required a high sampling frequency to get accurate estimation usually 100 Hz is usedbut in this test 10 Hz only was used and this was modified in the other test flight for LowSuper trainer RC model.Also u was replaced with the linear acceleration in x direction axand was replaced with the linear acceleration in z direction az .So finally the state spacemodel becomes

    axazq

    = Auq

    + B[elev

    ](5.2)

    In the flight the throttle was set constant and then the throttle was neglected.The datawere added to the Hopfield Neural Network code and using a good sample from the testwith smooth outputs and inputs for about 4 seconds. The code was designed to iterateand get estimated A,B matrices. These A,B matrices are now the estimated linear statespace model to the aircraft.input data collected from the test are applied to this model andcompare its states response to the measured states.Error calculated was about 7.5 % where

    E =s

    1n

    1 |ei|n

    (5.3)

    where s is the number of states and n is the number of samples for each state.Themeasured and estimated states are shown in figure 5.5 .

    37

  • Figure 5.4: Longitudinal States (Measured and estimated).The yellow line is the elevatorsignal

    A remark was shown from this test is that the pitch angle (the 4th figure)indicates thatwe have two peaks one at the 0.5 sec and the other one at about 2.3 sec and the differencebetween the measured and estimated at 2.3 is higher than the one at 0.5.We can remarkthat also the rate of change of the elevator signal is higher at 2.3 more that its at 0.5. Thisindicates that the aircraft response is changing not only with the elevator signal but alsowith the rate of change in elevator signal. So another model was suggested to considerthat we have not one input signal but two input signals the elevator signal and the changein elevator signal (elev, elev) . Now the state space model become as follow

    axazq

    = Auq

    + B[elev elev

    ](5.4)

    By using the new state space model the error was reduced from 7.5 % to 6.3% and theresults are shown in figure 5.5. Another remark was shown now that the alpha signal hasthe maximum error with 59.37 % of the total error.The error in other 3 states is equal only2.56%.By this remark it was suggested to use another AOA and side slip sensor.

    38

  • Figure 5.5: Longitudinal States (Measured and estimated) when using elevator and changein elevator as inputs.The yellow line is the elevator signal

    The estimated state space has the following formaxazq

    =

    0.0858 0.2892 0.0004 9.72330.1890 4.8213 21.2426 0.00040.0335 0.1529 4.6181 0.02010.0091 0.0076 0.9953 0.0074

    uq

    +15.6149 1.24720.0070 0.00706.5863 0.81071.3036 0.4347

    [elev elev

    ](5.5)

    The A matrix shows a good match in the parameters order of magnitude with the linearstate space model derived in Nelson Flight Stability and Automatic Control book[9] as inequation 5.6.

    uwq

    =

    Xu Xw 0 gZu Zw uo 0

    Mu + MwZu Mw + MwZw Mq + Mwuo 00 0 1 0

    uwq

    (5.6)The root locus of the longitudinal dynamics is shown in figure 5.6.It is shown that

    the long period poles are lying on the real axes and it has two options. The first one isthat this is our situation and this is our aircraft dynamics.The second option is that wedidnt get the aircraft the sufficient elevator signal to force the aircraft to bring out all its

    39

  • dynamics.So it is suggested in the coming test to use a doublet elevator input which isvery good in doing the job.

    Figure 5.6: Estimated Pole map of the Longitudinal dynamics

    5.1.3 PI of Lateral DynamicsFor the linearized lateral equation of motion we have

    pr

    = Apr

    + B[r]

    (5.7)

    In this test we will differentiate all the four states to get their derivatives as it is notavailable to measure them directly.This is also a recall to use higher sampling frequencyin the coming tests to get a good differentiation to the states. After setting the HNN codewith the lateral data and iterate, the state space model was reached as shown in equation5.8.The order of magnitude of the parameters is reasonable with the general lateral statespace model derived in Nelson[9] as shown in equation 5.9

    pr

    =10.4457 0.0015 3.8845 0.59129.4239 6.3545 9.6868 0.119618.6195 0.3073 2.4556 0.62120.0517 1.6458 0.6615 0.0308

    pr

    +

    8.261845.159515.61592.4332

    [rdr

    ](5.8)

    pr

    =

    Yuo

    Ypuo(1 Yruo )

    gcosouo

    L Lp Lr 0N Np Nr 00 1 0 0

    pr

    (5.9)40

  • The estimated lateral dynamic system is fed with the measured aileron data to get theestimated states. Estimated and measured states are shown in figure 5.7.

    Figure 5.7: Lateral States (Measured and estimated).The last line is the aileron signal

    Again a recall that the AOA and side slip sensor must be changed. The Total errorbetween measured and estimated states calculated by equation 5.3 was equal 4.7% and theerror in side slip angle has alone a 42.13% from the total error where error in other threestates is only equal 2.72 %.

    The root locus of the lateral dynamics is shown in figure 5.8. The roots of theconventional aircraft are delivered : the spiral role root, the two imaginary poles of thedutch roll mode and the role pole.

    41

  • Figure 5.8: Estimated Pole Map of the Lateral dynamics

    5.1.4 Test Summary and recommendationOverall the results were appealing with total error equal 6.3% and 4.7% for longitudinaland lateral dynamics perspectively. The total system was successful to estimate the lineardynamics of the aircraft. In each stage suggestions were appearing with the results. Hereis a summary of this cautions to be taken under consideration in the next flight.

    1. A better A/C is recommended because the used one was very old and has difficul-ties while flying which prevent from apply a full doublet signals to the aircraft as it tendsto diverge and moving unstable.

    2. Electric Motor is recommended for constant thrust and also more clean.But for thismagnetic field must be taking under consideration

    3.A Better Design of AOA and Beta sensors is very recommended because the high-est value of error was coming from them.

    4. Central Position for AOA and Beta sensors must be studied because when the fins arein the tip, they are affected with the rolling motion.

    5.It was noticed that the servos have some jumpy signals when no orders are send tothem. This happen around one time each 10 seconds.

    6.A Better GCS Software is recommended for better inspection of the test while it isperformed to be able to assure the test was done in the right way. For example The servossignals should be shown to assure that the doublet input is done. The AOA and side slipsensors data should be shown to assure that they are normal with no ups and downs.

    7. For servo to work: The transmitter sends data to receiver, then from receiver to

    42

  • Arduino then Arduino saves data and also sends it to the servo. In this circuit if a problemoccurred to the Arduino board, The signal will not be able to transfer from transmitter tothe servos and the aircraft then is out of control. So a relay must be added to be able toswitch the signal directly from receiver to the servos if Arduino suddenly stopped working.

    8.For the collected data to be saved the Arduino sends them by wireless Xbee mod-ule to the GCS and they make a restriction on the sampling frequency and if the Xbeestopped working the data will not be able to be sent to the GCS So a data logging SD-Cardis recommended.

    9.A newer PCB will be a newer edition to the data gathering system and it will bebetter for a better sensors arrangement and to be able to put the system in a closed boxwith better wires arrangement and to ensure more safety for the circuit.

    10. For the new aircraft the aerodynamic stability and control derivatives could becalculated with Datcom and compared with the Neural network results.

    5.2 Low Super Trainer RC model

    Figure 5.9: Low Super Trainer RC model

    5.2.1 Modifications for Test 2From Test 1 some suggestions were given to et better results for test 2. The modificationswere done as follow:1- A new RC model aircraft was used for this test called Low super trainer.Specificationsof the aircraft are shown in table 5.2. It has a takeoff weight for about 3.5 kg. In this newmodel we could guarantee that the Y plane is the a symmetric plane so a pure longitudinal

    43

  • Table 5.2: Low Super trainer RC model Specifications

    Wing Span 1650mmWing Area 45sq.dmLength 1250mmFlying Weight 3450gEngine required 2c 0.40 - 0.46 cu inEngine used Brushless motor 46

    motion could be achieved. Also the engine was replaced with an electric motor for constantand a cleaner source of thrust as shown in figure 5.10.

    Figure 5.10: Replacing the engine with an electric motor

    2- The sampling frequency of collecting the data was doubled from 10 Hz to 20 Hz .This increase assure a better smooth data and also better values when differentiating thestates.3- The problem of alpha beta sensors was extremely solved here by the following modifi-cations:a- The fin was replaced with a similar fin but scaled by 0.7 . The new small fin couldguarantee a lower fin inertia and mass which could help in increasing the fin response tothe change in the flow direction. When the fin becomes low in its mass, it becomes moreeasy to rotate it with a low speed flow.b- Not only decreasing the mass will help, but also it is a must to decrease the potentiome-ter friction through using a very low friction encoder.c- A central positioning for the air prob could help to get the right air data but because theaircraft has a pusher motor fixed in the center, the air data sensors were fixed again at thetip of the wing. But to guarantee good results, two sets of air data sensors were fixed oneat the right wing tip and another at the left wing tip. Before the flight it was found that oneof the angle of attack sensors was stopped working so one AOA sensors was only used to

    44

  • measure the angle of attack.d- limiters were added to the fins to make sure that fins will not rotate above 90 degreeand settle at the opposite direction. At last before the test flight, All sensors and controlsurfaces deflections were calibrated and tested before the test flight.

    Figure 5.11: The fin of the old sensor and the smaller one of the new sensor

    Figure 5.12: The black potentiometer and the golden Encoder

    45

  • Figure 5.13: The modified Air data system

    Figure 5.14: The Air data systems setup for both aircrfats

    46

  • Figure 5.15: The Air data systems of both two aircrfats

    Figure 5.16: The two sets of the new Air data system

    The results of the sensors were very appealing and each pair has a very close results.

    47

  • Figure 5.17: The two velocity sensors data during the flight

    Figure 5.18: The two beta sensors data during the flight

    5.2.2 Flight testThe flight was done at about 3:00 pm in Sheikh Zayed flight area zone.The airflow wasquiet and suitable for the test. A failure was occurred in the electric motor and it suddenlystopped working during the flight. The plane was fall down and the engine mount wasbroken and one of air data sets was taken away from its place.But a flight for about 30seconds was successfully recorded, a doublet input for the elevator was achieved anda roughly pure longitudinal motion was done. In the coming sections longitudinal andlateral dynamics will be discussed.

    5.2.3 Longitudinal Dynamics IdentificationTo activate both the short and long period dynamics it is recommended to use 3211input,see [6]. In this test a doublet input was applied with various frequencies and it was

    48

  • helping in activating the dynamics even it is recommended to enhance it in the comingflights. In the input vector the throttle was added even it doesnt changed and this ehnaced

    Figure 5.19: Doublet elevator input

    the results.It may be as a result of the initial value the throttle helps the states to start withand maintain at a certain value till changing with elevator or other states. The results showsthat the error was about 1.47% and the results of the alpha sensor was accepted not likethe results of test 1. Using a sampling frequency of 20 Hz helped also in differentiating thestates. Through the test, It was accepted to use u not using ax. Also using not using az .

    uq

    = Auq

    + B[elev elev

    ](5.10)

    49

  • Figure 5.20: Measured and Estimated Longitudinal States

    For the poles, The results showed both the imaginary short and long period poles.Theorder of magnitude of A matrix was in good match with Nelson [9].

    uq

    =1.0422 76.9002 0.1338 9.78700.1386 15.8909 1 0.01064.1345 216.1426 21.4856 0.00270.0077 0.0102 1.1431 0.0126

    uq

    +

    47.8624 0.22622.3533 0.0215240.0769 1.06330.0446 0.0034

    [elevthrotle

    ](5.11)

    Figure 5.21: Longitudinal Pole Map

    5.2.4 Lateral Dynamics IdentificationIt was not able to get a pure lateral and directional motion from the flight with doubletaileron or rudder as the engine was cutoff before the test and the only achievable control

    50

  • surface deflection was the elevator. So we cannot make a final desision about the lateralidentification.However by testing the data it get some accepted results but the error cannotbe a rule here even it is lower than the first test(Error=4% and for test one it was 4.7% ) aswhen the yaw angle increase than 180 degree, the data has a fault jump from 180 to -180and this increases the error.The data measured and estimated and root locus results aregiven below.The order of dynamic matrix A is very close to that is given in Nelson [9].

    Figure 5.22: Lateral States , Last line for Aileron

    pr

    =44.7421 2.4141 2.0447 3.5779633.3455 88.9262 94.5293 0.0327440.4360 6.4201 24.9187 0.18930.0200 0.8450 0.2985 0.0426

    pr

    +0.0130410.8903310.0469

    5.8755

    [ail

    ](5.12)

    51

  • Figure 5.23: Lateral Pole Map

    52

  • Chapter 6: Conclusion and FutureWorkHopfield neural network combined with the designed framework delivered an appallingresults in the problem of oine PI. With the low Arduino mega processing power andRAM compared with other used microcontroller for PI purposes, It had an acceptedperformance and durability in the project. The purpose of the was to use low cost fordecreasing the funds but for a first trial of PI and to make just a proof of concept. HigherMicrocontroller is planned to be used for the second iteration.The need for real flightto know the dynamics of an aircraft seems to be a mandatory object in autopilot designand we cannot fully depend on Datcom or Roskam to get the dynamics of a small UAV.No remarkable work can be done by only one person, Team work and accumulation ofKnowledge is the way for successful and beneficial work.

    6.1 The Future suggested work

    6.1.1 Parameter IdentificationPI work may be a second iteration on Oine PI or Online parameter identification andhere are suggested disciplines

    6.1.1.1 Hardware

    1- Using Arduino 2- Using MyRio(Labview) 3- Build an IMU

    6.1.1.2 Software

    A- Monitoring Software Try to increase its speed. You may use Visual Basic,Lab view orSimulink. B- PI software You may iterate again for Neural network or try to use anothermethod may genetic alogrithm or frequency response techniques.You may use a newmethod for Oine or using NN for online.

    6.1.2 AutopilotUsing the calculated state space models, you may now transfer to the new stage ofAutopilot: Stability control. Stability control was introduced in the introduction chapterbefore. You may try to work for Altitude hold then towards the heading autopilot andfinish your work by a horizontal loop mission.

    53

  • Figure 6.1: Suggested Work

    54

  • References

    [1] DiyDrones. Diydrnes,http://diydrones.com/.

    [2] electronics, R. Ram,http://ram-e-shop.com/oscmax/catalog/.

    [3] futureelectronics egypt. futureelectronics egypt,http://www.fut-electronics.com/.

    [4] George Zogopoulos Papaliakos, Graziano Capelli, J. L. J. Basic air data web-site,http://www.basicairdata.eu/.

    [5] Gu, Y. Design and flight testing actuator failure accommodation controllers on WVUYF-22 research UAVs. PhD thesis, College of Engineering and Mineral Resources atWest Virginia University, Morgantown, West Virginia, 2004.

    [6] J.R. Raol, G. G., and Singh, J. Modelling and Parameter Estimation of DynamicSystems, 1st ed. The Institution of Engineering and Technology, 2004.

    [7] J.R. Raol, H. Neural network architectures for parameter estimation of dynamicalsystems. IEE Proceedings 143, 19960338 (July 1996), 386394.

    [8] McGrail, A. K. Onboard parameter identification for a small uav. Msc. thesis,College of Engineering and Mineral Resources at West Virginia University, 2012.

    [9] Nelson, R. C. Flight Stability and Automatic Control, 1st ed. McGraw-Hil BookCompany, 1989.

    [10] Seanor, B. A. Flight Testing of a Remotely Piloted Vehicle for Aircraft ParameterEstimation Purposes. PhD thesis, College of Engineering and Mineral Resources atWest Virginia University, Morgantown, West Virginia, 2002.

    [11] Sparkfun. Sparkfunwebsite, https://www.sparkfun.com/.

    [12] Team, A. O. http://https://code.google.com/p/ardu-imu/wiki/introductionpage.

    55

  • Appendix A: Hopfield neural networkmatlab code

    In t h i s code :1 choose t h e d a t a f i l e t o use2 i n i t i a t e wi th a A, B i n i t i a l3 choose ro t o va ry f o r s igmoid fn4 i n t r d o u c e t h e d a t a and s t a t e s6 choose lamda f o r s igmoid fn7 Get t h e w e i g h t i n g m a t r i x and t h e b i a s v e c t o r8 i t e r a t e t o g e t new A, B m a t r i x f o r each ro9 g e t t h e r e s p o n s e f o r each ro10 choose t h e l o w e s t e r r o r ro11 a g a i n g e t i t s A, B12 i t e r a t e wi th t h e new A, BHin t you may s t o p t h e program s e v e r a l t i m e s and f o r t h a tr e p l a e t h e l a s t g i v e n A, B == AA, BB wi th A, B i n i t a lHere i s t h e f u l l code :

    c l o s e a l l ;c l e a r a l l ; c l c ;l o a d t e s t 2 v b 2 . mat

    %% TEst Regimes t a r t =671+3.720+2.520;%805s t o p =671+200; %906

    %% d t and t imed t=q . t ime ( s t a r t +1)q . t ime ( s t a r t ) ;s ample s=s top s t a r t +1;t =q . t ime ( s t a r t : s t o p ) ;i t e r =1;s t e p p =1;d t t =1 ;

    %% N eu ra l ne twork P a r a m e t e r sr 1 = [ 2 0 0 : 5 0 . 1 : 2 0 0 ] ;r 2 =[ . 1 : . 0 3 1 3 : . 1 ] ;r 3 =[4: 1 .40123 : 4 ] ;r 4 =[400000: 10000 .21 : 4 0 0 0 0 0 ] ;r 5 =[ . 01 : . 0 0 3 1 3 : . 0 1 ] ;k a t =[ r 1 , r 2 , r 3 ] ;

    %% C o n t r o l S u r f a c e se l e v s = e l e v s e r v o . d a t a p i / 1 8 0 ;a i l s = a i l s e r v o . d a t a p i / 1 8 0 ;t h r o t l e s = t h r o t l e s e r v o . d a t a +10 ;r d r s = r d r s e r v o . d a t a p i / 1 8 0 ;

    56

  • [ e l ev , a i l , t h r o t l e , r d r ] =c o n t s u r f a c e s ( e l e v s , a i l s , t h r o t l e s , r d r s ) ;

    e l e v=e l e v ( s t a r t : s t o p )+1 p i / 1 8 0 ;a i l = a i l ( s t a r t : s t o p ) ;t h r o t l e = t h r o t l e ( s t a r t : s t o p ) ;r d r = r d r ( s t a r t : s t o p ) ;

    %% I n i t i a l c o n d i t i o n s

    AA=[

    0 0 .1353 1 .7769 9.80 9.8555 1 .2098 0.02540 184.2615 9.7172 0.17850 0.0133 1 .1742 0 . 0 6 1 3 ] ;BB=[

    10 .83701.7455166 .11250 .0192] ;

    % AA=[ 0 .0858 0 .2892 0.0004 9.7233% 0.1890 4.8213 21 .2426 0.0004% 0.0335 0.1529 4.6181 0 .0201% 0.0091 0.0076 0 .9953 0.0074 ] ;% BB=[ 15 .6149% 0.0070% 6.5863% 1.3036 ] ;AA= [

    0 .1603 4 .7492 0 .1893 9.18540.0236 11.4540 1 .6679 0.01700.3632 51.8025 12.2717 1.01400.0073 0.0221 1 .0347 0.0267

    ] ;BB= [

    4 .0488 03.6889 0110 .0381 00 .0087 0] ;

    AA=[1.0422 76.9002 0.1338 9.7870

    57

  • 0.1386 15.8909 1 0.01064 .1345 216.1426 21.4856 0.00270.0077 0.0102 1 .1431 0.0126

    ] ;

    BB=[47 .8624 0 .22622.3533 0 .0215

    240 .0769 1.06330.0446 0.0034

    ] ;%% s i z e s & i n i t i a l c o n d i t i o n s[ ma , na ]= s i z e (AA) ;[mb , nb ]= s i z e (BB ) ;

    %% STATESd a t a ( : , 1 ) = v e l d o t . d a t a ( s t a r t : s t o p ) ;

    % d a t a ( : , 1 ) = axk . d a t a ( s t a r t : s t o p ) ;d a t a ( : , 2 ) = a l p h a d o t . d a t a ( s t a r t : s t o p ) ;d a t a ( : , 3 ) = qdo t . d a t a ( s t a r t : s t o p ) ;d a t a ( : , 4 ) = pc hd o t . d a t a ( s t a r t : s t o p ) ;

    % d a t a ( : , 4 ) = qq . cos ( R o l l . d a t a ( s t a r t : s t o p ) p i / 1 8 0 )

    % d a t a ( : , 4 ) = qk . d a t a ( s t a r t : s t o p ) ;d a t a ( : , 5 ) = vk . d a t a ( s t a r t : s t o p ) + . 5 ;d a t a ( : , 6 ) = a l p h a k . d a t a ( s t a r t : s t o p ) ;

    d a t a ( : , 7 ) = qk . d a t a ( s t a r t : s t o p ) ;d a t a ( : , 8 ) = pchk . d a t a ( s t a r t : s t o p ) ;d a t a ( : , 9 ) = e l e v ;d a t a ( : , 1 0 ) = t h r o t l e ;

    % d a t a ( : , 1 1 ) = a i l s e r v o . d a t a ( s t a r t : s t o p ) ;nos =4; % No Of S t a t e su=[ e l e v t h r o t l e ] ;% u= [ e l e v ] ;n =2; % no of i n p u t sn o i =2;% no of i n p u t sE l a s t =10100 ;x i n t =[ d a t a ( 1 , 5 ) ; d a t a ( 1 , 6 ) ; d a t a ( 1 , 7 ) ; d a t a ( 1 , 8 ) ] ;

    %% The NEURAL NETWORK method HOPFIELD G e t t i n g W, b

    58

  • f o r i =1: nosf o r j =1: nos

    alphaw ( i , j )=sum ( d a t a ( : , nos+ i ) . d a t a ( : , nos+ j ) ) ;end

    endf o r i =1: nos

    f o r j =1: n o ibetaw ( i , j )=sum ( d a t a ( : , nos+ i ) . d a t a ( : , 2 nos+ j ) ) ;

    endendf o r i =1: n o i

    f o r j =1: n o it h e t a w ( i , j )=sum ( d a t a ( : , 2 nos+ i ) . d a t a ( : , 2 nos+ j ) ) ;

    endendW1=z e r o s ( nos nos , nos nos ) ;W2=z e r o s ( nos nos , n o i nos ) ;W4=z e r o s ( nos noi , nos n o i ) ;f o r i =1: nos

    W1( ( i 1) nos +1: i nos , ( i 1) nos +1: i nos )= alphaw ;endf o r i =1: nos

    W4( ( i 1) n o i +1: i noi , ( i 1) n o i +1: i n o i )= t h e t a w ;endf o r i =1: nos

    W2( ( i 1) nos +1: i nos , ( i 1) n o i +1: i n o i )= betaw ;end

    W=[W1 W2W2 W4] ; % Weigh t ing Mat r i x

    f o r j =1: nosf o r i =1: nos

    b1 ( i , j )=sum ( d a t a ( : , j ) . d a t a ( : , nos+ i ) ) ;end

    endf o r j =1: nos

    f o r i =1: n o ib2 ( i , j )=sum ( d a t a ( : , j ) . d a t a ( : , 2 nos+ i ) ) ;

    endend

    [ mb1 , nb1 ]= s i z e ( b1 ) ;[ mb2 , nb2 ]= s i z e ( b2 ) ;b= [ r e s h a p e ( b1 , mb1nb1 , 1 ) ; r e s h a p e ( b2 , mb2nb2 , 1 ) ] ;

    % THE BIAS MATRIX %%%%%

    59

  • %%

    BETA=[ r e s h a p e (AA , mana , 1 ) ; r e s h a p e (BB , mbnb , 1 ) ] ;B e t a r i g h t =[ r e s h a p e (AA , mana , 1 ) ; r e s h a p e (BB , mbnb , 1 ) ] ;Beta new= B e t a r i g h t ;b e t a d o t =z e r o s ( 1 , 2 4 ) ;Q=z e r o s ( 1 , 2 4 ) ;U=z e r o s ( 1 , 2 4 ) ;

    lmda ( 1 : 2 4 )=1 0 5 ;% lmda (1 :16)=10 6 ;

    lmda ( 1 3 : 1 6 )=1 0 8 ;lmda (3 )=10 6 ;lmda (4 )=10 9 ;

    lmda (8 )=10 8 ;lmda (12)=10 8 ;

    lmda (7 )=10 86 ;% lmda (9 )=10 6 ;% lmda (11)=10 6 ;% lmda (18)=10 6 ;% lmda (22)=10 6 ;% lmda (21)=10 6 ;% lmda (5 )=10 6 ;% lmda (10)=10 6 ;% lmda (20)=10 6 ;% lmda (24)=10 6 ;

    % lmda (10)=10 4 ;f o r LoL=1:520000000

    % f o r wew= [ 1 , 2 , 5 , 6 , 7 , 9 , 1 0 , 1 1 , 1 7 , 1 8 , 1 9 ]% f o r wew=[1 : 1 6 , 1 7 , 1 9 , 2 1 , 2 3 ]

    f o r wew= [ 1 : 2 4 ]f o r k i t =1: l e n g t h ( k a t )

    ro= k a t ( k i t ) ;

    B e t a r i g h t =[ r e s h a p e (AA , mana , 1 ) ; r e s h a p e (BB , mbnb , 1 ) ] ;B e t a o l d= B e t a r i g h t ;

    BBU= B e t a r i g h t ;

    60

  • BBYT=0 B e t a r i g h t ;% B e t a r i g h t ( 2 , 3 ) = 1 ;f i g u r e ( 9 0 9 0 )

    f o r i =1: i t e r

    f o r s h o f=wew

    roo= ro ;U( s h o f )=W( shof , : ) B e t a o l d+b ( s h o f ) ;Q( s h o f )= ( lmda ( s h o f ) ( roo 2 B e t a o l d ( s h o f ) 2 ) ) / ( 2 roo) ; % d e r i v a t i v e de l a s igmoid

    % Q=( lmda . ( ro 2 ones ( nos nos+n o i nos ,1) B e t a o l d . 2 ) ) / ( 2 ro ) ;

    b e t a d o t ( s h o f )=U( s h o f )Q( s h o f ) ;Beta new ( s h o f )= B e t a o l d ( s h o f )+ ( b e t a d o t ( s h o f ) d t t ) ;B e t a o l d ( s h o f )= Beta new ( s h o f ) ;

    end

    Beta=Beta new ;A= r e s h a p e ( Beta ( 1 : nos nos ) , nos , nos ) ;B= r e s h a p e ( Beta ( nos nos +1: l e n g t h ( Beta ) ) , n o i , nos ) ;

    Remm = rem ( i , s t e p p ) ;i f Remm==0

    BBU=[BBU, r e s h a p e ( Beta , nos nos+n o i nos , 1 ) ] ;BBYT=[BBYT , r e s h a p e ( b e t a d o t , nos nos+n o i nos , 1 ) ] ;

    C=[1 0 0 0 ; 0 1 0 0 ; 0 0 1 0 ; 0 0 0 1 ] ;D=[0 0 ; 0 0 ; 0 0 ; 0 0 ] ;

    t = e l e v s e r v o . t ime ( s t a r t : s t o p ) e l e v s e r v o . t ime ( s t a r t ) ;

    x0 = x i n t ; %i n i t i a l c o n d i t i o n o f sys tem s t a t e s[ y ] = l s i m (A, B , C , D, u , t , x0 ) ; %do t h e s i m u l a t i o n

    f o r kuy =1:4u i=abs ( d a t a ( : , kuy+nos ) y ( : , kuy ) ) ;

    y t t =sum ( u i ) ;e r r o r ( kuy )= ( ( y t t / sum ( abs ( d a t a ( : , kuy+nos ) ) ) ) 1 0 0 ) / sample s ;

    endE=sum ( e r r o r ) ;

    % e r r o r (5 )=E ;p l o t ( i , E )

    61

  • ho ld on

    end

    endE r r o r ( k i t )=E ;

    end%%%%%%%%%%%%%%%%%%%]%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%

    wewi f E l a s t > min ( E r r o r )

    E l a s t =min ( E r r o r ) ;t o k t o k= f i n d ( E r r o r==min ( E r r o r ) ) ;ro=k a t ( t o k t o k ( 1 ) )[ min ( E r r o r ) wew ]

    B e t a r i g h t =[ r e s h a p e (AA , mana , 1 ) ; r e s h a p e (BB , mbnb , 1 ) ] ;B e t a o l d= B e t a r i g h t ;BBU= B e t a r i g h t ;BBYT=0 B e t a r i g h t ;% B e t a r i g h t ( 2 , 3 ) = 1 ;f i g u r e ( 9 0 9 0 )

    s e t ( gcf , u n i t s , no rma l i zed , o u t e r p o s i t i o n , [ . 4 . 4 . 4 . 6 ] )

    f o r i =1: i t e r

    f o r s h o f=wew

    roo= ro ;U( s h o f )=W( shof , : ) B e t a o l d+b ( s h o f ) ;Q( s h o f )= ( lmda ( s h o f ) ( roo 2 B e t a o l d ( s h o f ) 2 ) ) / ( 2 roo

    ) ; % d e r i v a t i v e de l a s igmoid% Q=( lmda . ( ro 2 abs ( B e t a r i g h t . 2 ) B e t a o l d . 2 ) ) / ( 2 ro ) ;

    % Q=( lmda . ( ro 2 ones ( nos nos+n o i nos ,1) B e t a o l d . 2 ) ) / ( 2 ro ) ;

    b e t a d o t ( s h o f )=U( s h o f )Q( s h o f ) ;Beta new ( s h o f )= B e t a o l d ( s h o f )+ ( b e t a d o t ( s h o f ) d t t ) ;

    B e t a o l d ( s h o f )= Beta new ( s h o f ) ;

    62

  • end

    Beta=Beta new ;A= r e s h a p e ( Beta ( 1 : nos nos ) , nos , nos ) ;

    B= r e s h a p e ( Beta ( nos nos +1: l e n g t h ( Beta ) ) , n o i , nos ) ;

    Remm = rem ( i , s t e p p ) ;i f Remm==0

    BBU=[BBU, r e s h a p e ( Beta , nos nos+n o i nos , 1 ) ] ;BBYT=[BBYT , r e s h a p e ( b e t a d o t , nos nos+n o i nos , 1 ) ] ;

    C=[1 0 0 0 ; 0 1 0 0 ; 0 0 1 0 ; 0 0 0 1 ] ;D=[0 0 ; 0 0 ; 0 0 ; 0 0 ] ;

    t = e l e v s e r v o . t ime ( s t a r t : s t o p ) e l e v s e r v o . t ime ( s t a r t ) ;

    x0 = x i n t ; %i n i t i a l c o n d i t i o n o f sys tem s t a t e s[ y ] = l s i m (A,


Recommended