-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainFunc1.m
65 lines (58 loc) · 1.73 KB
/
MainFunc1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
clear;
close all;
addpath('Quaternions');
filePath = 'Datasets/imudata14.xlsx';
global Velocity VelocityChaRat Attitude AttitudeChaRat Position_GPS Position
IMUdata= xlsread(filePath);
Velocity = [0;0;0];
VelocityChaRat = [0;0;0];
Attitude = [0;0;0];
AttitudeChaRat = [0;0;0;0];
Position_GPS = [30.5277*pi/180;114.3566*pi/180;40];
Position = [0;0;0];
Attitude_whole = zeros(size(IMUdata,1),3);
Velocity_whole = zeros(size(IMUdata,1),3);
Position_whole = zeros(size(IMUdata,1),3);
dt = 1/100;
time = zeros(size(IMUdata,1),1);
for i=1:size(IMUdata,1)
time(i) = (i-1)*dt;
receiveData = IMUdata(i,:);
TraceState(receiveData,dt);
Attitude_whole(i,:) = Attitude';
Velocity_whole(i,:) = Velocity';
Position_whole(i,:) = Position';
end
% Plot translational accelerations
figure('Position', [9 39 900 300], 'NumberTitle', 'off', 'Name', 'Attitude');
hold on;
plot(time, Attitude_whole(:,1), 'r');
plot(time, Attitude_whole(:,2), 'g');
plot(time, Attitude_whole(:,3), 'b');
title('Attitude');
xlabel('Time (s)');
ylabel('Attitude (deg)');
legend('Pitch', 'Roll', 'Azimuth');
hold off;
% Plot translational velocity
figure('Position', [9 39 900 300], 'NumberTitle', 'off', 'Name', 'Velocity');
hold on;
plot(time, Velocity_whole(:,1), 'r');
plot(time, Velocity_whole(:,2), 'g');
plot(time, Velocity_whole(:,3), 'b');
title('Velocity');
xlabel('Time (s)');
ylabel('Velocity (m/s)');
legend('X', 'Y', 'Z');
hold off;
% Plot translational position
figure('Position', [9 39 900 600], 'NumberTitle', 'off', 'Name', 'PositionXYZ');
hold on;
plot(time, Position_whole(:,1), 'r');
plot(time, Position_whole(:,2), 'g');
plot(time, Position_whole(:,3), 'b');
title('PositionXYZ');
xlabel('Time (s)');
ylabel('Position (m)');
legend('X', 'Y', 'Z');
hold off;