Vous êtes sur la page 1sur 15

University at Buffalo

Project 2
MAE 425
BKimiecik - P#3642-4340

11

Contents
Introduction ............................................................................................................................................ 3 Task 1 ...................................................................................................................................................... 4

Task 2 ...................................................................................................................................................... 5

Task 3 ...................................................................................................................................................... 7

Task 4 ...................................................................................................................................................... 8

Task 5 and Task 6 ................................................................................................................................... 10

Task 7 (Extra Credit)............................................................................................................................... 15

Introduction
This project centers on investigating the attitude motion of the Wilkinson Microwave Anisotropy Probe Spacecraft (WMAP). In the first few tasks, we use the desired initial conditions in order to discuss various aspects of the attitude motion including quaternion movement and rotational velocity and how the overall aircraft moves with respect to time. Figure 1 represents the spacecraft which will be discussed.

Task 1
The first task has the strident pick a time interval of 1 second to 2 hours (7200 seconds) and determine the Euler angles for the entire span. The desired initial conditions are given as follows:

Where for the desired Euler angles for each angle is determined by integrating over the respective Eulerian rates, setting each Euler angles initial position at 0 degrees. At each time interval within the span, The Euler angles are calculated by adding the given rates of each change for the given angle multiplied by the time interval. Upon calculation of each angle at each time interval, the resulting angle for the given span was plugged into the supplied "e" formulas in order to track the aircrafts movement. This movement was graphed in an y vs. x plot which is supplied below.

Figure 1: Scan patter for Task 1.

The following Matlab code is utilized for this task: %Part one mfile theta=0.3927; phidot=0.001745; psidot=0.04859; t=0; phi=0; psi=0; i=1; for t=[0:1:7200] phi=phi+phidot; psi=psi+psidot; e1=cos(theta)*cos(psi)*cos(phi)-(cos(theta)^2)*sin(psi)*sin(phi)+(sin(theta)^2)*sin(phi); e2=cos(theta)*cos(psi)*sin(phi)+(cos(theta)^2)*sin(psi)*cos(phi)-(sin(theta)^2)*cos(phi); e3=cos(theta)*sin(theta)*(sin(psi)+1); x(i)=e1/(1+e3); y(i)=e2/(1+e3); i=i+1; end plot(x,y);

Task 2
For a time span of 1second to 600 seconds, new Euler angles and rates were calculated for the given time span. The desired body angular velocity trajectories were found by using a 3-1-3 attitude rotation sequence. This task was completed in Matlab by calculating the 3 angular velocity vectors separately by utilizing the given change in angle found with respect to time, then multiplying the Euler rate by the time interval and adding this rate of change calculated previously. This was done using a for loop for the given time span. Upon completion, the following graph is generated.

Figure 2: Desired angular velocity vs. time for the given time span.

The following code was used to derive the angular rates: %Task 2 theta=0.3927; phidot=0.001745; psidot=0.04859; thetadot=0; deltat=0.1; t=0; phi=0; psi=0; i=1; for i=(1:1:6001) w1(i)=[sin(psi)*sin(theta) cos(psi) 0]*[phidot;thetadot;psidot]; w2(i)=[cos(psi)*sin(theta) -sin(psi) 0]*[phidot;thetadot;psidot]; w3(i)=[cos(theta) 0 1]*[phidot;thetadot;psidot]; t(i)=i/10; phi=phi+phidot*0.1; psi=psi+psidot*0.1; end global Wtild Wtild=[w1;w2;w3] plot(t,Wtild);

Task 3
Task 3 requires using the calculated Euler angle matrix for a 3-1-3 attitude sequence with initial given initial conditions and extracting the desired initial quaternion. The following attitude matrix (M) is derived and the initial quaternion (Q) is extracted. These values are as follows: M= 1.0000 0 0 0 0.9239 0.3827 0 -0.3827 0.9239 Q= 0.1951 0.0000 0.0000 0.9808 The following code is used to find the above values: %Task 3 %3-1-3 Matrix phi=0 theta=0.3927; psi=0

M=[cos(phi)*cos(psi)-sin(phi)*cos(theta)*sin(psi) cos(phi)*sin(psi)+sin(psi)*cos(theta)*cos(phi) sin(psi)*sin(theta); -sin(psi)*cos(phi)-cos(psi)*cos(theta)*sin(phi) -sin(phi)*sin(psi)+cos(phi)*cos(theta)*cos(psi) cos(psi)*sin(theta); sin(theta)*sin(phi) -sin(theta)*cos(phi) cos(theta)] q1=sqrt(0.25*(1+M(1,1)-M(2,2)-M(3,3))); q2=sqrt(0.25*(1+M(2,2)-M(1,1)-M(3,3))); q3=sqrt(0.25*(1+M(3,3)-M(1,1)-M(2,2))); q4=sqrt(0.25*(1+M(1,1)+M(2,2)+M(3,3))); Q=[q1;q2;q3;q4]

