aero3560a1

Upload: nicholas-giannelis

Post on 07-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 AERO3560A1

    1/16

    AERO3560

    FLIGHT MECHANICS 1TUTORIAL ASSIGNMENT 1

    NICHOLAS GIANNELIS

    308150856Monday 22nd August 2011

  • 8/4/2019 AERO3560A1

    2/16

    2

    Contents

    Page No.

    1. Question 1 31.1 Part A 3

    1.2 Part B 3

    2. Question 2 4

    3. Question 3 5

    3.1 Part A 5

    3.2 Part B 6

    3.3 Part C 6

    4. Question 4 7

    4.1 Part A 7

    4.2 Part B 8

    5. Appendix A-Matlab Script to Question 3 11

    5.1 Part A 11

    5.2 Part B 12

    6. Appendix B-Matlab Script to Question 4 13

    6.1 Quaternion Integration 13

    6.2 Euler Angle Integration 14

  • 8/4/2019 AERO3560A1

    3/16

    3

    1. Question 1

    1.1 Part A

    J = A2500 EIn order to convert from body frame to LVLH we require the transformation matrix H.

    H = H#{H${H%{{H#{I# = A1 0 00 cos I# sinI#0 s i n I# cosI#E

    H${I$ = AcosI$ 0 s i n I$0 1 0sinI$ 0 cos I$ E

    H%{I% = A cosI% sinI% 0sinI% cosI% 00 0 1EAs we only have a rolling body rate we can expressI#as a function of time, explicitly

    I# = 25 = 5

    36

    The transformation matrix from the LVLH frame to the body frame thus becomes:

    H = H# 536 F H${0H%{0 =

    1 0 00 cos 536 5360 s i n 536 cos 536

    However, we require the transformation matrix from body to LVLH; this is merely the transpose of

    the above:

    H =1 0 00 c o s 536 sin 5360 s i n 536 cos 536

    1.2 Part BIn order to allow for simultaneous pitching the governing equations incorporate highly coupled

    nonlinear terms. In order to determine the aircraft attitude one would have to calculate the Euler

    angle rates of change and integrate these rates over the time of simulation. The integration

    procedure may involve simple Euler integration, incrementing the original value of each Euler angle

    by the product of the time differential and the rate of change.

  • 8/4/2019 AERO3560A1

    4/16

    4

    2. Question 2

    In order to establish a transformation matrix from the Sydney reference frame (=151, = -34) to

    the Saskatoon reference frame (=-106.66, = 52.13) we consider three separate rotations. The firstof which is a -124 rotation about the y-axis (easterly direction) to bring the system to the North

    Pole. The transformation matrix is as below:

    H${124 = Acos124 0 sin1240 1 0sin 124 0 cos124 E = A0.559 0 0.8290 1 00.829 0 0.559E

    The North Pole acts as a singularity on the Earths surface with respect to the North East Down

    reference frame, as such we may then make a rotation about the x-axis of -257.66 to bring the

    system to the same longitude as Saskatoon as below:

    H#{257 = A1 0 00 cos 257.66 sin 257.660 sin257.66 cos257.66E = A1 0 00 0.214 0.9770 0.977 0.214EThe system is then brought to the correct latitude as Saskatoon by considering a 37.87 rotation

    about the y-axis:

    H${37.87 = Acos37.87 0 sin37.870 1 0sin37.87 0 cos37.87 E = A0.789 0 0.6140 1 00.614 0 0.789 E

    The transformation matrix relating the Sydney and Saskatoon reference frame is thus a product of

    the aforementioned rotation matrices, explicitly:

    H = H${124 H#{257 H${37.87The matrix multiplication is performed in Matlab, yielding:

    H = A0.5502 0.8099 0.20340.5997 0.2137 0.77120.5811 0.5463 0.6033EIn order to best describe the relative orientation of a person standing at Saskatoon with respect to

    Sydney reference frame we consider the Saskatoon up vector. We take the Inverse of the Htransformation matrix and multiply this by a unit up vector in the Saskatoon frame, yielding:H# = H = A0.5502 0.5997 0.58110.8099 0.2137 0.54630.2034 0.7712 0.6033 E

    A0.5502 0.5997 0.58110.8099 0.2137 0.54630.2034 0.7712 0.6033 E A001E = A

    0.54630.58110.6033EIn the Sydney reference frame. The Saskatoon up vector is illustrated in dark blue below:

  • 8/4/2019 AERO3560A1

    5/16

    5

    -0.5

    0

    0.5

    1

    -0.1

    00.1

    0.2

    0.3

    0.40.5

    0.6

    0.7

    0.8

    0.9

    -1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    North

    Sydney North-East-Down

    East

    Down

    Saskatoon Up Vector

    North

    East

    Down

    3. Question 3

    3.1Part AThe Matlab script written to convert Euler Angles to Quaternions is provided in the appendix. The

    table of provided Euler Angles is supplied below, followed by the corresponding Quaternions output

    from the function file E2Q.

    EulerAngles

    Case

    1 0 0 90

    2 0 -90 0

    3 -90 0 0

    4 0 90 -90

    5 45 45 456 45 -30 100

    7 -150 -10 -120

    8 97 -103 43

    Quaternions

    Case " # $ %1 0.7071 0 0 0.7071

    2 0.7071 0 -0.7071 0

    3 0.7071 -0.7071 0 0

    4 0.5000 0.5000 0.5000 -0.50005 0.8446 0.1913 0.4619 0.1913

  • 8/4/2019 AERO3560A1

    6/16

    6

    6 0.4977 0.4208 0.1295 0.7473

    7 0.0560 -0.5007 0.8221 -0.2654

    8 0.1690 0.6239 -0.3116 0.6965

    3.2Part BThe Matlab script to convert from Quaternions to Euler Angles is provided in the appendix. The table

    below provides the Quaternions, their conversion to Euler angles and a conversion back to

    Quaternions using the E2Q function to confirm its functionality.

    Quaternions

    Case " # $ %1 0.5862 -0.6941 0.1349 0.3954

    2 0.4822 -0.8698 0.0914 -0.0507

    Euler AnglesCase

    1 -90.0046 45.0007 23.0034

    2 -121.9938 -0.0030 -11.9992

    E2Q(ans)

    Case " # $ %1 0.5862 -0.6941 0.1349 0.3954

    2 0.4822 -0.8698 0.0914 -0.0507

    As the conversion confirms the precise input arguments we may ascertain the codes function

    correctly.

    3.3Part C>> Q2E(ans)

    Case

    1 0 0 90.0000

    2 0 -90.0000 0

    3 -90.0000 0 0

    4 0 90.0000 -90.00005 45.0000 45.0000 45.0000

    6 45.0000 -30.0000 100.0000

    7 -150.0000 -10.0000 -120.0000

    8 -83.0000 -77.0000 -137.0000

    In employing the inversion quaternion function to convert back to Euler angles it is evident that all

    bar the last case are identical to the input arguments. Although the final arguments may appear to

    differ when input into the trigonometric functions governing the quaternion and Euler angle

    conversion equations they yield identical results. As such the script cannot discern betweentrigonometrically identical arguments.

  • 8/4/2019 AERO3560A1

    7/16

    7

    0 2 4 6 8 10 12 14 16 18 20

    -200

    -150

    -100

    -50

    0

    50

    100

    150

    200Euler Angles Derived from Quaternion Integration

    Time(s)

    g

    (

    g)

    Phi

    Theta

    Psi

    0 2 4 6 8 10 12 14 16 18 20

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1Quaternions Derived from Quaternion Integration

    Time(s)

    Quaternions(rad)

    e0

    e1

    e2

    e3

    0 2 4 6 8 10 12 14 16 18 200

    50

    100

    150

    200

    250

    300Euler Angles Derived Directly from Euler Rates

    Time(s)

    EulerAngles(deg)

    Phi

    Theta

    Psi

    0 2 4 6 8 10 12 14 16 18 20-0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Quaternions Derived Directly from Euler Rates

    Time(s)

    Quaternions(rad)

    e0

    e1

    e2

    e3

    4. Question 4

    4.1Part APresented below are the output plots of Euler angle and Quaternion variation with time, as derivedfrom the quat_int and euler_int functions over a twenty second time interval with yaw rate of 5.6

    seconds (Student Number 308150856).

    Quaternion Integration with normalising correction

    Euler angle Direct Integration

  • 8/4/2019 AERO3560A1

    8/16

    8

    0 2 4 6 8 10 12 14 16 18 20-200

    -150

    -100

    -50

    0

    50

    100

    150

    200

    250

    300Euler Angles Derived from Quaternion Integration

    Time(s)

    EulerAngles(d

    eg)

    Phi

    Theta

    Psi

    0 2 4 6 8 10 12 14 16 18 20-0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1Quaternions Derived from Quaternion Integration

    Time(s)

    Quaternions(ra

    d)

    e0

    e1

    e2

    e3

    Discussion of difference in results

    As evident when comparing the prior Euler angle and Quaternion integration not a great deal of

    discrepancy can be seen, bar a distinct jump in the Quaternion integration Euler Angle plot. The

    Quaternion angles are bounded between the range 180 and thus the apparent discontinuity is

    simply a switch from 180 to -180, the same point. The Euler angles derived from the Euler rate

    integration however are unbounded and continuous.

    In order to better observe any difference in results the plots for Euler rate and Quaternion rate

    integration are overlayed below with dashed segments representing Euler rate integration and solid

    lines Quaternion integration. Small differences are evident as the time of simulation increase, with

    the curves appearing to diverge. This divergence is an expected characteristic as the direct

    integration of Euler rates accumulates the error resulting from the linear segmented Euler

    integration method. The Quaternion integration however employs a normalising factor in order to

    mitigate this error at each time step. As such as the length of simulation is increased we would

    expect a greater divergence of the two curves. Further the timestep of 0.1 s is quite large relative to

    the rotation rates and as such has quite a bearing on the results. The Quaternions split this time step

    across four variables rather than three, again mitigating error.

    4.2Part BBy imposing a zero roll rate on the system it necessarily assures that the aircraft will exhibit a vertical

    nose up attitude, the point of singularity regarding Euler angle attitude representation. Distinct

    discrepancies are evident between the quaternion and Euler rate integration methods with zero roll

    rate. It is evident that at the point of singularity (approximately 15 seconds) theta attains a

    maximum value regarding quaternion integration and phi and psi attain their equivalent

    trigonometric values. The Euler rate integration plot however permits the unbounded increase of

    theta.

  • 8/4/2019 AERO3560A1

    9/16

    9

    0 2 4 6 8 10 12 14 16 18 20-100

    -50

    0

    50

    100

    150

    200Euler Angles Derived from Quaternion Integration

    Time(s)

    EulerAngles(deg)

    Phi

    Theta

    Psi

    0 2 4 6 8 10 12 14 16 18 20-0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Quaternions Derived from Quaternion Integration

    Time(s)

    Quaternions(rad)

    e0

    e1

    e2

    e3

    0 2 4 6 8 10 12 14 16 18 20-0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Quaternions Derived Directly from Euler Rates

    Time(s)

    Quaternions(rad)

    e0

    e1

    e2

    e3

    0 2 4 6 8 10 12 14 16 18 200

    20

    40

    60

    80

    100

    120

    140Euler Angles Derived Directly from Euler Rates

    Time(s)

    EulerAngles(deg)

    Phi

    Theta

    Psi

    r = 0 deg/s

  • 8/4/2019 AERO3560A1

    10/16

    10

    0 2 4 6 8 10 12 14 16 18 20-100

    -50

    0

    50

    100

    150

    200Euler Angles Derived from Quaternion Integration

    Time(s)

    EulerAng

    les(deg)

    Phi

    Theta

    Psi

    0 2 4 6 8 10 12 14 16 18 20-0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Quaternions Derived from Quaternion Integration

    Time(s)

    Quaternions(rad)

    e0

    e1

    e2

    e3

    0 2 4 6 8 10 12 14 16 18 200

    200

    400

    600

    800

    1000

    1200

    1400Euler Angles Derived Directly from Euler Rates

    Time(s)

    Phi

    Theta

    Psi

    0 2 4 6 8 10 12 14 16 18 20-0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Quaternions Derived Directly from Euler Rates

    Time(s)

    Quaternions(rad)

    e0

    e1

    e2

    e3

    As another means of comparison we consider the system experiencing a near zero roll rate. At the

    singularity point it is evident the Euler rate integration yields nonsensical results, indicating an

    increase in phi and psi on the order of 1200%. The Quaternion integration procedure remains well

    behaved at this point of singularity. The Quaternion plots accentuate this interpretation, as we see

    kinks in the Quaternion plot at the singularity point whereas the Quaternion rate integration

    maintains a smooth continuous curve.

  • 8/4/2019 AERO3560A1

    11/16

    11

    5. Appendix A-Matlab Script Q3

    5.1 Part A-Euler Angle to Quaternions

    function [ Quaternions ] = E2Q( EulerAngles )%Function file to convert Euler angles to Quaternions% Each set of Euler angles is entered as a row vector% EulerAngles = [phi1 theta1 psi1;phi2 theta2 psi2;etc]% Quaternions are output in sets of row vectors corresponding to% the relevant Euler angle row vector% Quaternions = [e01 e11 e21 e31;e02 e12 e22 e32;etc]

    %%%Convert Euler angles to half angles in radianseuler = 0.5*EulerAngles*pi/180;

    %%%Convert Euler angle to Quaternion components through relevant

    % equations (Lecture Notes Week 2 Pg 37a)e0 = cos(euler(:,3)).*cos(euler(:,2)).*sin(euler(:,1))-sin(euler(:,3))...

    .*sin(euler(:,2)).*cos(euler(:,1));

    e1 =cos(euler(:,3)).*cos(euler(:,2)).*cos(euler(:,1))+sin(euler(:,3))...

    .*sin(euler(:,2)).*sin(euler(:,1));

    e2 =cos(euler(:,3)).*sin(euler(:,2)).*cos(euler(:,1))+sin(euler(:,3))...

    .*cos(euler(:,2)).*sin(euler(:,1));

    e3 = -cos(euler(:,3)).*sin(euler(:,2)).*sin(euler(:,1))+sin(euler(:,3))...

    .*cos(euler(:,2)).*cos(euler(:,1));

    %%%Check root sum square of quaternion components to ensure%%%equations have been input in correct formatmusquared = e0.^2+e1.^2+e2.^2+e3.^2;

    if musquared > 2fprintf('Calculation Error-Root Sum square too large\n');

    end

    %%%Output Quaternion MatrixQuaternions = [e0 e1 e2 e3];

    end

    M-file to call Euler angle conversion

    clcclear allclose allEulerAngles = [0 0 90;0 -90 0;-90 0 0;0 90 -90; 45 45 45;45 -30

    100;-150 -10 -120;97 -103 43]E2Q(EulerAngles)

  • 8/4/2019 AERO3560A1

    12/16

    12

    5.2 Part B-Quaternions to Euler Anglesfunction [ EulerAngles ] = Q2E( quat )%Function file to convert Quaternions to Euler angles% Each set of Quaternions is entered as a row vector% quat = [e01 e11 e21 e31;e02 e12 e22 e32;etc]

    % Euler Angles are output in sets of row vectors corresponding to% the relevant Quaternion row vector% EulerAngles = [phi1 theta1 psi1;phi2 theta2 psi2;etc]

    %%%Convert Quaternions to Euler Angles through relevant equations% (Lecture Notes Week 2 Pg 37)phi =atan2((quat(:,3).*quat(:,4)+quat(:,1).*quat(:,2)),(quat(:,1)...

    .^2+quat(:,4).^2-0.5));

    theta = atan2((quat(:,1).*quat(:,3)-quat(:,2).*quat(:,4)),((quat(:,1)...

    .^2+quat(:,2).^2-0.5).^2+(quat(:,2).*quat(:,3)+quat(:,1).*quat(:,4)).^2).^0.5);

    psi =atan2((quat(:,2).*quat(:,3)+quat(:,1).*quat(:,4)),(quat(:,1)...

    .^2+quat(:,2).^2-0.5));

    %%%Output Euler Angles in degreesEulerAngles = [phi theta psi]*180/pi;

    end

    M-file to call Quaternion conversion

    clcclear allclose allquat = [0.5862 -0.6941 0.1349 0.3954;0.4822 -0.8698 0.0914 -0.0507]Q2E(quat)

  • 8/4/2019 AERO3560A1

    13/16

    13

    6. Appendix B-Matlab Script Q4

    6.1 Quaternion Integration

    function [ euler,quat ] = quat_int( initial_euler, body_rates )%Function file integrating Quaternion rates to determine aircraft attitude% Initial conditions are input as below% initial_euler = [phi theta psi]-initial Euler angles% body_rates = [p q r]-initial rotation rates about body axis

    % Both Euler angles and Quaternions are output as matricies with a unit% timestep increase from row to row.% Plots are output for both Quaternion and Euler angle variation with% time

    %%%Initialise Euler angles vector for initial valuesphi = initial_euler(1);

    theta = initial_euler(2);

    psi = initial_euler(3);

    euler = [phi theta psi];

    %%%Convert Euler angles to Quaternions for Quaternion Integration, take% transpose of vector for subsequent calculations such that values% increasing with timestep are stored as new columns in the Quaternion% (quat) matrixquat = E2Q(euler)';

    %%%Initialise body rotation rates in rad/secp = body_rates(1)*pi/180;

    q = body_rates(2)*pi/180;

    r = body_rates(3)*pi/180;

    %%%Initialise Time/Step Variablestime = 20; %Duration of simulation

    dt = 0.1; %Time step

    n = time/dt; %Number of iterations

    %%%Input equation for Quaternion rates calculation as per Lecture Notes% Week 2 Pg 37.quat_dot(:,:) = 0.5*[-quat(2,:) -quat(3,:) -quat(4,:);...

    quat(1,:) -quat(4,:) quat(3,:);...quat(4,:) quat(1,:) -quat(2,:);...-quat(3,:) quat(2,:) quat(1,:)]*[p;q;r];

    %%%Define for loop for duration of simulation, apply Euler Integrationfor i = 1:n

    %%%Euler Integration

    quat(:,i+1) = quat(:,i)+quat_dot(:,i)*dt;

  • 8/4/2019 AERO3560A1

    14/16

    14

    %%%Normalise Quaternions for correctionMu = (quat(1,i+1)^2+quat(2,i+1)^2+quat(3,i+1)^2+quat(4,i+1)^2)^0.5;

    quat(:,i+1) = quat(:,i+1)./Mu;

    %%%Increment Euler angle ratesquat_dot(:,i+1) = 0.5*[-quat(2,i) -quat(3,i) -quat(4,i);...

    quat(1,i) -quat(4,i) quat(3,i);...quat(4,i) quat(1,i) -quat(2,i);...-quat(3,i) quat(2,i) quat(1,i)]*[p;q;r];

    end

    %%%Transpose quaternion vector to output as matrix with unit time step% increasing from row to rowquat = quat';

    %%%Convert quaternions to Euler angleseuler = Q2E(quat);

    %%%Plot Resultsplot(0:0.1:20, euler);title('Euler Angles Derived from Quaternion Integration');xlabel('Time(s)');ylabel('Euler Angles (deg)');legend('Phi','Theta','Psi');grid on;grid minor;

    figure

    plot(0:0.1:20, quat);title('Quaternions Derived from Quaternion Integration');xlabel('Time(s)');ylabel('Quaternions (rad)');legend('e0','e1','e2','e3');grid on;grid minor;end

    M-file to call Quaternion Integration

    clc;clear all;

    close all;initial_euler = [0 0 90];body_rates = [0 6 5.6];quat_int(initial_euler,body_rates)

    6.2 Euler Angle Integrationfunction [ euler,quaternions ] = euler_int( initial_euler, body_rates )%Function file integrating Euler rates to determine aircraft attitude% Initial conditions are input as below% initial_euler = [phi theta psi]-initial Euler angles% body_rates = [p q r]-initial rotation rates about body axis

    % Both Euler angles and Quaternions are output as matricies with a unit% timestep increase from row to row.

  • 8/4/2019 AERO3560A1

    15/16

    15

    % Plots are output for both Quaternion and Euler angle variation with% time

    %%%Initialise euler angles in radiansphi = initial_euler(1)*pi/180;

    theta = initial_euler(2)*pi/180;

    psi = initial_euler(3)*pi/180;

    euler = [phi; theta; psi];

    %%%Initialise body rotation rates in rad/secp = body_rates(1)*pi/180;

    q = body_rates(2)*pi/180;

    r = body_rates(3)*pi/180;

    %%%Initialise Time/Step Variablestime = 20; %Duration of simulation

    dt = 0.1; %Time step

    n = time/dt; %Number of iterations

    %%%Input equation for Euler rates calculation as per Lecture Notes Week 2% Pg 31euler_dot(:,:) = [1 sin(euler(1,:))*tan(euler(2,:))cos(euler(1,:))*tan(euler(2,:)); ...

    0 cos(euler(1,:)) -sin(euler(1,:));...0 sin(euler(1,:))*sec(euler(2,:)) cos(euler(1,:))*sec(euler(2,:))]*...[p;q;r];

    %%%Define for loop for duration of simulation, apply Euler Integration

    for i = 1:n%%%Euler Integrationeuler(:,i+1) = euler(:,i)+euler_dot(:,i)*dt;

    %%%Increment Euler angle rateseuler_dot(:,i+1) = [1 sin(euler(1,i))*tan(euler(2,i))

    cos(euler(1,i))*tan(euler(2,i)); ...

    0 cos(euler(1,i)) -sin(euler(1,i));...0 sin(euler(1,i))*sec(euler(2,i)) cos(euler(1,i))*sec(euler(2,i))]*...[p;q;r];

    end

    %%%Transpose euler vector to output as matrix with unit time step% increasing from row to roweuler = (euler*180/pi)';

    %%%Convert Euler angles to quaternionsquaternions = E2Q(euler)

    %%%Plot Resultsplot(0:0.1:20, euler);title('Euler Angles Derived Directly from Euler Rates');

  • 8/4/2019 AERO3560A1

    16/16

    16

    xlabel('Time(s)');ylabel('Euler Angles (deg)');legend('Phi','Theta','Psi');grid on;grid minor;

    figure

    plot(0:0.1:20, quaternions);title('Quaternions Derived Directly from Euler Rates');xlabel('Time(s)');ylabel('Quaternions (rad)');legend('e0','e1','e2','e3');grid on;grid minor;end

    M-file to call Euler Angle Integration

    clc;clear all;close all;initial_euler = [0 0 90];body_rates = [0 6 5.6];euler_int(initial_euler,body_rates)