statistical analysis of vibrations in inertial measurement units · the kalman filter will be...
TRANSCRIPT
1
Statistical Analysis of Vibrations in Inertial Measurement
Units
Joseph D. Hawley1
Arizona State University, Tempe, Arizona, 85287
Nomenclature
A = Acceleration
𝛼 = Angle of Pitch
𝛽 = Angle of Yaw
g = Gravitational Acceleration
𝛾 = Angle of Roll
�̇� = Angular Velocity
dt = time step
C = Complementary Coefficient
I. Executive Summary
he following study draws comparisons between a complementary filter and no filter responses from an inertia
measurement unit subject to different frequencies of vibrations. This study shows through paired t-testing that a
complementary filter is more accurate when subjected to vibrations than using no data fusing methods. The result of
using methods to minimize error of measurement will increase performance of active control systems and reduce risk
of catastrophic events leading to injuries, wasted finances, and lost time. While the complimentary filter is significantly
more accurate, means for higher-order algorithms are essential and can further reduce risk.
II. Introduction
In a sounding rocket, passive controls are used to stabilize a rocket throughout flight by means of fixed devices,
such as fins, to maintain the rocket in a vertical trajectory. Rockets that are stable by passive controls are statically
stable. To be statically stable, the rockets center of pressure must be at least one body diameter behind (towards the
nozzle-side) from its center of gravity. As a statically stable rocket deviates from its vertical trajectory, the drag forces
are no longer in the direction of axis of symmetry and a lifting force is imposed on the body. These two forces, known
as restoring forces, then rotate the rocket about its center of pressure back to a vertical trajectory. The draw back to
passive controls are that each time the rocket deviates from a vertical trajectory, the maximum achievable altitude
becomes less and less. Furthermore, passive controls will not keep a rocket from rotating about its axis of symmetry.
As a result, energy used by the rocket is wasted on rotational motion as opposed to that energy being used to move
the rocket in its current direction.
To achieve maximum apogee for a sounding rocket, active controls may be utilized. Examples of active controls
on a rocket are vanes, moveable fins, and gimbaled nozzles. These active controls are used to maintain a constant
vertical trajectory as well as to inhibit the rotational motion. Most active controls use an inertial measurement unit
(IMU) so the rockets orientation is known, and the control system can output the appropriate response. IMUs with six
degrees of freedom (6DOF) consist of an accelerometer and gyroscope. An accelerometer measures the acceleration
in three-axes while gyroscopes measure the angular velocity on three-axes. The advantage of a 6DOF IMU over a
3DOF IMU is the tilting angles from the pitch and yaw axes can be calculated using Euler angles. This allows for
complete control of the rockets vertical trajectory.
There are issues with both accelerometers and gyroscopes regarding their ability to accurately measure acceleration
and angular velocity. Accelerometers are sensitive to vibrations since vibrations rapidly changing the motion of the
accelerometer and can simulate change in acceleration, even if the accelerometer is static. Gyroscopes are not as
1 Student, SEMTE, 501 E Tyler Mall, Tempe, Arizona, 85287.
T
2
sensitive to vibrations as
accelerometers, but
gyroscopes tend to drift over
time, leading to inaccuracies
in Euler angle calculations.
Figure 1 and figure 2 to the
left is data taken over a ten-
minute period to demonstrate
the drift of the gyroscope.
The solution to these
problems can be solved by
data fusing filters. In this
report, a complementary filter
will be investigated and
compared with results from
no filtering. The control script
used to obtain data also included a Kalman filter. The Kalman filter will be presented in plots along with the raw data
and complementary filter but will not be used in the analysis or discussed further.
Complementary filters utilize both high-pass and low-pass filters simultaneously. The high-pass filter filters out
low frequency signals and the low-pass filter filters out high frequency signals. Accelerometers that experience
vibrations will output high frequencies. The drift of a gyroscope will output low frequencies. Complementary filters
are then able to minimize error and can obtain a much more accurate signal. To better understand how complementary
filters work, first it is necessary to understand how IMUs calculate angles. Accelerometers calculate acceleration by,
𝐴 = 𝑔 ⋅ sin(𝛼) → 𝛼 = arcsin (𝐴
𝑔)
where g is the vector of Earth’s gravity and 𝛼 is the angle from a horizontal plane and its sensing axis. Extending
this to three-axes we obtain,
𝛼 = arcsin (𝐴𝑥
𝑔)
𝛽 = arcsin (𝐴𝑦
𝑔)
𝛾 = arccos (𝐴𝑧
𝑔)
For the IMU to calculate both pitch and yaw, it needs all variables in terms of its measured acceleration vectors,
𝛼 = arctan (𝐴𝑥
√𝐴𝑦2 + 𝐴𝑧
2)
(1)
𝛽 = arctan (𝐴𝑦
√𝐴𝑥2 + 𝐴𝑧
2)
(2)
6DOF IMUs can only calculate angles in two directions. Gyroscopes are much simpler for calculating angles. Since
they measure angular velocity, then the angle is just the previous angle plus the angular velocity multiplied by the
change in time,
𝛼 = 𝛼0 + �̇�𝑑𝑡
(3)
𝛽 = 𝛽0 + �̇�𝑑𝑡
(4)
Figure 1: Y-Axis angle measurements with
no vibrations.
Figure 2: X-Axis angle measurements with no
vibrations.
3
To get the best signal using the complementary filter, two numerical constants will be used to grab a portion of the
signal from the accelerometer and a portion from the gyroscope and then summed together. The unfiltered equation
to find angles is then,
𝛼𝑖 = (𝛼𝑖−1 + �̇�𝑥𝑑𝑡) + arctan (𝐴𝑥
√𝐴𝑦2 + 𝐴𝑧
2)
(5)
𝛽𝑖 = (𝛽𝑖−1 + �̇�𝑦𝑑𝑡) + arctan (𝐴𝑦
√𝐴𝑥2 + 𝐴𝑧
2)
(6)
and the complimentary filter,
𝛼𝑖 = 𝐶1(𝛼𝑖−1 + �̇�𝑥𝑑𝑡) + 𝐶2 (arctan (𝐴𝑥
√𝐴𝑦2 + 𝐴𝑧
2))
(7)
𝛽𝑖 = 𝐶1(𝛽𝑖−1 + �̇�𝑦𝑑𝑡) + 𝐶2 (arctan (𝐴𝑦
√𝐴𝑥2 + 𝐴𝑧
2))
(8)
where 𝐶1 & 𝐶2 are numerical constants chosen based on the system parameters. In this study, 𝐶1 = 0.93 & 𝐶2 =0.07.
This study will draw conclusions about the effectiveness of the complementary filter in response to applied
vibrations on an IMU. The variables considered in this study will be the pitch and yaw angles where the pitch and
yaw are the rockets tilting angles about its center of pressure. Pitch will describe the IMUs x-axis and yaw will
describe the y-axis. The null hypothesis is there is no difference between measured angles by the both the unfiltered
and complimentary filter measurements. The alternative hypothesis is there is a difference between measured angles
by the unfiltered and complementary filter measurements. This will be a two-tailed hypothesis test based on
limitations by SPSS, but assumptions can be made based on the sign of the test-statistic.
To measure the angles, Eq. 5., 6., 7., and 8. will be added to a control script that will be uploaded to an Arduino
Uno which is connected to a MPU-6050 IMU with a GY-521 breakout board. The IMU is pinned into a breadboard
which lies on a flat surface and will be calibrated before each test to ensure accurate measurements. To apply
vibrations to the IMU, a LG V20 will lie on the breadboard while the vibration feature in the cell phone is controlled
remotely. Three different vibration frequencies will be tested; the lowest frequency, the middle frequency, and the
highest frequency output available on the phone. Vibration frequency data is not published by LG. An attempt was
made to gather frequency data from LG but at the time of the writing of this report, no response has been received.
The data gathered by the Arduino will be output into the serial monitor which is then exported as a text file and
analyzed using both MATLAB and SPSS.
III. Procedure
As stated in the previous section, the IMU and microcontroller are to be connected and the microcontroller
connected to a laptop or computer. Once the microcontroller has a connection to the laptop, test the I2C connection to
ensure the IMU is communicating with the microcontroller. Once an I2C connection has been verified, upload a
program to the microcontroller to calibrate the IMU. Ensure the IMU is completely horizontal and on a flat surface.
Do not move or touch the IMU while calibration is taking place. Once the calibration is completed, upload the control
script that will calculate angles and open the serial monitor. First, make sure the angles calculated are approximately
zero. If they are not, recalibrate or incorporate MPU offsets into the program. To begin the test, clear the output of the
serial monitor and make sure auto scroll is checked. Apply the first vibration at the lowest frequency. After the
vibration is complete, uncheck the auto scroll and copy/paste the above data into a plain text file. Repeat this five
times for each frequency, for a total of fifteen samples. Double check the data obtained and make sure there are no
signs of experimental error in the data.
The sample space of this experiment will be all angles between 0 and 180 degrees. Since both positive and negative
angles are equally undesirable, all angles used for analysis will be absolute values. This will also help keep oscillations
above and below zero from skewing the mean of the data.
4
IV. Results
To analyze the data and to determine whether to accept or reject the null hypothesis, a paired t-test will be used.
In order to use the paired t-test correctly, samples of the same size, from the same test will be compared. To use same
exact raw data that went through the unfiltered equation and filtered equation for comparison, the same range for each
unfiltered and filtered sample will be taken from each trial. For example, two arrays, one with unfiltered signals at a
low vibration frequency in trial 1, and one with filtered signals at the same low vibration frequency in the same trial
and range, will be compared against one another.
For the paired t-test to be valid these four assumptions have been met:
1. The dependent variable must be continuous
2. The observations are independent of one another
3. The dependent variable should be approximately normally distributed
4. The dependent variable should not contain any outliers.
Since every data point measured by the IMU is used by the microcontroller to make decisions and an output
response, no data points will be considered as an outlier.
The following figures are plots of the data obtained by each trial for both pitch and yaw angles. Time has been
normalized in all plots since data was taken in equally spaced intervals.
5
6
7
8
For the t test, a type-I error rate of 0.05 will be used since neither filter will be used on an actual rocket. The
complementary filter was created as a way of testing the effects of data fusing and a stepping stone toward more
advanced filtering algorithms. Therefore, making a type-I error will not have any serious consequences and 0.05 will
be sufficient enough to compare both methods.
As stated before, only the absolute value of each angle will be considered to compare its deviation from zero. In
the following results, the complementary filter is abbreviated to ‘comp’ and unfiltered to ‘unfilt’. The letter following
9
this is the axis being measured, ‘x’ or ‘y’. The last part of the variable specifies whether the frequency test was high,
medium, or low. The results of the SPSS paired t-test are as follows:
T-Test
Notes
Output Created 22-APR-2018 20:33:43
Comments
Input Data C:\Users\jhawl\Desktop\mae3
01_take2.sav
Active Dataset DataSet0
Filter <none>
Weight <none>
Split File <none>
N of Rows in Working Data
File
1139
Missing Value Handling Definition of Missing User defined missing values
are treated as missing.
Cases Used Statistics for each analysis are
based on the cases with no
missing or out-of-range data
for any variable in the
analysis.
Syntax T-TEST PAIRS=unfiltX_low
unfiltX_med unfiltX_high
unfiltY_low unfiltY_med
unfiltY_high WITH
compX_low compX_med
compX_high compY_low
compY_med compY_high
(PAIRED)
/CRITERIA=CI(.9500)
Resources Processor Time 00:00:00.00
Elapsed Time 00:00:00.01
[DataSet0] C:\Users\jhawl\Desktop\mae301_take2.sav
10
Paired Samples Statistics
Mean N Std. Deviation Std. Error Mean
Pair 1 unfiltX_low 1.2012 483 .63163 .02874
compX_low .0634 483 .04761 .00217
Pair 2 unfiltX_med 4.6070 623 3.02811 .12132
compX_med .4109 623 .32714 .01311
Pair 3 unfiltX_high 6.6130 705 8.95465 .33725
compX_high 3.8510 705 3.19508 .12033
Pair 4 unfiltY_low 3.9681 483 2.12691 .09678
compY_low .1697 483 .11480 .00522
Pair 5 unfiltY_med 14.3065 623 7.97847 .31965
compY_med 1.2480 623 .95336 .03820
Pair 6 unfiltY_high 23.8881 705 14.57605 .54897
compY_high 6.6455 705 4.81077 .18118
Paired Samples Test
Paired Differences
Mean Std. Deviation Std. Error Mean
95% Confidence
Interval of the
Difference
Lower
Pair 1 unfiltX_low - compX_low 1.13787 .61431 .02795 1.08294
Pair 2 unfiltX_med - compX_med 4.19608 2.96418 .11876 3.96287
Pair 3 unfiltX_high - compX_high 2.76199 8.78450 .33084 2.11243
Pair 4 unfiltY_low - compY_low 3.79839 2.07264 .09431 3.61308
Pair 5 unfiltY_med - compY_med 13.05851 7.81476 .31309 12.44366
Pair 6 unfiltY_high - compY_high 17.24262 13.30039 .50092 16.25914
Paired Samples Test
Paired Differences
t df Sig. (2-tailed)
95% Confidence
Interval of the
Difference
Upper
Pair 1 unfiltX_low - compX_low 1.19279 40.708 482 .000
Pair 2 unfiltX_med - compX_med 4.42930 35.333 622 .000
11
Pair 3 unfiltX_high - compX_high 3.41154 8.348 704 .000
Pair 4 unfiltY_low - compY_low 3.98369 40.276 482 .000
Pair 5 unfiltY_med - compY_med 13.67335 41.708 622 .000
Pair 6 unfiltY_high - compY_high 18.22610 34.422 704 .000
From the data, the null hypothesis should be rejected and the alternative hypothesis is accepted. Since the test statistic
is positive, the complementary filter was significantly closer to zero than the unfiltered data.
It can also be seen that the complementary filters effectiveness decreased significantly with higher and higher
vibration frequencies. For future work, it would be worth looking into finding a frequency where there is no statistical
significance between the two.
Conclusion
The need for data fusing methods is essential to active controls in rocketry and the results from this study have
shown that complementary filters are significantly more accurate than not using any data fusing methods. For future
work, a comparison between the complementary filter and Kalman filter can further show the effectiveness of data
fusing in higher order algorithms.
This was a difficult study to conduct, oscillating data is not as straight forward to analyze as other numerical data.
More advanced methods of data analysis not covered in the scope of an introductory statistics course were considered
but time constraints did not allow for a proper analysis to be completed in time. Another issue with the study is the
complementary filter tends to create a data lag. This means there is a difference in oscillations between both the filtered
and unfiltered data almost like a phase shift. With the paired t test, the same data points were compared, but the lag in
the output from the complimentary filter does not give a true representative of comparing two identical points in time.
From the results, it is recommended those looking for a method of data fusing without the complexities of Kalman
filtering methods should use a complementary filter as opposed to not using any type of data fusing method.
References
Computer Software
IBM Corp. Released 2018. IBM SPSS Statistics for Windows, Version 25.0. Armonk, NY: IBM Corp.
MATLAB Release 2016a, The MathWorks, Inc., Natick, Massachusetts, United States.
Electronic Publications 1 STMicroelectronics., “Tilt Measurement Using a Low-g 3-axis Accelerometer,” AN4509, 2014.
http://www.st.com/content/ccc/resource/technical/document/application_note/d2/d6/22/4f/b9/8f/45/59/DM00119046.pdf/files/D
M00119046.pdf/jcr:content/translations/en.DM00119046.pdf [cited 24 April 2018] 2Colton, Shane, “The Balance Filter,” Massachusetts Institute of Technology., June 2007.
http://robottini.altervista.org/wp-content/uploads/2014/04/filter.pdf [cited 24 April 2018] 3National Aeronautics and Space Administration., “Rocket Stability,”
https://spaceflightsystems.grc.nasa.gov/education/rocket/rktstab.html[cited 25 April 2018] 4National Aeronautics and Space Administration., “Practical Rocketry,”
https://spaceflightsystems.grc.nasa.gov/education/rocket/TRCRocket/practical_rocketry.html [cited 25 April 2018]
Appendixclc; clear; close;
load('vibtest_data')
time_low1 = linspace(0,1,726);
figureplot(time_low1, unfiltX_low1, time_low1, compX_low1,'r', time_low1, kalX_low1,'k')title 'Tilt Angle vs Time (Low Frequency: Test 1)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.5 0.9])grid on
figureplot(time_low1, unfiltY_low1, time_low1, compY_low1,'r', time_low1, kalY_low1,'k')title 'Tilt Angle vs Time (Low Frequency: Test 1)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.5 0.9])grid on
time_low2 = linspace(0,1,782);
figureplot(time_low2, unfiltX_low2, time_low2, compX_low2,'r', time_low2, kalX_low2,'k')title 'Tilt Angle vs Time (Low Frequency: Test 2)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.8])grid on
figureplot(time_low2, unfiltY_low2, time_low2, compY_low2,'r', time_low2, kalY_low2,'k')title 'Tilt Angle vs Time (Low Frequency: Test 2)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.8])grid on
time_low3 = linspace(0,1,854);
1
figureplot(time_low3, unfiltX_low3, time_low3, compX_low3,'r', time_low3, kalX_low3,'k')title 'Tilt Angle vs Time (Low Frequency: Test 3)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.8])grid on
figureplot(time_low3, unfiltY_low3, time_low3, compY_low3,'r', time_low3, kalY_low3,'k')title 'Tilt Angle vs Time (Low Frequency: Test 3)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.8])grid on
time_low4 = linspace(0,1,810);
figureplot(time_low4, unfiltX_low4, time_low4, compX_low4,'r', time_low4, kalX_low4,'k')title 'Tilt Angle vs Time (Low Frequency: Test 4)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.7])grid on
figureplot(time_low4, unfiltY_low4, time_low4, compY_low4,'r', time_low4, kalY_low4,'k')title 'Tilt Angle vs Time (Low Frequency: Test 4)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.7])grid on
time_low5 = linspace(0,1,793);
figureplot(time_low5, unfiltX_low5, time_low5, compX_low5,'r', time_low5, kalX_low5,'k')title 'Tilt Angle vs Time (Low Frequency: Test 5)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.2 0.6])grid on
2
figureplot(time_low5, unfiltY_low5, time_low5, compY_low5,'r', time_low5, kalY_low5,'k')title 'Tilt Angle vs Time (Low Frequency: Test 5)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.2 0.6])grid on
time_med1 = linspace(0,1,711);
figureplot(time_med1, unfiltX_med1, time_med1, compX_med1,'r', time_med1, kalX_med1,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 1)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0 0.5])grid on
figureplot(time_med1, unfiltY_med1, time_med1, compY_med1,'r', time_med1, kalY_med1,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 1)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0 0.5])grid on
time_med2 = linspace(0,1,1058);
figureplot(time_med2, unfiltX_med2, time_med2, compX_med2,'r', time_med2, kalX_med2,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 2)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0 0.5])grid on
figureplot(time_med2, unfiltY_med2, time_med2, compY_med2,'r', time_med2, kalY_med2,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 2)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0 0.5])grid on
3
time_med3 = linspace(0,1,926);
figureplot(time_med3, unfiltX_med3, time_med3, compX_med3,'r', time_med3, kalX_med3,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 3)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.8])grid on
figureplot(time_med3, unfiltY_med3, time_med3, compY_med3,'r', time_med3, kalY_med3,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 3)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.3 0.8])grid on
time_med4 = linspace(0,1,562);
figureplot(time_med4, unfiltX_med4, time_med4, compX_med4,'r', time_med4, kalX_med4,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 4)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0.1 0.7])grid on
figureplot(time_med4, unfiltY_med4, time_med4, compY_med4,'r', time_med4, kalY_med4,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 4)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Compementry Filter','Kalman Filter')xlim([0.1 0.7])grid on
time_med5 = linspace(0,1,593);
figureplot(time_med5, unfiltX_med5, time_med5, compX_med5,'r', time_med5, kalX_med5,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 5)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0 0.6])
4
grid on
figureplot(time_med5, unfiltY_med5, time_med5, compY_med5,'r', time_med5, kalY_med5,'k')title 'Tilt Angle vs Time (Medium Frequency: Test 5)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')xlim([0 0.6])grid on
time_high1 = linspace(0,1,393);
figureplot(time_high1, unfiltX_high1, time_high1, compX_high1,'r', time_high1, kalX_high1,'k')title 'Tilt Angle vs Time (High Frequency: Test 1)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
figureplot(time_high1, unfiltY_high1, time_high1, compY_high1,'r', time_high1, kalY_high1,'k')title 'Tilt Angle vs Time (High Frequency: Test 1)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
time_high2 = linspace(0,1,581);
figureplot(time_high2, unfiltX_high2, time_high2, compX_high2,'r', time_high2, kalX_high2,'k')title 'Tilt Angle vs Time (High Frequency: Test 2)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
figureplot(time_high2, unfiltY_high2, time_high2, compY_high2,'r', time_high2, kalY_high2,'k')title 'Tilt Angle vs Time (High Frequency: Test 2)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
time_high3 = linspace(0,1,430);
5
figureplot(time_high3, unfiltX_high3, time_high3, compX_high3,'r', time_high3, kalX_high3,'k')title 'Tilt Angle vs Time (High Frequency: Test 3)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
figureplot(time_high3, unfiltY_high3, time_high3, compY_high3,'r', time_high3, kalY_high3,'k')title 'Tilt Angle vs Time (High Frequency: Test 3)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
time_high4 = linspace(0,1,455);
figureplot(time_high4, unfiltX_high4, time_high4, compX_high4,'r', time_high4, kalX_high4,'k')title 'Tilt Angle vs Time (High Frequency: Test 4)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
figureplot(time_high4, unfiltY_high4, time_high4, compY_high4,'r', time_high4, kalY_high4,'k')title 'Tilt Angle vs Time (High Frequency: Test 4)'xlabel 'Time (normalized)'ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
time_high5 = linspace(0,1,491);
figureplot(time_high5, unfiltX_high5, time_high5, compX_high5,'r', time_high5, kalX_high5,'k')title 'Tilt Angle vs Time (High Frequency: Test 5)'xlabel 'Time (normalized)'ylabel 'X-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
figureplot(time_high5, unfiltY_high5, time_high5, compY_high5,'r', time_high5, kalY_high5,'k')title 'Tilt Angle vs Time (High Frequency: Test 5)'xlabel 'Time (normalized)'
6
ylabel 'Y-Axis Tilt Angle (degrees)'legend('Unfiltered','Complementry Filter','Kalman Filter')grid on
% Medium Freq
compX_med1 = (compX_med1(142:284));unfiltX_med1 = unfiltX_med1(142:284);compX_med2 = (compX_med2(211:317));unfiltX_med2 = unfiltX_med2(211:317);compX_med3 = (compX_med3(463:602));unfiltX_med3 = (unfiltX_med3(463:602));compX_med4 = (compX_med4(168:281));unfiltX_med4 = unfiltX_med4(168:281);compX_med5 = (compX_med5(148:266));unfiltX_med5 = unfiltX_med5(148:266);
unfiltX_med = abs([unfiltX_med1;unfiltX_med2;unfiltX_med3;unfiltX_med4;unfiltX_med5]);compX_med = abs([compX_med1;compX_med2;compX_med3;compX_med4;compX_med5]);
compY_med1 = (compY_med1(142:284));unfiltY_med1 = unfiltY_med1(142:284);compY_med2 = (compY_med2(211:317));unfiltY_med2 = unfiltY_med2(211:317);compY_med3 = (compY_med3(463:602));unfiltY_med3 = (unfiltY_med3(463:602));compY_med4 = (compY_med4(168:281));unfiltY_med4 = unfiltY_med4(168:281);compY_med5 = (compY_med5(148:266));unfiltY_med5 = unfiltY_med5(148:266);
unfiltY_med = abs([unfiltY_med1;unfiltY_med2;unfiltY_med3;unfiltY_med4;unfiltY_med5]);compY_med = abs([compY_med1;compY_med2;compY_med3;compY_med4;compY_med5]);
% Low Freq
compX_low1 = (compX_low1(508:580));unfiltX_low1 = unfiltX_low1(508:580);compX_low2 = (compX_low2(391:509));unfiltX_low2 = unfiltX_low2(391:509);compX_low3 = (compX_low3(427:513));unfiltX_low3 = (unfiltX_low3(427:513));compX_low4 = (compX_low4(364:486));unfiltX_low4 = unfiltX_low4(364:486);compX_low5 =(compX_low5(277:357));unfiltX_low5 = unfiltX_low5(277:357);
unfiltX_low = abs([unfiltX_low1;unfiltX_low2;unfiltX_low3;unfiltX_low4;unfiltX_low5]);
7
compX_low = abs([compX_low1;compX_low2;compX_low3;compX_low4;compX_low5]);
compY_low1 = (compY_low1(508:580));unfiltY_low1 = unfiltY_low1(508:580);compY_low2 = (compY_low2(391:509));unfiltY_low2 = unfiltY_low2(391:509);compY_low3 = (compY_low3(427:513));unfiltY_low3 = (unfiltY_low3(427:513));compY_low4 = (compY_low4(364:486));unfiltY_low4 = unfiltY_low4(364:486);compY_low5 = (compY_low5(277:357));unfiltY_low5 = unfiltY_low5(277:357);
unfiltY_low = abs([unfiltY_low1;unfiltY_low2;unfiltY_low3;unfiltY_low4;unfiltY_low5]);compY_low = abs([compY_low1;compY_low2;compY_low3;compY_low4;compY_low5]);
% High Freq
compX_high1 = compX_high1(98:256);unfiltX_high1 = unfiltX_high1(98:256);compX_high2 = compX_high2(232:378);unfiltX_peak2 = unfiltX_high2(232:378);compX_high3 = compX_high3(129:258);unfiltX_high3 = unfiltX_high3(129:258);compX_high4 = compX_high4(91:278);unfiltX_high4 = unfiltX_high4(91:278);compX_high5 = compX_high5(78:158);unfiltX_high5 = unfiltX_high5(78:158);
unfiltX_high = abs([unfiltX_high1;unfiltX_high2;unfiltX_high3;unfiltX_high4;unfiltX_high5]);compX_high = abs([compX_high1;compX_high2;compX_high3;compX_high4;compX_high5]);
compY_high1 = compY_high1(98:256);unfiltY_high1 = unfiltY_high1(98:256);compY_high2 =(compY_high2(232:378));unfiltY_high2 = unfiltY_high2(232:378);compY_high3 = (compY_high3(129:258));unfiltY_high3 = (unfiltY_high3(129:258));compY_high4 = (compY_high4(91:278));unfiltY_high4 = unfiltY_high4(91:278);compY_high5 = compY_high5(78:158);unfiltY_high5 = unfiltY_high5(78:158);
unfiltY_high = abs([unfiltY_high1;unfiltY_high2;unfiltY_high3;unfiltY_high4;unfiltY_high5]);compY_high = abs([compY_high1;compY_high2;compY_high3;compY_high4;compY_high5]);
8
Published with MATLAB® R2017b
9