Task 4
Using the angular velocities found in Task 2, and the initial quaternion found in Task 3, it is possible to find the desired quaternion trajectory. The desired quaternion is derived for this task by using the following closed form solution supplied in the project.

Where:

Evaluating the supplied matrix requires converting the vectors in 1,1 1,2 and 1,3 (row, column) into scalars for analysis. This was done by matrix multiplication. The product of this matrix multiplication gives a 4x4 matrix that is used for analysis. With the aid of Matlab, Fig.3 is generate.

Figure 3: Desired Quaternion Trajectory vs. time.

The Matlab code used is as follows: **Note: for the following syntax, the values in the second column are used in the code to represent the values in the first column. Z Zcross Wtild Ohm

%Task 4 theta=0.3927; phidot=0.001745; psidot=0.04859; thetadot=0; q=[0.1951; 0 ; 0; 0.9808]; deltat=0.1; t=0; phi=0; psi=0; i=1; for i=(1:1:6001) W1=Wtild(1,i); W2=Wtild(2,i); W3=Wtild(3,i); w=[W1;W2;W3]; z1(i)=(sin(0.5*abs(W1)*deltat)*W1)/(abs(W1)); z2(i)=(sin(0.5*abs(W2)*deltat)*W2)/(abs(W2)); z3(i)=(sin(0.5*abs(W3)*deltat)*W3)/(abs(W3)); Z1=z1(i); Z2=z2(i); Z3=z3(i); Z=(sin(0.5*norm(w)*deltat)*w)/(norm(w)); Zcross=[0 -Z(3) Z(2); Z(3) 0 -Z(1); -Z(2) Z(1) 0]; %Omega operator

op1=cos(0.5*norm(w)*deltat); I=[1 0 0; 0 1 0; 0 0 1]; Ohm=[op1*I-Zcross Z; -Z' op1]; q=Ohm*q; q1(i)=q(1); q2(i)=q(2); q3(i)=q(3); q4(i)=q(4); t(i)=i/10; phi=phi+phidot; psi=psi+psidot; end global Qtild; global Wtild; Wtild=[w1;w2;w3]; Qtild=[q1;q2;q3;q4]; plot(t,Qtild);

Task 5 and Task 6


For task 5 and 6, the combined quaternion kinematics and Euler rotation equations were integrated over time. They were integrated at the same time and time steps and take the form of a state model with seven states, 3 angular velocities and 4 quaternion. The states derived above are for ideal conditions, and in order for the actual states to match this trajectory the system must be acted upon by an external controller. The actual quaternion and angular velocity conditions are supplied as follows: q(0)=[0 0 0 1]T [(0)=[0 0 0]T By starting with these initial conditions, it is seen that the trajectory will be different than that of the desired case. Using the integrated data the following conditions were plotted: part of the error quaternion (delta alpha) vs. time, the difference between actual and desired angular velocity vs. time, and the torque vs. time. If the controller works then the error quaternion will approach zero as time increases, the difference in angular velocities will approach zero as the actual catches up with the desired, and the controller torque will reduce towards zero as the desired trajectory and angular velocities are met.

With Matlab the following graphs are defined:

Figure 4: Delta alpha of the Error Quaternion vs. Time

This plot shows that as time increases, the error between actual and desired quaternion (only the alpha terms) decreases to zero. The quaternion were converted to degrees.

Figure 5: Difference between anctual aand desired angular velocity vs. time.

This plot shows that as time increases, the error between actual and desired angular velocity decreases to zero.

Figure 6: Torque vs. time

This plot shows that as time increases, the input torque required by the controller to reach desired conditions decreases to zero.

The error quaternion is given as follows:

Where Torque is calculated with the following equation:

**Note: for the following syntax, the values in the second column are used in the code to represent the values in the first column. qdiff delA Xitildinv q Qtildinv qprime Xitild T (for plotting)

The following code is used for analysis: phi=0; psi=0; theta=0.3927; phidot=0.001745; psidot=0.04859; thetadot=0; I=[1 0 0; 0 1 0; 0 0 1]; q=[0; 0 ; 0; 1]; Q=q; t=0; W=[0;0;0]; Wcross=[0 -W(3) W(2); W(3) 0 -W(1); -W(2) W(1) 0]; Qcross=[0 -q(3) q(2); q(3) 0 -q(1); -q(2) q(1) 0]; Xi=[q(4)*I+Qcross; -q(1) -q(2) -q(3)]; global n n=1; for n=1:1:6001 b=n; if (n<=1) q=Q; else q=Q(:,n-1); end t(n)=n/10; Wcross=[0 -W(3) W(2); W(3) 0 -W(1); -W(2) W(1) 0]; Qeval=[Qtild(1,n), Qtild(2,n), Qtild(3,n), Qtild(4,n)]; Qcross=[0 -q(3) q(2); q(3) 0 -q(1); -q(2) q(1) 0]; Qtildcross=[0 -Qeval(3) Qeval(2); Qeval(3) 0 -Qeval(1); -Qeval(2) Qeval(1) 0]; Xi=[q(4)*I+Qcross; -q(1) -q(2) -q(3)]; Xitild=[Qeval(4)*I+Qtildcross; -Qeval(1), -Qeval(2), -Qeval(3)]; Weval=[Wtild(1,n); Wtild(2,n); Wtild(3,n)]; J=[399 -2.81 -1.31; -2.81 377 2.54; -1.31 2.54 377]; iJ=inv(J); kq=10; kw=10; L=-kq*Xitild'*q-kw*(W-Weval);

q=q+(0.5*Xi*W)*0.1; W=W+(-iJ*Wcross*J*W+iJ*L)*0.1; Q(1,n)=q(1); Q(2,n)=q(2); Q(3,n)=q(3); Q(4,n)=q(4); w(1,n)=W(1); w(2,n)=W(2); w(3,n)=W(3); T1(n)=L(1); T2(n)=L(2); T3(n)=L(3); qprime=q; Qtildinv=[-Qtild(1,n);-Qtild(2,n);-Qtild(3,n);Qtild(4,n)]; Qinvcross=[0 Qtild(3,n) -Qtild(2,n); -Qtild(3,n) 0 Qtild(1,n); Qtild(2,n) -Qtild(1,n) 0]; Xitildinv=[Qtild(4,n)*I+Qinvcross; Qtild(1,n), Qtild(2,n), Qtild(3,n)]; qdiff=[Xitildinv Qtildinv]*qprime; delA(1,n)=2*qdiff(1)*180/3.14; delA(2,n)=2*qdiff(2)*180/3.14; delA(3,n)=2*qdiff(3)*180/3.14;

end T=[T1;T2;T3]; plot(t, delA) %plot(t,T); %plot(t,w-Wtild)

Task 7 (Extra Credit)


The torque controller gains, kq and k[, are parameters that affect the behavior of the spacecraft as it tries to orient itself to the desired trajectory and angular velocity. The torque equation is given by , so it can be seen that kq operates on the quaternion terms and k[operates on the difference in angular velocities. : By increasing the k[and keeping kq the same, the amount of time for to approach zero is

decreases. Decreasing k[has the opposite effect, and seems to make the system diverge if k[is too low. By decreasing kq and keeping k[ the same the amount of time taken to approach zero decreases, and the frequencies of the resulting curves are also decreased. By increasing kq and keeping k[the same frequencies of the resulting curves are increased and the amount of time taken for the difference to approach zero increases. Increasing both gains together reduces the time to approach zero, and decreasing both together has the opposite effect. xE(t): By changing k[and keeping kq the same, the behavior of the system is almost identical to that of the change in angular velocities. By increasing kq the behavior is similar to that of the change in angular velocities, but when kq is reduced it makes it so that the delta q function approaches zero much more slowly, and doesn t even come close to reaching zero for the time period we are analyzing. L(t): Increasing k[and kq separately the behaviors of the system are similar to the behavior of the other two parameters. Increasing them together also produces the same behaviors as above. Decreasing them together keeps the torque magnitudes low and the system never seems to approach zero. The torques oscillate somewhat irregularly. Decreasing k[and keeping kq makes it so that the torques do not approach zero, and seem to be increasing as time increases. Decreasing kq and keeping k[ the same decreases the amount of time for the torques to approach zero. Torque Magnitudes: The magnitude of the torque changes proportionally to the difference in the angular velocities, and the difference in the quaternion. When the difference in angular velocity takes longer to converge, then the torque will work harder for longer and its magnitude will remain large. As the difference in the angular velocities begin to converge the torque required approaches zero. The same can be said for the difference in quaternion. The gain conditions discussed above directly affect the magnitude of the torque. For example, reducing the k[value causes the angular velocity difference to appear to increase over time. This is going to cause the torque required to also increase over time as it tries to correct the behavior. The gain would have to be increased again to make these values converge.

Vous aimerez peut-être aussi